repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
wagtail | wagtail/images/views/images.py | .py | import json
import os
from tempfile import SpooledTemporaryFile
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.core.serializers.json import DjangoJSONEncoder
from django.http import (
FileResponse,
Http404,
HttpResponseBadRequest,
HttpResponseForbidden,... | 544 | 18,934 |
saleor | saleor/graphql/payment/mutations/__init__.py | .py | from .payment import (
CheckoutPaymentCreate,
PaymentCapture,
PaymentCheckBalance,
PaymentInitialize,
PaymentRefund,
PaymentVoid,
)
from .stored_payment_methods import (
PaymentGatewayInitializeTokenization,
PaymentMethodInitializeTokenization,
PaymentMethodProcessTokenization,
S... | 46 | 1,187 |
returns | returns/contrib/mypy/_structures/args.py | .py | from itertools import starmap
from typing import NamedTuple, final
from mypy.nodes import ArgKind, Context, TempNode
from mypy.types import CallableType
from mypy.types import Type as MypyType
class _FuncArgStruct(NamedTuple):
"""Basic struct to represent function arguments."""
name: str | None
type: My... | 35 | 1,028 |
jupytext | tests/data/notebooks/inputs/percent/hydrogen.py | .py | # %%
import pandas as pd
# %% Display a data frame
df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]},
index=pd.Index(['x0', 'x1'], name='x'))
df
# %% Pandas plot {"tags": ["parameters"]}
df.plot(kind='bar')
| 11 | 222 |
kafka | docker/test/__init__.py | .py | #!/usr/bin/env python
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "Lice... | 17 | 803 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/text_outputs_and_images.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: '{{{,}}}'
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# This notebook contains outputs of many different types: text, HTML, plots and errors.
# # Text outputs
#
# Using `print`, `sys.stdout` and `sys.stderr`
import s... | 64 | 1,179 |
saleor | saleor/thumbnail/apps.py | .py | from django.apps import AppConfig
from django.db.models.signals import post_delete
class ThumbnailAppConfig(AppConfig):
name = "saleor.thumbnail"
def ready(self):
from .models import Thumbnail
from .signals import delete_thumbnail_image
post_delete.connect(
delete_thumbna... | 17 | 421 |
probability | tensorflow_probability/python/layers/dense_variational_test.py | .py | # Copyright 2018 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 530 | 20,733 |
biopython | Bio/Graphics/GenomeDiagram/_LinearDrawer.py | .py | # Copyright 2003-2008 by Leighton Pritchard. All rights reserved.
# Revisions copyright 2008-2009 by Peter Cock.
#
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been incl... | 1,585 | 63,449 |
saleor | saleor/graphql/warehouse/tests/queries/test_warehouses_pagination.py | .py | import graphene
import pytest
from .....warehouse.models import Warehouse
from ....tests.utils import get_graphql_content
@pytest.fixture
def warehouses_for_pagination(db, address):
return Warehouse.objects.bulk_create(
[
Warehouse(
name="Warehouse1",
address=a... | 167 | 4,673 |
beam | sdks/python/apache_beam/internal/util.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 154 | 5,398 |
wandb | tests/unit_tests/test_public_api/test_summary.py | .py | import json
from pathlib import Path
from types import SimpleNamespace
from unittest import mock
from wandb.apis.public.summary import HTTPSummary, Summary
def _run(tmp_path: Path) -> SimpleNamespace:
return SimpleNamespace(
dir=str(tmp_path),
id="run-id",
entity="entity",
project... | 39 | 1,127 |
sphinx | tests/test_ext_autodoc/test_ext_autodoc_autodata.py | .py | """Test the autodoc extension.
This tests mainly the Documenters; the auto directives are tested in a test
source file translated by test_build.
"""
from __future__ import annotations
import pytest
from tests.test_ext_autodoc.autodoc_util import do_autodoc
pytestmark = pytest.mark.usefixtures('inject_autodoc_root_... | 105 | 2,409 |
saleor | saleor/tests/e2e/pages/utils/page_create.py | .py | from ...utils import get_graphql_content
PAGE_CREATE_MUTATION = """
mutation PageCreate($input: PageCreateInput!) {
pageCreate(input: $input) {
errors {
field
message
code
}
page {
id
title
slug
isPublished
publishedAt
attributes{
attribute{
... | 80 | 1,420 |
mlflow | tests/tracking/fluent/test_fluent.py | .py | import json
import multiprocessing
import os
import random
import re
import subprocess
import sys
import threading
import time
import uuid
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor
from importlib import reload
from itertools import zip_longest
from pathlib import Path
from ty... | 2,815 | 107,479 |
ipython | IPython/core/magics/pylab.py | .py | """Implementation of magic functions for matplotlib/pylab support.
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2012 The IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distri... | 174 | 6,624 |
pyomo | scripts/get_pyomo.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 45 | 1,266 |
mlflow | mlflow/bedrock/__init__.py | .py | import logging
from mlflow.telemetry.events import AutologgingEvent
from mlflow.telemetry.track import _record_event
from mlflow.utils.autologging_utils import autologging_integration, safe_patch
_logger = logging.getLogger(__name__)
FLAVOR_NAME = "bedrock"
@autologging_integration(FLAVOR_NAME)
def autolog(
lo... | 50 | 1,988 |
cvxpy | cvxpy/atoms/dist_ratio.py | .py | """
Copyright, the CVXPY authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
... | 85 | 2,404 |
astropy | astropy/coordinates/tests/accuracy/test_galactic_fk4.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
from astropy import units as u
from astropy.coordinates import angular_separation
from astropy.coordinates.builtin_frames import FK4, Galactic
from astropy.table import Table
from astropy.time import Time
from astropy.utils.data impor... | 66 | 1,905 |
mlflow | tests/server/auth/test_auth_workspace.py | .py | import json
from contextlib import contextmanager
from types import SimpleNamespace
from unittest.mock import MagicMock, Mock
import pytest
from flask import Response, request
from mlflow.environment_variables import MLFLOW_ENABLE_WORKSPACES
from mlflow.exceptions import MlflowException
from mlflow.prompt.constants i... | 4,057 | 166,483 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_SegmentMax.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng()
class TestSegmentMax(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
... | 101 | 4,393 |
readthedocs.org | readthedocs/search/tests/test_faceted_search.py | .py | import pytest
from readthedocs.search.faceted_search import PageSearch
@pytest.mark.django_db
@pytest.mark.search
class TestPageSearch:
@pytest.mark.parametrize("case", ["upper", "lower", "title"])
def test_search_exact_match(self, client, project, case):
"""Check quoted query match exact phrase with... | 58 | 2,290 |
astropy | astropy/uncertainty/tests/test_distribution.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import operator
import numpy as np
import pytest
from numpy.testing import assert_array_equal
from astropy import units as u
from astropy.coordinates import Angle
from astropy.tests.helper import assert_quantity_allclose
from astropy.uncertainty import d... | 717 | 25,742 |
beam | sdks/python/apache_beam/yaml/cache_provider_artifacts.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 49 | 1,771 |
coremltools | coremltools/converters/mil/backend/mil/passes/sanitize_name_strings.py | .py | # Copyright (c) 2020, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from coremltools.converters.mil.mil.passes.defs.preprocess import NameSanitizer
from coremltools.conv... | 30 | 1,272 |
wandb | wandb/integration/ultralytics/__init__.py | .py | """Tools for integrating with [`ultralytics`](https://docs.ultralytics.com/).
Ultralytics is a computer vision framework for training and deploying YOLOv8 models.
"""
from wandb.integration.ultralytics.callback import (
WandBUltralyticsCallback,
add_wandb_callback,
)
__all__ = ("WandBUltralyticsCallback", "a... | 12 | 340 |
sphinx | tests/roots/test-inheritance/conf.py | .py | import sys
from pathlib import Path
sys.path.insert(0, str(Path.cwd().resolve()))
extensions = ['sphinx.ext.inheritance_diagram']
| 7 | 132 |
pyomo | examples/performance/misc/diag2_100000.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 32 | 1,012 |
saleor | saleor/graphql/core/federation/schema.py | .py | from collections import defaultdict
from typing import Any
import graphene
from django.conf import settings
from graphene.utils.str_converters import to_snake_case
from graphql import (
GraphQLArgument,
GraphQLError,
GraphQLField,
GraphQLList,
GraphQLNonNull,
)
from ...schema_printer import print_... | 203 | 6,280 |
kafka | tests/kafkatest/services/replica_verification_tool.py | .py | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | 92 | 4,086 |
beam | learning/tour-of-beam/learning-content/splittable-dofn/splittable/python-example/task.py | .py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); y... | 75 | 3,322 |
saleor | saleor/giftcard/tests/test_lock_objects.py | .py | from ..lock_objects import gift_card_qs_select_for_update
from ..models import GiftCard
def test_gift_card_qs_select_for_update_returns_giftcard_queryset(gift_card):
# when
qs = gift_card_qs_select_for_update()
# then
assert qs.model is GiftCard
assert qs.query.select_for_update is True
| 12 | 311 |
openvino | tests/layer_tests/onnx_tests/test_bn.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
class TestBatchNormalization(OnnxRuntimeLayerTest):
def create_net(self, shape, epsilon, precision, ir_version, opset=... | 135 | 4,580 |
qutip | qutip/tests/core/data/test_mean.py | .py | import pytest
import numpy as np
import qutip
import numbers
from qutip.core.data.mean import mean_csr, mean_dia, mean_dense
from qutip.core.data.mean import mean_abs_csr, mean_abs_dia, mean_abs_dense
from qutip.core.data import CSR, Dia, Dense
from . import test_mathematics as testing
class TestMean(testing.UnaryOp... | 84 | 2,632 |
pymc | pymc/progress_bar/__init__.py | .py | # Copyright 2025 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 24 | 901 |
hatch | src/hatch/cli/env/lock.py | .py | from __future__ import annotations
import os
from typing import TYPE_CHECKING
import click
if TYPE_CHECKING:
from hatch.cli.application import Application
def dependency_lock_click_options(fn):
"""Options shared by ``hatch dep lock`` and top-level ``hatch lock``."""
decorators = [
click.option(... | 256 | 9,168 |
sphinx | tests/roots/test-environment-record-dependencies/example_module.py | .py | def example_function():
return 42
| 3 | 38 |
probability | tensorflow_probability/python/distributions/relaxed_bernoulli.py | .py | # Copyright 2018 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 364 | 15,327 |
jupytext | tests/functional/simple_notebooks/test_read_simple_R.py | .py | import pytest
import jupytext
from jupytext.compare import compare
@pytest.mark.parametrize("ext", [".r", ".R"])
def test_read_simple_file(
ext,
rnb="""#' ---
#' title: Simple file
#' ---
#' Here we have some text
#' And below we have some R code
f <- function(x) {
x + 1
}
h <- function(y)
y ... | 204 | 4,460 |
eve | tests/utils.py | .py | # -*- coding: utf-8 -*-
import copy
import hashlib
from datetime import datetime, timedelta
from bson.json_util import dumps
from eve.utils import (
config,
date_to_str,
debug_error_message,
document_etag,
extract_key_values,
import_from_string,
parse_request,
querydef,
str_to_dat... | 350 | 15,123 |
pyomo | pyomo/core/beta/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 11 | 602 |
onnxruntime | orttraining/orttraining/python/training/ortmodule/experimental/hierarchical_ortmodule/__init__.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# __init__.py
from ._hierarchical_ortmodule import HierarchicalORTModule # noqa: F401
| 6 | 182 |
textual | docs/examples/styles/opacity.py | .py | from textual.app import App
from textual.widgets import Label
class OpacityApp(App):
CSS_PATH = "opacity.tcss"
def compose(self):
yield Label("opacity: 0%", id="zero-opacity")
yield Label("opacity: 25%", id="quarter-opacity")
yield Label("opacity: 50%", id="half-opacity")
yiel... | 19 | 494 |
onnx | onnx/reference/ops/op_bitwise_or.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.ops._op import OpRunBinary
class BitwiseOr(OpRunBinary):
def _run(self, x, y):
return (np.bitwise_or(x, y),)
| 14 | 280 |
mlflow | tests/projects/test_utils.py | .py | import os
import tempfile
import threading
import zipfile
from http.server import BaseHTTPRequestHandler, HTTPServer
from typing import Generator
from unittest import mock
import git
import pytest
import mlflow
from mlflow.exceptions import ExecutionException, MlflowException
from mlflow.projects import _project_spec... | 276 | 10,245 |
rq | rq/repeat.py | .py | from __future__ import annotations
from collections.abc import Iterable
from dataclasses import dataclass
from datetime import datetime, timedelta
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from redis.client import Pipeline
from .job import Job
from .queue import Queue
@dataclass
class Repeat:
... | 119 | 4,304 |
onnx | onnx/backend/test/case/node/gemm.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
def gemm_reference_implementation(
A: np.ndarray,
B: np.ndarray,
... | 158 | 5,938 |
probability | tensorflow_probability/python/mcmc/internal/leapfrog_integrator_test.py | .py | # Copyright 2018 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 110 | 3,922 |
saleor | saleor/account/__init__.py | .py | class CustomerEvents:
"""The different customer event types."""
# Account related events
ACCOUNT_CREATED = "account_created"
ACCOUNT_ACTIVATED = "account_activated"
ACCOUNT_DEACTIVATED = "account_deactivated"
PASSWORD_RESET_LINK_SENT = "password_reset_link_sent"
PASSWORD_RESET = "password_r... | 43 | 1,928 |
confluent-kafka-python | tests/integration/consumer/test_consumer_memberid.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2022 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 65 | 1,990 |
beam | learning/tour-of-beam/learning-content/common-transforms/motivating-challenge/python-solution/task.py | .py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); y... | 78 | 2,503 |
beam | sdks/python/apache_beam/io/textio.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 1,117 | 44,983 |
beam | sdks/python/apache_beam/io/gcp/tests/utils.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 169 | 5,314 |
saleor | saleor/graphql/product/tests/mutations/test_product_media_update.py | .py | from unittest.mock import patch
import graphene
from .....graphql.tests.utils import get_graphql_content
from .....product.error_codes import ProductErrorCode
PRODUCT_MEDIA_UPDATE_QUERY = """
mutation updateProductMedia($mediaId: ID!, $alt: String) {
productMediaUpdate(id: $mediaId, input: {alt: $alt}) {... | 88 | 2,584 |
saleor | saleor/plugins/webhook/tests/utils.py | .py | def generate_request_headers(event_type, domain, signature):
return {
"Content-Type": "application/json",
# X- headers will be deprecated in Saleor 4.0, proper headers are without X-
"X-Saleor-Event": event_type,
"X-Saleor-Domain": domain,
"X-Saleor-Signature": signature,
... | 13 | 487 |
hatch | src/hatch/cli/python/install.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
import click
if TYPE_CHECKING:
from hatch.cli.application import Application
def ensure_path_public(path: str, shells: list[str]) -> bool:
import userpath
if userpath.in_current_path(path) or userpath.in_new_path(path, shells):
... | 108 | 3,907 |
hatch | backend/src/hatchling/version/source/env.py | .py | from __future__ import annotations
import os
from hatchling.version.source.plugin.interface import VersionSourceInterface
class EnvSource(VersionSourceInterface):
PLUGIN_NAME = "env"
def get_version_data(self) -> dict:
variable = self.config.get("variable", "")
if not variable:
... | 30 | 911 |
beam | learning/katas/python/Streaming/Timestamps/Add Timestamps/tests/test_task.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not... | 42 | 1,728 |
qutip | qutip/tests/test_progressbar.py | .py | from qutip.ui.progressbar import progress_bars
import pytest
import time
bars = ["base", "text", "Enhanced"]
try:
import tqdm
bars.append("tqdm")
except ImportError:
bars.append(
pytest.param("tqdm", marks=pytest.mark.skip("module not installed"))
)
try:
import IPython
bars.append("h... | 69 | 1,505 |
astropy | astropy/coordinates/builtin_frames/skyoffset.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from functools import cache
from astropy import units as u
from astropy.coordinates.attributes import CoordinateAttribute, QuantityAttribute
from astropy.coordinates.baseframe import BaseCoordinateFrame, frame_transform_graph
from astropy.coordinates.mat... | 197 | 8,120 |
pyro | pyro/infer/reparam/studentt.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pyro
import pyro.distributions as dist
from .reparam import Reparam
class StudentTReparam(Reparam):
"""
Auxiliary variable reparameterizer for
:class:`~pyro.distributions.StudentT` random variables.
This is u... | 45 | 1,477 |
toolz | bench/test_join.py | .py | from toolz.curried import *
try:
xrange
except NameError:
xrange = range
def burn(seq):
for item in seq:
pass
small = [(i, str(i)) for i in range(100)] * 10
big = pipe([110]*10000, map(range), concat, list)
def test_many_to_many_large():
burn(join(get(0), small, identity, big))
def test_... | 35 | 640 |
wandb | wandb/proto/v5/wandb_settings_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: wandb/proto/wandb_settings.proto
# Protobuf Python Version: 5.26.0
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from... | 49 | 19,224 |
probability | spinoffs/fun_mc/fun_mc/backends/tensorflow_integration_test.py | .py | # Copyright 2021 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 36 | 1,118 |
sqlmap | extra/esperanto/atlas.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Capability atlas: the candidate SQL forms Esperanto tries (best-first) to discover a
dialect blind, mined from data/xml/queries.xml across the supported DBMSes. Data only,
no logic. E... | 509 | 27,723 |
astropy | astropy/wcs/wcsapi/tests/test_high_level_wcs_wrapper.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.coordinates import SkyCoord
from astropy.wcs.wcsapi.high_level_wcs_wrapper import HighLevelWCSWrapper
from astropy.wcs.wcsapi.low_level_api import BaseLowLevelWCS
class CustomLowLevelWCS(BaseLowLevelWCS):
@property
def pi... | 82 | 2,106 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_If.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng(32345)
class TestIfFloat(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
... | 309 | 14,313 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/plotly_graphs.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: '{{{,}}}'
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# This notebook contains complex outputs, including plotly javascript graphs.
# # Interactive plots
# We use Plotly's connected mode to make the notebook lighter ... | 27 | 657 |
httpie | tests/utils/http_server.py | .py | import threading
import json
from collections import defaultdict
from contextlib import contextmanager
from http import HTTPStatus
from http.cookies import SimpleCookie
from http.server import HTTPServer, BaseHTTPRequestHandler
from urllib.parse import urlparse, parse_qs
import pytest
class TestHandler(BaseHTTPRequ... | 159 | 4,482 |
saleor | saleor/graphql/giftcard/tests/queries/test_gift_cards_currencies.py | .py | from .....giftcard.models import GiftCard
from ....tests.utils import assert_no_permission, get_graphql_content
QUERY_GIFT_CARD_CURRENCIES = """
query {
giftCardCurrencies
}
"""
def test_fetch_gift_card_currencies(
gift_card,
gift_card_expiry_date,
gift_card_used,
staff_api_client,
... | 87 | 2,107 |
loguru | tests/exceptions/source/diagnose/syntax_error.py | .py | import sys
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="", colorize=True, backtrace=False, diagnose=True)
code = """
if True:
a = 5
b = 7 *
"""
try:
exec(code)
except SyntaxError:
logger.exception("")
| 20 | 251 |
textual | src/textual/widgets/input.py | .py | from textual.widgets._input import Selection
__all__ = ["Selection"]
| 4 | 70 |
gunicorn | benchmarks/simple_app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# Simple WSGI app for benchmarking
import time
def application(environ, start_response):
"""Basic hello world response."""
path = environ.get('PATH_INFO', '/')
if path == '/large':
body = b'... | 29 | 669 |
beam | learning/tour-of-beam/learning-content/core-transforms/combine/combine-fn/python-example/task.py | .py | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | 67 | 2,088 |
clearml | examples/datasets/data_ingestion.py | .py | # Using ClearML's Dataset class to register data
# Make sure to execute dataset_creation.py first
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torchvision.datasets as datasets
import torchvision.transforms as transforms
from ignite... | 205 | 7,165 |
bazel | src/test/py/bazel/bzlmod/bazel_repo_mapping_test.py | .py | # pylint: disable=g-backslash-continuation
# Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICEN... | 464 | 16,570 |
hatch | src/hatch/cli/python/remove.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
import click
if TYPE_CHECKING:
from hatch.cli.application import Application
@click.command(short_help="Remove Python distributions")
@click.argument("names", required=True, nargs=-1)
@click.option("--dir", "-d", "directory", help="The directo... | 37 | 1,033 |
saleor | saleor/graphql/order/mutations/order_line_discount_update.py | .py | import copy
import graphene
from ....core.tracing import traced_atomic_transaction
from ....order import events
from ....order.utils import invalidate_order_prices, update_discount_for_order_line
from ....permission.enums import OrderPermissions
from ...app.dataloaders import get_app_promise
from ...core import Resol... | 90 | 3,455 |
saleor | saleor/core/editorjs/__init__.py | .py | from .converters import clean_editorjs, editorjs_to_text, parse_editorjs
__all__ = ("clean_editorjs", "parse_editorjs", "editorjs_to_text")
| 4 | 141 |
pyro | examples/eight_schools/data.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
J = 8
y = torch.tensor([28, 8, -3, 7, -1, 1, 18, 12]).type(torch.Tensor)
sigma = torch.tensor([15, 10, 16, 11, 9, 11, 10, 18]).type(torch.Tensor)
| 9 | 249 |
jupyterlab | examples/localization/main.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
"""A standalone application demonstrating localization."""
from __future__ import annotations
import json
import os
from jupyter_server.base.handlers import APIHandler, JupyterHandler
from jupyter_server.extension.h... | 127 | 4,289 |
saleor | saleor/graphql/giftcard/enums.py | .py | from typing import Final
import graphene
from ...giftcard import GiftCardEvents
from ..core.doc_category import DOC_CATEGORY_GIFT_CARDS
from ..core.enums import to_enum
GiftCardEventsEnum: Final[graphene.Enum] = to_enum(GiftCardEvents)
GiftCardEventsEnum.doc_category = DOC_CATEGORY_GIFT_CARDS
| 11 | 297 |
astropy | astropy/nddata/mixins/tests/test_ndslicing.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_array_equal
from astropy import units as u
from astropy.nddata import NDData, NDSlicingMixin
from astropy.nddata import _testing as nd_testing
from astropy.nddata.nduncertainty import (
... | 204 | 6,024 |
biopython | Tests/test_SCOP_Raf.py | .py | # This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
#
"""Unit test for Raf."""
import unittest
from io import StringIO
from Bio.SCOP import Raf
class RafTests(unittest.TestCase):
rafLine = "101m_... | 101 | 4,199 |
mlflow | tests/genai/judges/utils/test_get_default_model.py | .py | import pytest
from mlflow.genai.judges.utils import get_default_model
@pytest.mark.parametrize(
("env_value", "tracking_uri", "expected"),
[
("openai:/gpt-5", "databricks", "openai:/gpt-5"),
("anthropic:/claude-4", "http://localhost:5000", "anthropic:/claude-4"),
("", "databricks", "d... | 24 | 924 |
probability | tensorflow_probability/python/experimental/sequential/__init__.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 42 | 2,296 |
coremltools | coremltools/converters/sklearn/_SVR.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from coremltools import proto
from ... import SPECIFICATION_VERSION
from ..._deps import _HAS_SKLEARN
f... | 83 | 2,363 |
saleor | saleor/tests/e2e/orders/utils/draft_order_delete.py | .py | from saleor.graphql.tests.utils import get_graphql_content
DRAFT_ORDER_DELETE_MUTATION = """
mutation DraftOrderDelete($id: ID!) {
draftOrderDelete(id: $id) {
errors {
message
field
}
order {
status
}
}
}
"""
def draft_order_delete(api_client, id):
variables = {"id": id}
resp... | 33 | 586 |
wandb | tests/system_tests/test_core/test_label_full.py | .py | """label full tests."""
import inspect
import sys
import pytest
import wandb
@pytest.fixture()
def doc_inject(user):
m = sys.modules.get("__main__")
main_doc = getattr(m, "__doc__", None)
def fn(new_doc=None, labels=None, init_kwargs=None):
init_kwargs = init_kwargs or {}
# clean up lea... | 237 | 6,984 |
clearml | examples/automation/manual_random_param_search_example.py | .py | from random import sample
from clearml import Task
# Connecting ClearML with the current process,
# from here on everything is logged automatically
task = Task.init(
project_name="examples",
task_name="Random Hyper-Parameter Search Example",
task_type=Task.TaskTypes.optimizer,
)
# Create a hyper-paramete... | 76 | 2,397 |
pdm | src/pdm/models/repositories/base.py | .py | from __future__ import annotations
import fnmatch
import re
import sys
import warnings
from collections.abc import Generator
from functools import wraps
from typing import TYPE_CHECKING, NamedTuple, TypeVar, cast
from pdm import termui
from pdm._types import NotSet, NotSetType
from pdm.exceptions import CandidateInfo... | 344 | 15,122 |
wandb | wandb/sdk/artifacts/storage_handlers/http_handler.py | .py | """HTTP storage handler."""
from __future__ import annotations
import os
from dataclasses import asdict
from typing import TYPE_CHECKING, Any, Dict, Optional, cast # noqa: UP035
from urllib.parse import ParseResult
from pydantic.dataclasses import dataclass as pydantic_dataclass
from typing_extensions import Self
... | 121 | 4,447 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_global_average_pooling2D.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasGlobalAvgPool2D(CommonTF2LayerTest):
def create_keras_global_avg_pooling2D_net(self, input_names, input_shapes, input_... | 41 | 1,750 |
probability | spinoffs/inference_gym/inference_gym/targets/ground_truth/brownian_motion_missing_middle_observations.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 126 | 3,424 |
textual | docs/examples/widgets/digits.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Digits
class DigitApp(App):
CSS = """
Screen {
align: center middle;
}
#pi {
border: double green;
width: auto;
}
"""
def compose(self) -> ComposeResult:
yield Digits("3.141,592,653,5897... | 23 | 396 |
cvxpy | cvxpy/tests/test_custom_solver.py | .py | import unittest
import cvxpy as cp
from cvxpy.reductions.solvers.conic_solvers.scs_conif import SCS
from cvxpy.reductions.solvers.qp_solvers.osqp_qpif import OSQP
class CustomQPSolverCalled(Exception):
pass
class CustomConicSolverCalled(Exception):
pass
class CustomQPSolver(OSQP):
def name(self) -> s... | 111 | 3,939 |
sphinx | sphinx/builders/latex/transforms.py | .py | """Transforms for LaTeX builder."""
from __future__ import annotations
from typing import TYPE_CHECKING, cast
from docutils import nodes
from docutils.transforms.references import Substitutions
from sphinx import addnodes
from sphinx.builders.latex.nodes import (
captioned_literal_block,
footnotemark,
f... | 662 | 20,962 |
astropy | astropy/coordinates/tests/test_api_ape5.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This is the APE5 coordinates API document re-written to work as a series of test
functions.
Note that new tests for coordinates functionality should generally *not* be
added to this file - instead, add them to other appropriate test modules in
this ... | 472 | 21,150 |
pymc | tests/progress_bar/__init__.py | .py | # Copyright 2025 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 15 | 654 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.