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
ipython
IPython/core/hooks.py
.py
"""Hooks for IPython. In Python, it is possible to overwrite any method of any object if you really want to. But IPython exposes a few 'hooks', methods which are *designed* to be overwritten by users for customization purposes. This module defines the default versions of all such hooks, which get used by IPython if ...
164
5,452
wagtail
wagtail/users/tests/test_permissions.py
.py
from django.contrib.auth import get_user_model from django.contrib.auth.models import Group from django.test import TestCase from wagtail.permission_policies import ModelPermissionPolicy from wagtail.permissions import policy_registry class TestPermissions(TestCase): def test_get_user_permission_policy_from_regi...
20
803
beam
sdks/python/apache_beam/testing/load_tests/dataflow_cost_consts.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
1,905
mlflow
tests/tracking/_tracking_service/test_utils.py
.py
import io import itertools import os import pickle import uuid from importlib import reload from pathlib import Path from unittest import mock from urllib.parse import urlparse from urllib.request import url2pathname import pytest import mlflow from mlflow.environment_variables import ( MLFLOW_ENABLE_WORKSPACES, ...
548
20,669
wandb
wandb/sdk/artifacts/_generated/artifact_type.py
.py
# Generated by ariadne-codegen # Source: tools/graphql_codegen/artifacts/ from __future__ import annotations from pydantic import Field from wandb._pydantic import GQLResult class ArtifactType(GQLResult): project: ArtifactTypeProject | None class ArtifactTypeProject(GQLResult): artifact: ArtifactTypeProj...
30
661
mkdocs-material
material/utilities/filter/config.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...
48
1,947
onnxruntime
samples/cxx/generate_model.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """Generate a simple ONNX model that computes C = A + B. Inputs: A : float tensor of shape [1, 3] B : float tensor of shape [1, 3] Output: C : float tensor of shape [1, 3] Usage: pip install onnx python generate_...
43
1,120
conda
conda/cli/main_env_config.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """CLI implementation for `conda-env config`. Allows for programmatically interacting with conda-env's configuration files (e.g., `~/.condarc`). """ from argparse import ArgumentParser, Namespace, _SubParsersAction def configure_parser(sub_p...
45
1,166
astropy
astropy/utils/masked/tests/test_pickle.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pickle import numpy as np import pytest import astropy.units as u from astropy.coordinates import Angle, Latitude, Longitude from astropy.units import Quantity from astropy.utils.masked import Masked @pytest.mark.parametrize( "data", [ ...
38
900
saleor
saleor/product/tests/test_utils_product.py
.py
import datetime from unittest.mock import patch from ...discount.models import PromotionRule from ..models import ProductChannelListing from ..utils.product import ( get_channel_to_products_map_from_rules, mark_products_in_channels_as_dirty, ) @patch("saleor.product.utils.product.ProductChannelListing.object...
211
6,991
wandb
tests/system_tests/test_functional/test_tensorboard/test_keras_tb_callback.py
.py
"""Based on examples from https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/TensorBoard Test that the Keras TensorBoard callback works with W&B. """ import keras import numpy as np import tensorflow as tf import wandb from tests.fixtures.wandb_backend_spy import WandbBackendSpy class MyModel(keras.Model)...
89
2,725
onnxruntime
onnxruntime/test/python/transformers/test_onnx_attention/test_mha.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- """ Te...
3,089
107,263
biopython
Tests/PAML/gen_results.py
.py
# Copyright (C) 2012, 2013, 2016, 2019 by Brandon Invergo (b.invergo@gmail.com) # 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. """Generate output for PAML tests.""" import os.path import sys VERSIO...
181
6,629
sqlmap
tests/test_hash_crack.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission Dictionary-attack machinery in lib/utils/hash.py (the cracking loop, hash-file parsing, result storage and table/cache post-processing) - the part NOT covered by tests/test_hash.py, w...
233
8,697
lemur
lemur/plugins/lemur_email/templates/config.py
.py
import os import arrow from jinja2 import Environment, FileSystemLoader, select_autoescape from lemur.plugins.utils import get_plugin_option loader = FileSystemLoader(searchpath=os.path.dirname(os.path.realpath(__file__))) env = Environment( loader=loader, # nosec: potentially dangerous types esc. autoescape...
29
678
onnxruntime
orttraining/orttraining/python/training/ortmodule/torch_cpp_extensions/cuda/torch_gpu_allocator/setup.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import fileinput import os import sys from setuptools import setup from...
40
1,438
saleor
saleor/graphql/channel/mutations/utils.py
.py
import datetime from django.conf import settings from django.core.exceptions import ValidationError from django.utils import timezone from ....channel.models import Channel from ...core.enums import ChannelErrorCode CHANNEL_UPDATE_FIELDS = [ "name", "slug", "default_country", "is_active", "alloca...
304
11,387
hydra
plugins/hydra_ax_sweeper/hydra_plugins/hydra_ax_sweeper/_core.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import logging from dataclasses import dataclass from typing import ( Any, Dict, Iterable, List, Literal, Mapping, Optional, Tuple, Union, cast, ) from ax.api.client import Client # type: ignore from ax.api....
444
16,446
confluent-kafka-python
tests/integration/consumer/test_consumer_topicpartition_metadata.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2022 Confluent Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
64
2,130
sphinx
sphinx/util/i18n.py
.py
"""Builder superclass for all builders.""" from __future__ import annotations import os import os.path import re from datetime import datetime from typing import TYPE_CHECKING import babel.dates from babel.messages.mofile import write_mo from babel.messages.pofile import read_po from sphinx.errors import SphinxErro...
344
11,917
pymc
pymc/distributions/truncated.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...
510
19,328
sqlmap
plugins/dbms/sybase/__init__.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.enums import DBMS from lib.core.settings import SYBASE_SYSTEM_DBS from lib.core.unescaper import unescaper from plugins.dbms.sybase.enumeration import Enumeration fr...
30
908
sqlmap
tamper/versionedkeywords.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import os import re from lib.core.common import singleTimeWarnMessage from lib.core.data import kb from lib.core.enums import DBMS from lib.core.enums import PRIORITY __priority...
53
1,602
onnxruntime
onnxruntime/python/tools/microbench/topk.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import argparse from dataclasses import dataclass import numpy as np fr...
62
1,956
metrics
src/torchmetrics/clustering/dunn_index.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...
130
5,014
beam
sdks/python/apache_beam/dataframe/partitionings_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...
92
3,591
slimit
src/slimit/visitors/nodevisitor.py
.py
############################################################################### # # Copyright (c) 2011 Ruslan Spivak # # 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, inc...
87
2,877
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/jupyter_with_raw_cell_on_top.py
.py
# --- # title: Quick test # output: # ioslides_presentation: # widescreen: true # smaller: true # editor_options: # chunk_output_type: console # jupyter: # jupytext: # cell_markers: region,endregion # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- 1+2+3
21
320
deap
deap/tools/crossover.py
.py
import random import warnings try: from collections.abc import Sequence except ImportError: from collections import Sequence from itertools import repeat ###################################### # GA Crossovers # ###################################### def cxOnePoint(ind1, ind2): """...
463
17,311
saleor
saleor/graphql/channel/dataloaders/by_checkout.py
.py
from uuid import UUID from ....channel.models import Channel from ...checkout.dataloaders import CheckoutByTokenLoader from ...core.dataloaders import DataLoader from .by_self import ChannelByIdLoader class ChannelByCheckoutIDLoader(DataLoader[UUID, Channel]): context_key = "channel_by_checkout" def batch_l...
29
997
probability
tensorflow_probability/python/experimental/mcmc/diagonal_mass_matrix_adaptation_test.py
.py
# Copyright 2020 The TensorFlow Probability Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
427
17,886
pymc
pymc/vartypes.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...
44
1,277
gunicorn
tests/requests/invalid/obs_fold_01.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. from gunicorn.http.errors import ObsoleteFolding request = ObsoleteFolding
8
182
astropy
astropy/io/fits/header.py
.py
# Licensed under a 3-clause BSD style license - see PYFITS.rst import collections import copy import itertools import numbers import os import re import warnings import numpy as np from astropy.utils.exceptions import AstropyUserWarning from ._utils import parse_header from .card import KEYWORD_LENGTH, UNDEFINED, C...
2,278
79,989
mlflow
mlflow/genai/review_queues/validation.py
.py
"""Server-side validation and normalization for review queues. Called from the store layer's create / update / attach / status paths. Length caps on the validated identity fields (queue name, user, schema id, item id) are aligned with their SQL column widths so a value that passes validation also fits its column. The ...
256
10,043
kombu
kombu/entity.py
.py
"""Exchange and Queue declarations.""" from __future__ import annotations import numbers from .abstract import MaybeChannelBound, Object from .exceptions import ContentDisallowed from .serialization import prepare_accept_content TRANSIENT_DELIVERY_MODE = 1 PERSISTENT_DELIVERY_MODE = 2 DELIVERY_MODES = {'transient':...
889
33,286
jupytext
tests/data/notebooks/outputs/ipynb_to_script/jupyter.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # # Jupyter notebook # # This notebook is a simple jupyter notebook. It only has markdown and code cells. And it does not contain consecutive markdown cells. We start with an addition: a = 1 b = 2 a + b # N...
24
410
sqlmap
thirdparty/chardet/big5prober.py
.py
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Communicator client code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights R...
48
1,757
sphinx
sphinx/ext/duration.py
.py
"""Measure document reading durations.""" from __future__ import annotations import json import time from itertools import islice from operator import itemgetter from types import NoneType from typing import TYPE_CHECKING import sphinx from sphinx.domains import Domain from sphinx.locale import __ from sphinx.util i...
176
5,743
probability
tensorflow_probability/python/monte_carlo/__init__.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...
26
963
hatch
tests/env/collectors/test_custom.py
.py
import re import pytest from hatch.env.collectors.custom import CustomEnvironmentCollector from hatch.plugin.constants import DEFAULT_CUSTOM_SCRIPT def test_no_path(isolation): config = {"path": ""} with pytest.raises( ValueError, match="Option `path` for environment collector `custom` must not be ...
106
2,934
onnx
tests/python/reference_evaluator_test.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # mypy: ignore-errors from __future__ import annotations import importlib.util import math import warnings from os import getenv from textwrap import dedent from typing import TYPE_CHECKING import ml_dtypes import numpy as np import pyt...
6,591
244,044
saleor
saleor/plugins/webhook/tests/test_stored_payment_method_request_delete.py
.py
import json from unittest import mock import graphene import pytest from ....core.models import EventDelivery from ....payment.interface import ( ListStoredPaymentMethodsRequestData, StoredPaymentMethodRequestDeleteData, StoredPaymentMethodRequestDeleteResponseData, StoredPaymentMethodRequestDeleteRes...
470
15,384
mlflow
tests/tracing/test_provider.py
.py
import random import threading from concurrent.futures import ThreadPoolExecutor from unittest import mock import pytest from opentelemetry import trace from opentelemetry.sdk.trace.id_generator import RandomIdGenerator import mlflow from mlflow.entities.trace_location import ( MlflowExperimentLocation, UCSch...
1,234
44,146
python-prompt-toolkit
src/prompt_toolkit/contrib/regular_languages/compiler.py
.py
r""" Compiler for a regular grammar. Example usage:: # Create and compile grammar. p = compile('add \s+ (?P<var1>[^\s]+) \s+ (?P<var2>[^\s]+)') # Match input string. m = p.match('add 23 432') # Get variables. m.variables().get('var1') # Returns "23" m.variables().get('var2') # Return...
582
21,979
kafka
tests/kafkatest/tests/core/security_test.py
.py
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use ...
174
8,308
wandb
wandb/sdk/internal/progress.py
.py
"""progress.""" from __future__ import annotations import os from typing import IO, TYPE_CHECKING from wandb.errors import CommError if TYPE_CHECKING: from typing import Protocol class ProgressFn(Protocol): def __call__(self, new_bytes: int, total_bytes: int) -> None: pass class Progr...
78
2,296
conda
conda/notices/types.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Implements all conda.notices types.""" from __future__ import annotations import hashlib from datetime import datetime from typing import TYPE_CHECKING, NamedTuple from ..base.constants import NoticeLevel if TYPE_CHECKING: from collec...
116
3,631
onnxruntime
onnxruntime/python/tools/transformers/fusion_gpt_attention.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger import numpy as np from fusion_base impor...
547
21,962
saleor
saleor/core/db/fields.py
.py
from collections.abc import Callable from decimal import Decimal from functools import total_ordering import orjson from django.core import validators from django.db.models import Field, JSONField from django.db.models.expressions import Expression from prices import Money, TaxedMoney class SanitizedJSONField(JSONFi...
183
5,978
probability
spinoffs/inference_gym/inference_gym/internal/ground_truth_encoding.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...
223
7,295
readthedocs.org
readthedocs/api/v2/test/test_tasks.py
.py
from datetime import timedelta from django.test import TestCase from django.utils import timezone from django_dynamic_fixture import get from readthedocs.api.v2.models import BuildAPIKey from readthedocs.api.v2.tasks import delete_old_revoked_build_api_keys from readthedocs.projects.models import Project class Test...
59
1,859
onnxruntime
tools/ci_build/github/linux/ort_minimal/check_build_binary_size.py
.py
#!/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import argparse import os import sys # local helpers import readelf_utils def _check_binary_size(path, readelf, threshold, os_str, arch, build_config): print(f"Checking binary size of {path} usin...
68
2,635
python-prompt-toolkit
src/prompt_toolkit/contrib/regular_languages/validation.py
.py
""" Validator for a regular language. """ from __future__ import annotations from prompt_toolkit.document import Document from prompt_toolkit.validation import ValidationError, Validator from .compiler import _CompiledGrammar __all__ = [ "GrammarValidator", ] class GrammarValidator(Validator): """ Val...
61
2,059
beam
sdks/python/apache_beam/yaml/generate_yaml_docs.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...
615
19,744
textual
tests/snapshot_tests/snapshot_apps/notification_through_screens.py
.py
from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Label class StackableScreen(Screen): TARGET_DEPTH = 10 def __init__(self, count:int = TARGET_DEPTH) -> None: super().__init__() self._number = count def compose(self) -> ComposeResult...
32
824
astropy
astropy/timeseries/periodograms/bls/setup_package.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import os from numpy import get_include as get_numpy_include from setuptools import Extension BLS_ROOT = os.path.relpath(os.path.dirname(__file__)) def get_extensions(): ext = Extension( "astropy.timeseries.periodograms.bls._impl", ...
21
503
metrics
tests/unittests/retrieval/test_fallout.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...
200
7,330
openvino
tests/layer_tests/common/tf2_layer_test_class.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os from common.layer_test_class import CommonLayerTest from common.utils.tflite_utils import get_tflite_results, save_tf2_saved_model_to_tflite def save_to_tf2_savedmodel(tf2_model, path_to_saved_tf2_model): import tensorfl...
47
1,832
kombu
t/integration/test_kafka.py
.py
from __future__ import annotations import pytest import kombu from .common import (BaseExchangeTypes, BaseFailover, BaseMessage, BasicFunctionality) def get_connection(hostname, port): return kombu.Connection( f'confluentkafka://{hostname}:{port}', ) def get_failover_connecti...
70
1,464
readthedocs.org
readthedocs/invitations/backends.py
.py
"""Backends for the objects from the invitations.""" import structlog from django.conf import settings from django.urls import reverse from django.utils import formats from django.utils import timesince from django.utils import translation from readthedocs.core.permissions import AdminPermission from readthedocs.core...
155
4,825
openvino
src/frontends/onnx/tests/tests_python/__init__.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0
4
106
saleor
saleor/graphql/order/mutations/order_grant_refund_update.py
.py
from typing import Any, cast import graphene from django.core.exceptions import ValidationError from django.db import transaction from graphql import GraphQLError from ....order import OrderGrantedRefundStatus, models from ....order.utils import update_order_charge_data from ....page.models import Page from ....permi...
469
17,742
onnxruntime
onnxruntime/test/python/transformers/cuda_plugin_ep_helper.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import logging import os import sys from importlib.metadata import PackageNotFoundError, distribution from pathlib import Path import torch import onnxruntime as onnxrt CUDA_PLUGIN_EP_NAME = "CUDAExecutionProvider" enable_...
205
6,919
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_leaky_relu.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # leaky_relu paddle model generator # import numpy as np from save_model import saveModel import paddle import sys def leaky_relu(name: str, x, alpha: float = 0.01, data_type='float32'): paddle.enable_static() with paddle.st...
47
1,351
probability
tensorflow_probability/python/distributions/two_piece_student_t.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...
632
23,419
wandb
wandb/integration/sagemaker/resources.py
.py
from __future__ import annotations import os import secrets import socket import string import wandb from . import config from . import files as sm_files def set_run_id(run_settings: wandb.Settings) -> bool: """Set a run ID and group when using SageMaker. Returns whether the ID and group were updated. ...
64
1,944
hypercorn
src/hypercorn/asyncio/worker_context.py
.py
from __future__ import annotations import asyncio from collections.abc import Callable from ..typing import Event, SingleTask, TaskGroup class AsyncioSingleTask: def __init__(self) -> None: self._handle: asyncio.Task | None = None self._lock = asyncio.Lock() async def restart(self, task_gro...
79
2,108
luigi
test/contrib/mongo_test.py
.py
# -*- coding: utf-8 -*- # # Copyright 2017 Big Datext Inc # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law ...
263
9,862
sphinx
tests/test_ext_autodoc/test_ext_autodoc_signatures.py
.py
"""Test the autodoc extension. This mainly tests the signature utilities.""" from __future__ import annotations from typing import Generic, TypeVar import pytest from sphinx.ext.autodoc._directive_options import _AutoDocumenterOptions from sphinx.ext.autodoc._dynamic._docstrings import _get_docstring_lines from sp...
358
10,935
sphinx
tests/test_ext_autodoc/test_ext_autodoc_automodule.py
.py
"""Test the autodoc extension. This tests mainly the Documenters; the auto directives are tested in a test source file translated by test_build. """ from __future__ import annotations import inspect import sys import typing import pytest from sphinx.ext.autodoc._dynamic._mock import _MockObject from sphinx.ext.aut...
240
6,409
pyomo
pyomo/contrib/mpc/data/tests/test_get_cuid.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...
109
4,442
onnxruntime
onnxruntime/python/datasets/__init__.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """ Short examples used in the documentation. """ import os def get_example(name): """ Retrieves the absolute file name of an example. """ this = os.path.abspath(os.path.dirname(__file__)) full = os.path...
19
455
astropy
astropy/units/enums.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from enum import StrEnum, auto from typing import Self class DeprecatedUnitAction(StrEnum): SILENT = auto() WARN = auto() RAISE = auto() CONVERT = auto() @classmethod def _missing_(cls, value) -> Self | None: raise Value...
19
479
gunicorn
gunicorn/uwsgi/__init__.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. from gunicorn.uwsgi.message import UWSGIRequest from gunicorn.uwsgi.parser import UWSGIParser from gunicorn.uwsgi.errors import ( UWSGIParseException, InvalidUWSGIHeader, UnsupportedModifier, Forbid...
22
502
probability
tensorflow_probability/python/experimental/bayesopt/acquisition/expected_improvement_test.py
.py
# Copyright 2023 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...
248
9,476
wagtail
wagtail/tests/streamfield_migrations/test_simple_structures.py
.py
from django.test import TestCase from wagtail.blocks.migrations.operations import ( AlterBlockValueOperation, ListChildrenToStructBlockOperation, RemoveStreamChildrenOperation, RemoveStructChildrenOperation, RenameStreamChildrenOperation, RenameStructChildrenOperation, StreamChildrenToListB...
536
22,123
saleor
saleor/graphql/core/tests/garbage_collection/test_saleor_context.py
.py
import gc import json import pytest from django.core.serializers.json import DjangoJSONEncoder from .....core.jwt import create_access_token from ....api import backend, schema from ....tests.utils import get_graphql_content from ....views import GraphQLView from .utils import ( clean_up_after_garbage_collection_...
104
3,378
onnx
onnx/backend/test/case/node/rotaryembedding.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 from onnx.reference.ops.op_rotary_embedding import rotary_embedding class Ro...
232
7,829
qutip
qutip/tests/solver/heom/test_bofin_solvers.py
.py
""" Tests for qutip.solver.heom.bofin_solvers. """ import numpy as np import pytest from numpy.linalg import eigvalsh from scipy.integrate import quad from qutip import ( basis, destroy, expect, liouvillian, qeye, sigmax, sigmaz, sigmay, tensor, Qobj, QobjEvo, fidelity, fdestroy ) from qutip.core import data ...
1,926
68,488
ipython
tests/test_display_2.py
.py
# Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. import json import os import sys import warnings from pathlib import Path from unittest import mock import pytest from IPython import display from IPython.core.display import ImageFormat from IPython.core.getipython...
608
19,158
wagtail
wagtail/admin/forms/workflows.py
.py
import swapper from django import forms from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ImproperlyConfigured, ValidationError from django.db import transaction from django.db.models import Q from django.utils.functional import cached_property from django.utils.text import c...
322
12,063
coremltools
coremltools/models/ml_program/experimental/torch/debugging_utils.py
.py
# Copyright (c) 2025, 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.converters import convert from collections import OrderedDict, deque from dataclasses...
2,335
79,102
saleor
saleor/graphql/checkout/resolvers.py
.py
from uuid import UUID from ...checkout import models from ...core.exceptions import PermissionDenied from ...permission.enums import ( AccountPermissions, CheckoutPermissions, PaymentPermissions, ) from ..channel.dataloaders.by_self import ChannelByIdLoader from ..core.context import SyncWebhookControlCont...
84
2,867
sphinx
tests/roots/test-ext-graphviz/conf.py
.py
extensions = ['sphinx.ext.graphviz'] exclude_patterns = ['_build'] html_static_path = ['_static']
4
98
mlflow
tests/demo/test_base.py
.py
import pytest from mlflow.demo.base import ( DEMO_EXPERIMENT_NAME, DEMO_PROMPT_PREFIX, BaseDemoGenerator, DemoFeature, DemoResult, ) def test_demo_feature_enum(): assert DemoFeature.TRACES == "traces" assert DemoFeature.EVALUATION == "evaluation" assert isinstance(DemoFeature.TRACES, ...
133
3,567
openvino
tests/layer_tests/pytorch_tests/test_det.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest import torch import openvino as ov from pytorch_layer_test_class import PytorchLayerTest class TestDet(PytorchLayerTest): """aten::det / aten::linalg_det — batched matrix determinant. The PyTo...
119
5,438
mlflow
tests/utils/test_resources/dummy_package/base.py
.py
# This call should import the **system** operator, not the dummy_package.operator # module that is adjacent to this file import operator # noqa: F401
4
151
mlflow
examples/mlflow-3/sklearn_example.py
.py
# ruff: noqa """ python examples/demo.py """ import logging import tempfile import numpy as np import pandas as pd from sklearn.linear_model import ElasticNet from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score from sklearn.model_selection import train_test_split import mlflow # Read the ...
127
3,666
astropy
astropy/visualization/wcsaxes/coordinate_range.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import warnings import numpy as np from astropy import units as u from astropy.utils.exceptions import AstropyDeprecationWarning # Algorithm inspired by PGSBOX from WCSLIB by M. Calabretta LONLAT = {"longitude", "latitude"} def wrap_180(values): ...
148
5,379
confluent-kafka-python
src/confluent_kafka/schema_registry/rules/cel/cel_executor.py
.py
# Copyright 2024 Confluent Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
176
6,123
openvino
src/frontends/tensorflow/tests/test_models/models_pbtxt/string_tensors_model.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import tensorflow.compat.v1 as tf tf.reset_default_graph() # Create the graph and model with tf.Session() as sess: x = tf.placeholder(tf.float32, [2, 3], 'x') y = tf.placeholder(tf.float32, [2, 3], 'y') cond = tf.constant(Tr...
20
805
beam
learning/katas/python/Common Transforms/Filter/Filter/tests/test_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"); you may not...
36
1,240
saleor
saleor/plugins/tests/test_views.py
.py
import pytest from .sample_plugins import ( ChannelPluginSample, InactiveChannelPluginSample, PluginInactive, PluginSample, ) @pytest.mark.parametrize( ("plugin_id", "plugin_path", "status_code"), [ (PluginSample.PLUGIN_ID, "/webhook/paid", 200), (PluginInactive.PLUGIN_ID, "/w...
73
2,240
hatch
tests/cli/test_root.py
.py
import os from hatch.config.constants import ConfigEnvVars from hatch.config.user import ConfigFile from hatch.utils.structures import EnvVars class TestFreshInstallation: INSTALL_MESSAGE = """\ No config file found, creating one with default settings now... Success! Please see `hatch config`. """ def test_...
42
1,328
returns
returns/primitives/reawaitable.py
.py
from collections.abc import Awaitable, Callable, Generator from functools import wraps from typing import NewType, ParamSpec, TypeVar, cast, final _ValueType = TypeVar('_ValueType') _AwaitableT = TypeVar('_AwaitableT', bound=Awaitable) _Ps = ParamSpec('_Ps') _Sentinel = NewType('_Sentinel', object) _sentinel: _Sentin...
140
3,827
mlflow
mlflow/gateway/providers/groq.py
.py
from mlflow.gateway.config import _OpenAICompatibleConfig from mlflow.gateway.providers.openai_compatible import OpenAICompatibleProvider class GroqProvider(OpenAICompatibleProvider): DISPLAY_NAME = "Groq" CONFIG_TYPE = _OpenAICompatibleConfig DEFAULT_API_BASE = "https://api.groq.com/openai/v1"
9
310
astropy
astropy/timeseries/periodograms/lombscargle_multiband/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from .core import LombScargleMultiband
4
104
openvino
tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_batch_normalization.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 TestKerasBatchNormalization(CommonTF2LayerTest): def create_keras_batch_normalization_net(self, axis, momentum, epsilon, center...
63
3,337
saleor
saleor/webhook/observability/payloads.py
.py
import datetime import json import uuid from collections.abc import Mapping from typing import TYPE_CHECKING, Any import graphene from django.core.serializers.json import DjangoJSONEncoder from django.http import HttpRequest, HttpResponse from django.utils import timezone from graphene.utils.str_converters import to_c...
276
9,761