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
textual
tests/test_screen_modes.py
.py
from itertools import cycle from typing import Type import pytest from textual.app import ( ActiveModeError, App, ComposeResult, InvalidModeError, UnknownModeError, ) from textual.screen import ModalScreen, Screen from textual.widgets import Footer, Header, Label class ScreenBindingsMixin(Screen...
232
6,305
wagtail
wagtail/admin/tests/ui/test_tables.py
.py
from django.template import Context, Template from django.test import RequestFactory, TestCase from django.utils.html import format_html from wagtail.admin.ui.tables import ( BaseColumn, Column, RelatedObjectsColumn, Table, TitleColumn, ) from wagtail.models import Site from wagtail.test.utils impo...
373
11,265
metrics
src/torchmetrics/regression/mse.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...
153
5,609
saleor
saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_transactions.py
.py
import datetime from decimal import Decimal from unittest.mock import ANY, patch import graphene import pytest from django.contrib.sites.models import Site from django.db import transaction from django.db.models.aggregates import Sum from django.test import override_settings from django.utils import timezone from pric...
6,110
196,260
sphinx
sphinx/ext/intersphinx/__main__.py
.py
"""Command line interface for the intersphinx extension.""" from __future__ import annotations import logging as _logging import sys from sphinx.ext.intersphinx._cli import inspect_main _logging.basicConfig() raise SystemExit(inspect_main(sys.argv[1:]))
13
259
wandb
wandb/sdk/lib/wbauth/auth.py
.py
from __future__ import annotations import abc import dataclasses import pathlib from typing_extensions import final, override from wandb.errors import AuthenticationError from . import validation from .host_url import HostUrl # We use an abstract base class instead of a union because # (1) All Auth subtypes hav...
147
4,130
mlflow
dev/normalize_chars.py
.py
import sys from pathlib import Path # Mapping of characters to normalize. Start with quotes; extend as needed. CHAR_MAP = { "\u2018": "'", # left single quotation mark "\u2019": "'", # right single quotation mark "\u201c": '"', # left double quotation mark "\u201d": '"', # right double quotation ma...
44
1,073
pyfilesystem2
fs/move.py
.py
"""Functions for moving files between filesystems. """ from __future__ import print_function, unicode_literals import typing from ._pathcompat import commonpath from .copy import copy_dir, copy_file from .errors import FSError from .opener import manage_fs from .osfs import OSFS from .path import frombase if typing...
151
5,619
sphinx
sphinx/ext/mathjax.py
.py
"""Allow `MathJax`_ to be used to display math in Sphinx's HTML writer. This requires the MathJax JavaScript library on your webserver/computer. .. _MathJax: https://www.mathjax.org/ """ from __future__ import annotations import json from types import NoneType from typing import TYPE_CHECKING, cast from docutils i...
179
6,790
astropy
astropy/cosmology/_src/units_equivalencies.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Cosmological unit equivalencies.""" __all__ = ( # redshift equivalencies "dimensionless_redshift", "redshift_distance", "redshift_hubble", "redshift_temperature", # other equivalencies "with_H0", "with_redshift", ) imp...
370
12,527
astropy
astropy/timeseries/periodograms/bls/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Box Least Squares Algorithms. Box Least Squares ================= AstroPy-compatible reference implementation of the transit periorogram used to discover transiting exoplanets. """ __all__ = ["BoxLeastSquares", "BoxLeastSquaresResults"] from .core...
16
368
saleor
saleor/shipping/models.py
.py
from decimal import Decimal from typing import TYPE_CHECKING, Optional, Union, cast from django.conf import settings from django.contrib.postgres.indexes import GinIndex from django.db import models from django.db.models import OuterRef, Q, Subquery from django_countries.fields import CountryField from django_measurem...
369
13,195
pyomo
examples/dae/car_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...
119
2,760
astropy
astropy/io/fits/scripts/__init__.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This subpackage contains implementations of command-line scripts that are included with Astropy. The actual scripts that are installed in bin/ are simple wrappers for these modules that will run in any Python version. """
9
291
gunicorn
tests/test_header_policy_parity.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Parity tests for WSGI header policy across Python and fast parsers. These checks ensure that Expect, secure_scheme_headers, forwarder_headers, and the forwarded_allow_ips trust gate are enforced identically reg...
186
5,648
saleor
saleor/tax/tests/test_utils.py
.py
from decimal import Decimal from unittest.mock import Mock import pytest from ...checkout.fetch import fetch_checkout_info, fetch_checkout_lines from ...core.prices import Money, TaxedMoney from ...core.utils.country import get_active_country from ...graphql.tax.enums import TaxCalculationStrategy from ...order.utils...
440
14,378
sphinx
sphinx/util/nodes.py
.py
"""Docutils node-related utility functions for Sphinx.""" from __future__ import annotations import contextlib import re import unicodedata from io import StringIO from typing import TYPE_CHECKING, Any, cast from docutils import nodes from docutils.nodes import Node from sphinx import addnodes from sphinx.locale im...
785
26,552
pyomo
pyomo/core/base/block.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...
2,547
98,379
probability
tensorflow_probability/python/experimental/distributions/mvn_precision_factor_linop.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...
328
11,625
mlflow
mlflow/genai/judges/prompts/groundedness.py
.py
from typing import Any from mlflow.genai.prompts.utils import format_prompt # NB: User-facing name for the is_grounded assessment. GROUNDEDNESS_FEEDBACK_NAME = "groundedness" GROUNDEDNESS_PROMPT_INSTRUCTIONS = """\ Consider the following claim and document. You must determine whether claim is supported by the \ doc...
50
1,630
pyfilesystem2
tests/test_new_name.py
.py
from __future__ import unicode_literals import unittest import warnings from fs.base import _new_name class TestNewNameDecorator(unittest.TestCase): def double(self, n): "Double a number" return n * 2 times_2 = _new_name(double, "times_2") def test_old_name(self): """Test _new_...
28
791
probability
spinoffs/autobnn/autobnn/bnn_tree.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...
163
5,386
wagtail
wagtail/embeds/tests/test_embeds.py
.py
import datetime import json import unittest import urllib.request from unittest.mock import Mock, patch from urllib.error import HTTPError, URLError import responses from django import template from django.core.exceptions import ValidationError from django.test import TestCase, override_settings from django.urls impor...
1,166
42,634
probability
tensorflow_probability/python/experimental/auto_batching/dsl_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...
203
8,057
wandb
tests/system_tests/test_launch/test_launch_sagemaker.py
.py
from unittest.mock import MagicMock import pytest import wandb from wandb.apis.internal import Api from wandb.sdk.launch import loader from wandb.sdk.launch._project_spec import EntryPoint, LaunchProject from wandb.sdk.launch.environment.aws_environment import AwsEnvironment @pytest.fixture def mock_sagemaker_enviro...
156
5,158
sqlmap
extra/dbwire/postgres.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 PostgreSQL frontend/backend protocol v3 client (stdlib only). Covers the whole PostgreSQL-wire family (PostgreSQL, CockroachDB, CrateDB, Redshift, Greenpl...
332
16,121
hypercorn
tests/test___main__.py
.py
from __future__ import annotations import inspect import os from unittest.mock import Mock import pytest from _pytest.monkeypatch import MonkeyPatch import hypercorn.__main__ from hypercorn.config import Config def test_load_config_none() -> None: assert isinstance(hypercorn.__main__._load_config(None), Config...
86
2,898
pymc
tests/gp/test_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...
113
3,698
astropy
astropy/timeseries/periodograms/lombscargle_multiband/implementations/mbflex_impl.py
.py
import numpy as np __all__ = ["lombscargle_mbflex"] def lombscargle_mbflex( t, y, bands, frequency, dy=None, nterms_base=1, nterms_band=1, reg_base=None, reg_band=1e-6, regularize_by_trace=True, center_data=True, ): if (nterms_base == 0) and (nterms_band == 0): ...
128
3,867
onnxruntime
onnxruntime/test/python/quantization/test_conv_dynamic.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. # ---------------------------------------------------------------...
124
5,020
wagtail
wagtail/actions/create_alias.py
.py
import logging import uuid import swapper from django.core.exceptions import PermissionDenied from wagtail.actions.base import BaseAction from wagtail.log_actions import log logger = logging.getLogger("wagtail") class CreatePageAliasIntegrityError(RuntimeError): """ Raised when creating an alias of a page ...
286
9,983
mlflow
mlflow/utils/databricks_tracing_utils.py
.py
import logging from google.protobuf.duration_pb2 import Duration from google.protobuf.timestamp_pb2 import Timestamp from mlflow.entities import Assessment, Span, Trace, TraceData, TraceInfo from mlflow.entities.trace_info_v2 import _truncate_request_metadata, _truncate_tags from mlflow.entities.trace_location import...
292
11,200
sphinx
tests/test_extensions/test_ext_ifconfig.py
.py
"""Test sphinx.ext.ifconfig extension.""" from __future__ import annotations from typing import TYPE_CHECKING import docutils.utils import pytest from sphinx import addnodes from sphinx.testing import restructuredtext if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('text',...
35
1,031
pyomo
pyomo/solvers/tests/piecewise_linear/problems/concave_multi_vararray1.py
.py
# ____________________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and Engineering # Solutions of...
77
2,847
scikit-bio
checklist.py
.py
#!/usr/bin/env python """Validate the content and structure of a scikit-bio repository. ---------------------------------------------------------------------------- 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...
510
17,451
saleor
saleor/graphql/core/tests/test_base_mutation.py
.py
from unittest import mock import graphene import pytest from django.core.exceptions import ImproperlyConfigured from freezegun import freeze_time from ....core.jwt import create_access_token from ....graphql.tests.utils import get_graphql_content from ....order.models import Order from ....permission.enums import Pro...
317
9,637
gunicorn
gunicorn/http/message.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. from enum import IntEnum import ipaddress import re import socket import struct from gunicorn.http.body import ChunkedReader, LengthReader, EOFReader, Body from gunicorn.http.errors import ( InvalidHeader, Inv...
892
34,182
beam
sdks/python/apache_beam/ml/inference/test_resources/vertex_ai_custom_prediction/echo_server.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...
44
1,295
sqlmap
tamper/concat2concatws.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.enums import DBMS from lib.core.enums import PRIORITY __priority__ = PRIORITY.HIGHEST def de...
42
1,033
scikit-optimize
examples/sklearn-gridsearchcv-replacement.py
.py
""" ========================================== Scikit-learn hyperparameter search wrapper ========================================== Iaroslav Shcherbatyi, Tim Head and Gilles Louppe. June 2017. Reformatted by Holger Nahrstaedt 2020 .. currentmodule:: skopt Introduction ============ This example assumes basic famili...
213
7,105
pyomo
pyomo/repn/tests/mps/test_mps.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...
249
8,100
beam
sdks/python/apache_beam/runners/interactive/messaging/interactive_environment_inspector.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...
214
8,306
sphinx
sphinx/ext/intersphinx/__init__.py
.py
"""Insert links to objects documented in remote Sphinx documentation. This works as follows: * Each Sphinx HTML build creates a file named "objects.inv" that contains a mapping from object names to URIs relative to the HTML set's root. * Projects using the Intersphinx extension can specify links to such mapping ...
111
3,661
loguru
tests/exceptions/source/backtrace/chaining_third.py
.py
import sys from loguru import logger logger.remove() logger.add(sys.stderr, format="", colorize=False, backtrace=True, diagnose=False) def a_decorator(): b_decorator() def a_context_manager(): b_context_manager() def a_explicit(): b_explicit() def b_decorator(): c_decorated() def b_context_m...
49
624
qutip
doc/guide/scripts/ex_steady.py
.py
import numpy as np import matplotlib.pyplot as plt import qutip # Define paramters N = 20 # number of basis states to consider a = qutip.destroy(N) H = a.dag() * a psi0 = qutip.basis(N, 10) # initial state kappa = 0.1 # coupling to oscillator # collapse operators c_op_list = [] n_th_a = 2 # temperature with aver...
46
1,417
readthedocs.org
readthedocs/search/api/v2/serializers.py
.py
""" Serializers for the ES's search result object. .. note:: Some fields are re-named to make their meaning more clear. They should be renamed in the ES index too. """ import re from functools import namedtuple from urllib.parse import urlparse from rest_framework import serializers from readthedocs.builds.mo...
188
6,682
beam
sdks/python/apache_beam/transforms/__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...
36
1,484
saleor
saleor/graphql/menu/types.py
.py
import graphene from graphene import relay from ...menu import models from ...permission.enums import PagePermissions from ...permission.utils import has_one_of_permissions from ...product.models import ALL_PRODUCTS_PERMISSIONS from ..channel.dataloaders.by_self import ChannelBySlugLoader from ..core import ResolveInf...
259
9,545
black
tests/data/cases/module_docstring_1.py
.py
"""Single line module-level docstring should be followed by single newline.""" a = 1 """I'm just a string so should be followed by 2 newlines.""" b = 2 # output """Single line module-level docstring should be followed by single newline.""" a = 1 """I'm just a string so should be followed by 2 newlines."""...
26
329
astropy
astropy/cosmology/_src/traits/baryons.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Baryon component.""" __all__ = ("BaryonComponent",) from collections.abc import Callable from typing import Any import numpy as np from numpy.typing import ArrayLike, NDArray from astropy.cosmology._src.typing import FArray from astropy.cosmology._s...
48
1,356
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_gelu.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # gelu paddle model generator # import numpy as np from save_model import saveModel import paddle import sys data_type = 'float32' def gelu(name:str, x, approximate=False): paddle.enable_static() with paddle.static.program_g...
45
1,264
biopython
Bio/SearchIO/_model/query.py
.py
# Copyright 2012 by Wibowo Arindrarto. All rights reserved. # This file is part of the Biopython distribution and governed by your # choice of the "Biopython License Agreement" or the "BSD 3-Clause License". # Please see the LICENSE file that should have been included as part of this # package. """Bio.SearchIO object ...
738
30,199
beam
sdks/python/apache_beam/io/aws/clients/s3/boto3_client.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...
305
9,687
ipython
tests/test_page.py
.py
# ----------------------------------------------------------------------------- # Copyright (C) 2010-2011 The IPython Development Team. # # Distributed under the terms of the BSD License. # # The full license is in the file COPYING.txt, distributed with this software. # ----------------------------------------------...
463
15,550
cvxpy
cvxpy/tests/test_openmp_conflict.py
.py
""" Copyright, 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, software ...
78
2,806
wandb
wandb/sync/__init__.py
.py
"""module sync.""" from .sync import TFEVENT_SUBSTRING, SyncManager, get_run_from_path, get_runs
4
98
confluent-kafka-python
tests/integration/share_consumer/test_share_consumer.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2026 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...
1,745
73,872
gunicorn
gunicorn/__init__.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. version_info = (26, 0, 0) __version__ = ".".join([str(v) for v in version_info]) SERVER = "gunicorn" SERVER_SOFTWARE = "%s/%s" % (SERVER, __version__)
9
257
django-cms
menus/menu_pool.py
.py
from functools import partial from logging import getLogger from django.contrib import messages from django.contrib.sites.models import Site from django.core.exceptions import ValidationError from django.urls import NoReverseMatch from django.utils.functional import cached_property from django.utils.module_loading imp...
397
15,575
probability
tensorflow_probability/python/experimental/linalg/linear_operator_unitary_test.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...
94
3,712
metrics
src/torchmetrics/wrappers/bootstrapping.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...
222
9,075
luigi
luigi/contrib/ftp.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...
431
13,140
wagtail
wagtail/contrib/settings/tests/generic/base.py
.py
from wagtail.coreutils import get_dummy_request from wagtail.models import Site from wagtail.test.testapp.models import TestGenericSetting from wagtail.test.utils import Page class GenericSettingsTestMixin: def setUp(self): root = Page.objects.first() other_root = Page(title="Other Root") ...
24
810
pyro
tests/contrib/timeseries/test_gp.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import math import pytest import torch import pyro from pyro.contrib.timeseries import ( DependentMaternGP, GenericLGSSM, GenericLGSSMWithGPNoiseModel, IndependentMaternGP, LinearlyCoupledMaternGP, ) from pyro...
172
5,986
hypercorn
tests/test_utils.py
.py
from __future__ import annotations from collections.abc import Callable, Iterable from typing import Any import pytest from hypercorn.typing import Scope from hypercorn.utils import ( build_and_validate_headers, filter_pseudo_headers, is_asgi, suppress_body, ) @pytest.mark.parametrize( "method,...
83
2,169
sphinx
tests/test_ext_napoleon/pep526_data_google.py
.py
"""Test module for napoleon PEP 526 compatibility with google style""" from __future__ import annotations module_level_var: int = 99 """This is an example module level variable""" class PEP526GoogleClass: """Sample class with PEP 526 annotations and google docstring. Attributes: attr1: Attr1 descri...
19
400
readthedocs.org
readthedocs/search/api/v3/utils.py
.py
from readthedocs.projects.models import Feature def should_use_advanced_query(projects): # TODO: we should make this a parameter in the API, # we are checking if the first project has this feature for now. if projects: project = projects[0][0] return not project.has_feature(Feature.DEFAULT...
11
354
pymc
tests/step_methods/test_metropolis.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...
428
15,998
onnxruntime
orttraining/orttraining/test/python/orttraining_test_utilities.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. from collections import abc import pytest import torch from onnxruntime.training.utils import extract_data_and_schema, unflatten_data_using_schema from onnxruntime.training.utils.torch_io_helper import _TensorStub @pytest...
292
11,260
beam
learning/tour-of-beam/learning-content/common-transforms/aggregation/mean/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...
52
1,724
readthedocs.org
readthedocs/settings/proxito/test.py
.py
from ..test import CommunityTestSettings from .base import CommunityProxitoSettingsMixin class CommunityProxitoTestSettings( CommunityProxitoSettingsMixin, CommunityTestSettings ): PUBLIC_DOMAIN = "dev.readthedocs.io" RTD_BUILD_MEDIA_STORAGE = "readthedocs.proxito.tests.storage.BuildMediaStorageTest" Co...
13
371
mkdocs
mkdocs/tests/localization_tests.py
.py
#!/usr/bin/env python import unittest from unittest import mock from mkdocs.config.base import ValidationError from mkdocs.localization import install_translations, parse_locale from mkdocs.tests.base import tempdir class LocalizationTests(unittest.TestCase): def setUp(self): self.env = mock.Mock() ...
75
2,645
gunicorn
tests/requests/invalid/003b.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. from gunicorn.http.errors import InvalidRequestMethod request = InvalidRequestMethod
6
190
mlflow
mlflow/genai/scorers/trulens/scorers/agent_trace.py
.py
""" Agent trace scorers for goal-plan-action alignment evaluation. These scorers analyze agent execution traces to detect internal errors and evaluate the quality of agent reasoning, planning, and tool usage. Based on TruLens' benchmarked goal-plan-action alignment evaluations which achieve 95% error coverage against...
277
7,729
returns
tests/test_pipeline/test_is_successful.py
.py
import pytest from returns.io import IOFailure, IOSuccess from returns.maybe import Nothing, Some from returns.pipeline import is_successful from returns.result import Failure, Success @pytest.mark.parametrize( ('container', 'correct_result'), [ (Success('a'), True), (Failure('a'), False), ...
24
635
openvino
tools/ovc/unit_tests/moc_tf_fe/test_models/model_with_convolution_dynamic_rank.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import tensorflow.compat.v1 as tf tf.reset_default_graph() with tf.Session() as sess: x = tf.placeholder(tf.float32, None, 'x') filter = tf.placeholder(tf.float32, [2, 2, 3, 1], 'kernel') conv2d = tf.raw_ops.Conv2D(input=x,...
19
616
gunicorn
tests/requests/valid/025.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. request = { "method": "POST", "uri": uri("/chunked"), "version": (1, 1), "headers": [ ('TRANSFER-ENCODING', 'gzip'), ('TRANSFER-ENCODING', 'chunked') ], "body": b"hello world...
15
324
sqlmap
tamper/space2mssqlhash.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.compat import xrange from lib.core.enums import PRIORITY __priority__ = PRIORITY.LOW def tamper(payload, **kwargs): """ Replaces space character (' ') with...
52
1,483
mlflow
examples/h2o/random_forest.py
.py
import h2o from h2o.estimators.random_forest import H2ORandomForestEstimator import mlflow import mlflow.h2o h2o.init() wine = h2o.import_file(path="wine-quality.csv") r = wine["quality"].runif() train = wine[r < 0.7] test = wine[0.3 <= r] def train_random_forest(ntrees): with mlflow.start_run(): rf = ...
33
841
returns
returns/contrib/mypy/_features/kind.py
.py
from collections.abc import Sequence from enum import StrEnum, unique from mypy.checkmember import analyze_member_access from mypy.plugin import ( AttributeContext, FunctionContext, MethodContext, MethodSigContext, ) from mypy.typeops import bind_self from mypy.types import ( AnyType, CallableT...
175
5,234
jupytext
tests/external/pre_commit/test_pre_commit_2_sync_nbstripout.py
.py
import pytest from git.exc import HookExecutionError from pre_commit.main import main as pre_commit from jupytext import read, write from jupytext.cli import jupytext def test_pre_commit_hook_sync_nbstripout( tmpdir, cwd_tmpdir, tmp_repo, jupytext_repo_root, jupytext_repo_rev, notebook_with_o...
65
1,665
readthedocs.org
readthedocs/invitations/signals.py
.py
"""Invitations related signals.""" import structlog from django.db.models.signals import pre_delete from django.dispatch import receiver from readthedocs.invitations.models import Invitation from readthedocs.organizations.models import Organization from readthedocs.organizations.models import Team from readthedocs.pr...
35
1,012
probability
tensorflow_probability/python/experimental/tangent_spaces/spaces_test_util.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...
123
5,014
pyomo
pyomo/solvers/wrappers.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...
14
634
beam
learning/katas/python/Streaming/Triggers/Early Triggers/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...
56
3,026
jupytext
tests/unit/test_stringparser.py
.py
from jupytext.stringparser import StringParser def test_long_string( text="""'''This is a multiline comment with "quotes", 'single quotes' # and comments and line breaks and it ends here''' 1 + 1 """, ): quoted = [] sp = StringParser("python") for i, line in enumerate(text.splitlines()): i...
80
1,412
pyro
tests/perf/conftest.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import pytest def pytest_collection_modifyitems(items): for item in items: if item.nodeid.startswith("tests/perf"): if "perf" not in item.keywords: item.add_marker(pytest.mark.stage("perf")...
14
430
mlflow
dev/clint/src/clint/rules/no_class_based_tests.py
.py
import ast from typing_extensions import Self from clint.rules.base import Rule class NoClassBasedTests(Rule): def __init__(self, class_name: str) -> None: self.class_name = class_name @classmethod def check(cls, node: ast.ClassDef, path_name: str) -> Self | None: # Only check in test f...
36
932
ipython
IPython/testing/plugin/setup.py
.py
#!/usr/bin/env python """A Nose plugin to support IPython doctests. """ from setuptools import setup setup(name='IPython doctest plugin', version='0.1', author='The IPython Team', description = 'Nose plugin to load IPython-extended doctests', license = 'LGPL', py_modules = ['ipdoctest'],...
19
539
metrics
tests/unittests/audio/test_srmr.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...
126
5,053
pyomo
pyomo/contrib/solver/tests/solvers/test_solvers.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...
2,519
104,493
luigi
luigi/contrib/batch.py
.py
# -*- coding: utf-8 -*- # # Copyright 2018 Outlier Bio, LLC # # 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 la...
205
7,790
textual
src/textual/css/_help_renderables.py
.py
from __future__ import annotations from typing import Iterable import rich.repr from rich.console import Console, ConsoleOptions, RenderResult from rich.highlighter import ReprHighlighter from rich.markup import render from rich.text import Text _highlighter = ReprHighlighter() def _markup_and_highlight(text: str)...
98
2,833
openvino
tests/layer_tests/pytorch_tests/test_polar.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 TestPolar(PytorchLayerTest): def _prepare_input(self, input_shape=(1, 1000), dtype=np.float32): return ( s...
39
1,319
saleor
saleor/graphql/utils/sorting.py
.py
from django.db.models import QuerySet from graphql.error import GraphQLError from ..channel.utils import get_default_channel_slug_or_graphql_error from ..core.enums import OrderDirection from ..core.types import SortInputObjectType from ..core.utils import from_global_id_or_error REVERSED_DIRECTION = { "-": "", ...
129
4,813
sphinx
utils/babel_runner.py
.py
"""Run babel for translations. Usage: babel_runner.py extract Extract messages from the source code and update the ".pot" template file. babel_runner.py update Update all language catalogues in "sphinx/locale/<language>/LC_MESSAGES" with the current messages in the template file. babel_runner.py compile...
301
9,471
hydra
tools/configen/configen/config.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from dataclasses import dataclass, field from typing import List, Optional from hydra.core.config_store import ConfigStore from hydra.utils import ConvertMode from omegaconf import MISSING @dataclass class Flags: _convert_: Optional[ConvertMo...
44
960
pdm
tests/fixtures/projects/demo-module/foo_module.py
.py
__version__ = "0.1.0" foo = "hello"
3
36
onnxruntime
orttraining/orttraining/python/training/optim/fp16_optimizer.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from ._modifier_registry import OptimizerModifierTypeRegistry, get_full...
92
3,870
saleor
saleor/graphql/decorators.py
.py
from collections.abc import Iterable from enum import Enum from functools import wraps from graphene import ResolveInfo from ..attribute import AttributeType from ..attribute.models import Attribute from ..core.exceptions import PermissionDenied from ..permission.auth_filters import is_app, is_staff_user from ..permi...
152
4,436