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
pyomo
pyomo/contrib/appsi/solvers/maingo.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...
554
20,083
biopython
Tests/pairwise2_testCases.py
.py
#!/usr/bin/env python # 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. """Tests for pairwise2 module. Put new test case here, the classes here will be imported and run as TestCases in ``test_pairwis...
918
27,399
hatch
backend/src/hatchling/cli/metadata/__init__.py
.py
from __future__ import annotations import argparse from typing import Any def metadata_impl( *, called_by_app: bool, # noqa: ARG001 field: str, compact: bool, ) -> None: import json import os from hatchling.bridge.app import Application from hatchling.metadata.core import ProjectMet...
59
1,695
django-cms
cms/test_utils/project/pluginapp/plugins/style/cms_plugins.py
.py
from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from .models import Style class StylePlugin(CMSPluginBase): model = Style name = 'Style' render_template = 'pluginapp/style/style.html' allow_children = True fieldsets = ( (None, { 'fields': ( ...
30
622
metrics
src/torchmetrics/functional/nominal/tschuprows.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...
194
7,639
wagtail
wagtail/models/draft_state.py
.py
from django.core import checks from django.db import models from django.utils.functional import cached_property from django.utils.translation import gettext_lazy as _ from wagtail.actions.publish_revision import PublishRevisionAction from wagtail.actions.unpublish import UnpublishAction from wagtail.locks import Sched...
198
6,657
coremltools
deps/pybind11/tests/test_methods_and_attributes.py
.py
from __future__ import annotations import sys import pytest import env # noqa: F401 from pybind11_tests import ConstructorStats from pybind11_tests import methods_and_attributes as m NO_GETTER_MSG = ( "unreadable attribute" if sys.version_info < (3, 11) else "object has no getter" ) NO_SETTER_MSG = ( "can'...
540
18,462
wagtail
wagtail/contrib/frontend_cache/backends/dummy.py
.py
from .base import BaseBackend class DummyBackend(BaseBackend): def __init__(self): super().__init__() self.urls = [] def purge(self, url) -> None: self.urls.append(url)
12
205
biopython
Bio/Phylo/PhyloXML.py
.py
# Copyright (C) 2009 by Eric Talevich (eric.talevich@gmail.com) # # 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 included as part of this # package. """Classes corres...
1,481
46,829
records
examples/randomuser-sqlite.py
.py
#!/usr/bin/env python3 # coding: utf-8 import json import requests import records # Fetch random user data from randomuser.me API response = requests.get('http://api.randomuser.me/0.6/?nat=us&results=10') user_data = response.json()['results'] # Database connection string DATABASE_URL = 'sqlite:///users.db' # Initi...
37
1,062
sphinx
sphinx/search/_stopwords/fr.py
.py
# automatically generated by utils/generate-snowball.py # from https://github.com/snowballstem/snowball-website/raw/efb4ae4d65769fb1652acbe608c0c817e746c730/algorithms/french/stop.txt from __future__ import annotations FRENCH_STOPWORDS = frozenset({ 'ai', 'aie', 'aient', 'aies', 'ait', 'as', ...
172
2,240
onnxruntime
onnxruntime/test/python/quantization/test_get_qdq_config.py
.py
#!/usr/bin/env python # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # ---------------------------------------------------------------...
490
21,566
saleor
saleor/payment/tests/test_tasks.py
.py
import datetime from decimal import Decimal from unittest import mock from freezegun import freeze_time from ...checkout import CheckoutAuthorizeStatus, CheckoutChargeStatus from ...checkout.actions import transaction_amounts_for_checkout_updated from .. import TransactionAction, TransactionEventType from ..tasks imp...
494
16,931
pyomo
pyomo/common/timing.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,080
37,962
probability
tensorflow_probability/python/experimental/util/__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...
38
1,735
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/trt_utilities.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import tensorrt as trt TRT_LOGGER = trt.Logger(trt.Logger.ERROR) def ...
13
420
openvino
samples/python/hello_classification/hello_classification.py
.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import logging as log import sys import cv2 import numpy as np import openvino as ov def main(): log.basicConfig(format='[ %(levelname)s ] %(message)s', level=log.INFO, stream=sys.std...
114
4,208
beam
sdks/python/apache_beam/testing/pipeline_verifiers.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...
160
5,411
onnxruntime
onnxruntime/test/testdata/transform/computation_reduction/gathernd/gathernd_gelu.py
.py
import onnx from onnx import OperatorSetIdProto, TensorProto, helper X = helper.make_tensor_value_info("input", TensorProto.FLOAT, ["batch", "seqlen", 128]) unsqueezed_masked_lm_positions = helper.make_tensor_value_info( "unsqueezed_masked_lm_positions", TensorProto.INT64, ["batch", "dynamic_prediction_cou...
48
1,495
clearml
clearml/backend_config/__init__.py
.py
from .defs import Environment from .config import Config, ConfigEntry from .errors import ConfigurationError from .environment import EnvEntry __all__ = ["Environment", "Config", "ConfigEntry", "ConfigurationError", "EnvEntry"]
7
229
bazel
third_party/py/abseil/absl/flags/_validators.py
.py
# Copyright 2017 The Abseil 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 ...
353
14,144
black
tests/data/cases/expression.py
.py
... 'some_string' b'\\xa3' Name None True False 1 1.0 1j True or False True or False or None True and False True and False and None (Name1 and Name2) or Name3 Name1 and Name2 or Name3 Name1 or (Name2 and Name3) Name1 or Name2 and Name3 (Name1 and Name2) or (Name3 and Name4) Name1 and Name2 or Name3 and Name4 Name1 or (...
631
18,624
mlflow
mlflow/entities/model_registry/prompt.py
.py
""" Prompt entity for MLflow Model Registry. This represents a prompt in the registry with its metadata, without version-specific content like template text. For version-specific content, use PromptVersion. """ class Prompt: """ Entity representing a prompt in the MLflow Model Registry. This contains pr...
72
2,151
saleor
saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_free_shipping_voucher_with_min_spent_amount.py
.py
import pytest from ....product.utils.preparing_product import prepare_product from ....shop.utils import prepare_default_shop from ....utils import assign_permissions from ....vouchers.utils import create_voucher, create_voucher_channel_listing from ...utils import ( checkout_add_promo_code, checkout_complete,...
180
5,583
qutip
qutip/tests/test_qpt.py
.py
import numpy as np import scipy.linalg as la from qutip import spre, spost, qeye, sigmax, sigmay, sigmaz, qpt from qutip.core.gates import snot, cnot def test_qpt_snot(): "quantum process tomography for snot gate" U_psi = snot() U_rho = spre(U_psi) * spost(U_psi.dag()) N = 1 op_basis = [[qeye(2)...
47
1,350
coveragepy
tests/modules/usepkgs.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 import pkg1.p1a, pkg1.p1b, pkg1.sub import pkg2.p2a, pkg2.p2b import othermods.othera, othermods.otherb import othermods.sub.osa, othermods.sub.osb import ambiguo...
9
349
saleor
saleor/giftcard/tests/fixtures/giftcard.py
.py
import datetime import secrets import pytest from ....core.prices import Money from ....graphql.giftcard.tests.benchmark import GIFT_CARD_COUNT_IN_BENCHMARKS from ... import GiftCardEvents from ...models import GiftCard, GiftCardEvent, GiftCardTag @pytest.fixture def gift_card(customer_user): gift_card = GiftCa...
148
4,186
qutip
qutip/tests/solver/test_brmesolve.py
.py
import pytest import numpy as np import qutip from qutip.solver.brmesolve import brmesolve from qutip.core.environment import ( DrudeLorentzEnvironment, LorentzianEnvironment ) def pauli_spin_operators(): return [qutip.sigmax(), qutip.sigmay(), qutip.sigmaz()] _simple_qubit_gamma = 0.25 coeff = qutip.coeffi...
394
13,266
kombu
t/unit/asynchronous/aws/sqs/test_connection.py
.py
from __future__ import annotations import json from unittest import mock from unittest.mock import MagicMock, Mock import pytest from kombu.asynchronous.aws.ext import AWSRequest, boto3 from kombu.asynchronous.aws.sqs.connection import (AsyncSQSConnection, _query_ob...
752
27,156
wandb
tests/unit_tests/test_trace_tree.py
.py
import time import pytest from wandb.sdk.data_types.trace_tree import Span, SpanKind, StatusCode, Trace def test_trace_creation(): t = Trace(name="test_trace", kind="LLM", status_code="SUCCESS") assert isinstance(t._span, Span) assert t._span.name == "test_trace" assert t._span.span_kind == SpanKind....
306
8,676
openvino
tests/layer_tests/pytorch_tests/test_mm.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest from pytorch_layer_test_class import PytorchLayerTest class TestMatMul(PytorchLayerTest): def _prepare_input(self, matrix1_shape=(2, 2), matrix2_shape=(2, 2)): return (self.random.randn(*matrix1_shape), self....
88
3,753
django-cms
cms/models/query.py
.py
import warnings from collections import Counter from django.db import models from django.db.models import Case, F, When from cms.exceptions import NoHomeFound from cms.utils.compat.warnings import RemovedInDjangoCMS60Warning from cms.utils.mptree import get_queryset_base, get_tree_backend # Resolved once at import t...
134
5,082
pyomo
pyomo/core/expr/relational_expr.py
.py
# -*- coding: utf-8 -*- # ____________________________________________________________________________________ # # 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 En...
910
28,912
saleor
saleor/graphql/account/tests/fixtures/utils.py
.py
import random import uuid from .....account import CustomerEvents from .....account.models import CustomerEvent, Group from .....giftcard.models import GiftCard GIFT_CARDS_PER_USER = 5 EVENTS_PER_USER = 5 GROUPS_PER_USER = 5 def prepare_events_for_user(user): events = [ CustomerEvent(type=random.choice(...
39
982
sphinx
sphinx/environment/adapters/asset.py
.py
"""Assets adapter for sphinx.environment.""" from __future__ import annotations from typing import TYPE_CHECKING from sphinx.util._pathlib import _StrPath if TYPE_CHECKING: from sphinx.environment import BuildEnvironment class ImageAdapter: def __init__(self, env: BuildEnvironment) -> None: self.e...
23
573
saleor
saleor/graphql/__init__.py
.py
from typing import Any, NotRequired, TypedDict class GraphQLOperationResult(TypedDict): data: NotRequired[dict[str, Any] | None] errors: NotRequired[list[dict[str, Any]] | None] extensions: NotRequired[dict[str, dict] | None]
8
240
coremltools
coremltools/converters/mil/mil/ops/tests/iOS18/test_states.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 itertools import platform import numpy as np import pytest from coremltools.converters.mil.mil...
342
10,028
textual
src/textual/actions.py
.py
from __future__ import annotations import ast import re from functools import lru_cache from typing import Any from typing_extensions import TypeAlias ActionParseResult: TypeAlias = "tuple[str, str, tuple[object, ...]]" """An action is its name and the arbitrary tuple of its arguments.""" class SkipAction(Exceptio...
60
1,669
jupytext
tests/external/pre_commit/test_pre_commit_scripts.py
.py
import os import stat import unittest.mock as mock import pytest from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook from jupytext import read, write from jupytext.cli import jupytext, system from jupytext.compare import compare_cells, compare_notebooks def git_in_tmpdir(tmpdir): """Re...
390
12,544
pyro
tests/__init__.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import logging import os # create log handler for tests level = logging.INFO if "CI" in os.environ else logging.DEBUG logging.basicConfig(format="%(levelname).1s \t %(message)s", level=level)
10
282
conda
tests/gateways/test_repodata_gateway.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """ Strongly related to subdir_data / test_subdir_data. """ from __future__ import annotations import datetime import json import math import sys import time from pathlib import Path from typing import TYPE_CHECKING import pytest from conda....
529
16,138
pyomo
doc/OnlineDocs/src/data/param6.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...
35
1,147
onnx
onnx/backend/test/case/node/instancenorm.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 InstanceNormalization(Base): @staticmethod def export() -> Non...
59
2,010
wandb
tests/unit_tests/test_api_utils.py
.py
import pytest from wandb.apis.public.utils import ( fetch_org_from_settings_or_entity, parse_org_from_registry_path, ) from wandb.sdk.internal.internal_api import _OrgNames @pytest.mark.parametrize( "path, path_type, expected", [ # Valid cases ("my-org/wandb-registry-model", "project",...
98
3,944
sqlmap
lib/parse/sitemap.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import re from lib.core.common import readInput from lib.core.convert import htmlUnescape from lib.core.data import kb from lib.core.data import logger from lib.core.datatype imp...
86
3,378
qutip
qutip/core/options.py
.py
# Required for Sphinx to follow autodoc_type_aliases from __future__ import annotations from ..settings import settings from .numpy_backend import np as qt_np import numpy from typing import overload, Literal, Any import types __all__ = ["CoreOptions"] class QutipOptions: """ Class for basic functionality f...
269
8,893
python-prompt-toolkit
examples/prompts/auto-completion/nested-autocompletion.py
.py
#!/usr/bin/env python """ Example of nested autocompletion. """ from prompt_toolkit import prompt from prompt_toolkit.completion import NestedCompleter completer = NestedCompleter.from_nested_dict( { "show": {"version": None, "clock": None, "ip": {"interface": {"brief": None}}}, "exit": None, ...
24
468
coremltools
coremltools/test/xgboost_tests/test_boosted_trees_regression_numeric.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 import itertools import unittest import pandas as pd import pytest from ..utils import load_boston fro...
310
11,011
pyomo
scripts/performance/main.py
.py
#!/usr/bin/env python # ____________________________________________________________________________________ # # 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 Engi...
258
8,292
mlflow
mlflow/utils/request_utils.py
.py
# DO NO IMPORT MLFLOW IN THIS FILE. # This file is imported by download_cloud_file_chunk.py. # Importing mlflow is time-consuming and we want to avoid that in artifact download subprocesses. import os import random import socket from functools import lru_cache import requests import urllib3 from packaging.version impo...
325
12,039
mlflow
mlflow/protos/webhooks_pb2.py
.py
import google.protobuf from packaging.version import Version if Version(google.protobuf.__version__).major >= 5: # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: webhooks.proto # Protobuf Python Version: 5.26.0 """Generated protocol buffer code.""" from google.pr...
389
30,378
pyro
pyro/nn/auto_reg_nn.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import warnings from typing import List, Optional, Sequence, Tuple, Union import torch import torch.nn as nn from torch.nn import functional as F def sample_mask_indices( input_dim: int, hidden_dim: int, simple: bool = True ...
359
14,455
mlflow
dev/clint/tests/rules/test_extraneous_docstring_param.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.extraneous_docstring_param import ExtraneousDocstringParam def test_extraneous_docstring_param(index: SymbolIndex) -> None: code = ''' def bad_function...
35
1,036
onnxruntime
onnxruntime/python/tools/transformers/fusion_gelu.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_base import Fusion from onnx ...
259
10,193
mlflow
tests/pytorch/test_pytorch_autolog.py
.py
from unittest import mock import numpy as np import pytest import pytorch_lightning as pl import torch from packaging.version import Version from pytorch_lightning.callbacks import ModelCheckpoint from pytorch_lightning.callbacks.early_stopping import EarlyStopping import mlflow import mlflow.pytorch from mlflow impo...
832
28,002
openvino
tests/layer_tests/jax_tests/test_binary_comparison.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest from jax import lax from jax import numpy as jnp from jax_layer_test_class import JaxLayerTest rng = np.random.default_rng(56342) class TestBinaryComparison(JaxLayerTest): def _prepare_input(self):...
60
2,409
confluent-kafka-python
src/confluent_kafka/schema_registry/rules/encryption/hcvault/hcvault_client.py
.py
# Copyright 2024 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 required by applicable law or agreed to in writi...
101
3,781
pdm
src/pdm/misc/sysconfig_patcher.py
.py
# Copyright 2024 Ulrik Sverdrup "bluss" # # 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, copy, modify, merge, publish, ...
285
9,594
black
src/black/ranges.py
.py
"""Functions related to Black's formatting by line ranges feature.""" import difflib from collections.abc import Collection, Iterator, Sequence from dataclasses import dataclass from black.nodes import ( LN, STANDALONE_COMMENT, Leaf, Node, Visitor, first_leaf, furthest_ancestor_with_last_l...
638
25,579
black
tests/data/cases/multiline_strings.py
.py
"""cow say""", call(3, "dogsay", textwrap.dedent("""dove coo""" % "cowabunga")) call(3, "dogsay", textwrap.dedent("""dove coo""" % "cowabunga")) call(3, textwrap.dedent("""cow moo""" % "cowabunga"), "dogsay") call(3, "dogsay", textwrap.dedent("""crow caw""" % "cowabunga"),) call(3, textwrap.dedent("""cat ...
540
9,985
probability
spinoffs/inference_gym/inference_gym/targets/bayesian_model.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...
103
3,650
pyomo
pyomo/core/plugins/transform/discrete_vars.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...
280
10,548
deap
doc/code/tutorials/part_2/2_1_fitness.py
.py
## 2.1 Fitness from deap import base from deap import creator ## FitnessMin creator.create("FitnessMin", base.Fitness, weights=(-1.0,)) ## FitnessMulti creator.create("FitnessMulti", base.Fitness, weights=(-1.0, 1.0))
10
220
hatch
tests/helpers/templates/wheel/standard_default_build_script.py
.py
from hatch.template import File from hatch.utils.fs import Path from hatchling.__about__ import __version__ from hatchling.metadata.spec import DEFAULT_METADATA_VERSION from ..new.feature_no_src_layout import get_files as get_template_files from .utils import update_record_file_contents def get_files(**kwargs): ...
50
1,294
omegaconf
tests/test_tuple_integration.py
.py
from dataclasses import dataclass from typing import Any, Dict, Tuple from pytest import raises from omegaconf import MISSING, DictConfig, Node, OmegaConf, TupleConfig, read_write from omegaconf.errors import ConfigTypeError, InterpolationToMissingValueError @dataclass class TupleObject: values: Tuple[int, str]...
187
5,905
ipython
IPython/terminal/tests/test_ptutils.py
.py
"""Tests for IPython.terminal.ptutils elision helpers.""" import os import pytest from IPython.terminal.ptutils import _elide_point, _elide_typed ELLIPSIS = "\N{HORIZONTAL ELLIPSIS}" # --------------------------------------------------------------------------- # _elide_point # ---------------------------------------...
87
3,139
openvino
src/bindings/python/tests/test_graph/test_random_uniform.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import openvino.opset8 as ops from openvino import Type def test_random_uniform(): input_tensor = ops.constant(np.array([2, 4, 3], dtype=np.int32)) min_val = ops.constant(np.array([-2....
22
884
openvino
tests/layer_tests/pytorch_tests/test_multinomial.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest import torch from pytorch_layer_test_class import PytorchLayerTest class TestMultinomial(PytorchLayerTest): def _prepare_input(self, input, num_samples, out): model_inputs = [input, np.arra...
101
3,438
hatch
src/hatch/cli/self/report.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Any import click if TYPE_CHECKING: from hatch.cli.application import Application def get_install_source(platform_name: str) -> str: import os import sys import sysconfig from platformdirs import user_data_dir from hatch....
130
3,890
python-prompt-toolkit
src/prompt_toolkit/input/ansi_escape_sequences.py
.py
""" Mappings from VT100 (ANSI) escape sequences to the corresponding prompt_toolkit keys. We are not using the terminfo/termcap databases to detect the ANSI escape sequences for the input. Instead, we recognize 99% of the most common sequences. This works well, because in practice, every modern terminal is mostly Xter...
345
13,663
openvino
tests/layer_tests/tensorflow_tests/test_tf_Div.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 class TestDiv(CommonTFLayerTest): def _prepare_input(self, inputs_info): assert 'x:0' in inputs_info ...
49
1,926
returns
returns/interfaces/container.py
.py
from collections.abc import Callable, Sequence from typing import ClassVar, Never, TypeVar, final from returns.interfaces import applicative, bindable from returns.primitives.asserts import assert_equal from returns.primitives.hkt import KindN from returns.primitives.laws import ( Law, Law1, Law3, Lawf...
132
3,636
openvino
tests/model_hub_tests/models_hub_common/test_convert_model.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import gc import os import numpy as np # noinspection PyUnresolvedReferences try: import openvino_tokenizers # do not delete, needed for text models except: pass from models_hub_common.multiprocessing_utils import multiprocessin...
142
5,908
pyfilesystem2
tests/test_iotools.py
.py
from __future__ import unicode_literals import io import six import unittest from fs import iotools, tempfs from fs.test import UNICODE_TEXT class TestIOTools(unittest.TestCase): def setUp(self): self.fs = tempfs.TempFS("iotoolstest") def tearDown(self): self.fs.close() del self.fs ...
157
5,357
flit
flit_core/flit_core/config.py
.py
import difflib from email.headerregistry import Address import errno import logging import os import os.path as osp from pathlib import Path import re try: import tomllib except ImportError: try: from .vendor import tomli as tomllib # Some downstream distributors remove the vendored tomli. # Wh...
793
28,790
gunicorn
tests/test_dirty_client.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Tests for dirty client module.""" import os import socket import tempfile import threading import pytest from gunicorn.dirty.client import ( DirtyClient, get_dirty_client, get_dirty_socket_path, ...
325
10,548
mlflow
mlflow/genai/judges/prompts/relevance_to_query.py
.py
from mlflow.genai.prompts.utils import format_prompt # NB: User-facing name for the is_context_relevant assessment. RELEVANCE_TO_QUERY_ASSESSMENT_NAME = "relevance_to_context" RELEVANCE_TO_QUERY_PROMPT_INSTRUCTIONS = """\ Consider the following question and answer. You must determine whether the answer provides \ in...
37
1,397
openvino
tests/e2e_tests/common/plugins/ref_collect/conftest.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 """Local pytest plugin for reference collection.""" import logging as log import yaml import e2e_tests.common.plugins.common.base_conftest as base from e2e_tests.common.env_utils import fix_env_conf from e2e_tests.test_utils.env_tools...
57
2,178
mlflow
mlflow/assistant/providers/claude_code.py
.py
""" Claude Code provider for MLflow Assistant. This module provides the Claude Code integration for the assistant API, enabling AI-powered trace analysis through the Claude Code CLI. """ import asyncio import json import logging import os import shutil import subprocess import tempfile from pathlib import Path from t...
852
38,926
pyro
pyro/infer/abstract_infer.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import numbers import warnings from abc import ABCMeta, abstractmethod from collections import OrderedDict, defaultdict import torch import pyro.poutine as poutine from pyro.distributions import Categorical, Empirical from pyro.o...
397
16,011
openvino
tests/layer_tests/pytorch_tests/test_repeat.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest from pytorch_layer_test_class import PytorchLayerTest class TestRepeat(PytorchLayerTest): def _prepare_input(self): return (self.random.randn(2, 10),) def create_model(self, repeats): import torc...
85
2,910
sphinx
tests/roots/test-ext-autosummary-ext/dummy_module.py
.py
""" .. autosummary:: module_attr C.class_attr C.instance_attr C.prop_attr1 C.prop_attr2 C.C2 """ # NoQA: D212 def with_sentence(): """I have a sentence which spans multiple lines. Then I have more stuff """ pass def no_sentence(): """this doesn't start with a capital....
82
1,320
saleor
saleor/permission/tests/test_all_permissions_required.py
.py
from unittest.mock import Mock import pytest from ..auth_filters import AuthorizationFilters from ..enums import CheckoutPermissions from ..utils import one_of_permissions_or_auth_filter_required @pytest.mark.parametrize( ("permissions", "expected_result"), [ (None, True), ([], True), ...
209
5,898
mlflow
tests/genai/scorers/trulens/test_trulens.py
.py
from unittest.mock import Mock, patch import pytest import trulens # noqa: F401 from mlflow.entities.assessment import Feedback from mlflow.entities.assessment_source import AssessmentSourceType from mlflow.exceptions import MlflowException from mlflow.genai.judges.utils import CategoricalRating from mlflow.genai.sc...
291
10,665
saleor
saleor/graphql/account/mutations/authentication/set_password.py
.py
import graphene from django.contrib.auth import password_validation from django.core.exceptions import ObjectDoesNotExist, ValidationError from .....account import events as account_events from .....account import models from .....account.error_codes import AccountErrorCode from .....core.db.connection import allow_wr...
99
3,880
pdm
tests/fixtures/projects/demo-prerelease/setup.py
.py
from setuptools import setup setup( name="demo", version="0.0.2b0", description="test demo", py_modules=["demo"], python_requires=">=3.3", install_requires=["idna", "chardet; os_name=='nt'"], extras_require={ "tests": ["pytest"], "security": ['requests; python_version>="3.6...
16
334
conda
conda/auxlib/__init__.py
.py
"""Auxlib is an auxiliary library to the python standard library. The aim is to provide core generic features for app development in python. Auxlib fills in some python stdlib gaps much like `pytoolz <https://github.com/pytoolz/>`_ has for functional programming, `pyrsistent <https://github.com/tobgu/pyrsistent/>`_ ha...
91
3,042
wandb
wandb/sdk/lib/progress.py
.py
"""Defines an object for printing run progress at the end of a script.""" from __future__ import annotations import asyncio import contextlib import time from collections.abc import Generator from typing import NoReturn from wandb.proto import wandb_internal_pb2 as pb from wandb.sdk.interface import interface from w...
360
11,159
mlflow
tests/pyfunc/sample_code/utils.py
.py
def my_function(input): return f"My utils function received this input: {input}"
3
85
saleor
saleor/graphql/attribute/resolvers.py
.py
from ...attribute import models from ..core.context import get_database_connection_name from ..utils import get_user_or_app_from_context def resolve_attributes(info, qs=None): requestor = get_user_or_app_from_context(info.context) qs = qs or models.Attribute.objects.using( get_database_connection_name...
12
386
onnxruntime
onnxruntime/python/backend/backend.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Implements ONNX's backend API. """ import os import unittest import...
215
10,233
biopython
Tests/test_SearchIO_blast_xml_index.py
.py
# Copyright 2012 by Wibowo Arindrarto. 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. """Tests for SearchIO blast-xml indexing.""" import unittest from search_tests_common im...
767
38,120
gunicorn
tests/test_asgi_callback_parser.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Tests for ASGI callback parsers. Tests both PythonProtocol and H1CProtocol (if available) to ensure consistent behavior across implementations. """ from gunicorn.asgi.parser import PythonProtocol def get_par...
615
19,379
kafka
tests/kafkatest/tests/core/replication_replica_failure_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 use ...
117
5,472
pyomo
pyomo/scripting/pyomo_parser.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...
120
3,812
textual
docs/examples/how-to/center06.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static QUOTE = "Could not find you in Seattle and no terminal is in operation at your classified address." class CenterApp(App): """How to center things.""" CSS = """ Screen { align: center middle; } #hello { ...
31
597
readthedocs.org
readthedocs/core/management/commands/collectstatic.py
.py
""" Override to send ``pre_collectstatic`` and ``post_collectstatic`` signal. ``post_collectstatic`` is used to purge the CDN of static files. """ from django.contrib.staticfiles.management.commands import collectstatic from readthedocs.core.signals import post_collectstatic from readthedocs.core.signals import pre_...
19
585
saleor
saleor/graphql/product/tests/mutations/test_product_media_create.py
.py
import json import os from unittest.mock import Mock, patch import graphene import pytest from django.conf import settings from requests import RequestException from requests.exceptions import InvalidSchema from requests_hardened.ip_filter import InvalidIPAddress from .....graphql.tests.utils import get_graphql_conte...
627
20,064
gunicorn
tests/docker/asgi_framework_compat/frameworks/blacksheep_app/app.py
.py
""" BlackSheep ASGI Application for Compatibility Testing Implements the contract endpoints for ASGI 3.0 compliance testing. BlackSheep is a high-performance ASGI framework. """ import asyncio import json import time from typing import Any from blacksheep import Application, Request, WebSocket, StreamedContent, Cont...
228
6,835
sphinx
sphinx/search/fi.py
.py
"""Finnish search language.""" from __future__ import annotations import snowballstemmer from sphinx.search import SearchLanguage from sphinx.search._stopwords.fi import FINNISH_STOPWORDS class SearchFinnish(SearchLanguage): lang = 'fi' language_name = 'Finnish' js_stemmer_rawcode = 'finnish-stemmer.js...
23
596