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
scikit-bio
skbio/tree/tests/test_majority_rule.py
.py
# ---------------------------------------------------------------------------- # Copyright (c) 2013--, scikit-bio development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file LICENSE.txt, distributed with this software. # --------------------------------------------...
198
7,394
pyro
examples/eight_schools/svi.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import argparse import logging import torch from data import J, sigma, y from torch.distributions import constraints, transforms import pyro import pyro.distributions as dist from pyro.infer import SVI, JitTrace_ELBO, Trace_ELBO ...
96
3,025
textual
src/textual/renderables/background_screen.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Iterable from rich.console import Console, ConsoleOptions, RenderResult from rich.segment import Segment from rich.style import Style from textual.color import Color if TYPE_CHECKING: from textual.screen import Screen class BackgroundScreen:...
99
2,975
returns
returns/pointfree/bind_future.py
.py
from collections.abc import Callable from typing import TypeVar from returns.future import Future from returns.interfaces.specific.future import FutureLikeN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_ThirdType...
65
1,834
probability
tensorflow_probability/python/bijectors/glow_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...
387
14,880
beam
sdks/python/apache_beam/examples/inference/tensorflow_imagenet_segmentation.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...
131
4,442
qutip
qutip/core/cy/openmp/bench_openmp.py
.py
import numpy as np from qutip.settings import settings as qset from timeit import default_timer as timer def _min_timer(function, *args, **kwargs): min_time = 1e6 for kk in range(10000): t0 = timer() function(*args, **kwargs) t1 = timer() min_time = min(min_time, t1-t0) ret...
155
4,640
wandb
tests/fixtures/mock_wandb_log.py
.py
from __future__ import annotations import re import textwrap import unittest.mock from collections.abc import Iterable import pytest @pytest.fixture def mock_wandb_log(monkeypatch: pytest.MonkeyPatch) -> MockWandbLog: """Mocks the wandb.term*() methods for a test. This patches the termlog() / termwarn() / ...
116
4,006
mlflow
mlflow/data/dataset_source.py
.py
import json from abc import abstractmethod from typing import Any class DatasetSource: """ Represents the source of a dataset used in MLflow Tracking, providing information such as cloud storage location, delta table name / version, etc. """ @staticmethod @abstractmethod def _get_source_t...
111
3,550
readthedocs.org
readthedocs/doc_builder/environments.py
.py
"""Documentation Builder Environments.""" import os import re import subprocess import sys import uuid from datetime import datetime import structlog from django.conf import settings from django.urls import reverse from django.utils.translation import gettext_lazy as _ from docker import APIClient from docker.errors ...
942
37,333
saleor
saleor/graphql/account/mutations/customer_type/customer_type_unassign_attributes.py
.py
import graphene from django.core.exceptions import ValidationError from .....permission.enums import CustomerTypePermissions from .....webhook.event_types import WebhookEventAsyncType from ....attribute.types import Attribute from ....core import ResolveInfo from ....core.descriptions import ADDED_IN_323 from ....core...
96
3,392
pyomo
pyomo/core/tests/unit/test_dict_objects.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...
394
14,141
gunicorn
tests/test_dirty_config.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Tests for dirty arbiter configuration settings.""" import pytest from gunicorn.config import Config class TestDirtyConfig: """Tests for dirty arbiter configuration settings.""" def test_dirty_apps_d...
144
4,653
pyomo
pyomo/contrib/preprocessing/util.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...
32
1,182
sphinx
tests/roots/test-ext-autosummary-filename-map/conf.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path.cwd().resolve())) extensions = ['sphinx.ext.autosummary'] autosummary_generate = True autosummary_filename_map = { 'autosummary_dummy_module': 'module_mangled', 'autosummary_dummy_module.bar': 'bar', }
12
276
saleor
saleor/core/tokens.py
.py
from django.conf import settings # nosemgrep: django-no-default-token-generator # _DjangoGenerator is used safely from django.contrib.auth.tokens import PasswordResetTokenGenerator as _DjangoGenerator from django.utils.module_loading import import_string from saleor.account.models import User _base_token_generator_c...
85
2,915
openvino
tests/e2e_tests/test_utils/coverage_runner.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 #!/usr/bin/env python3 """ Copyright (c) 2020 Intel Corporation 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...
91
3,530
readthedocs.org
readthedocs/rtd_tests/tests/projects/test_admin_actions.py
.py
from unittest import mock import django_dynamic_fixture as fixture from django import urls from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME from django.contrib.auth.models import User from django.test import TestCase from readthedocs.projects.models import Project class ProjectAdminActionsTest(TestCase...
78
2,628
probability
tensorflow_probability/python/experimental/tangent_spaces/spherical.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...
88
4,337
openvino
tests/layer_tests/tensorflow_tests/test_tf_BitwiseShift.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import platform import pytest import tensorflow as tf from common.tf_layer_test_class import CommonTFLayerTest rng = np.random.default_rng(21097) op_type_to_tf = { 'LeftShift': tf.raw_ops.RightShift, 'RightSh...
76
3,162
onnxruntime
onnxruntime/python/tools/transformers/onnx_model_bart.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging from fusion_attention import AttentionMask from fusion_b...
142
5,406
openvino
src/bindings/python/tests/test_transformations/test_graph_rewrite.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from openvino import opset8 from openvino.passes import Manager, GraphRewrite, MatcherPass, WrapType, Matcher from tests.test_transformations.utils.utils import count_ops, get_relu_model, PatternReplacement def ...
75
2,299
saleor
saleor/graphql/invoice/mutations/invoice_update.py
.py
import graphene from django.core.exceptions import ValidationError from ....core import JobStatus from ....invoice import models from ....invoice.error_codes import InvoiceErrorCode from ....order import events as order_events from ....permission.enums import OrderPermissions from ...app.dataloaders import get_app_pro...
123
4,448
readthedocs.org
readthedocs/doc_builder/tests/test_environments.py
.py
from django.test import TestCase from readthedocs.doc_builder.environments import DockerBuildCommand class TestDockerBuildEnvironment(TestCase): def test_command_escape(self): commands = [ ( ["ls", ".", "; touch /tmp/test"], "nice -n 10 /bin/sh -c 'ls . \\;\\ t...
33
1,144
probability
tensorflow_probability/python/experimental/bijectors/scalar_function_with_inferred_inverse.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...
489
20,745
pyomo
pyomo/util/diagnostics.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,317
sphinx
sphinx/writers/xml.py
.py
"""Docutils-native XML and pseudo-XML writers.""" from __future__ import annotations from typing import TYPE_CHECKING from docutils.writers import docutils_xml if TYPE_CHECKING: from typing import Any from docutils.writers.docutils_xml import XMLTranslator from sphinx.builders import Builder class X...
62
1,846
pyro
examples/contrib/forecast/bart.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import argparse import logging import numpy as np import torch import pyro import pyro.distributions as dist from pyro.contrib.examples.bart import load_bart_od from pyro.contrib.forecast import ForecastingModel, backtest from pyro.o...
182
7,530
astropy
astropy/io/fits/tests/test_connect.py
.py
import contextlib import gc import warnings from io import BytesIO from pathlib import Path import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal from astropy import units as u from astropy.io import fits from astropy.io.fits import ( BinTableHDU, HDUList, ImageHDU...
1,213
44,093
mlflow
examples/pyfunc/custom_code.py
.py
flower_classes = ["setosa", "versicolor", "virginica"] def iris_classes(preds): return [flower_classes[x] for x in preds]
6
128
sqlmap
tamper/base64encode.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.convert import encodeBase64 from lib.core.enums import PRIORITY __priority__ = PRIORITY.LOW def dependencies(): pass def tamper(payload, **kwargs): """ ...
25
509
saleor
saleor/graphql/tax/tests/queries/test_tax_country_configuration.py
.py
from typing import TYPE_CHECKING import graphene from saleor.tax.models import TaxClassCountryRate from ....tests.utils import assert_no_permission, get_graphql_content from ..fragments import TAX_COUNTRY_CONFIGURATION_FRAGMENT if TYPE_CHECKING: from django.db.models import QuerySet QUERY = ( """ quer...
85
2,335
scikit-bio
skbio/sequence/_protein.py
.py
# ---------------------------------------------------------------------------- # Copyright (c) 2013--, scikit-bio development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file LICENSE.txt, distributed with this software. # --------------------------------------------...
302
9,721
scikit-optimize
skopt/learning/gaussian_process/tests/test_gpr.py
.py
import numpy as np import pytest from scipy import optimize from numpy.testing import assert_almost_equal from numpy.testing import assert_array_almost_equal from numpy.testing import assert_array_equal from skopt.learning import GaussianProcessRegressor from skopt.learning.gaussian_process.kernels import RBF from s...
122
3,775
luigi
luigi/freezing.py
.py
"""Internal-only module with immutable data structures. Please, do not use it outside of Luigi codebase itself. """ from collections import OrderedDict try: from collections.abc import Mapping except ImportError: from collections import Mapping # type: ignore import functools import operator class FrozenO...
70
2,138
more-itertools
more_itertools/__init__.py
.py
"""More routines for operating on iterables, beyond itertools""" from .more import * # noqa from .recipes import * # noqa __version__ = '11.1.0'
7
149
wagtail
wagtail/contrib/redirects/urls.py
.py
from django.urls import path from wagtail.contrib.redirects import views app_name = "wagtailredirects" urlpatterns = [ path("", views.IndexView.as_view(), name="index"), path("results/", views.IndexView.as_view(results_only=True), name="index_results"), path("add/", views.CreateView.as_view(), name="add")...
15
613
metrics
src/torchmetrics/classification/precision_recall_curve.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...
704
35,413
beam
sdks/python/apache_beam/io/gcp/bigquery_schema_tools_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...
518
20,529
openvino
tools/ovc/openvino/tools/ovc/logger.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import importlib.util import logging as log import os import re from copy import copy # WA for abseil bug that affects logging while importing TF starting 1.14 version # Link to original issue: https://github.com/abseil/abseil-py/issues...
95
3,172
onnxruntime
orttraining/orttraining/test/python/orttraining_test_experimental_gradient_graph.py
.py
import os import unittest from pathlib import Path import numpy as np import onnx import torch import onnxruntime from onnxruntime.training.experimental import export_gradient_graph class NeuralNet(torch.nn.Module): r""" Simple example model. """ def __init__(self, input_size: int, embedding_size: ...
116
4,324
pyomo
pyomo/contrib/parmest/utils/model_utils.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...
245
9,682
django-cms
cms/tests/test_site.py
.py
import warnings from django.contrib.sites.models import Site from django.test import RequestFactory, override_settings from cms.api import create_page from cms.models import Page from cms.test_utils.testcases import CMSTestCase from cms.utils import get_current_site from cms.utils.admin import get_site_from_request f...
161
7,016
wagtail
wagtail/contrib/frontend_cache/backends/http.py
.py
import logging from urllib.error import HTTPError, URLError from urllib.parse import urlsplit, urlunsplit from urllib.request import Request, urlopen from wagtail import __version__ from .base import BaseBackend logger = logging.getLogger("wagtail.frontendcache") __all__ = ["PurgeRequest", "HTTPBackend"] class P...
65
1,836
gunicorn
tests/docker/__init__.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Docker-based integration tests package."""
6
152
jupytext
tests/functional/simple_notebooks/test_read_dotnet_try_markdown.py
.py
import jupytext from jupytext.cell_metadata import parse_key_equal_value from jupytext.compare import compare def test_parse_metadata(): assert parse_key_equal_value("--key value --key-2 .\\a\\b.cs") == { "incorrectly_encoded_metadata": "--key value --key-2 .\\a\\b.cs" } def test_parse_double_hyphen...
50
1,571
hypercorn
src/hypercorn/utils.py
.py
from __future__ import annotations import inspect import os import socket import sys from collections.abc import Awaitable, Callable, Iterable from enum import Enum from importlib import import_module from multiprocessing.synchronize import Event as EventType from pathlib import Path from typing import Any, cast, Lite...
209
6,444
pyro
pyro/ops/stats.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import math import numbers from typing import Callable, List, Optional, Tuple, Union import torch from torch.fft import irfft, rfft from .tensor_utils import next_fast_len def _compute_chain_variance_stats(input): # compute...
606
23,706
lemur
lemur/plugins/lemur_cryptography/tests/test_cryptography.py
.py
import arrow def test_build_certificate_authority(): from lemur.plugins.lemur_cryptography.plugin import build_certificate_authority options = { "key_type": "RSA2048", "country": "US", "state": "CA", "location": "Example place", "organization": "Example, Inc.", ...
66
2,124
sqlmap
plugins/dbms/presto/enumeration.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.data import logger from plugins.generic.enumeration import Enumeration as GenericEnumeration class Enumeration(GenericEnumeration): # NOTE: getBanner()/getCurre...
52
1,597
beam
sdks/python/apache_beam/examples/streaming_wordcount_debugging_it_test.py
.py
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not us...
129
4,614
bazel
tools/compliance/packages_used_test.py
.py
# Copyright 2023 The Bazel Authors. All rights reserved. # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law ...
59
1,787
pyomo
pyomo/contrib/doe/tests/test_doe_solve.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...
922
32,616
saleor
saleor/giftcard/models.py
.py
import os from django.conf import settings from django.contrib.postgres.indexes import BTreeIndex, GinIndex from django.contrib.postgres.search import SearchVectorField from django.core.validators import MinLengthValidator from django.db import models from django.db.models import JSONField, Q from django.utils import ...
175
5,755
mlflow
tests/server/test_handlers.py
.py
import json import urllib.parse import uuid from dataclasses import asdict from datetime import datetime, timezone from types import SimpleNamespace from unittest import mock import pytest from flask import Response, request from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan from werkzeug.exceptions ...
7,877
292,958
clearml
examples/frameworks/jsonargparse/pytorch_lightning_cli.py
.py
try: from lightning.pytorch.cli import LightningCLI from lightning.pytorch.demos.boring_classes import DemoModel, BoringDataModule except ImportError: import sys print("Module 'lightning' not installed (only available for Python 3.8+)") sys.exit(0) from clearml import Task if __name__ == "__main__...
15
497
conda
conda/models/channel.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Defines Channel and MultiChannel objects and other channel-related functions. Object inheritance: .. autoapi-inheritance-diagram:: Channel MultiChannel :top-classes: conda.models.channel.Channel :parts: 1 """ from __future__ import a...
754
24,874
sphinx
tests/test_util/test_util_display.py
.py
"""Tests util functions.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx._cli.util.errors import strip_escape_sequences from sphinx.util import logging from sphinx.util.display import ( SkipProgressMessage, display_chunk, progress_message, status_iter...
120
3,806
onnx
onnx/backend/test/case/node/dft.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 DFT(Base): @staticmethod def export_opset19() -> None: ...
153
5,913
sphinx
sphinx/ext/autodoc/preserve_defaults.py
.py
"""Preserve function defaults. Preserve the default argument values of function signatures in source code and keep them not evaluated for readability. """ from __future__ import annotations from typing import TYPE_CHECKING from sphinx.ext.autodoc._dynamic._preserve_defaults import ( DefaultValue, # NoQA: F401 ...
33
853
pyomo
pyomo/core/plugins/transform/nonnegative_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...
468
16,551
luigi
test/worker_parallel_scheduling_test.py
.py
# -*- coding: utf-8 -*- # # Copyright 2012-2015 Spotify AB # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law...
194
6,615
openvino
tests/layer_tests/pytorch_tests/test_derive_index_range_length.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 @pytest.mark.parametrize( "start, stop, step", [ [1, 32, 1], [1, 32, 2], [1, 32, 10], [1, 32, -...
58
1,740
httpie
httpie/output/ui/man_pages.py
.py
"""Logic for checking and displaying man pages.""" import subprocess import os from httpie.context import Environment MAN_COMMAND = 'man' NO_MAN_PAGES = os.getenv('HTTPIE_NO_MAN_PAGES', False) # On some systems, HTTP(n) might exist, but we are only interested in HTTP(1). # For more information on man page sections:...
49
1,305
ipython
tools/tests/embed/embed1.py
.py
"""This tests standard embedding, automatically detecting the module and local namespaces.""" f = set([1,2,3,4,5]) def bar(foo): import IPython IPython.embed(banner1='check f in globals, foo in locals') bar(f)
11
221
beam
sdks/python/apache_beam/io/filebasedio_perf_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...
190
6,766
wagtail
wagtail/contrib/redirects/tests/test_import_forms.py
.py
from django.test import TestCase from wagtail.contrib.redirects.forms import ConfirmImportForm, ImportForm class TestImportForm(TestCase): def test_file_input_generates_proper_accept(self): form = ImportForm(["csv", "tsv"]) self.assertIn('accept=".csv,.tsv"', form.as_table()) class TestConfirmI...
24
923
onnxruntime
onnxruntime/test/python/transformers/benchmark_onnx_attention_vs_gqa.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Benchmark ONNX Attention (opset 23/24, CUDA EP) against contrib Gro...
800
34,683
ipython
IPython/terminal/pt_inputhooks/osx.py
.py
"""Inputhook for OS X Calls NSApp / CoreFoundation APIs via ctypes. """ # obj-c boilerplate from appnope, used under BSD 2-clause import ctypes import ctypes.util objc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("objc")) # type: ignore void_p = ctypes.c_void_p objc.objc_getClass.restype = void_p objc.sel_...
147
4,420
coremltools
coremltools/optimize/torch/_typing.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 Any as _Any from typing import Callable as _Callable from typing import Dict as _D...
14
438
black
tests/data/cases/fmtonoff3.py
.py
# fmt: off x = [ 1, 2, 3, 4, ] # fmt: on # fmt: off x = [ 1, 2, 3, 4, ] # fmt: on x = [ 1, 2, 3, 4 ] # output # fmt: off x = [ 1, 2, 3, 4, ] # fmt: on # fmt: off x = [ 1, 2, 3, 4, ] # fmt: on x = [1, 2, 3, 4]
36
251
onnxruntime
tools/python/wgsl_template/test/test_build.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """End-to-end tests for the top-level build() orchestrator. Combines focused unit tests with a fixture-driven runner over the ``build-*`` cases in ``testcases/``. Generated files are compared against the ``expected/<generator...
262
9,843
mlflow
dev/clint/tests/rules/test_invalid_experimental_decorator.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.invalid_experimental_decorator import InvalidExperimentalDecorator def test_invalid_experimental_decorator(index: SymbolIndex) -> None: code = """ from...
57
1,659
astropy
astropy/io/fits/hdu/compressed/settings.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # Quantization dithering method constants; these are right out of fitsio.h NO_DITHER = -1 SUBTRACTIVE_DITHER_1 = 1 SUBTRACTIVE_DITHER_2 = 2 QUANTIZE_METHOD_NAMES = { NO_DITHER: "NO_DITHER", SUBTRACTIVE_DITHER_1: "SUBTRACTIVE_DITHER_1", SUBTRAC...
46
993
pyfilesystem2
fs/wrap.py
.py
"""Collection of useful `~fs.wrapfs.WrapFS` subclasses. Here's an example that opens a filesystem then makes it *read only*:: >>> home_fs = fs.open_fs('~') >>> read_only_home_fs = fs.wrap.read_only(home_fs) >>> read_only_home_fs.removedir('Desktop') Traceback (most recent call last): ... fs....
332
9,847
textual
tests/snapshot_tests/snapshot_apps/component_text_opacity.py
.py
from textual.app import App, ComposeResult from textual.scroll_view import ScrollView from textual.strip import Strip from rich.segment import Segment class LineWidget(ScrollView): COMPONENT_CLASSES = {"faded"} DEFAULT_CSS = """ LineWidget { background:blue; color:white; &>.faded{...
34
700
metrics
src/torchmetrics/clustering/__init__.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...
45
1,794
onnx
onnx/backend/test/case/node/prelu.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 PRelu(Base): @staticmethod def export() -> None: node ...
41
1,156
mlflow
mlflow/cli/genai_eval_utils.py
.py
""" Utility functions for trace evaluation output formatting. """ from dataclasses import dataclass from typing import Any import click import pandas as pd from mlflow.exceptions import MlflowException from mlflow.genai.scorers import Scorer, get_all_scorers, get_scorer from mlflow.tracing.constant import Assessment...
278
9,160
cvxpy
cvxpy/atoms/perspective.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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software...
151
5,085
beam
sdks/python/apache_beam/examples/wordcount_it_test.py
.py
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not us...
186
6,727
beam
sdks/python/apache_beam/ml/rag/ingestion/spanner_it_test.py
.py
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not us...
607
20,407
saleor
saleor/graphql/discount/mutations/promotion/promotion_create.py
.py
import datetime from collections import defaultdict import graphene from django.conf import settings from django.core.exceptions import ValidationError from django.db import transaction from django.db.models import Q from graphql.error import GraphQLError from .....channel import models as channel_models from .....di...
307
11,426
mlflow
tests/store/artifact/test_artifact_repo.py
.py
import logging import posixpath import time from unittest import mock import pytest from mlflow.entities import FileInfo from mlflow.exceptions import MlflowException from mlflow.store.artifact.artifact_repo import ( ArtifactRepository, _is_object_key_within_path, _sanitize_path_component_for_windows, ...
406
15,066
qutip
qutip/tests/core/data/test_dispatch.py
.py
import pytest import itertools import qutip from qutip.core.data.dispatch import Dispatcher, _constructed_specialisation import qutip.core.data as _data class pseudo_dipatched: def __init__(self, types, output): if output: self.output = types[-1] self.inputs = types[:-1] el...
218
6,802
beam
sdks/python/apache_beam/utils/proto_utils.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...
157
4,561
conda
conda/plugins/hookspec.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """ Pluggy hook specifications ("hookspecs") to register conda plugins. Each hookspec defined in :class:`~conda.plugins.hookspec.CondaSpecs` contains an example of how to use it. """ from __future__ import annotations from typing import TYPE...
935
30,223
hatch
tests/backend/builders/test_config.py
.py
import os import re from os.path import join as pjoin import pathspec import pytest from hatch.utils.structures import EnvVars from hatchling.builders.constants import BuildEnvVars from .utils import MockBuilder class TestDirectory: def test_default(self, isolation): builder = MockBuilder(str(isolation...
2,070
89,203
pyfilesystem2
fs/tempfs.py
.py
"""Manage filesystems in temporary locations. A temporary filesytem is stored in a location defined by your OS (``/tmp`` on linux). The contents are deleted when the filesystem is closed. A `TempFS` is a good way of preparing a directory structure in advance, that you can later copy. It can also be used as a temporar...
138
4,291
pyomo
examples/kernel/piecewise_nd_functions.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...
148
4,190
mlflow
tests/transformers/test_transformers_signature.py
.py
import json import time from unittest import mock import pytest from mlflow.models.signature import ModelSignature from mlflow.transformers import _try_import_conversational_pipeline from mlflow.transformers.signature import ( _TEXT2TEXT_SIGNATURE, format_input_example_for_special_cases, infer_or_get_defa...
199
7,509
saleor
saleor/app/actions.py
.py
import logging from django.utils import timezone from ..core.telemetry import get_task_context from ..core.utils.events import call_event from ..plugins.manager import PluginsManager from ..webhook.event_types import WebhookEventAsyncType from ..webhook.transport.asynchronous.transport import ( create_deliveries_...
76
2,518
mlflow
mlflow/utils/workspace_utils.py
.py
from __future__ import annotations from mlflow.environment_variables import MLFLOW_WORKSPACE, MLFLOW_WORKSPACE_STORE_URI _workspace_store_uri: str | None = None DEFAULT_WORKSPACE_NAME = "default" WORKSPACES_DIR_NAME = "workspaces" WORKSPACE_HEADER_NAME = "X-MLFLOW-WORKSPACE" def _normalize_workspace(workspace: str...
119
3,459
onnx
onnx/backend/test/case/node/tile.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 Tile(Base): @staticmethod def export_tile() -> None: n...
39
1,103
ipython
_build_meta.py
.py
# See https://setuptools.pypa.io/en/latest/build_meta.html#dynamic-build-dependencies-and-other-build-meta-tweaks from setuptools.build_meta import *
3
150
wandb
wandb/sdk/launch/inputs/schema.py
.py
META_SCHEMA = { "type": "object", "properties": { "type": { "type": "string", "enum": ["boolean", "integer", "number", "string", "object", "array"], }, "title": {"type": "string"}, "description": {"type": "string"}, "label": {"type": "string"}, ...
74
2,900
probability
tensorflow_probability/python/distributions/categorical.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...
522
19,730
biopython
Bio/Nexus/__init__.py
.py
# Copyright Frank Kauff and Cymon J. Cox 2005. 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. """The Bio.Ne...
9
388
openvino
src/frontends/tensorflow/tests/test_models/gen_scripts/generate_partitioned_call_with_unique.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os import sys import tensorflow.compat.v1 as tf def main(): tf.compat.v1.reset_default_graph() @tf.function def second_func(x): relu = tf.raw_ops.Relu(features=x) y, idx = tf.raw_ops.Unique(x=relu) ...
34
896
openvino
src/bindings/python/tests/test_runtime/test_async_infer_request.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from collections.abc import Iterable from copy import deepcopy import numpy as np import pytest import time import openvino.opset13 as ops from openvino import ( Core, InferRequest, AsyncInferQueue, ...
385
12,428