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
biopython
Tests/test_SCOP_Astral.py
.py
# Copyright 2001 by Gavin E. Crooks. All rights reserved. # 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 Astral.""" import unittest from Bio.SCOP import Astral from Bio.SCOP impo...
61
2,265
coveragepy
tests/test_xml.py
.py
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt """Tests for XML reports from coverage.py.""" from __future__ import annotations import os import os.path import re from typing import Any from collections.abc...
616
22,854
hypercorn
tests/helpers.py
.py
from __future__ import annotations from collections.abc import Callable from copy import deepcopy from json import dumps from socket import AF_INET from typing import cast from hypercorn.typing import ASGIReceiveCallable, ASGISendCallable, Scope, WWWScope SANITY_BODY = b"Hello Hypercorn" class MockSocket: fami...
110
4,027
pyro
pyro/contrib/gp/models/sgpr.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import torch from torch.distributions import constraints from torch.nn import Parameter import pyro import pyro.distributions as dist from pyro.contrib.gp.models.model import GPModel from pyro.nn.module import PyroParam, pyro_meth...
278
11,001
textual
tests/snapshot_tests/snapshot_apps/dev_previews_border.py
.py
from textual_dev.previews import BorderApp app = BorderApp() if __name__ == "__main__": app.run()
6
103
metrics
tests/unittests/wrappers/test_minmax.py
.py
# Copyright The Lightning team. # # 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 writin...
197
7,514
astropy
astropy/visualization/lupton_rgb.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Combine 3 images to produce a properly-scaled RGB image following Lupton et al. (2004). The three images must be aligned and have the same pixel scale and size. For details, see : https://ui.adsabs.harvard.edu/abs/2004PASP..116..133L """ import nump...
759
25,129
metrics
src/torchmetrics/functional/classification/calibration_error.py
.py
# Copyright The Lightning team. # # 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 writin...
366
16,976
astropy
astropy/extern/configobj/configobj.py
.py
# configobj.py # A config file reader/writer that supports nested sections in config files. # Copyright (C) 2005-2014: # (name) : (email) # Michael Foord: fuzzyman AT voidspace DOT org DOT uk # Nicola Larosa: nico AT tekNico DOT net # Rob Dennis: rdennis AT gmail DOT com # Eli Courtwright: eli AT courtwright DOT org #...
2,473
87,358
sqlmap
tests/test_kbchars.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission Invariants of the random markers in kb.chars (lib/core/option.py). These markers are drawn at random once per run, so a collision between two of them is a heisenbug: it corrupts extr...
79
3,177
sqlmap
lib/utils/sgmllib.py
.py
"""A parser for SGML, using the derived class as a static DTD.""" # Note: missing in Python3 # XXX This only supports those SGML features used by HTML. # XXX There should be a way to distinguish between PCDATA (parsed # character data -- the normal case), RCDATA (replaceable character # data -- only char and entity ...
575
18,275
saleor
saleor/graphql/account/tests/mutations/staff/test_staff_delete.py
.py
import json from collections import defaultdict from unittest.mock import Mock, patch import graphene import pytest from django.core.exceptions import ValidationError from django.utils.functional import SimpleLazyObject from freezegun import freeze_time from ......account.error_codes import AccountErrorCode from .......
381
13,360
metrics
tests/unittests/classification/test_roc.py
.py
# Copyright The Lightning team. # # 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 writin...
414
17,481
deap
examples/ga/nsga3.py
.py
from math import factorial import random import matplotlib.pyplot as plt import numpy import pymop.factory from deap import algorithms from deap import base from deap.benchmarks.tools import igd from deap import creator from deap import tools # Problem definition PROBLEM = "dtlz2" NOBJ = 3 K = 10 NDIM = NOBJ + K - 1...
133
4,200
textual
examples/dictionary.py
.py
from __future__ import annotations try: import httpx except ImportError: raise ImportError("Please install httpx with 'pip install httpx' ") from textual import getters, work from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widgets import Input, Markdown ...
76
2,464
mkdocs
mkdocs/tests/integration.py
.py
""" # MkDocs Integration tests. This is a simple integration test that builds the MkDocs documentation against all of the builtin themes. From the root of the MkDocs git repo, use: python -m mkdocs.tests.integration --help TODOs - Build with different configuration options. - Build documentation other ...
76
2,156
conda
conda/common/iterators.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Replacements for parts of the toolz library.""" from __future__ import annotations from typing import TYPE_CHECKING from ..deprecations import deprecated if TYPE_CHECKING: from collections.abc import Callable, Iterable from typing...
60
1,446
gunicorn
tests/dirty/test_per_app_worker_allocation.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Integration tests for per-app worker allocation.""" import pytest from gunicorn.config import Config from gunicorn.dirty.arbiter import DirtyArbiter class MockLog: """Mock logger for testing.""" def...
325
10,757
scikit-bio
skbio/diversity/beta/__init__.py
.py
"""Beta diversity measures (:mod:`skbio.diversity.beta`) ===================================================== .. currentmodule:: skbio.diversity.beta This package provides implementations of beta diversity measures for computing sample dissimilarity. Users should also explore SciPy's :func:`~scipy.spatial.distance.p...
34
1,122
sqlmap
plugins/dbms/hsqldb/filesystem.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ from lib.core.common import randomStr from lib.core.data import kb from lib.core.data import logger from lib.core.decorators import stackedmethod from lib.core.enums import PLACE ...
61
2,501
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_batch_norm.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # pool2d paddle model generator # import numpy as np from save_model import saveModel import sys def batch_norm1(name : str, x, scale, bias, mean, var, data_layout): import paddle paddle.enable_static() node_x = paddle.s...
93
3,766
openvino
src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # mypy: ignore-errors import logging import inspect import torch # Import HigherOrderOperator for detecting higher-order operations (while_loop, cond, etc.) # This is the official PyTorch API used in torch.expor...
742
30,315
astropy
astropy/coordinates/tests/test_spectral_quantity.py
.py
import numpy as np import pytest from numpy.testing import assert_allclose from astropy import units as u from astropy.coordinates.spectral_quantity import SpectralQuantity from astropy.tests.helper import assert_quantity_allclose SPECTRAL_UNITS = (u.GHz, u.micron, u.keV, u.nm**-1, u.km / u.s) SPECTRAL_UNITS_NO_VELOC...
280
9,812
textual
tests/snapshot_tests/snapshot_apps/pilot_resize_terminal.py
.py
from textual.app import App, ComposeResult from textual.widgets import Label class SingleLabelApp(App[None]): """An app with a single label that's 20 x 10.""" def compose(self) -> ComposeResult: yield Label(("12345678901234567890\n" * 10).strip()) if __name__ == "__main__": SingleLabelApp().run...
14
323
metrics
src/torchmetrics/classification/ranking.py
.py
# Copyright The Lightning team. # # 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 writin...
432
18,332
coremltools
coremltools/converters/mil/mil/passes/__init__.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 # Import all frontend/backend passes to make sure they got registered. from coremltools.converters.mi...
52
1,617
onnxruntime
onnxruntime/test/testdata/training_api/ort_format/prepare_artifacts.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """This file is used to generate test data for ort format model tests in orttraining/orttraining/test/training_api/core/training_capi_tests.cc.""" import onnx import torch import torch.nn as nn from onnxruntime.training imp...
71
1,977
pyro
examples/svi_horovod.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 # Distributed training via Horovod. # # This tutorial demonstrates how to distribute SVI training across multiple # machines (or multiple GPUs on one or more machines) using the Horovod # library. Horovod enables data-parallel training...
170
6,668
hatch
src/hatch/cli/self/__init__.py
.py
import os import click from hatch.cli.self.report import report __management_command = os.environ.get("PYAPP_COMMAND_NAME", "self") @click.group(name=__management_command, short_help="Manage Hatch") def self_command(): pass self_command.add_command(report) if __management_command: from hatch.cli.self.re...
23
462
probability
tensorflow_probability/python/internal/tensorshape_util_test.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...
81
2,760
saleor
saleor/tests/e2e/account/account/test_staff_login_customers_only_mode.py
.py
from unittest.mock import patch import pytest from .....site import PasswordLoginMode from ...account.utils.token_create import raw_token_create from ...conftest import E2eApiClient from ...product.utils.category import create_category from ...product.utils.product import PRODUCT_CREATE_MUTATION from ...product.utils...
106
3,768
openvino
src/bindings/python/tests/test_runtime/test_memory_modes.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest from openvino import Tensor, Type from openvino.op import Constant from tests.utils.helpers import generate_image @pytest.mark.parametrize(("cls", "cls_str"), [ (Tensor, "T...
151
5,249
openvino
tests/layer_tests/common/utils/tf_utils.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import os import re import tensorflow as tf os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' def run_in_jenkins(): if "JENKINS_URL" in os.environ and len(os.environ["JENKINS_URL"]): return True return False ...
166
6,683
mlflow
tests/db/test_tracking_operations.py
.py
import sqlite3 import uuid from unittest import mock import pytest import sqlalchemy.dialects.sqlite.pysqlite import mlflow from mlflow import MlflowClient from mlflow.environment_variables import MLFLOW_TRACKING_URI pytestmark = pytest.mark.notrackingurimock class Model(mlflow.pyfunc.PythonModel): def load_co...
155
5,909
saleor
saleor/graphql/order/tests/mutations/test_order_grant_refund_update_line_reason.py
.py
from decimal import Decimal import graphene from .....page.models import Page, PageType from ....core.utils import to_global_id_or_none from ....tests.utils import get_graphql_content from ...enums import ( OrderGrantRefundUpdateErrorCode, OrderGrantRefundUpdateLineErrorCode, ) ORDER_GRANT_REFUND_UPDATE = ""...
286
8,143
wagtail
wagtail/users/views/groups.py
.py
from django.contrib.auth.models import Group from django.urls import reverse from django.utils.functional import cached_property from django.utils.translation import gettext from django.utils.translation import gettext_lazy as _ from wagtail import hooks from wagtail.admin.ui.tables import TitleColumn from wagtail.adm...
187
5,559
sphinx
tests/roots/test-ext-autodoc/target/empty_all.py
.py
"""docsting of empty_all module.""" __all__ = [] def foo(): """docstring""" def bar(): """docstring""" def baz(): """docstring"""
16
149
probability
tensorflow_probability/python/bijectors/gev_cdf.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...
240
9,224
kombu
kombu/transport/azureservicebus.py
.py
"""Azure Service Bus Message Queue transport module for kombu. Note that the Shared Access Policy used to connect to Azure Service Bus requires Manage, Send and Listen claims since the broker will create new queues and delete old queues as required. Notes when using with Celery if you are experiencing issues with pr...
706
26,253
cvxpy
cvxpy/reductions/solvers/qp_solvers/xpress_qpif.py
.py
import numpy as np import cvxpy.interface as intf import cvxpy.settings as s from cvxpy.reductions.matrix_stuffing import extract_mip_idx from cvxpy.reductions.solution import Solution, failure_solution from cvxpy.reductions.solvers import utilities from cvxpy.reductions.solvers.conic_solvers.xpress_conif import ( ...
374
13,592
flit
flit_core/tests_core/samples/package1/__init__.py
.py
"""A sample package""" __version__ = '0.1' def main(): print("package1 main")
7
84
wandb
tests/system_tests/test_functional/dspy/dspy_callback_log_results_false.py
.py
import dspy import wandb from dspy.evaluate.evaluate import EvaluationResult # type: ignore class MinimalProgram(dspy.Module): def __init__(self) -> None: super().__init__() self.predict = dspy.Predict("question: str -> answer: str") def _build_results_stub(): ex1 = dspy.Example(question="W...
42
1,159
beam
infra/keys/test_secret_manager.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 t...
840
40,779
openvino
tests/layer_tests/tensorflow_tests/test_tf_CheckNumerics.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 OPS = { "tf.raw_ops.CheckNumerics": tf.raw_ops.CheckNumerics, "tf.raw_ops.CheckNumericsV2": tf.raw_ops.CheckNumer...
52
1,992
confluent-kafka-python
src/confluent_kafka/__init__.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2020 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...
184
5,111
scikit-optimize
skopt/tests/test_parallel_cl.py
.py
"""This script contains set of functions that test parallel optimization with skopt, where constant liar parallelization strategy is used. """ from numpy.testing import assert_equal from numpy.testing import assert_raises from skopt.space import Real from skopt import Optimizer from skopt.benchmarks import branin im...
165
5,399
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/benchmark_controlnet.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import gc import importlib.util import time from statistics import mean...
427
12,929
metrics
tests/unittests/regression/test_rse.py
.py
# Copyright The Lightning team. # # 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 writin...
151
5,635
saleor
saleor/tests/e2e/checkout/zero_total/test_0_total_checkout_catalog_promotion_and_shipping_voucher.py
.py
import pytest from .....product.tasks import recalculate_discounted_price_for_products_task from ...channel.utils import update_channel from ...product.utils.preparing_product import prepare_products from ...promotions.utils import create_promotion, create_promotion_rule from ...shop.utils.preparing_shop import prepar...
209
7,589
mlflow
tests/tracking/request_header/test_databricks_request_header_provider.py
.py
import itertools from unittest import mock import pytest from mlflow.tracking.request_header.databricks_request_header_provider import ( DatabricksRequestHeaderProvider, ) bool_values = [True, False] @pytest.mark.parametrize( ("is_in_databricks_notebook", "is_in_databricks_job", "is_in_cluster"), list(...
92
3,768
django-cms
cms/utils/page_permissions.py
.py
from functools import wraps from cms.cache.permissions import get_permission_cache, set_permission_cache from cms.constants import GRANT_ALL_PERMISSIONS from cms.models import Page, PermissionTuple from cms.utils.compat.dj import available_attrs from cms.utils.conf import get_cms_setting from cms.utils.permissions imp...
517
15,470
beam
sdks/python/apache_beam/ml/inference/model_manager_test.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...
695
23,854
clearml
examples/frameworks/tensorflow/legacy/tensorboard_toy.py
.py
# ClearML - Example of tensorboard with tensorflow (without any actual training) # import os from tempfile import gettempdir import tensorflow as tf import numpy as np from PIL import Image from clearml import Task # Connecting ClearML with the current process, # from here on everything is logged automatically task...
87
3,203
readthedocs.org
readthedocs/embed/v3/tests/test_internal_pages.py
.py
from contextlib import contextmanager from unittest import mock import django_dynamic_fixture as fixture import docutils import pytest from django.core.cache import cache from django.urls import reverse from packaging.version import Version from readthedocs.projects.models import Project from readthedocs.subscription...
127
6,057
mlflow
tests/openai/test_openai_responses_autolog.py
.py
from unittest import mock import httpx import openai import pytest from packaging.version import Version import mlflow from mlflow.entities.span import SpanType from mlflow.tracing.constant import SpanAttributeKey, TokenUsageKey from tests.tracing.helper import get_traces if Version(openai.__version__) < Version("1...
384
11,536
saleor
saleor/graphql/warehouse/tests/mutations/test_warehouse_update.py
.py
import json from unittest.mock import patch import graphene import pytest from django.utils.functional import SimpleLazyObject from .....core.utils.json_serializer import CustomJsonEncoder from .....warehouse import WarehouseClickAndCollectOption from .....warehouse.error_codes import WarehouseErrorCode from .....war...
620
18,311
deap
examples/ga/onemax_island_scoop.py
.py
# This file is part of DEAP. # # DEAP is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation, either version 3 of # the License, or (at your option) any later version. # # DEAP is distributed ...
73
2,336
saleor
saleor/graphql/giftcard/tests/queries/test_gift_card_sorting.py
.py
import datetime import graphene import pytest from django.utils import timezone from .....giftcard.models import GiftCard from ....tests.utils import get_graphql_content, get_graphql_content_from_response QUERY_GIFT_CARDS = """ query giftCards($sortBy: GiftCardSortingInput, $filter: GiftCardFilterInput){ ...
214
5,420
hydra
examples/plugins/example_launcher_plugin/tests/test_example_launcher_plugin.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from pytest import mark from hydra.core.plugins import Plugins from hydra.plugins.launcher import Launcher from hydra.test_utils.launcher_common_tests import ( IntegrationTestSuite, LauncherTestSuite, ) from hydra_plugins.example_launcher...
42
1,132
astropy
astropy/modeling/tests/test_input.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This module tests fitting and model evaluation with various inputs """ import numpy as np import pytest from numpy.testing import assert_allclose from astropy.modeling import fitting, models from astropy.modeling.core import Fittable1DModel, Fittable...
1,217
38,992
pyomo
pyomo/contrib/solver/solvers/gams.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...
646
24,565
conda
tests/plugins/reporter_backends/test_console.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from contextlib import nullcontext from errno import EPIPE from io import StringIO from pathlib import Path from types import SimpleNamespace import pytest from conda.exceptions import CondaError from conda.plugins.reporter_backends.console im...
353
11,431
wandb
tests/unit_tests/test_cli_beta_core.py
.py
from __future__ import annotations from dataclasses import dataclass from click.testing import CliRunner from wandb import env as wandb_env from wandb.cli import beta_core, cli from wandb.proto import wandb_server_pb2 as spb from wandb.sdk.lib.service import service_token @dataclass class _FakeProc: token: serv...
85
2,383
astropy
astropy/units/typing_utils.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Utilities for generating type stubs for unit definition modules. This module is meant for internal use only (in setup.py). """ __all__: list[str] = [] import inspect from collections.abc import Iterable from pathlib import Path from types import Fun...
75
2,119
onnxruntime
tools/python/util/ort_format_model/__init__.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import os import sys # need to add the path to the ORT flatbuffers python module before we import anything else here. # we also auto-magically adjust to whether we're running from the ORT repo, or from within the ORT python ...
28
1,280
metrics
tests/unittests/audio/test_si_sdr.py
.py
# Copyright The Lightning team. # # 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 writin...
151
5,714
black
tests/data/cases/pep646_typed_star_arg_type_var_tuple.py
.py
# flags: --minimum-version=3.11 def fn(*args: *tuple[*A, B]) -> None: pass fn.__annotations__
9
102
kombu
t/integration/test_py_amqp.py
.py
from __future__ import annotations import os import uuid import pytest from amqp.exceptions import NotFound import kombu from kombu.connection import ConnectionPool from .common import (BaseExchangeTypes, BaseFailover, BaseMessage, BasePriority, BaseTimeToLive, BasicFunctionality) def get_con...
147
4,305
confluent-kafka-python
tests/integration/share_consumer_sasl/conftest.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2026 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...
52
1,820
loguru
loguru/_simple_sinks.py
.py
import inspect import logging import weakref from ._asyncio_loop import get_running_loop, get_task_loop class StreamSink: """A sink that writes log messages to a stream object. Parameters ---------- stream A stream object that supports write operations. """ def __init__(self, stream...
242
6,758
mlflow
mlflow/types/llm.py
.py
from __future__ import annotations import time import uuid from dataclasses import asdict, dataclass, field, fields from typing import Any, Literal from mlflow.types.schema import AnyType, Array, ColSpec, DataType, Map, Object, Property, Schema # TODO: Switch to pydantic in a future version of MLflow. # For no...
952
37,735
onnxruntime
onnxruntime/python/tools/transformers/models/longformer/torch_extensions/setup.py
.py
from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CppExtension setup( name="longformer_attention", ext_modules=[ CppExtension( name="longformer_attention", sources=["longformer_attention.cpp"], include_dirs=[], extra_compi...
16
399
saleor
saleor/graphql/discount/tests/deprecated/test_voucher_create.py
.py
import datetime import json from unittest.mock import call, patch import graphene from django.utils import timezone from django.utils.functional import SimpleLazyObject from freezegun import freeze_time from .....core.utils.json_serializer import CustomJsonEncoder from .....discount import DiscountValueType, VoucherT...
277
9,369
returns
returns/pointfree/bind_context.py
.py
from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING, TypeVar from returns.interfaces.specific.reader import ReaderLike2, ReaderLike3 from returns.primitives.hkt import Kind2, Kind3, Kinded, kinded if TYPE_CHECKING: from returns.context import RequiresContext ...
119
3,510
scikit-bio
skbio/metadata/_mixin.py
.py
# ---------------------------------------------------------------------------- # Copyright (c) 2013--, scikit-bio development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file LICENSE.txt, distributed with this software. # --------------------------------------------...
563
18,268
sphinx
tests/test_builders/test_build_text.py
.py
"""Test the build process with Text builder with the test root.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from docutils.utils import column_width from sphinx.testing.util import SphinxTestApp from sphinx.writers.text import MAXWIDTH, Cell, Table if TYPE_CHECKING: from...
267
8,976
coremltools
coremltools/optimize/torch/palettization/_partitioner.py
.py
# Copyright (c) 2024, 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 import math as _math from typing import Optional as _Optional from typing import Tuple as _Tuple imp...
356
14,652
saleor
saleor/graphql/product/tests/mutations/test_product_create.py
.py
import datetime import json from unittest.mock import ANY, patch import graphene import pytest from django.conf import settings from django.utils.text import slugify from freezegun import freeze_time from .....core.taxes import TaxType from .....discount.utils.promotion import get_active_catalogue_promotion_rules fro...
3,830
125,281
astropy
astropy/convolution/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from .convolve import ( convolve, convolve_fft, convolve_models, convolve_models_fft, interpolate_replace_nans, ) from .core import * from .kernels import * from .utils import *
14
264
wagtail
wagtail/utils/forms.py
.py
from django.core.exceptions import ValidationError from django.forms import BaseForm #: A field's location, e.g. ``("title",)`` or, for an InlinePanel-backed #: formset's child field, ``("carousel_items", 0, "link_page")``. FieldPath = tuple[str | int, ...] #: A single error message alongside its Django error code (e...
76
3,184
black
tests/data/cases/preview_comments7.py
.py
# flags: --unstable from .config import ( Any, Bool, ConfigType, ConfigTypeAttributes, Int, Path, # String, # resolve_to_config_type, # DEFAULT_TYPE_ATTRIBUTES, ) from .config import ( Any, Bool, ConfigType, ConfigTypeAttributes, Int, no_comma_here_yet ...
309
8,995
kafka
release/gh_actions.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...
96
3,300
clearml
clearml/backend_api/session/session.py
.py
from __future__ import print_function import json as json_lib import logging import os import sys import types import weakref from io import IOBase from socket import gethostname from time import sleep import jwt import requests from requests.auth import HTTPBasicAuth from requests.exceptions import ( ChunkedEncod...
1,174
46,766
pyro
examples/contrib/oed/ab_test.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import argparse from functools import partial import numpy as np import torch from gp_bayes_opt import GPBayesOptimizer from torch.distributions import constraints import pyro import pyro.contrib.gp as gp from pyro import optim f...
136
4,658
qutip
qutip/solver/sode/_noise.py
.py
import numpy as np __all__ = ["Wiener", "PreSetWiener"] class Wiener: """ Wiener process. """ def __init__(self, t0, dt, generator, shape): self.t0 = t0 self.dt = dt self.shape = shape self.generator = generator self.noise = np.zeros((0,) + shape, dtype=float) ...
145
4,447
openvino
tests/model_hub_tests/pytorch/torch_utils.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os import pytest import torch from models_hub_common.test_convert_model import TestConvertModel from models_hub_common.utils import get_models_list from openvino import convert_model, PartialShape def flattenize_tuples(list_inpu...
136
5,153
pyomo
pyomo/common/unittest.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...
1,117
40,570
hatch
scripts/update_ruff.py
.py
from __future__ import annotations import json import re import subprocess import sys import typing from importlib.metadata import version from utils import ROOT if typing.TYPE_CHECKING: from pathlib import Path # fmt: off UNSELECTED_RULE_PATTERNS: list[str] = [ # Allow non-abstract empty methods in abstrac...
173
5,921
pymc
pymc/step_methods/step_sizes.py
.py
# Copyright 2024 - 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...
106
3,496
mkdocs-material
material/plugins/blog/structure/options.py
.py
# Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com> # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, c...
129
5,081
pyomo
pyomo/contrib/gdpopt/util.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...
565
21,351
pyomo
pyomo/solvers/plugins/solvers/__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...
36
1,008
saleor
saleor/graphql/giftcard/tests/queries/test_gift_cards.py
.py
import graphene import pytest from .....core.anonymize import obfuscate_email from ....tests.utils import get_graphql_content QUERY_GIFT_CARDS = """ query giftCards{ giftCards(first: 10) { edges { node { id last4CodeChars ...
269
9,168
sqlmap
extra/kerberos/discovery.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ # Dependency-free KDC discovery for a realm, so '--auth-type=Negotiate' works without an explicit # KDC address. Resolution order: the 'SQLMAP_KERBEROS_KDC' environment variable, ...
201
7,562
wagtail
wagtail/admin/views/bulk_action/mixins.py
.py
from django.core.exceptions import PermissionDenied from wagtail.models import ReferenceIndex class ReferenceIndexMixin: def annotate_items(self, items): items = super().annotate_items(items) self.object_references = ReferenceIndex.get_grouped_references_to_in_bulk(items) self.is_protecte...
39
1,332
python-prompt-toolkit
src/prompt_toolkit/output/vt100.py
.py
""" Output for vt100 terminals. A lot of thanks, regarding outputting of colors, goes to the Pygments project: (We don't rely on Pygments anymore, because many things are very custom, and everything has been highly optimized.) http://pygments.org/ """ from __future__ import annotations import io import os import sys...
762
23,485
mlflow
dev/clint/tests/rules/test_pytest_mark_repeat.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.pytest_mark_repeat import PytestMarkRepeat def test_pytest_mark_repeat(index: SymbolIndex) -> None: code = """ import pytest @pytest.mark.repeat(10) d...
22
655
onnx
onnx/backend/test/case/node/elu.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 class Elu(Base): @staticmethod def export() -> None: node = ...
38
1,259
openvino
src/bindings/python/tests/test_graph/test_ops.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # flake8: noqa import numpy as np import pytest from contextlib import nullcontext as does_not_raise import openvino.opset8 as ov from openvino import Shape, Type from openvino import AxisSet from openvino.op im...
463
14,454
mlflow
tests/gateway/test_openai_compatibility.py
.py
from unittest import mock import openai import pytest from mlflow.gateway.providers.openai import OpenAIProvider from tests.gateway.tools import ( UvicornGateway, save_yaml, ) @pytest.fixture(scope="module") def config(): return { "endpoints": [ { "name": "chat", ...
160
4,707