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
mlflow
tests/langchain/test_responses_agent_langchain.py
.py
import json from langchain_core.messages import AIMessage, HumanMessage, ToolMessage from mlflow.types.responses import ResponsesAgentStreamEvent, output_to_responses_items_stream def test_output_to_responses_items_stream_langchain(): """ Tests langchain message stream to responses items stream conversion. ...
407
14,783
pdm
src/pdm/__version__.py
.py
import importlib.metadata import importlib.resources def read_version() -> str: try: return importlib.metadata.version(__package__ or "pdm") except importlib.metadata.PackageNotFoundError: return importlib.resources.read_text("pdm", "VERSION").strip() __version__ = read_version()
13
309
wagtail
wagtail/admin/paginator.py
.py
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.utils.functional import cached_property from django.utils.translation import gettext as _ class WagtailPaginator(Paginator): num_page_buttons = 6 @cached_property def model(self): return getattr(self.object_list,...
96
3,393
kafka
release/runtime.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...
147
4,034
wandb
tests/unit_tests/test_launch/test_inputs/test_internal.py
.py
"""Test internal methods of the job input management sdk.""" import platform import sys from enum import Enum from unittest.mock import MagicMock import pytest from pydantic import BaseModel, Field from wandb.sdk.launch.errors import LaunchError from wandb.sdk.launch.inputs.internal import ( ConfigTmpDir, Job...
771
25,827
textual
tests/test_fuzzy.py
.py
from textual.content import Span from textual.fuzzy import Matcher from textual.style import Style def test_no_match(): """Check non matching score of zero.""" matcher = Matcher("x") assert matcher.match("foo") == 0 def test_match_single_group(): """Check that single groups rang higher.""" match...
40
1,092
confluent-kafka-python
tests/test_docs.py
.py
#!/usr/bin/env python import enum import re import sys from collections import defaultdict from types import ModuleType import confluent_kafka def build_doctree(tree, prefix, parent): """Build doctree dict with format: dict key = full class/type name (e.g, "confluent_kafka.Message.timestamp") value = ob...
105
3,516
saleor
saleor/graphql/warehouse/bulk_mutations/stock_bulk_update.py
.py
from collections import defaultdict import graphene from django.core.exceptions import ValidationError from django.db.models import F, Q from ....core.tracing import traced_atomic_transaction from ....core.utils.events import call_event from ....permission.enums import ProductPermissions from ....warehouse import mod...
461
16,678
biopython
Scripts/xbbtools/xbbtools.py
.py
#!/usr/bin/env python # Copyright 2000 by Thomas Sicheritz-Ponten. # Copyright 2016 by Markus Piotrowski. # 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. # Created: Thu Jul 13 ...
29
701
sqlmap
lib/core/readlineng.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ _readline = None try: import readline as _readline except: try: import pyreadline as _readline except: pass if _readline: _symbols = getattr(_read...
69
1,998
saleor
saleor/tests/e2e/checkout/test_checkout_complete_respect_saving_address_settings.py
.py
import pytest from .. import ADDRESS_DE from ..account.utils import get_own_data from ..product.utils.preparing_product import prepare_product from ..shop.utils.preparing_shop import prepare_default_shop from ..utils import assert_address_data, assign_permissions from .utils import ( checkout_complete, checkou...
133
4,343
mlflow
dev/clint/tests/rules/test_unnamed_thread_pool.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 import UnnamedThreadPool def test_thread_pool_executor(index: SymbolIndex) -> None: code = """ from concurrent.futures import ThreadPoolExecutor # Bad...
24
657
returns
tests/test_contrib/test_hypothesis/test_laws/test_unsatisfiable_type.py
.py
from collections.abc import Callable from typing import TypeVar import pytest from hypothesis.errors import ResolutionFailed from returns.contrib.hypothesis.laws import check_all_laws from returns.interfaces import mappable from returns.primitives.container import BaseContainer from returns.primitives.hkt import Supp...
34
911
wandb
tests/system_tests/test_core/test_footer.py
.py
from __future__ import annotations import re import wandb def _run_history_lines(lines: list[str]) -> list[str]: """Returns the lines corresponding to the run history footer.""" try: header_idx = lines.index("wandb: Run history:") end_idx = lines.index("wandb:", header_idx) except ValueE...
142
3,991
pyfilesystem2
fs/constants.py
.py
"""Constants used by PyFilesystem. """ import io DEFAULT_CHUNK_SIZE = io.DEFAULT_BUFFER_SIZE * 16 """`int`: the size of a single chunk read from or written to a file. """
9
173
pyro
pyro/distributions/improper_uniform.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import torch from torch.distributions import constraints from .torch_distribution import TorchDistribution from .util import broadcast_shape class ImproperUniform(TorchDistribution): """ Improper distribution with zero :meth...
69
2,448
sphinx
tests/test_highlighting.py
.py
"""Test the Pygments highlighting bridge.""" from __future__ import annotations from typing import TYPE_CHECKING from unittest import mock import pygments import pytest from pygments.formatters.html import HtmlFormatter from pygments.lexer import RegexLexer from pygments.token import Name, Text from sphinx.highligh...
135
4,009
openvino
tests/layer_tests/tensorflow_tests/test_tf_CTCGreedyDecoder.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest from common.tf_layer_test_class import CommonTFLayerTest import numpy as np import tensorflow as tf # Testing operation CTCGreedyDecoder # Documentation: https://www.tensorflow.org/api_docs/python/tf/raw_ops/CTCGreedyDec...
66
2,354
saleor
saleor/graphql/product/tests/mutations/test_collection_create.py
.py
import os from unittest.mock import patch import graphene import pytest from .....product.error_codes import CollectionErrorCode from .....product.models import Collection from .....product.tests.utils import create_image from .....tests.utils import dummy_editorjs from ....tests.utils import ( get_graphql_conten...
246
7,992
coveragepy
coverage/python.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 """Python source expertise for coverage.py""" from __future__ import annotations import os.path import types import zipimport from collections.abc import Iterab...
272
8,732
clearml
examples/router/http_router.py
.py
""" Example on how to use the ClearML HTTP router. For this example, you would first need a webserver to route the traffic to: `simple_webserver.py` launches such a server. Running the script will start a webserver, bound to localhost:8000. Then, when running this example, it creates a router which binds to 0.0.0.0:90...
43
1,734
pymc
tests/step_methods/hmc/test_hmc.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...
91
3,252
wagtail
wagtail/actions/copy_for_translation.py
.py
from django.core.exceptions import PermissionDenied from django.db import transaction from wagtail.actions.base import BaseAction from wagtail.coreutils import find_available_slug from wagtail.models.copying import _copy from wagtail.signals import copy_for_translation_done class ParentNotTranslatedError(Exception):...
262
8,765
mlflow
mlflow/store/_unity_catalog/registry/uc_native_rest_store.py
.py
"""Unity Catalog model-registry store that talks to the native /api/2.1/unity-catalog/* surface. ``UcNativeModelRegistryStore`` subclasses :class:`UcModelRegistryStore` and overrides the model-registry operations that have a native Unity Catalog equivalent so they issue requests against the native ``UnityCatalogServic...
668
28,709
pyfilesystem2
tests/test_move.py
.py
from __future__ import unicode_literals import unittest try: from unittest import mock except ImportError: import mock from parameterized import parameterized, parameterized_class import fs.move from fs import open_fs from fs.errors import FSError, ResourceReadOnly from fs.path import join from fs.wrap impo...
209
8,991
scikit-bio
skbio/stats/ordination/_utils.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. # --------------------------------------------...
290
9,969
saleor
saleor/order/tests/test_actions.py
.py
from unittest.mock import patch import pytest from ...graphql.core.utils import to_global_id_or_none from ...webhook.utils import get_webhooks_for_multiple_events from .. import OrderStatus from ..actions import ( WEBHOOK_EVENTS_FOR_ORDER_CREATED, _get_extra_for_order_line_logger, _get_extra_for_order_log...
181
5,334
pyomo
pyomo/core/tests/unit/kernel/test_parameter.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...
324
10,440
probability
tensorflow_probability/python/internal/cache_util.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...
569
20,570
pyomo
examples/pyomo/benders/subproblem.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...
145
4,159
beam
sdks/python/apache_beam/examples/complete/autocomplete_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...
75
2,604
mlflow
mlflow/store/db_migrations/versions/39d1c3be5f05_add_is_nan_constraint_for_metrics_tables_if_necessary.py
.py
"""add_is_nan_constraint_for_metrics_tables_if_necessary Create Date: 2021-03-16 20:40:24.214667 """ import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. revision = "39d1c3be5f05" down_revision = "a8c4a736bde6" branch_labels = None depends_on = None def upgrade(): # This par...
40
1,415
saleor
saleor/tests/e2e/vouchers/utils/voucher_catalogues_add.py
.py
from ...utils import get_graphql_content VOUCHER_CATALOGUE_ADD_MUTATION = """ mutation VoucherCataloguesAdd($id: ID!, $input: CatalogueInput!) { voucherCataloguesAdd(id: $id, input: $input) { errors { message field } voucher { id code type discountValueType chann...
59
1,255
beam
sdks/python/apache_beam/io/gcp/pubsub_test.py
.py
# coding=utf-8 # # 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");...
1,284
49,732
saleor
saleor/tests/e2e/metadata/utils/delete_metadata.py
.py
from ...utils import get_graphql_content METADATA_DELETE_MUTATION = """ mutation DeleteMetadata( $id: ID!, $keys:[String!]!, ) { deleteMetadata(id: $id, keys: $keys) { errors { message field } item { metadata { key value } } } } """ def delet...
42
750
wandb
tests/system_tests/test_functional/multiprocessing/test_mp.py
.py
import functools import multiprocessing import pathlib import subprocess import pytest import wandb from tests.fixtures.wandb_backend_spy import WandbBackendSpy @pytest.mark.parametrize( "start_method", ["spawn", "forkserver"], ) def test_share_child_base( wandb_backend_spy: WandbBackendSpy, start_m...
71
2,007
beam
sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql_it_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...
635
21,500
voila
tests/execute_output_test.py
.py
import os from copy import deepcopy from nbformat import NO_CONVERT, read from voila.execute import executenb BASE_DIR = os.path.dirname(__file__) WIDGET_MIME_TYPE_VIEW = "application/vnd.jupyter.widget-view+json" WIDGET_MIME_TYPE_STATE = "application/vnd.jupyter.widget-state+json" # based on nbconvert.preprocesso...
61
2,304
jupytext
tests/functional/round_trip/test_mirror.py
.py
"""Here we generate mirror representation of py, Rmd and ipynb files as py or ipynb, and make sure that these representations minimally change on new releases. """ import os import re import pytest from nbformat.v4.nbbase import new_notebook import jupytext from jupytext.compare import ( assert_conversion_same_a...
181
6,146
readthedocs.org
readthedocs/subscriptions/utils.py
.py
"""Utilities to interact with subscriptions and stripe.""" import structlog from django.conf import settings from djstripe import models as djstripe from readthedocs.payments.utils import get_stripe_api_key from readthedocs.payments.utils import get_stripe_client log = structlog.get_logger(__name__) def create_st...
71
2,524
coremltools
coremltools/converters/mil/backend/nn/passes/test_passes.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 copy import itertools import numpy as np import pytest from coremltools.converters.mil impor...
228
7,734
beam
sdks/python/apache_beam/io/external/kafka.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...
32
1,175
astropy
astropy/timeseries/periodograms/lombscargle/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ lombscargle =========== AstroPy-compatible implementation of the Lomb-Scargle periodogram. """ from .core import LombScargle
10
195
onnxruntime
orttraining/orttraining/python/training/experimental/gradient_graph/_gradient_graph_tools.py
.py
import io from collections.abc import Callable from pathlib import Path from typing import Any import torch from torch.onnx import TrainingMode from onnxruntime.capi._pybind_state import GradientGraphBuilder from ...ortmodule._custom_op_symbolic_registry import CustomOpSymbolicRegistry def export_gradient_graph( ...
92
3,386
mlflow
dev/clint/tests/rules/test_prefer_dict_union.py
.py
from pathlib import Path import pytest from clint.config import Config from clint.index import SymbolIndex from clint.linter import lint_file from clint.rules import PreferDictUnion @pytest.mark.parametrize( "code", [ pytest.param("{**dict1, **dict2}", id="two_dict_unpacks"), pytest.param("{*...
48
1,976
confluent-kafka-python
tests/test_ShareConsumer_callbacks.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Unit tests for ShareConsumer callback dispatch. Covers the librdkafka callbacks routed through common_conf_setup (error_cb, throttle_cb, stats_cb, log_cb, and oauthbearer_token_refresh_cb), plus the share-consumer paths where they may be dispatched (poll, commit_sync, ...
1,046
35,068
onnx
onnx/reference/ops/op_add.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 OpRunBinaryNumpy class Add(OpRunBinaryNumpy): def __init__(self, onnx_node, run_params): OpRunBinaryNumpy.__init__(self, np.add, onnx_...
14
338
hydra
examples/tutorials/structured_configs/1_minimal/my_app.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from dataclasses import dataclass import hydra from hydra.core.config_store import ConfigStore @dataclass class MySQLConfig: host: str = "localhost" port: int = 3306 cs = ConfigStore.instance() # Registering the Config class with the na...
26
540
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_p_norm.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # p_norm paddle model generator # import sys import numpy as np import paddle if paddle.__version__ >= '2.6.0': from paddle.base.layer_helper import LayerHelper else: from paddle.fluid.layer_helper import LayerHelper from s...
92
3,035
gunicorn
tests/requests/valid/009.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. request = { "method": "POST", "uri": uri("/post_identity_body_world?q=search#hey"), "version": (1, 1), "headers": [ ("ACCEPT", "*/*"), ("TRANSFER-ENCODING", "identity"), ("CO...
16
370
mlflow
examples/gateway/plugin/example.py
.py
from mlflow.deployments import get_deploy_client def main(): client = get_deploy_client("http://127.0.0.1:7000") print(f"Plugin endpoints: {client.list_endpoints()}\n") print(f"Plugin chat endpoint info: {client.get_endpoint(endpoint='chat')}\n") # Chat request response_chat = client.predict( ...
27
634
saleor
saleor/graphql/translations/tests/mutations/test_sale_translate.py
.py
from unittest.mock import ANY, patch import graphene from freezegun import freeze_time from .....discount.error_codes import DiscountErrorCode from .....webhook.event_types import WebhookEventAsyncType from .....webhook.transport.asynchronous.transport import WebhookPayloadData from ....tests.utils import get_graphql...
162
4,676
probability
tensorflow_probability/python/mcmc/eight_schools_hmc_eager_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...
31
1,095
onnx
onnx/reference/ops/op_cast.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.reference.op_run import OpRun def cast_to( x: np.ndarray, to: onnx.TensorProto.DataType, saturate: bool, round_mode: str = "up" ): if to == onnx.Tensor...
55
1,417
sqlmap
tests/test_techniques.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission Mocked-oracle / canned-input coverage for the self-contained extraction / inference engines under lib/techniques/*: * lib/techniques/union/use.py - _oneShotUnionUse / unionU...
1,794
81,952
sqlmap
tests/test_common.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission Consolidated unit coverage for lib/core/common.py. This module merges the previously separate test_common_utils.py, test_common_parsers.py and the common.py-specific classes from tes...
1,793
68,341
qutip
qutip/core/data/_creator_utils.py
.py
""" Define functions to use as Data creator for `create` in `convert.py`. """ import numpy as np from .csr import CSR from .base import Data from .dense import Dense from ._scipy_sparse import is_csr, is_dia, issparse __all__ = [ 'data_copy', 'is_data', 'is_nparray', 'is_csr', 'is_dia', 'isspa...
39
724
httpie
tests/test_transport_plugin.py
.py
from io import BytesIO from requests.adapters import BaseAdapter from requests.models import Response from requests.utils import get_encoding_from_headers from httpie.plugins import TransportPlugin from httpie.plugins.registry import plugin_manager from .utils import HTTP_OK, http SCHEME = 'http+fake' class FakeA...
46
1,229
gunicorn
tests/test_config.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. import os import re import sys import tempfile import pytest from gunicorn import config from gunicorn.config import _get_default_control_socket from gunicorn.app.base import Application from gunicorn.app.wsgiapp...
592
17,865
wandb
tests/unit_tests/test_normalize.py
.py
from __future__ import annotations import re from typing import NoReturn import pytest import requests from wandb.apis.normalize import normalize_exceptions from wandb.errors import CommError def _http_response( status_code: int, body: bytes | None = None, reason: str | None = None, ): response = re...
88
2,318
biopython
Tests/test_PDB_MMCIF2Dict.py
.py
# Copyright 2017 by Francesco Gastaldello. All rights reserved. # Revisions copyright 2017 by Peter Cock. All rights reserved. # # Converted by Francesco Gastaldello from an older unit test copyright 2002 # by Thomas Hamelryck. # # This file is part of the Biopython distribution and governed by your # choice of the "B...
353
17,681
wagtail
wagtail/contrib/forms/urls.py
.py
from django.urls import path from wagtail.contrib.forms.views import ( DeleteSubmissionsView, FormPagesListView, get_submissions_list_view, ) app_name = "wagtailforms" urlpatterns = [ path("", FormPagesListView.as_view(), name="index"), path( "results/", FormPagesListView.as_view(results_o...
30
776
openvino
tests/layer_tests/tensorflow_tests/test_tf_BroadcastArgs.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 TestBroadcastArgs(CommonTFLayerTest): def _prepare_input(self, inputs_info): assert 's0:0' in inputs_in...
61
2,456
wagtail
wagtail/documents/tests/test_document_chooser.py
.py
import json from http import HTTPStatus from django.contrib.auth.models import Group, Permission from django.test import TestCase from django.urls import reverse from wagtail.documents.models import Document from wagtail.models import ( Collection, GroupCollectionPermission, get_root_collection_id, ) from...
411
17,163
wandb
wandb/apis/public/runhistory/__init__.py
.py
__all__ = ( "DownloadHistoryResult", "IncompleteRunHistoryError", "wait_for_download_with_progress", ) from .downloads import ( DownloadHistoryResult, IncompleteRunHistoryError, wait_for_download_with_progress, )
12
238
saleor
saleor/webhook/serializers.py
.py
import datetime from collections import defaultdict from decimal import Decimal from typing import TYPE_CHECKING, Any import graphene from prices import Money from ..attribute import AttributeEntityType, AttributeInputType from ..checkout.fetch import fetch_checkout_lines from ..core.prices import quantize_price from...
195
6,845
pyomo
examples/doc/samples/comparisons/cutstock/cutstock_lpsolve.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...
91
2,746
omegaconf
tests/test_config_eq.py
.py
from dataclasses import dataclass, field from typing import Any, List import attr from pytest import mark, param from omegaconf import MISSING, AnyNode, DictConfig, ListConfig, OmegaConf from tests import Group, User @mark.parametrize( "i1,i2", [ # === LISTS === # empty list param([]...
430
14,714
onnx
onnx/backend/test/case/node/reducel1.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 ReduceL1(Base): @staticmethod def export_do_not_keepdims() -> ...
190
5,604
openvino
tests/layer_tests/ovc_python_api_tests/test_complex_params.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os import tempfile import unittest import numpy as np import openvino as ov import pytest from openvino import PartialShape, Type, Dimension from common.mo_convert_test_class import CommonMOConvertTest from common.utils.tf_utils...
258
10,323
conda
tests/gateways/disk/test_create.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from __future__ import annotations from contextlib import nullcontext import pytest from conda.gateways.disk import create @pytest.mark.parametrize( "function,raises", [ ("create_application_entry_point", TypeError), ...
25
699
astropy
astropy/io/votable/tree.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # TODO: Test FITS parsing # STDLIB import base64 import codecs import gzip import io import json import os import re import urllib.request # THIRD-PARTY import numpy as np from numpy import ma # LOCAL from astropy import __version__ as astropy_version f...
4,729
153,523
pyomo
pyomo/core/kernel/set_types.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...
77
1,637
wagtail
wagtail/images/views/bulk_actions/image_bulk_action.py
.py
from django.utils.functional import cached_property from wagtail.admin.views.bulk_action import BulkAction from wagtail.images import get_image_model from wagtail.permissions import policy_registry class ImageBulkAction(BulkAction): models = [get_image_model()] @cached_property def permission_policy(sel...
42
1,408
probability
spinoffs/inference_gym/inference_gym/targets/ground_truth/synthetic_item_response_theory.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...
1,559
39,578
saleor
saleor/tests/e2e/account/account/test_should_create_account_without_email_confirmation.py
.py
from unittest import mock import pytest from .....account.models import User from .....graphql.core.utils import to_global_id_or_none from ...shop.utils import prepare_shop from ...utils import assign_permissions from ..utils import account_register, token_create @mock.patch("saleor.account.throttling.cache") @pyte...
74
2,051
biopython
Tests/test_SeqIO_QualityIO.py
.py
# Copyright 2009-2013 by Peter Cock. 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. """Additional unit tests for Bio.SeqIO.QualityIO (covering FASTQ and QUAL).""" import os imp...
1,121
43,542
black
tests/data/cases/module_docstring_followed_by_function.py
.py
"""Two blank lines between module docstring and a function def.""" def function(): pass # output """Two blank lines between module docstring and a function def.""" def function(): pass
11
196
qutip
qutip/random_objects.py
.py
""" This module is a collection of random state and operator generators. """ __all__ = [ 'rand_herm', 'rand_unitary', 'rand_dm', 'rand_stochastic', 'rand_ket', 'rand_kraus_map', 'rand_super', "rand_super_bcsz", ] import numpy as np from numpy.random import Generator, SeedSequence, defa...
907
31,664
python-prompt-toolkit
tests/test_formatted_text.py
.py
from __future__ import annotations from prompt_toolkit.formatted_text import ( ANSI, HTML, FormattedText, PygmentsTokens, Template, merge_formatted_text, to_formatted_text, ) from prompt_toolkit.formatted_text.utils import split_lines def test_basic_html(): html = HTML("<i>hello</i>")...
339
8,882
conda
conda/gateways/connection/__init__.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from __future__ import annotations from typing import TYPE_CHECKING, Protocol, runtime_checkable from requests import ConnectionError, HTTPError, Session # noqa: F401, TID253 from requests.adapters import ( # noqa: F401, TID253 DEFAULT_P...
58
2,117
mlflow
dev/proto_to_graphql/parsing_utils.py
.py
from autogeneration_utils import get_method_name from google.protobuf.descriptor import FieldDescriptor from mlflow.protos import databricks_pb2 def get_method_type(method_descriptor): return method_descriptor.GetOptions().Extensions[databricks_pb2.rpc].endpoints[0].method def process_method(method_descriptor,...
68
2,768
textual
tests/test_features.py
.py
from __future__ import annotations from textual.app import App async def test_textual_env_var(monkeypatch): monkeypatch.setenv("TEXTUAL", "") app = App() assert app.features == set() assert app.devtools is None assert app.debug is False monkeypatch.setenv("TEXTUAL", "devtools") app = App...
30
796
saleor
saleor/webhook/tests/circuit_breaker/fixtures.py
.py
import fakeredis import pytest from ....app.models import App from ....webhook.circuit_breaker.storage import RedisStorage from ....webhook.event_types import WebhookEventSyncType from ....webhook.models import Webhook, WebhookEvent @pytest.fixture def breaker_storage(): server = fakeredis.FakeServer() serve...
47
1,213
textual
src/textual/demo/_project_data.py
.py
from dataclasses import dataclass @dataclass class ProjectInfo: """Dataclass for storing project information.""" title: str author: str url: str description: str repo_url_part: str PROJECTS = [ ProjectInfo( "Posting", "Darren Burns", "https://posting.sh/", ...
108
3,444
scikit-optimize
examples/plots/visualizing-results.py
.py
""" ================================ Visualizing optimization results ================================ Tim Head, August 2016. Reformatted by Holger Nahrstaedt 2020 .. currentmodule:: skopt Bayesian optimization or sequential model-based optimization uses a surrogate model to model the expensive to evaluate objective...
225
8,574
gunicorn
tests/requests/valid/011.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. request = { "method": "POST", "uri": uri("/two_chunks_mult_zero_end"), "version": (1, 1), "headers": [ ("TRANSFER-ENCODING", "chunked") ], "body": b"hello world" }
14
302
pymc
tests/tuning/test_scaling.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...
34
1,176
readthedocs.org
readthedocs/api/v3/permissions.py
.py
from rest_framework.permissions import BasePermission from readthedocs.subscriptions.constants import TYPE_EMBED_API from readthedocs.subscriptions.products import get_feature class HasEmbedAPIAccess(BasePermission): """ Check if the project being accessed has access to the Embed API. The embedded API V...
60
2,022
biopython
Tests/test_AlignIO_PhylipIO.py
.py
# Copyright 2006-2014 by Peter Cock. All rights reserved. # Revisions copyright 2011 Brandon Invergo. 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 Bio.AlignIO.Phy...
130
4,584
clearml
clearml/config/cache.py
.py
import json from os.path import expanduser from pathlib2 import Path from . import running_remotely from .defs import SESSION_CACHE_FILE class SessionCache: """ Handle SDK session cache. TODO: Improve error handling to something like "except (FileNotFoundError, PermissionError, JSONDecodeError)" TOD...
54
1,714
mkdocs
mkdocs/utils/templates.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Sequence, TypedDict if TYPE_CHECKING: import datetime from markupsafe import Markup try: from jinja2 import pass_context as contextfilter # type: ignore except ImportError: from jinja2 import contextfilter # type: ignore from mkdocs...
56
1,740
python-prompt-toolkit
examples/prompts/multiline-prompt.py
.py
#!/usr/bin/env python """ Demonstration of how the input can be indented. """ from prompt_toolkit import prompt if __name__ == "__main__": answer = prompt( "Give me some input: (ESCAPE followed by ENTER to accept)\n > ", multiline=True ) print(f"You said: {answer}")
13
289
kafka
tests/kafkatest/services/security/kafka_acls.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 ...
66
3,900
beam
sdks/python/apache_beam/utils/interactive_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...
99
3,738
pyomo
examples/pyomobook/dae-ch/plot_path_constraint.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...
29
1,112
returns
tests/test_contrib/test_pytest/test_plugin_error_handler.py
.py
import pytest from returns.context import ( RequiresContextFutureResult, RequiresContextIOResult, RequiresContextResult, ) from returns.contrib.pytest import ReturnsAsserts from returns.functions import identity from returns.future import FutureResult from returns.io import IOFailure, IOSuccess from return...
106
3,307
readthedocs.org
readthedocs/gold/admin.py
.py
"""Django admin configuration for the Gold membership app.""" from django.contrib import admin from .models import GoldUser @admin.register(GoldUser) class GoldAdmin(admin.ModelAdmin): model = GoldUser raw_id_fields = ("user", "projects") list_display = ("user", "level", "modified_date", "subscribed") ...
15
433
coremltools
coremltools/converters/mil/frontend/tensorflow/test/test_parse.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 unittest import pytest pytest.importorskip("tensorflow", minversion="1.15.0") from tensorflo...
125
5,013
probability
tensorflow_probability/python/experimental/nn/convolutional_layers.py
.py
# Copyright 2019 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...
804
32,008