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
sphinx
sphinx/util/_timestamps.py
.py
from __future__ import annotations import time def _format_rfc3339_microseconds(timestamp: int, /) -> str: """Return an RFC 3339 formatted string representing the given timestamp. :param timestamp: The timestamp to format, in microseconds. """ seconds, fraction = divmod(timestamp, 10**6) time_tu...
14
431
pyro
tests/distributions/test_pickle.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import inspect import io import pickle import pytest import torch import pyro.distributions as dist from pyro.distributions.torch_distribution import TorchDistributionMixin from tests.common import xfail_param # Collect distribu...
93
3,031
clearml
clearml/backend_api/__init__.py
.py
from .session import ( Session, CallResult, TimeoutExpiredError, ResultNotReadyError, browser_login, ) from .config import load as load_config __all__ = [ "Session", "CallResult", "TimeoutExpiredError", "ResultNotReadyError", "load_config", "browser_login", ]
18
305
mlflow
mlflow/evaluation/assessment.py
.py
""" THE 'mlflow.evaluation` MODULE IS LEGACY AND WILL BE REMOVED SOON. PLEASE DO NOT USE THESE CLASSES IN NEW CODE. INSTEAD, USE `mlflow/entities/assessment.py` FOR ASSESSMENT CLASSES. """ import numbers import time from typing import Any from mlflow.entities._mlflow_object import _MlflowObject from mlflow.entities.a...
370
13,374
beam
sdks/python/apache_beam/yaml/yaml_specifiable.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...
60
2,179
mlflow
tests/pyfunc/custom_model/transitive_test/model_with_transitive.py
.py
from custom_model.transitive_test.transitive_dependency import some_function from mlflow.pyfunc import PythonModel class ModelWithTransitiveDependency(PythonModel): def predict(self, context, model_input, params=None): result = some_function() return [result] * len(model_input)
10
302
metrics
tests/unittests/clustering/test_normalized_mutual_info_score.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...
99
4,040
clearml
clearml/utilities/pyhocon/__init__.py
.py
from .config_parser import ConfigParser, ConfigFactory, ConfigMissingException from .config_tree import ConfigTree from .converter import HOCONConverter __all__ = ["ConfigParser", "ConfigFactory", "ConfigMissingException", "ConfigTree", "HOCONConverter"]
6
256
textual
src/textual/widgets/_tooltip.py
.py
from __future__ import annotations from textual.widgets import Static class Tooltip(Static, inherit_css=False): DEFAULT_CSS = """ Tooltip { layer: _tooltips; margin: 1 0; padding: 1 2; background: $panel; width: auto; height: auto; constrain: inside inf...
25
519
pymc
pymc/backends/zarr.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...
876
35,850
probability
tensorflow_probability/python/math/psd_kernels/exponentiated_quadratic.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...
180
7,713
sqlmap
extra/dbwire/cubrid.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ """ Minimal pure-python CUBRID client speaking the CAS (Common Application Server) broker protocol (stdlib only, no CUBRID-Python/CCI). Does the 10-byte broker handshake (+ option...
469
17,832
cvxpy
cvxpy/tests/test_mip_vars.py
.py
""" Copyright 2013 Steven Diamond, Eric Chu 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...
222
8,251
wandb
wandb/cli/beta_sync.py
.py
"""Implements `wandb sync` using wandb-core.""" from __future__ import annotations import asyncio import contextlib import pathlib from collections.abc import Iterable, Iterator import wandb from wandb.errors import term from wandb.proto.wandb_sync_pb2 import ServerSyncResponse from wandb.sdk import wandb_setup from...
389
11,551
pyomo
pyomo/solvers/plugins/solvers/IPOPT.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...
223
8,406
django-cms
cms/test_utils/project/app_with_cms_config/cms_config.py
.py
from cms.app_base import CMSAppConfig class CMSConfigConfig(CMSAppConfig): app_with_cms_feature_enabled = True
6
117
conda
tests/_preview/env_setup/cli/test_main_create.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Integration tests for conda/_preview/env_setup/cli/main_create.py. These tests verify that: - When the env-setup preview is NOT enabled, `conda create` runs via the standard path. - When the env-setup preview IS enabled, `conda create` is ro...
108
3,788
hypercorn
tests/asyncio/test_sanity.py
.py
from __future__ import annotations import asyncio import h2 import h11 import pytest import wsproto from hypercorn.app_wrappers import ASGIWrapper from hypercorn.asyncio.tcp_server import TCPServer from hypercorn.asyncio.worker_context import WorkerContext from hypercorn.config import Config from .helpers import Mem...
240
8,694
mlflow
mlflow/genai/scorers/trulens/scorers/__init__.py
.py
from mlflow.genai.scorers.trulens.scorers.agent_trace import ( ExecutionEfficiency, LogicalConsistency, PlanAdherence, PlanQuality, ToolCalling, ToolSelection, TruLensAgentScorer, ) __all__ = [ "TruLensAgentScorer", "LogicalConsistency", "ExecutionEfficiency", "PlanAdherence...
20
384
wandb
wandb/integration/sklearn/calculate/class_proportions.py
.py
from warnings import simplefilter import numpy as np from sklearn.utils.multiclass import unique_labels import wandb from wandb.integration.sklearn import utils # ignore all future warnings simplefilter(action="ignore", category=FutureWarning) def class_proportions(y_train, y_test, labels): # Get the unique va...
67
2,088
pyomo
pyomo/contrib/piecewise/transform/convex_combination.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...
41
1,711
probability
tensorflow_probability/python/optimizer/linesearch/hager_zhang.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...
639
30,645
saleor
saleor/invoice/tests/test_notifications.py
.py
from ...graphql.core.utils import to_global_id_or_none from ..models import Invoice from ..notifications import get_invoice_payload def test_collect_invoice_data_for_email(order): number = "01/12/2020/TEST" url = "http://www.example.com" invoice = Invoice.objects.create(number=number, url=url, order=order...
14
504
kombu
kombu/serialization.py
.py
"""Serialization utilities.""" from __future__ import annotations import codecs import os import pickle import sys from collections import namedtuple from contextlib import contextmanager from io import BytesIO from .exceptions import (ContentDisallowed, DecodeError, EncodeError, SerializerN...
464
15,446
mlflow
examples/mlflow-3/langchain_example.py
.py
from langchain_community.chat_models import ChatDatabricks from langchain_core.prompts import ChatPromptTemplate import mlflow # Define the chain chat_model = ChatDatabricks( endpoint="databricks-llama-2-70b-chat", temperature=0.1, max_tokens=2000, ) prompt = ChatPromptTemplate.from_messages([ ( ...
230
7,503
hatch
tests/conftest.py
.py
from __future__ import annotations import json import os import shutil import subprocess import sys import time from contextlib import suppress from functools import lru_cache from typing import TYPE_CHECKING, NamedTuple import pytest from click.testing import CliRunner as __CliRunner from filelock import FileLock fr...
602
19,855
openvino
tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_zeropadding3d.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest import tensorflow as tf from common.tf2_layer_test_class import CommonTF2LayerTest class TestKerasZeroPadding3D(CommonTF2LayerTest): def create_keras_zeropadding3d_net(self, input_names, input_shapes, input_type, pad...
58
2,864
metrics
tests/unittests/retrieval/helpers.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...
600
21,709
mlflow
dev/remove_experimental_decorators.py
.py
""" Script to automatically remove @experimental decorators from functions that have been experimental for more than a configurable cutoff period (default: 6 months). """ import argparse import ast import json import subprocess from dataclasses import dataclass from datetime import datetime, timedelta, timezone from p...
200
7,105
hydra
tests/test_apps/app_with_callbacks/custom_callback/my_app.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import logging from typing import Any from omegaconf import DictConfig, OmegaConf import hydra from hydra.core.utils import JobReturn from hydra.experimental.callback import Callback from hydra.utils import target_whitelist log = logging.getLogg...
50
1,456
pyomo
pyomo/contrib/pynumero/examples/nlp_interface.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...
60
2,093
openvino
src/bindings/python/tests/test_graph/test_string_tensor_unpack.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from openvino import Type, PartialShape, Dimension import openvino.opset15 as ov import pytest @pytest.mark.parametrize("input_shape", [ ((4,)), ((1, 3, 4)), ((3, 1, 2, 5)) ]) def test_string_tensor_...
27
938
saleor
saleor/graphql/tax/types.py
.py
import graphene from ...tax import models from ..channel.dataloaders.by_self import ChannelByIdLoader from ..channel.types import Channel from ..core import ResolveInfo from ..core.connection import CountableConnection from ..core.doc_category import DOC_CATEGORY_TAXES from ..core.types import BaseObjectType, CountryD...
231
8,541
astropy
astropy/io/fits/hdu/image.py
.py
# Licensed under a 3-clause BSD style license - see PYFITS.rst import mmap import sys import warnings import numpy as np from astropy.io.fits.header import Header from astropy.io.fits.util import ( _is_dask_array, _is_int, _is_pseudo_integer, _pseudo_zero, ) from astropy.io.fits.verify import VerifyW...
1,301
49,068
black
tests/data/cases/preview_return_annotation_brackets_string.py
.py
# flags: --unstable # Long string example def frobnicate() -> "ThisIsTrulyUnreasonablyExtremelyLongClassName | list[ThisIsTrulyUnreasonablyExtremelyLongClassName]": pass # splitting the string breaks if there's any parameters def frobnicate(a) -> "ThisIsTrulyUnreasonablyExtremelyLongClassName | list[ThisIsTrulyUnr...
25
742
probability
tensorflow_probability/python/bijectors/ascending_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...
97
3,895
saleor
saleor/tests/e2e/orders/discounts/test_order_products_on_fixed_sale.py
.py
import pytest from .....product.tasks import recalculate_discounted_price_for_products_task from ... import DEFAULT_ADDRESS from ...product.utils.preparing_product import prepare_product from ...sales.utils import create_sale, create_sale_channel_listing, sale_catalogues_add from ...shop.utils.preparing_shop import pr...
155
4,725
wagtail
wagtail/snippets/tests/test_api_v3/test_actions.py
.py
import json from django.contrib.auth.models import Permission from django.test import TestCase, override_settings from django.urls import reverse from django.utils import timezone from wagtail.api.v3.tests.base import TestV3Base from wagtail.models import Locale from wagtail.test.testapp.models import Advert, FullFea...
397
15,156
sphinx
sphinx/domains/cpp/__init__.py
.py
"""The C++ language domain.""" from __future__ import annotations import re from types import NoneType from typing import TYPE_CHECKING from docutils import nodes from docutils.parsers.rst import directives from sphinx import addnodes from sphinx.directives import ObjectDescription from sphinx.domains import Domain...
1,337
48,326
saleor
saleor/order/tests/test_shipping_context.py
.py
from ...shipping.models import ShippingMethod, ShippingMethodType from ..delivery_context import ( get_all_shipping_methods_for_order, get_valid_shipping_methods_for_order, ) def test_get_valid_shipping_methods_for_order(order_line_with_one_allocation, address): # given order = order_line_with_one_all...
170
4,877
hatch
tests/cli/publish/test_publish.py
.py
import os import secrets import tarfile import zipfile from collections import defaultdict import pytest from hatch.config.constants import PublishEnvVars pytestmark = [ pytest.mark.requires_docker, pytest.mark.requires_internet, pytest.mark.usefixtures("devpi"), pytest.mark.usefixtures("mock_backend...
710
23,542
beam
sdks/python/apache_beam/testing/__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 us...
17
784
astropy
astropy/cosmology/_src/parameter/converter.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst __all__ = ( "validate_non_negative", "validate_to_float", "validate_to_scalar", "validate_with_unit", ) from collections.abc import Callable from typing import TYPE_CHECKING, Any from numpy.typing import NDArray import astropy.units as ...
123
3,379
beam
sdks/python/apache_beam/examples/complete/juliaset/juliaset_main.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...
60
2,310
pyomo
pyomo/contrib/gdp_bounds/compute_bounds.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...
219
8,445
black
src/blackd/__init__.py
.py
import asyncio import logging import os from concurrent.futures import Executor, ProcessPoolExecutor from datetime import datetime, timezone from functools import cache, partial from multiprocessing import freeze_support try: from aiohttp import web from multidict import MultiMapping from .middlewares imp...
337
10,443
onnx
onnx/version.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 """Backward-compatibility shim for onnx.version. This module is deprecated. Use ``onnx.__version__`` instead. """ from __future__ import annotations import warnings from onnx import __version__ as version warnings.warn( "onnx.ve...
25
473
probability
tensorflow_probability/python/internal/backend/numpy/gen/linear_operator_lower_triangular.py
.py
# Copyright 2020 The TensorFlow Probability Authors. All Rights Reserved. # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ # THIS FILE IS AUTO-GENERATED BY `gen_linear_operators.py`. # DO NOT MODIFY DIRECTLY. # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...
282
10,965
wagtail
wagtail/models/__init__.py
.py
""" ``wagtail.models`` is split into submodules for maintainability. All definitions intended as public should be imported here (with 'noqa: F401' comments as required) and outside code should continue to import them from wagtail.models (e.g. ``from wagtail.models import Site``, not ``from wagtail.models.sites import S...
114
3,440
textual
src/textual/pilot.py
.py
""" This module contains the `Pilot` class used by [App.run_test][textual.app.App.run_test] to programmatically operate an app. See the guide on how to [test Textual apps](/guide/testing). """ from __future__ import annotations import asyncio from typing import Any, Generic import rich.repr from textual._wait im...
571
22,848
beam
sdks/python/apache_beam/yaml/yaml_testing.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...
558
18,585
biopython
Tests/seq_tests_common.py
.py
# This code is part of the Biopython distribution and governed by its # license. Please see the LICENSE file that should have been included # as part of this package. """Common code for SeqRecord object tests.""" import unittest import warnings from test_SeqIO import SeqIOTestBaseClass from Bio.Seq import Undefine...
298
13,152
metrics
tests/unittests/detection/__init__.py
.py
import os from unittests import _PATH_ALL_TESTS _SAMPLE_DETECTION_SEGMENTATION = os.path.join( _PATH_ALL_TESTS, "_data", "detection", "instance_segmentation_inputs.json" ) _DETECTION_VAL = os.path.join(_PATH_ALL_TESTS, "_data", "detection", "instances_val2014_100.json") _DETECTION_BBOX = os.path.join(_PATH_ALL_TE...
11
509
clearml
examples/reporting/html_reporting.py
.py
# ClearML - Example of manual graphs and statistics reporting # import math import numpy as np from bokeh.models import ColumnDataSource, GraphRenderer, Ellipse, StaticLayoutProvider from bokeh.palettes import Spectral5, Spectral8 from bokeh.plotting import figure, output_file, save from bokeh.sampledata.autompg impo...
247
8,569
onnx
onnx/fuzz/fuzz_compose.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 """Atheris fuzz harness for onnx.compose. Two input paths are exercised per iteration, selected by a fuzzer-controlled toggle byte read from the *tail* of the input: * Raw -> a 4-byte big-endian length prefix splits the remaining bytes...
148
5,033
onnxruntime
orttraining/orttraining/python/training/ortmodule/_custom_autograd_function_exporter.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from __future__ import annotations import sys from typing import ClassV...
645
27,073
pyomo
pyomo/core/kernel/piecewise_library/__init__.py
.py
# ____________________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and Engineering # Solutions of...
11
627
mlflow
mlflow/store/db_migrations/versions/867495a8f9d4_add_trace_tables.py
.py
"""add trace tables Create Date: 2024-04-27 12:29:25.178685 """ import sqlalchemy as sa from alembic import op from mlflow.store.tracking.dbmodels.models import SqlTraceInfo, SqlTraceMetadata, SqlTraceTag # revision identifiers, used by Alembic. revision = "867495a8f9d4" down_revision = "acf3f17fdcc7" branch_label...
89
2,765
mlflow
dev/clint/tests/rules/test_incorrect_type_annotation.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.incorrect_type_annotation import IncorrectTypeAnnotation def test_incorrect_type_annotation(index: SymbolIndex) -> None: code = """ def bad_function_ca...
28
985
wandb
tests/unit_tests/test_plot.py
.py
import pytest from wandb.plot import confusion_matrix, line_series, pr_curve, roc_curve def test_roc_curve_no_title(): """Test ROC curve with no title. The ROC curve is created with two sets of probabilities. The expected data is pre-defined and compared with the actual data. The title is also checked. ...
253
6,710
hatch
tests/backend/metadata/test_spec.py
.py
import pytest from hatchling.metadata.core import ProjectMetadata from hatchling.metadata.spec import ( LATEST_METADATA_VERSION, get_core_metadata_constructors, project_metadata_from_core_metadata, ) class TestProjectMetadataFromCoreMetadata: def test_missing_name(self): core_metadata = f"""\...
2,555
83,467
textual
tests/test_actions.py
.py
from __future__ import annotations from typing import Any import pytest from textual.actions import ActionError, parse @pytest.mark.parametrize( ("action_string", "expected_namespace", "expected_name", "expected_arguments"), [ ("spam", "", "spam", ()), ("hypothetical_action()", "", "hypothe...
91
2,694
pyomo
doc/OnlineDocs/src/data/ABCD4.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...
23
886
tqdm
examples/coroutine_pipe.py
.py
""" Inserting `tqdm` as a "pipe" in a chain of coroutines. Not to be confused with `asyncio.coroutine`. """ from functools import wraps from tqdm.auto import tqdm def autonext(func): @wraps(func) def inner(*args, **kwargs): res = func(*args, **kwargs) next(res) return res return i...
70
1,256
openvino
src/frontends/tensorflow_lite/tests/test_models/gen_scripts/generate_sparse_incomplete.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # WHAT: # Generates a family of small .tflite test models in which a constant # tensor carries a non-null SparsityParameters table with sub-fields that # are either incomplete (missing/empty traversal_order, dim_metadata, # dim_f...
462
18,925
pyro
pyro/poutine/seed_messenger.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 from types import TracebackType from typing import Optional, Type from pyro.poutine.messenger import Messenger from pyro.util import get_rng_state, set_rng_seed, set_rng_state class SeedMessenger(Messenger): """ Handler ...
39
1,308
hydra
hydra/extra/pytest_plugin.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import copy from pathlib import Path from typing import Callable, Generator, List, Optional from pytest import fixture from hydra.core.singleton import Singleton from hydra.test_utils.test_utils import SweepTaskFunction, TaskTestFunction from hydr...
91
2,508
saleor
saleor/webhook/tests/circuit_breaker/utils.py
.py
from saleor.webhook.circuit_breaker.breaker_board import BreakerBoard def create_breaker_board( storage, failure_min_count=0, failure_threshold=1, failure_min_count_recovery=0, failure_threshold_recovery=1, success_count_recovery=10, cooldown_seconds=10, ttl_seconds=10, ): return B...
24
711
beam
sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex_replace_first.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");...
60
1,824
coremltools
coremltools/test/sklearn_tests/test_SVC.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 copy import random import tempfile import unittest import numpy as np import pandas as pd import...
370
14,260
wagtail
wagtail/admin/viewsets/listing.py
.py
from wagtail.admin.viewsets.base import ViewSet class ListingViewSetMixin: #: The number of items to display per page in the index view. list_per_page = ViewSet.UNDEFINED #: The default ordering to use for the index view. #: Can be a string or a list/tuple in the same format as Django's #: :attr:...
81
3,146
saleor
saleor/tests/e2e/account/utils/__init__.py
.py
from .account_address_delete import account_address_delete from .account_register import account_register, raw_account_register from .create_customer import create_customer from .customer_bulk_update import customer_bulk_update from .customer_update import customer_update from .me import get_own_data from .staff_create...
26
755
sqlmap
thirdparty/chardet/hebrewprober.py
.py
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Universal charset detector code. # # The Initial Developer of the Original Code is # Shy Shalom # Portions created by the Initial Developer are Copyright (C) 2005 # the Initial Developer. All Rights Reserved. #...
293
13,838
kombu
kombu/message.py
.py
"""Message class.""" from __future__ import annotations import sys from .compression import decompress from .exceptions import MessageStateError, reraise from .serialization import loads from .utils.functional import dictfilter __all__ = ('Message',) ACK_STATES = {'ACK', 'REJECTED', 'REQUEUED'} IS_PYPY = hasattr(s...
235
8,151
astropy
astropy/io/typing.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Type annotations for ``astropy.io``. These are type annotations for I/O-related functions and classes. Some of the type objects can also be used as runtime-checkable :class:`~typing.Protocol` objects. """ __all__ = ["PathLike", "ReadableFileLike", "Wr...
47
1,612
probability
spinoffs/autobnn/autobnn/version.py
.py
# Copyright 2024 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...
37
1,402
saleor
saleor/page/tests/fixtures/__init__.py
.py
from .page import * # noqa: F403 from .page_translation import * # noqa: F403 from .page_type import * # noqa: F403
4
119
probability
tensorflow_probability/python/experimental/distributions/multitask_gaussian_process_test.py
.py
# Copyright 2021 The TensorFlow Probability Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
592
25,078
textual
src/textual/drivers/_byte_stream.py
.py
from __future__ import annotations import io from collections import deque from typing import ( Callable, Deque, Generator, Generic, Iterable, NamedTuple, Tuple, TypeVar, ) from typing_extensions import TypeAlias class ParseError(Exception): """Parse related errors.""" class Pa...
158
4,052
saleor
saleor/order/notifications.py
.py
from collections import defaultdict from collections.abc import Iterable from dataclasses import dataclass from decimal import Decimal from functools import partial from typing import TYPE_CHECKING, Optional from urllib.parse import urlencode from django.conf import settings from django.forms import model_to_dict fro...
584
20,106
onnx
onnx/reference/ops/op_hardmax.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 OpRunUnaryNum class Hardmax(OpRunUnaryNum): def _run(self, x, axis=None): axis = axis or self.axis if x.size == 0: ...
25
564
beam
sdks/python/apache_beam/internal/set_pickler_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...
279
7,135
wagtail
wagtail/fields.py
.py
import datetime import json from django.core.exceptions import ValidationError from django.core.serializers.json import DjangoJSONEncoder from django.core.validators import BaseValidator, MaxLengthValidator from django.db import models from django.utils.encoding import force_str from django.utils.functional import cac...
317
13,481
readthedocs.org
readthedocs/invitations/tests/test_querysets.py
.py
from unittest import mock from django.conf import settings from django.contrib.auth.models import User from django.test import TestCase from django.utils import timezone from django_dynamic_fixture import get from readthedocs.invitations.models import Invitation from readthedocs.organizations.models import Organizati...
175
5,914
wagtail
wagtail/admin/views/pages/usage.py
.py
import swapper from django.contrib.contenttypes.models import ContentType from django.core.exceptions import PermissionDenied from django.urls import reverse from django.utils.text import capfirst from django.utils.translation import gettext from django.utils.translation import gettext_lazy as _ from wagtail.admin.vie...
97
3,479
scikit-bio
skbio/stats/distance/tests/test_permdisp.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. # --------------------------------------------...
424
18,339
mlflow
mlflow/genai/datasets/__init__.py
.py
""" Databricks Agent Datasets Python SDK. For more details see Databricks Agent Evaluation: <https://docs.databricks.com/en/generative-ai/agent-evaluation/index.html> The API docs can be found here: <https://api-docs.databricks.com/python/databricks-agents/latest/databricks_agent_eval.html#datasets> """ import loggi...
798
28,145
saleor
saleor/tests/e2e/metadata/utils/update_metadata.py
.py
from ...utils import get_graphql_content METADATA_UPDATE_MUTATION = """ mutation UpdateMetadata( $id: ID!, $input:[MetadataInput!]!, ) { updateMetadata(id: $id, input: $input) { errors { message field } item { metadata { key value } } } } """ ...
42
763
gunicorn
tests/docker/asgi_compliance/test_framework_integration.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """ Framework integration tests for ASGI. Tests integration with popular ASGI frameworks like Starlette and FastAPI. """ import json import pytest pytestmark = [ pytest.mark.docker, pytest.mark.asgi, ...
503
20,172
pyomo
pyomo/core/expr/symbol_map.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...
203
7,138
pyomo
pyomo/core/tests/examples/__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...
12
573
pdm
tests/__init__.py
.py
from pathlib import Path FIXTURES = Path(__file__).parent / "fixtures"
4
72
textual
docs/examples/styles/border_title_colors.py
.py
from textual.app import App, ComposeResult from textual.widgets import Label class BorderTitleApp(App): CSS_PATH = "border_title_colors.tcss" def compose(self) -> ComposeResult: yield Label("Hello, World!") def on_mount(self) -> None: label = self.query_one(Label) label.border_ti...
20
460
saleor
saleor/plugins/openid_connect/client.py
.py
from authlib.integrations import requests_client from requests_hardened import HTTPSession from ...core.http_client import HTTPConfig class OAuth2Client(HTTPSession, requests_client.OAuth2Session): """Override the 3rd party OAuth client with our custom HTTP client.""" def __init__(self, **kwargs): k...
13
394
bazel
third_party/py/mock/tests/testsentinel.py
.py
# Copyright (C) 2007-2012 Michael Foord & the mock team # E-mail: fuzzyman AT voidspace DOT org DOT uk # http://www.voidspace.org.uk/python/mock/ from tests.support import unittest2 from mock import sentinel, DEFAULT class SentinelTest(unittest2.TestCase): def testSentinels(self): self.assertEqual(sent...
34
989
lemur
lemur/plugins/lemur_aws/iam.py
.py
""" .. module: lemur.plugins.lemur_aws.iam :platform: Unix :synopsis: Contains helper functions for interactive with AWS IAM Apis. :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. .. moduleauthor:: Kevin Glisson <kglisson@netflix.com> """ import ...
324
10,604
onnx
tests/python/model_container_test.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import os import tempfile import numpy as np import pytest import onnx import onnx.external_data_helper as ext_data import onnx.helper import onnx.model_container import onnx.numpy_helper def _linea...
134
5,059
openvino
tests/layer_tests/jax_tests/test_squeeze.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 class TestSqueeze(JaxLayerTest): def _prepare_input(self): inp = jnp.array(np.random.rand(*sel...
51
1,803
beam
learning/tour-of-beam/learning-content/cross-language/sql-transform/python-example/task.py
.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); y...
54
1,837
mkdocs
mkdocs/config/defaults.py
.py
from __future__ import annotations import logging from typing import IO, Dict, Mapping from mkdocs.config import base from mkdocs.config import config_options as c from mkdocs.structure.pages import Page, _AbsoluteLinksValidationValue from mkdocs.utils.yaml import get_yaml_loader, yaml_load class _LogLevel(c.Option...
219
8,948