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
black
tests/data/cases/class_methods_new_line.py
.py
class ClassSimplest: pass class ClassWithSingleField: a = 1 class ClassWithJustTheDocstring: """Just a docstring.""" class ClassWithInit: def __init__(self): pass class ClassWithTheDocstringAndInit: """Just a docstring.""" def __init__(self): pass class ClassWithInitAndVars: ...
271
4,318
lemur
lemur/common/validators.py
.py
import re from cryptography import x509 from cryptography.exceptions import UnsupportedAlgorithm, InvalidSignature from cryptography.hazmat.backends import default_backend from cryptography.x509 import NameOID from flask import current_app from marshmallow.exceptions import ValidationError from lemur.auth.permissions...
219
7,814
sqlmap
lib/takeover/registry.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import os from lib.core.common import openFile from lib.core.common import randomStr from lib.core.data import conf from lib.core.data import logger from lib.core.enums import RE...
119
3,837
confluent-kafka-python
examples/protobuf_producer_encryption.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # 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 requi...
159
6,239
returns
returns/pointfree/compose_result.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.specific.ioresult import IOResultLikeN from returns.primitives.hkt import Kind3, Kinded, kinded from returns.result import Result _FirstType = TypeVar('_FirstType') _NewFirstType = TypeVar('_NewFirstType') _SecondType = TypeVar('_...
64
1,894
pyro
tests/ops/gaussian.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import torch import pyro.distributions as dist from pyro.ops.gaussian import Gaussian from tests.common import assert_close def random_gaussian(batch_shape, dim, rank=None, *, requires_grad=False): """ Generate a random ...
48
1,675
lemur
lemur/plugins/lemur_aws/tests/test_elb.py
.py
import boto3 from moto import mock_sts, mock_ec2, mock_elb, mock_elbv2, mock_iam @mock_sts() @mock_elb() def test_get_all_elbs(app, aws_credentials): from lemur.plugins.lemur_aws.elb import get_all_elbs client = boto3.client("elb", region_name="us-east-1") elbs = get_all_elbs(account_number="12345678901...
195
5,703
black
src/blib2to3/pgen2/literals.py
.py
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Safely evaluate Python string literals without using eval().""" import re simple_escapes: dict[str, str] = { "a": "\a", "b": "\b", "f": "\f", "n": "\n", "r": "\r", "t": "\t"...
66
1,580
textual
tests/test_reactive.py
.py
from __future__ import annotations import asyncio import pytest from textual.app import App, ComposeResult from textual.message import Message from textual.message_pump import MessagePump from textual.reactive import Initialize, Reactive, TooManyComputesError, reactive, var from textual.widget import Widget OLD_VAL...
843
25,252
beam
sdks/python/apache_beam/ml/rag/enrichment/__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...
21
912
hypercorn
src/hypercorn/typing.py
.py
from __future__ import annotations from collections.abc import Awaitable, Callable, Iterable from multiprocessing.synchronize import Event as EventType from types import TracebackType from typing import Any, Literal, NewType, Optional, Protocol, TypedDict import h2.events import h11 from .config import Config, Socke...
361
7,892
mlflow
tests/litellm/conftest.py
.py
import importlib import openai import pytest from tests.helper_functions import start_mock_openai_server @pytest.fixture(autouse=True) def set_envs(monkeypatch, mock_openai): monkeypatch.setenv("OPENAI_API_KEY", "test") monkeypatch.setenv("OPENAI_API_BASE", mock_openai) importlib.reload(openai) @pytes...
20
451
onnxruntime
onnxruntime/test/testdata/transform/fusion/constant_folding_with_shape_to_initializer.py
.py
import numpy as np import onnx from onnx import OperatorSetIdProto, TensorProto, helper, numpy_helper X = helper.make_tensor_value_info("input", TensorProto.FLOAT, [2, 4, 8]) Y = helper.make_tensor_value_info("output", TensorProto.FLOAT, [2, 4, 16]) matmul_weight_vals = (0.01 * np.arange(2 * 4 * 4, dtype=np.float32))...
111
4,383
beam
learning/tour-of-beam/learning-content/common-transforms/filter/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,715
metrics
tests/unittests/retrieval/test_mrr.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...
210
8,225
onnx
onnx/reference/ops/op_or.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 OpRunBinary class Or(OpRunBinary): def _run(self, x, y): return (np.logical_or(x, y),)
14
273
astropy
astropy/coordinates/tests/test_matching.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import numpy as np import pytest from numpy import testing as npt from astropy import units as u from astropy.coordinates import ( ICRS, Angle, CartesianRepresentation, Galactic, SkyCoord, match_coordinates_3d, match_coordinat...
457
15,761
mlflow
tests/data/test_spark_dataset.py
.py
import json import os from typing import TYPE_CHECKING, Any import pandas as pd import pytest from packaging.version import Version import mlflow.data from mlflow.data.code_dataset_source import CodeDatasetSource from mlflow.data.delta_dataset_source import DeltaDatasetSource from mlflow.data.evaluation_dataset impor...
433
15,116
omegaconf
tests/test_create.py
.py
"""Testing for OmegaConf""" import platform import re import sys from collections import OrderedDict from collections.abc import Sequence from dataclasses import dataclass from pathlib import Path from textwrap import dedent from typing import Any, Dict, List, Optional import attr import yaml from pytest import mark,...
784
22,816
openvino
tests/layer_tests/common/tflite_layer_test_class.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import tensorflow as tf from tensorflow.lite.tools import flatbuffer_utils as utils from common.layer_test_class import CommonLayerTest from common.utils.tflite_utils import get_tflite_r...
81
3,568
pymc
tests/gp/test_gp.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...
533
22,715
mlflow
tests/spark/autologging/datasource/test_spark_datasource_autologging_order.py
.py
import os import time import pytest from pyspark.sql import Row from pyspark.sql.types import IntegerType, StructField, StructType import mlflow import mlflow.spark from tests.spark.autologging.utils import ( _assert_spark_data_logged, _assert_spark_data_not_logged, _get_or_create_spark_session, ) @pyt...
49
1,481
wagtail
wagtail/locales/tests/test_v3_api.py
.py
import json from django.contrib.auth.models import Permission from django.test import TestCase from django.urls import reverse from wagtail.api.v3.tests.base import TestV3Base from wagtail.models import Locale from wagtail.test.utils import Page, WagtailTestUtils LOCALE_FIELDS = { "meta", "id", "language...
326
12,198
mkdocs-material
material/plugins/tags/structure/listing/tree/__init__.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...
166
5,088
conda
conda/cli/main_remove.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """CLI implementation for `conda remove`. Removes the specified packages from an existing environment. """ import logging from argparse import ArgumentParser, Namespace, _SubParsersAction from ..reporters import confirm_yn log = logging.getL...
262
8,689
qutip
qutip/qip.py
.py
"""Module replicating the qutip_qip package from within qutip.""" import sys try: import qutip_qip del qutip_qip sys.modules["qutip.qip"] = sys.modules["qutip_qip"] except ImportError: raise ImportError( "Importing 'qutip.qip' requires the 'qutip_qip' package. Install it " "with `pip in...
14
416
astropy
astropy/io/fits/hdu/streaming.py
.py
# Licensed under a 3-clause BSD style license - see PYFITS.rst import gzip import os from astropy.io.fits.file import _File from astropy.io.fits.header import _pad_length from astropy.io.fits.util import fileobj_name from .base import BITPIX2DTYPE, _BaseHDU from .hdulist import HDUList from .image import PrimaryHDU ...
223
7,586
pyomo
pyomo/common/gsl.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...
33
1,253
pyomo
examples/pyomobook/overview-ch/wl_excel.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...
33
1,173
dirty-equals
dirty_equals/__init__.py
.py
from ._base import AnyThing, DirtyEquals, IsOneOf from ._boolean import IsFalseLike, IsTrueLike from ._datetime import IsDate, IsDatetime, IsNow, IsToday from ._dict import IsDict, IsIgnoreDict, IsPartialDict, IsStrictDict from ._inspection import HasAttributes, HasName, HasRepr, IsInstance from ._numeric import ( ...
112
2,102
lemur
lemur/plugins/lemur_openssl/tests/test_openssl.py
.py
from unittest import mock import pytest from lemur.plugins.lemur_openssl.plugin import run_process, get_openssl_version from lemur.tests.vectors import INTERNAL_PRIVATE_KEY_A_STR, INTERNAL_CERTIFICATE_A_STR def test_export_certificate_to_pkcs12(app): from lemur.plugins.base import plugins p = plugins.get("...
37
1,292
saleor
saleor/graphql/warehouse/tests/queries/test_warehouses.py
.py
import graphene from .....warehouse.models import Warehouse from ....tests.utils import assert_no_permission, get_graphql_content QUERY_WAREHOUSES = """ query { warehouses(first:100) { totalCount edges { node { id name companyName ...
125
3,687
openvino
tests/layer_tests/pytorch_tests/test_complex.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest import torch from pytorch_layer_test_class import PytorchLayerTest class TestComplex(PytorchLayerTest): def _prepare_input(self): return (self.random.randn(2),) def create_model(self, dtype): cla...
78
2,615
saleor
saleor/graphql/discount/tests/benchmark/test_promotion_update.py
.py
import datetime import graphene import pytest from django.utils import timezone from ....tests.utils import get_graphql_content from ..mutations.test_promotion_update import PROMOTION_UPDATE_MUTATION @pytest.mark.django_db @pytest.mark.count_queries(autouse=False) def test_promotion_update( staff_api_client, ...
46
1,189
mlflow
mlflow/agno/__init__.py
.py
import inspect import logging from mlflow.telemetry.events import AutologgingEvent from mlflow.telemetry.track import _record_event from mlflow.utils.annotations import experimental as experimental from mlflow.utils.autologging_utils import autologging_integration, safe_patch FLAVOR_NAME = "agno" _logger = logging.ge...
113
4,117
openvino
tests/e2e_tests/test_utils/modify_configs.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from collections import OrderedDict from copy import deepcopy from e2e_tests.test_utils.reshape_tests_utils import get_mo_input_with_frozen_values, reorder_shapes_to_old_api, \ get_input_data from e2e_tests.test_utils.test_utils imp...
130
6,032
astropy
astropy/extern/ply/cpp.py
.py
# ----------------------------------------------------------------------------- # cpp.py # # Author: David Beazley (http://www.dabeaz.com) # Copyright (C) 2007 # All rights reserved # # This module implements an ANSI-C style lexical preprocessor for PLY. # --------------------------------------------------------------...
915
33,639
textual
tests/css/test_styles.py
.py
from decimal import Decimal import pytest from rich.style import Style from textual.color import Color from textual.css.errors import StyleValueError from textual.css.scalar import Scalar, Unit from textual.css.styles import RenderStyles, Styles from textual.dom import DOMNode from textual.widget import Widget def ...
206
6,201
astropy
astropy/stats/tests/test_jackknife.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import numpy as np import pytest from numpy.testing import assert_allclose, assert_equal from astropy.stats.jackknife import jackknife_resampling, jackknife_stats from astropy.utils.compat.optional_deps import HAS_SCIPY def test_jackknife_resampling():...
63
2,094
luigi
luigi/contrib/pig.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...
205
6,517
coremltools
coremltools/optimize/torch/quantization/quantizer.py
.py
# Copyright (c) 2024, 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 as _copy import logging as _logging from typing import Any as _Any from typing import Opt...
445
20,350
pdm
src/pdm/resolver/reporters.py
.py
from __future__ import annotations from collections.abc import Generator from contextlib import contextmanager from typing import TYPE_CHECKING, Any from resolvelib import BaseReporter from rich import get_console from rich.live import Live from rich.progress import BarColumn, Progress, SpinnerColumn, TaskProgressCol...
154
6,088
mlflow
mlflow/pytorch/pickle_module.py
.py
""" This module imports contents from CloudPickle in a way that is compatible with the ``pickle_module`` parameter of PyTorch's model persistence function: ``torch.save`` (see https://github.com/pytorch/pytorch/blob/692898fe379c9092f5e380797c32305145cd06e1/torch/ serialization.py#L192). It is included as a distinct mod...
36
1,994
onnxruntime
orttraining/orttraining/python/training/onnxblock/loss/loss.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import copy import onnx import onnxruntime.training.onnxblock._graph_utils as _graph_utils import onnxruntime.training.onnxblock.blocks as blocks class MSELoss(blocks.Block): """MSELoss onnxblock for adding MSE loss t...
257
10,543
wagtail
wagtail/admin/tests/test_checks.py
.py
from django.core.checks import Error from django.test import TestCase, override_settings from django.utils.formats import reset_format_cache from wagtail.admin.checks import datetime_format_check from wagtail.test.utils import PageFixturesMixin, WagtailTestUtils class TestDateTimeChecks(PageFixturesMixin, WagtailTes...
143
4,584
ipython
IPython/utils/tokenutil.py
.py
"""Token-related utilities""" # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. from __future__ import annotations import itertools import tokenize from io import StringIO from keyword import iskeyword from tokenize import TokenInfo from typing import NamedTuple from...
211
7,029
httpie
tests/test_windows.py
.py
import pytest from httpie.context import Environment from .utils import MockEnvironment, http from httpie.compat import is_windows @pytest.mark.skipif(not is_windows, reason='windows-only') class TestWindowsOnly: @pytest.mark.skipif(True, reason='this test for some reason kills the proce...
26
948
coveragepy
tests/testenv.py
.py
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt """Environment settings affecting tests.""" from __future__ import annotations import os from coverage import env # What core are we using, either requested o...
48
1,285
openvino
tests/layer_tests/tensorflow_tests/test_tf_OnesLike.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest import tensorflow as tf from common.tf_layer_test_class import CommonTFLayerTest class TestOnesLike(CommonTFLayerTest): def _prepare_input(self, inputs_info): assert 'x:0' in inputs_info ...
87
3,366
gunicorn
gunicorn/workers/gthread.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. # design: # A threaded worker accepts connections in the main loop, accepted # connections are added to the thread pool as a connection job. # Keepalive connections are put back in the loop waiting for an event. # ...
714
26,573
mlflow
tests/pyfunc/sample_code/code_with_dependencies.py
.py
import os import mlflow from mlflow.models import set_model, set_retriever_schema from mlflow.pyfunc import PythonModel test_trace = os.environ.get("TEST_TRACE", "true").lower() == "true" class MyModel(PythonModel): def _call_retriever(self, id): return f"Retriever called with ID: {id}. Output: 42." ...
42
1,241
jupytext
tests/functional/docs/test_doc_files_are_notebooks.py
.py
from pathlib import Path import pytest from jupytext import read def documentation_files(): for path in (Path(__file__).parent / "../../../docs").iterdir(): if path.suffix == ".md": yield path @pytest.mark.parametrize( "doc_file", documentation_files(), ids=[doc_file.stem for d...
28
601
textual
docs/examples/how-to/layout01.py
.py
from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Placeholder class Header(Placeholder): # (1)! pass class Footer(Placeholder): # (2)! pass class TweetScreen(Screen): def compose(self) -> ComposeResult: yield Header(id="Header") # (3)! ...
28
523
pyomo
pyomo/contrib/incidence_analysis/__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...
37
1,480
mlflow
tests/resources/example_mlflow_2.12_langchain_model/lc_model.py
.py
from typing import Any from langchain.prompts import ChatPromptTemplate from langchain.schema.output_parser import StrOutputParser from langchain.schema.runnable import RunnablePassthrough from langchain.text_splitter import CharacterTextSplitter from langchain_community.chat_models import ChatDatabricks, ChatMlflow f...
77
2,483
wagtail
wagtail/admin/tests/test_buttons_hooks.py
.py
from django.contrib.auth.models import AbstractBaseUser, Group from django.test import SimpleTestCase, TestCase from django.urls import reverse from django.utils.http import urlencode from wagtail import hooks from wagtail.admin import widgets as wagtailadmin_widgets from wagtail.admin.wagtail_hooks import page_header...
512
19,434
textual
src/textual/css/types.py
.py
from __future__ import annotations from typing import Tuple from typing_extensions import Literal from textual.color import Color DockEdge = Literal["none", "top", "right", "bottom", "left"] EdgeType = Literal[ "", "ascii", "none", "hidden", "blank", "round", "solid", "thick", "b...
93
2,164
black
tests/data/cases/multiline_consecutive_open_parentheses_ignore.py
.py
# This is a regression test. Issue #3737 a = ( # type: ignore int( # type: ignore int( # type: ignore int( # type: ignore 6 ) ) ) ) b = ( int( 6 ) ) print( "111") # type: ignore print( "111" ) # type: igno...
41
644
mlflow
mlflow/openai/genai_semconv_converter.py
.py
""" OpenAI-format message converters for GenAI Semantic Convention export. Two converters handle the two OpenAI API shapes: - OpenAIChatCompletionConverter: Chat Completions API (also used by Groq, Bedrock) - OpenAIResponsesConverter: Responses API """ import json from typing import Any from mlflow.tracing.constant ...
268
10,341
sqlmap
lib/utils/sqlalchemy.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import importlib import logging import os import re import sys import traceback import warnings _path = list(sys.path) _sqlalchemy = None try: sys.path = sys.path[1:] mod...
169
7,741
wagtail
wagtail/tests/test_lockable_model.py
.py
from django.apps import apps from django.core import checks from django.db import models from django.test import TestCase from wagtail.models import LockableMixin, RevisionMixin class TestLockableMixin(TestCase): def tearDown(self): # Unregister the models from the overall model registry # so tha...
55
1,880
textual
tests/snapshot_tests/snapshot_apps/table_markup.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static from rich.table import Table class TableStaticApp(App): def compose(self) -> ComposeResult: table = Table("[i green]Foo", "Bar", "baz") table.add_row("Hello [bold magenta]World!", "[i]Italic", "[u]Underline") yi...
17
408
conda
conda/plugins/package_extractors/conda.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Package extractor plugin for .conda and .tar.bz2 formats.""" from __future__ import annotations import os from logging import getLogger from os.path import join from typing import TYPE_CHECKING from ..._private.extract import extract_cond...
81
2,720
onnx
onnx/backend/test/case/node/reducemin.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np import onnx from onnx.backend.test.case.base import Base from onnx.backend.test.case.node import expect class ReduceMin(Base): @staticmethod def export_do_not_keepdims() ->...
235
6,763
wagtail
wagtail/admin/tests/test_audit_log.py
.py
from datetime import timedelta from http import HTTPStatus from io import StringIO from django.conf import settings from django.contrib.auth.models import Group, Permission from django.core.management import call_command from django.test import TestCase from django.urls import reverse from django.utils import timezone...
675
25,738
pyomo
pyomo/contrib/appsi/examples/tests/test_examples.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...
27
1,193
mlflow
mlflow/store/workspace/utils.py
.py
from __future__ import annotations import logging from mlflow.entities import Workspace from mlflow.protos import databricks_pb2 _INVALID_PARAMETER_VALUE_CODE = databricks_pb2.INVALID_PARAMETER_VALUE _INVALID_PARAMETER_VALUE_NAME = databricks_pb2.ErrorCode.Name(_INVALID_PARAMETER_VALUE_CODE) _logger = logging.getL...
44
1,340
qutip
qutip/tests/solver/test_countstat.py
.py
import numpy as np import qutip import pytest def test_dqd_current(): "Counting statistics: current and current noise in a DQD model" G = 0 L = 1 R = 2 sz = qutip.projection(3, L, L) - qutip.projection(3, R, R) sx = qutip.projection(3, L, R) + qutip.projection(3, R, L) sR = qutip.project...
138
4,512
sphinx
tests/roots/test-ext-autodoc/target/overload.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, overload if TYPE_CHECKING: from typing import Any @overload def sum(x: int, y: int = 0) -> int: ... @overload def sum(x: float, y: float = 0.0) -> float: ... @overload def sum(x: str, y: str = ...) -> str: ... def sum(x, y=None): """...
82
1,320
coremltools
coremltools/converters/mil/mil/passes/defs/optimize_state.py
.py
# Copyright (c) 2024, 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 typing import List from coremltools.converters.mil.mil import Block from coremltools.converter...
210
7,558
onnx
onnx/backend/test/runner/item.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import dataclasses from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from collections.abc import Callable from onnx import ModelProto, NodeProto # A container that hosts the test functi...
22
484
probability
tensorflow_probability/python/experimental/bijectors/sharded.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...
81
2,856
metrics
src/torchmetrics/functional/text/bleu.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...
211
7,598
cvxpy
cvxpy/reductions/dcp2cone/cone_matrix_stuffing.py
.py
""" Copyright 2013 Steven Diamond 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...
510
20,416
mlflow
mlflow/tracing/otel/translation/traceloop.py
.py
""" Translation utilities for Traceloop/OpenLLMetry semantic conventions. Reference: https://github.com/traceloop/openllmetry/ """ import re from typing import Any from mlflow.entities.span import SpanType from mlflow.tracing.otel.translation.base import OtelSchemaTranslator class TraceloopTranslator(OtelSchemaTra...
83
3,733
biopython
Bio/ExPASy/cellosaurus.py
.py
# Copyright 2016 by Stephen Marshall. All rights reserved. # This code is part of the Biopython distribution and governed by its # license. Please see the LICENSE file that should have been included # as part of this package. """Parser for the cellosaurus.txt file from ExPASy. See https://web.expasy.org/cellosaurus...
209
6,670
sphinx
sphinx/util/docfields.py
.py
"""Utility code for "Doc fields". "Doc fields" are reST field lists in object descriptions that will be domain-specifically transformed to a more appealing presentation. """ from __future__ import annotations import contextlib from typing import TYPE_CHECKING, cast from docutils import nodes from sphinx import add...
511
18,273
black
tests/data/miscellaneous/debug_visitor.py
.py
@dataclass class DebugVisitor(Visitor[T]): tree_depth: int = 0 def visit_default(self, node: LN) -> Iterator[T]: indent = ' ' * (2 * self.tree_depth) if isinstance(node, Node): _type = type_repr(node.type) out(f'{indent}{_type}', fg='yellow') self.tree_depth ...
33
1,193
confluent-kafka-python
tests/integration/consumer/test_consumer_error.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2020 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...
117
4,401
pyro
examples/air/viz.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import math from collections import namedtuple import numpy as np from PIL import Image, ImageDraw def bounding_box(z_where, x_size): """This doesn't take into account interpolation, but it's close enough to be usable.""...
77
2,528
coveragepy
lab/branches.py
.py
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt # Demonstrate some issues with coverage.py branch testing. def my_function(x): """This isn't real code, just snippets...""" # An infinite loop is struc...
83
2,703
metrics
tests/unittests/image/test_mifid.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...
225
9,167
jupytext
tests/unit/data/landing_page/notebook_marimo.py
.py
import marimo __generated_with = "0.19.4" app = marimo.App() @app.cell(hide_code=True) def _(mo): mo.md(r""" # Quarterly Sales A look at Q4 revenue by region. """) return @app.cell def _(): import pandas as pd df = pd.read_csv("sales.csv") return (df,) @app.cell def _(df): df....
36
481
saleor
saleor/discount/utils/shared.py
.py
from collections import defaultdict from decimal import Decimal from typing import TYPE_CHECKING, Optional, Union import graphene from ...graphql.core.utils import to_global_id_or_none from .. import DiscountType from ..models import ( CheckoutDiscount, CheckoutLineDiscount, OrderDiscount, OrderLineDi...
134
4,957
python-prompt-toolkit
examples/full-screen/dummy-app.py
.py
#!/usr/bin/env python """ This is the most simple example possible. """ from prompt_toolkit import Application app = Application(full_screen=False) app.run()
10
160
metrics
src/torchmetrics/retrieval/hit_rate.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...
162
6,538
kombu
kombu/__init__.py
.py
"""Messaging library for Python.""" from __future__ import annotations import os import re import sys from collections import namedtuple from typing import Any, cast __version__ = '5.6.2' __author__ = 'Ask Solem' __contact__ = 'auvipy@gmail.com' __homepage__ = 'https://kombu.readthedocs.io' __docformat__ = 'restruct...
116
3,899
onnxruntime
orttraining/orttraining/python/training/ortmodule/experimental/pipe/__init__.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from ._ort_pipeline_module import ORTPipelineModule # noqa: F401
7
314
coremltools
deps/protobuf/python/protobuf_distutils/protobuf_distutils/generate_py_protobufs.py
.py
# Protocol Buffers - Google's data interchange format # Copyright 2008 Google Inc. All rights reserved. # https://developers.google.com/protocol-buffers/ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redi...
148
6,466
beam
sdks/python/apache_beam/pvalue_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...
72
2,319
conda
tests/gateways/test_connection.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from __future__ import annotations import hashlib from contextlib import nullcontext from importlib.util import find_spec from logging import getLogger from pathlib import Path from typing import TYPE_CHECKING import pytest from requests impor...
746
25,401
pyomo
pyomo/core/tests/transform/test_transform.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...
768
29,463
saleor
saleor/graphql/payment/tests/test_utils.py
.py
import pytest from django.core.exceptions import ValidationError from ....page.models import PageType from ....payment.error_codes import ( TransactionRequestActionErrorCode, TransactionRequestRefundForGrantedRefundErrorCode, ) from ..utils import validate_reason_reference_context def test_no_reference_type_...
193
6,563
saleor
saleor/graphql/attribute/tests/mutations/test_attribute_bulk_update.py
.py
from unittest.mock import patch import graphene from .....attribute.error_codes import AttributeBulkUpdateErrorCode from .....attribute.models import Attribute from .....attribute.tests.model_helpers import ( get_product_attribute_values, get_product_attributes, ) from ....core.enums import ErrorPolicyEnum fr...
1,273
38,840
onnx
onnx/backend/test/case/node/greater_equal.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np import onnx from onnx.backend.test.case.base import Base from onnx.backend.test.case.node import expect class Greater(Base): @staticmethod def export() -> None: nod...
69
2,574
pyomo
examples/pyomobook/pyomo-components-ch/obj_declaration.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...
84
1,812
mlflow
dev/clint/src/clint/rules/forbidden_set_active_model_usage.py
.py
import ast from clint.resolver import Resolver from clint.rules.base import Rule class ForbiddenSetActiveModelUsage(Rule): def _message(self) -> str: return ( "Usage of `set_active_model` is not allowed in mlflow, use `_set_active_model` instead." ) @staticmethod def check(no...
23
667
onnxruntime
orttraining/orttraining/test/python/orttraining_test_model_transform.py
.py
from onnx import numpy_helper def add_name(model): for i, node in enumerate(model.graph.node): node.name = f"{node.op_type}_{i}" def find_single_output_node(model, arg): result = [] for node in model.graph.node: for input in node.input: if input == arg: result...
113
3,857
metrics
src/torchmetrics/text/bert.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...
367
16,684
metrics
tests/unittests/image/test_vif.py
.py
# Copyright The PyTorch 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 i...
81
2,920