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
gunicorn
tests/test_dirty_integration.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Integration tests for dirty arbiter with main arbiter.""" import os import struct import pytest from gunicorn.arbiter import Arbiter from gunicorn.config import Config from gunicorn.app.base import BaseApplica...
383
13,444
astropy
astropy/table/tests/test_init_table.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from collections import OrderedDict, UserDict from collections.abc import Mapping import numpy as np import pytest from numpy.testing import assert_array_equal import astropy.units as u from astropy.table import Column, MaskedColumn, QTable, Table, Tabl...
666
23,870
wandb
wandb/sdk/internal/_generated/input_types.py
.py
# Generated by ariadne-codegen # Source: core/api/graphql/schemas/schema-latest.graphql from __future__ import annotations
5
124
beam
sdks/python/apache_beam/testing/benchmarks/nexmark/queries/query3.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
6,179
saleor
saleor/graphql/order/tests/queries/test_draft_order.py
.py
from decimal import Decimal from unittest.mock import patch import pytest from prices import Money, TaxedMoney from .....core.postgres import FlatConcatSearchVector from .....discount.models import OrderDiscount from .....order import OrderStatus from .....order.events import ( draft_order_created_from_replace_ev...
592
17,652
wandb
tests/unit_tests/test_mode_disabled.py
.py
import pickle import tempfile import pytest import wandb def test_mode_disabled(): """Test that the user can access all attributes of a Run object in disabled mode.""" run = wandb.init(mode="disabled") symbols = [s for s in dir(run) if not s.startswith("_") and s != "log"] # try logging some stuff ...
53
1,511
saleor
saleor/graphql/checkout/mutations/checkout_customer_detach.py
.py
import graphene from ....checkout.actions import call_checkout_event from ....core.exceptions import PermissionDenied from ....permission.auth_filters import AuthorizationFilters from ....permission.enums import AccountPermissions from ....webhook.event_types import WebhookEventAsyncType from ...core import ResolveInf...
81
3,109
wagtail
wagtail/images/api/v3/form_data.py
.py
from typing import Any from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import AnonymousUser from django.db.models import Model from django.forms import ModelForm from ninja import UploadedFile from wagtail.api.v3.form_data import build_form_data from wagtail.images.forms imp...
62
2,422
textual
docs/examples/styles/text_overflow.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static TEXT = """I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear.""" class WrapApp(App): CSS_PATH = "text_overflow.tcss" def compose(self) -> ComposeResult: y...
19
497
deap
examples/ga/evoknn.py
.py
#!/usr/bin/env python2.7 # 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. # ...
90
2,905
sqlmap
plugins/dbms/h2/takeover.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 Backend from lib.core.common import randomStr from lib.core.data import conf from lib.core.data import kb from lib.core.enums import OS from lib.core.e...
54
2,256
wandb
wandb/apis/_generated/create_user_from_admin.py
.py
# Generated by ariadne-codegen # Source: tools/graphql_codegen/api/ from __future__ import annotations from wandb._pydantic import GQLResult from .fragments import UserInfoFragment class CreateUserFromAdmin(GQLResult): result: CreateUserFromAdminResult | None class CreateUserFromAdminResult(GQLResult): u...
21
429
astropy
astropy/cosmology/_src/io/builtin/ecsv.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """|Cosmology| <-> ECSV I/O, using |Cosmology.read| and |Cosmology.write|. This module provides functions to write/read a |Cosmology| object to/from an ECSV file. The functions are registered with ``readwrite_registry`` under the format name "ascii.ecsv"....
514
18,517
astropy
astropy/cosmology/_src/tests/io/test_model.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import inspect import random import numpy as np import pytest from astropy.cosmology import Cosmology, w0wzCDM from astropy.cosmology._src.io.builtin.model import ( _CosmologyModel, from_model, to_model, ) from astropy.cosmology._src.tests.h...
183
6,652
mlflow
tests/genai/scorers/phoenix/test_registry.py
.py
from unittest import mock import pytest from mlflow.exceptions import MlflowException phoenix_evals = pytest.importorskip("phoenix.evals") @pytest.mark.parametrize( ("metric_name", "evaluator_name"), [ ("Hallucination", "HallucinationEvaluator"), ("Relevance", "RelevanceEvaluator"), ...
44
1,353
pyomo
pyomo/core/kernel/__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...
121
3,209
openvino
tests/layer_tests/pytorch_tests/test_bool.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest from pytorch_layer_test_class import PytorchLayerTest class TestBool(PytorchLayerTest): def _prepare_input(self): import numpy as np return (self.random.randint(0, 10, 1, dtype=np.int32),) def cr...
36
1,072
beam
sdks/python/apache_beam/ml/inference/vllm_inference.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...
656
25,367
python-prompt-toolkit
src/prompt_toolkit/clipboard/pyperclip.py
.py
from __future__ import annotations import pyperclip from prompt_toolkit.selection import SelectionType from .base import Clipboard, ClipboardData __all__ = [ "PyperclipClipboard", ] class PyperclipClipboard(Clipboard): """ Clipboard that synchronizes with the Windows/Mac/Linux system clipboard, us...
43
1,160
metrics
src/torchmetrics/functional/image/psnr.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...
148
5,560
conda
tests/notices/test_cache.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from __future__ import annotations from pathlib import Path from typing import TYPE_CHECKING import pytest from conda.notices import cache as notices_cache from conda.notices import core as notices_core if TYPE_CHECKING: from pytest impo...
96
2,967
gunicorn
tests/requests/invalid/rfc9112_chunked_size_minus_sign_01.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. # RFC 9112 section 7.1: chunk-size = 1*HEXDIG; negative sign is invalid. from gunicorn.http.errors import InvalidChunkSize request = InvalidChunkSize
8
256
saleor
saleor/graphql/attribute/tests/mutations/test_attribute_reorder_values.py
.py
import json from unittest import mock import graphene import pytest from django.utils.functional import SimpleLazyObject from freezegun import freeze_time from .....attribute.models import AttributeValue from .....core.utils.json_serializer import CustomJsonEncoder from .....webhook.event_types import WebhookEventAsy...
379
12,181
sphinx
tests/test_ext_autodoc/test_ext_autodoc_events.py
.py
"""Test the autodoc extension. This tests mainly for autodoc events""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx.ext.autodoc import between, cut_lines from tests.test_ext_autodoc.autodoc_util import FakeEvents, do_autodoc if TYPE_CHECKING: from typing impor...
172
4,364
deap
examples/coev/hillis.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 ...
165
5,679
saleor
saleor/tests/e2e/product/utils/collection_listing_update.py
.py
from ...utils import get_graphql_content COLLECTION_CHANNEL_LISTING_UPDATE_MUTATION = """ mutation CollectionListing($id: ID!, $input: CollectionChannelListingUpdateInput!) { collectionChannelListingUpdate(id: $id, input: $input) { errors { code field message channels } collection...
61
1,415
funcy
funcy/colls.py
.py
from builtins import all as _all, any as _any from copy import copy from operator import itemgetter, methodcaller, attrgetter from itertools import chain, tee from collections import defaultdict from collections.abc import Mapping, Set, Iterable, Iterator from .primitives import EMPTY from .funcs import partial, compo...
375
11,816
wandb
tools/bench/_timing.py
.py
#!/usr/bin/env python from __future__ import annotations import csv import dataclasses import time @dataclasses.dataclass(frozen=True) class FunctionTiming: function_name: str runtime_seconds: float def timeit( timings: list[FunctionTiming], ): """Timing decorator. Args: timings: list ...
57
1,363
textual
src/textual/_event_broker.py
.py
from __future__ import annotations from typing import Any, NamedTuple class NoHandler(Exception): """Raised when handler isn't found in the meta.""" class HandlerArguments(NamedTuple): """Information for event handler.""" modifiers: set[str] action: Any def extract_handler_actions(event_name: st...
38
999
openvino
src/bindings/python/src/openvino/opset7/ops.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 """Factory functions for all openvino ops.""" from functools import partial from typing import Optional, Union import numpy as np from openvino import Node, Shape from openvino.op import Constant, Parameter from ...
167
5,014
metrics
src/torchmetrics/functional/regression/nrmse.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...
107
4,376
probability
tensorflow_probability/python/bijectors/invert.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...
174
6,353
kafka
tests/kafkatest/services/performance/__init__.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 ...
21
1,125
sqlmap
plugins/dbms/db2/connector.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ try: import ibm_db_dbi except: pass import logging from lib.core.common import getSafeExString from lib.core.data import conf from lib.core.data import logger from lib.c...
61
2,027
mlflow
dev/create_release_branch.py
.py
import argparse import os import subprocess from packaging.version import Version def main(new_version: str, remote: str, dry_run: bool = False) -> None: version = Version(new_version) release_branch = f"branch-{version.major}.{version.minor}" exists_on_remote = ( subprocess.check_output( ...
63
2,169
python-prompt-toolkit
src/prompt_toolkit/contrib/telnet/__init__.py
.py
from __future__ import annotations from .server import TelnetServer __all__ = [ "TelnetServer", ]
8
104
openvino
docs/articles_en/assets/snippets/ov_execution_mode.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 #! [ov:execution_mode:part0] import openvino as ov import openvino.properties.hint as hints core = ov.Core() # in case of Accuracy core.set_property( "CPU", {hints.execution_mode: hints.ExecutionMode.ACCURACY}, ) # in case of Pe...
20
452
saleor
saleor/graphql/translations/mutations/voucher_translate.py
.py
import graphene from ....discount import models as discount_models from ....permission.enums import SitePermissions from ...core import ResolveInfo from ...core.context import ChannelContext from ...core.enums import LanguageCodeEnum from ...core.types import TranslationError from ...discount.types import Voucher from...
42
1,566
astropy
astropy/utils/metadata/merge.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Metadata merging.""" import warnings from contextlib import contextmanager from copy import deepcopy import numpy as np from .exceptions import MergeConflictError, MergeConflictWarning from .utils import result_type __all__ = [ "MERGE_STRATEGIES...
301
10,348
textual
src/textual/_log.py
.py
from enum import Enum class LogGroup(Enum): """A log group is a classification of the log message (*not* a level).""" UNDEFINED = 0 # Mainly for testing EVENT = 1 DEBUG = 2 INFO = 3 WARNING = 4 ERROR = 5 PRINT = 6 SYSTEM = 7 LOGGING = 8 WORKER = 9 class LogVerbosity(Enu...
24
436
saleor
saleor/graphql/giftcard/types.py
.py
import datetime from decimal import Decimal import graphene import prices from ...core.anonymize import obfuscate_email from ...core.exceptions import PermissionDenied from ...giftcard import GiftCardEvents, models from ...permission.auth_filters import AuthorizationFilters from ...permission.enums import ( Accou...
750
26,326
gunicorn
examples/boot_fail.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. raise RuntimeError("Bad app!") def app(environ, start_response): assert 1 == 2, "Shouldn't get here."
9
213
textual
docs/examples/widgets/directory_tree_filtered.py
.py
from pathlib import Path from typing import Iterable from textual.app import App, ComposeResult from textual.widgets import DirectoryTree class FilteredDirectoryTree(DirectoryTree): def filter_paths(self, paths: Iterable[Path]) -> Iterable[Path]: return [path for path in paths if not path.name.startswith...
21
512
onnx
onnx/reference/ops/op_max_pool.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_common_pool import CommonPool class MaxPool(CommonPool): def _run( self, x, auto_pad=None, ceil_mode=None, di...
414
14,553
onnxruntime
orttraining/orttraining/python/training/utils/torch_profile_utils.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from __future__ import annotations import torch def torch_nvtx_range_...
105
3,969
pyomo
pyomo/contrib/cspline_external/build.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...
31
1,150
openvino
tests/e2e_tests/collect_refs.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 """Main entry-point to collect references for E2E tests. Default run: $ pytest collect_refs.py Options[*]: --modules Paths to references --env_conf Path to environment config --dry_run Disable reference saving [*] For...
63
2,098
beam
sdks/python/apache_beam/examples/streaming_wordcount.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...
109
3,801
dirty-equals
tests/test_other.py
.py
import sys import uuid from dataclasses import dataclass from enum import Enum, auto from hashlib import md5, sha1, sha256 from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network import pytest from dirty_equals import ( FunctionCheck, IsDataclass, IsDataclassType, IsEnum, IsHash, ...
433
11,551
scikit-bio
skbio/sequence/tests/test_grammared_sequence.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. # --------------------------------------------...
774
30,398
beam
sdks/python/apache_beam/ml/inference/tensorflow_inference_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...
202
8,231
saleor
saleor/tests/e2e/gift_cards/utils/gift_cards_query.py
.py
from ...utils import get_graphql_content GIFT_CARDS_QUERY = """ query GiftCards($first: Int) { giftCards(first: $first) { edges { node { id code initialBalance { amount } } } } } """ def get_gift_cards( staff_api_client, first=10, ): varia...
35
566
gunicorn
examples/embedding_service/test_embedding.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. import os import requests import numpy as np def test_embedding_endpoint(): base_url = os.environ.get("EMBEDDING_SERVICE_URL", "http://127.0.0.1:8000") url = f"{base_url}/embed" # Test single text ...
38
1,115
qutip
qutip/solver/floquet.py
.py
# Required for Sphinx to follow autodoc_type_aliases from __future__ import annotations __all__ = [ "FloquetBasis", "floquet_tensor", "fsesolve", "fmmesolve", "FMESolver", ] from typing import Any, overload, TypeVar, Literal, Callable import warnings import numpy as np from numpy.typing import Arr...
1,045
33,994
gunicorn
tests/test_http2_config.py
.py
# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Tests for HTTP/2 configuration settings.""" import pytest from gunicorn import config from gunicorn.config import Config class TestHttpProtocolsConfig: """Test http_protocols config...
344
11,196
mlflow
mlflow/pytest/__init__.py
.py
from mlflow.pytest.decorator import test __all__ = ["test"]
4
61
onnx
onnx/reference/ops/op_compress.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.op_run import OpRun class Compress(OpRun): def _run(self, x, condition, axis=None): return (np.compress(condition, x, axis=axis),)
14
302
metrics
src/torchmetrics/utilities/compute.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...
244
8,319
coremltools
deps/pybind11/tests/test_numpy_array.py
.py
from __future__ import annotations import pytest import env # noqa: F401 from pybind11_tests import numpy_array as m np = pytest.importorskip("numpy") def test_dtypes(): # See issue #1328. # - Platform-dependent sizes. for size_check in m.get_platform_dtype_size_checks(): print(size_check) ...
673
22,915
metrics
tests/unittests/retrieval/test_precision.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...
224
8,500
pyomo
pyomo/contrib/parmest/examples/reactor_design/update_suffix_example.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...
66
2,350
openvino
tests/model_hub_tests/pytorch/test_llm.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import copy import inspect from contextlib import contextmanager import numpy as np import platform import pytest import torch from models_hub_common.utils import retry from openvino.frontend.pytorch.patch_model import __make_16bit_tra...
773
33,648
kombu
examples/simple_task_queue/worker.py
.py
from __future__ import annotations from kombu.log import get_logger from kombu.mixins import ConsumerMixin from kombu.utils.functional import reprcall from .queues import task_queues logger = get_logger(__name__) class Worker(ConsumerMixin): def __init__(self, connection): self.connection = connection...
47
1,276
cvxpy
setup/extensions.py
.py
""" Copyright 2023, the CVXPY authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, soft...
51
1,500
scikit-bio
skbio/tests/test_config.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. # --------------------------------------------...
88
3,045
saleor
saleor/graphql/order/tests/mutations/test_order_fulfill.py
.py
from unittest.mock import ANY, call, patch import graphene import pytest from django.test import override_settings from .....core.exceptions import InsufficientStock, InsufficientStockData from .....core.models import EventDelivery from .....giftcard import GiftCardEvents from .....giftcard.models import GiftCard, Gi...
1,790
61,365
beam
sdks/python/apache_beam/examples/inference/onnx_sentiment_classification.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
5,379
mlflow
mlflow/genai/git_versioning/git_info.py
.py
import logging from dataclasses import dataclass from typing_extensions import Self from mlflow.utils.mlflow_tags import ( MLFLOW_GIT_BRANCH, MLFLOW_GIT_COMMIT, MLFLOW_GIT_DIFF, MLFLOW_GIT_DIRTY, MLFLOW_GIT_REPO_URL, ) _logger = logging.getLogger(__name__) class GitOperationError(Exception): ...
101
3,276
onnx
onnx/backend/test/__init__.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations __all__ = ["BackendTest"] # for backward compatibility from onnx.backend.test.runner import Runner as BackendTest
9
232
mlflow
mlflow/genai/judges/utils/tool_calling_utils.py
.py
"""Tool calling support for judge models.""" from __future__ import annotations import json import logging from dataclasses import asdict, is_dataclass from typing import TYPE_CHECKING, Any, NoReturn if TYPE_CHECKING: from mlflow.entities.trace import Trace from mlflow.types.llm import ChatMessage, ToolCall ...
249
9,302
mkdocs-material
material/plugins/optimize/plugin.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...
389
14,982
wandb
wandb/sdk/lib/service/service_finalizer.py
.py
"""Allows Python garbage collection to trigger wandb-core cleanup. This is tricky to implement correctly and requires a good understanding of Python's garbage collection and every line in this file. If done wrong, it can cause random deadlocks, and it has in the past. Even if done correctly, it may still not work depe...
97
3,527
onnxruntime
onnxruntime/test/python/quantization/test_quantizeblockwise_2bits.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. # ---------------------------------------------------------------...
152
7,180
mlflow
tests/projects/backend/test_local.py
.py
import os from unittest import mock from mlflow.projects.backend.local import _get_docker_artifact_storage_cmd_and_envs def test_docker_s3_artifact_cmd_and_envs_from_env(monkeypatch): mock_env = { "AWS_SECRET_ACCESS_KEY": "mock_secret", "AWS_ACCESS_KEY_ID": "mock_access_key", "MLFLOW_S3_E...
91
3,355
pyro
pyro/contrib/gp/likelihoods/likelihood.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 from pyro.contrib.gp.parameterized import Parameterized class Likelihood(Parameterized): """ Base class for likelihoods used in Gaussian Process. Every inherited class should implement a forward pass which takes ...
29
875
gunicorn
tests/requests/valid/rfc9112_target_absolute_ipv6_01.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. # RFC 9112 section 3.2.2 + RFC 3986 section 3.2.2: absolute-form with an # IP-literal (IPv6) host wrapped in brackets. request = { "method": "GET", "uri": uri("http://[::1]:8080/foo"), "version": (1, 1)...
16
397
probability
tensorflow_probability/python/experimental/sts_gibbs/sample_parameters.py
.py
# Copyright 2022 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...
90
3,824
pdm
tests/cli/test_install.py
.py
import pytest from pdm.cli import actions from pdm.models.markers import EnvSpec from pdm.pytest import Distribution from pdm.utils import cd def test_sync_packages_with_group_all(project, working_set, pdm): project.add_dependencies(["requests"]) project.add_dependencies(["pytz"], "date") project.add_dep...
462
18,193
textual
tests/command_palette/test_command_source_environment.py
.py
from __future__ import annotations from textual.app import App, ComposeResult from textual.command import Hit, Hits, Provider from textual.screen import Screen from textual.widget import Widget from textual.widgets import Input class SimpleSource(Provider): environment: set[tuple[App, Screen, Widget | None]] = s...
41
1,247
onnxruntime
onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/RuntimeOptimizations.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: fbs import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class RuntimeOptimizations(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode...
80
2,721
openvino
tests/layer_tests/pytorch_tests/test_index_put_.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 TestIndexPut_SingleIndices(PytorchLayerTest): def _prepare_input(self): return (self.input_tensor, self.values) ...
279
10,461
qutip
qutip/solver/spectrum.py
.py
__all__ = ['spectrum', 'spectrum_correlation_fft'] import numpy as np import scipy.fftpack from .steadystate import steadystate from ..core import liouvillian, spre, expect from ..core import data as _data from qutip.settings import settings def spectrum(H, wlist, c_ops, a_op, b_op, solver="es"): r""" Calcul...
189
6,193
saleor
saleor/webhook/tests/circuit_breaker/test_redis_storage.py
.py
import datetime from freezegun import freeze_time from ....graphql.app.enums import CircuitBreakerState APP_ID = 1 NAME = "total" NOW = 1726215980 TTL_SECONDS = 60 def test_get_app_state(breaker_storage): # given status, changed_at = breaker_storage.get_app_state(APP_ID) assert status == CircuitBreaker...
80
2,418
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/The flavors of raw cells.py
.py
# --- # jupyter: # jupytext: # cell_markers: '{{{,}}}' # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # {{{ raw_mimetype="text/latex" active="" # $1+1$ # }}} # {{{ raw_mimetype="text/restructuredtext" active="" # :math:`1+1` # }}} # {{{ raw_mimetype="text/html" ac...
34
519
scikit-optimize
build_tools/circle/list_versions.py
.py
#!/usr/bin/env python3 # Copied from https://github.com/scikit-learn/scikit-learn/blob/master/ # build_tools/circle/list_versions.sh # The scikit-learn developers. # License: BSD-style # List all available versions of the documentation import json import re import sys from distutils.version import LooseVersion from ur...
105
3,501
onnxruntime
onnxruntime/python/tools/transformers/models/whisper/convert_to_onnx.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import ...
732
25,880
sqlmap
lib/request/basic.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import codecs import gzip import io import logging import re import zlib from lib.utils import brotli as _brotli try: from compression import zstd as _zstd # Python 3.14...
498
25,082
wagtail
wagtail/images/tests/test_shortcuts.py
.py
from django.test import TestCase from wagtail.images.models import Filter from wagtail.images.shortcuts import ( get_rendition_or_not_found, get_renditions_or_not_found, ) from wagtail.test.utils import PageFixturesMixin from .utils import Image, get_test_image_file class TestShortcuts(PageFixturesMixin, Te...
66
2,562
pyomo
pyomo/common/numeric_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...
401
14,336
mlflow
tests/utils/test_utils.py
.py
import importlib.metadata import socket from unittest import mock import pytest from packaging.version import Version from mlflow.utils import ( AttrDict, _chunk_dict, _get_fully_qualified_class_name, _truncate_dict, get_installed_version, merge_dicts, ) def test_truncate_dict(): d = {"1...
255
7,273
luigi
test/contrib/hadoop_test.py
.py
# -*- coding: utf-8 -*- # # Copyright 2012-2015 Spotify AB # # 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...
501
18,197
lemur
lemur/roles/schemas.py
.py
""" .. module: lemur.roles.schemas :platform: unix :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. .. moduleauthor:: Kevin Glisson <kglisson@netflix.com> """ from marshmallow import fields from lemur.users.schemas import UserNestedOutputSchema from ...
44
1,450
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_sqrt.py
.py
# # sqrt paddle model generator # import numpy as np from save_model import saveModel import paddle as pdpd import sys def sqrt(name: str, x, data_type): pdpd.enable_static() with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()): node_x = pdpd.static.data( name='inp...
42
1,048
pyfilesystem2
fs/_pathcompat.py
.py
# mypy: ignore-errors try: from os.path import commonpath except ImportError: # Return the longest common sub-path of the sequence of paths given as input. # The paths are not normalized before comparing them (this is the # responsibility of the caller). Any trailing separator is stripped from the #...
42
1,309
coremltools
coremltools/converters/mil/frontend/tensorflow/ssa_passes/tf_lstm_to_core_lstm.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 numpy as np from coremltools import _logger as logger from coremltools.converters.mil.mil imp...
309
12,440
pyro
examples/lkj.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import argparse import torch import pyro import pyro.distributions as dist from pyro.infer.mcmc import NUTS from pyro.infer.mcmc.api import MCMC """ This simple example is intended to demonstrate how to use an LKJ prior with a m...
78
2,735
coremltools
coremltools/models/feature_vectorizer.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools import proto from .. import SPECIFICATION_VERSION from . import datatypes from ._featu...
99
3,674
cvxpy
cvxpy/tests/test_constant.py
.py
import numpy as np import pytest import scipy.sparse as sp import scipy.sparse.linalg as sparla import cvxpy as cp import cvxpy.settings as s from cvxpy import psd_wrap def test_is_psd() -> None: n = 50 # trivial cases psd = np.eye(n) nsd = -np.eye(n) assert cp.Constant(psd).is_psd() asser...
123
3,908
pyomo
pyomo/core/base/enums.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...
100
3,182
pymc
pymc/util.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...
613
20,765