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
openvino
tests/e2e_tests/test_utils/tf_helper.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # pylint: disable=no-member """ The module contains helper class for working with TensorFlow version dependencies """ import os import logging as log from distutils.version import LooseVersion import yaml class TFVersionHelper: "...
90
3,487
textual
docs/examples/widgets/data_table_labels.py
.py
from rich.text import Text from textual.app import App, ComposeResult from textual.widgets import DataTable ROWS = [ ("lane", "swimmer", "country", "time"), (4, "Joseph Schooling", "Singapore", 50.39), (2, "Michael Phelps", "United States", 51.14), (5, "Chad le Clos", "South Africa", 51.14), (6, "...
35
1,005
wandb
wandb/apis/_generated/get_sweep_agent.py
.py
# Generated by ariadne-codegen # Source: tools/graphql_codegen/api/ from __future__ import annotations from wandb._pydantic import GQLResult from .fragments import AgentFragment class GetSweepAgent(GQLResult): project: GetSweepAgentProject | None class GetSweepAgentProject(GQLResult): sweep: GetSweepAgen...
26
530
onnxruntime
onnxruntime/test/python/quantization/test_op_split.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import un...
159
5,916
hydra
tools/landscape/test_analyze_hydra_projects.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import json import subprocess import threading from pathlib import Path from types import SimpleNamespace from typing import Any import analyze_hydra_projects as analyzer import pytest def row(**overrides: object) -> dict[str, object]: value...
545
18,109
ipython
IPython/core/displaypub.py
.py
"""An interface for publishing rich data to frontends. There are two components of the display system: * Display formatters, which take a Python object and compute the representation of the object in various formats (text, HTML, SVG, etc.). * The display publisher that is used to send the representation data to the...
205
6,841
pyomo
pyomo/solvers/tests/models/LP_unique_duals.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...
98
2,610
gunicorn
gunicorn/asgi/uwsgi.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Async uWSGI protocol parser for ASGI workers. Reuses the parsing logic from gunicorn/uwsgi/message.py, only async I/O differs. """ from gunicorn.uwsgi.message import UWSGIRequest from gunicorn.uwsgi.errors imp...
173
5,523
onnx
tools/pixi-shim.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 """Wrapper that runs a command via pixi if available, otherwise directly. Usage: python tools/pixi-shim.py <command> [args...] This allows non-pixi users to run pre-commit hooks by having the required tools (ruff, mypy, clang-format, s...
33
868
saleor
saleor/page/lock_objects.py
.py
from django.db.models import QuerySet from .models import Page def page_qs_select_for_update() -> QuerySet[Page]: return Page.objects.order_by("pk").select_for_update(of=["self"])
8
187
metrics
tests/unittests/nominal/test_theils_u.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...
163
6,169
textual
docs/blog/snippets/2022-12-07-responsive-app-background-task/blocking01.py
.py
import time from random import randint from textual.app import App, ComposeResult from textual.color import Color from textual.containers import Grid, VerticalScroll from textual.widget import Widget from textual.widgets import Footer, Label class ColourChanger(Widget): # (1)! def on_click(self) -> None: ...
41
904
python-prompt-toolkit
src/prompt_toolkit/contrib/telnet/protocol.py
.py
""" Parser for the Telnet protocol. (Not a complete implementation of the telnet specification, but sufficient for a command line interface.) Inspired by `Twisted.conch.telnet`. """ from __future__ import annotations import struct from collections.abc import Callable, Generator from .log import logger __all__ = [ ...
210
5,611
textual
tests/test_static.py
.py
from textual.content import Content from textual.widgets import Static async def test_content_property(): static = Static() assert static.content == "" static.content = "Foo" assert static.content == "Foo" assert isinstance(static.content, str) assert static.visual == "Foo" assert isinstan...
19
537
sqlmap
thirdparty/wininetpton/__init__.py
.py
#!/usr/bin/env python # # Copyright Ryan Vennell # # This software released into the public domain. Anyone is free to copy, # modify, publish, use, compile, sell, or distribute this software, # either in source code form or as a compiled binary, for any purpose, # commercial or non-commercial, and by any means. pass
11
319
sphinx
sphinx/domains/c/_ids.py
.py
from __future__ import annotations import re from typing import TYPE_CHECKING if TYPE_CHECKING: from collections.abc import Sequence, Set # https://en.cppreference.com/w/c/keyword _keywords: Set[str] = frozenset({ 'auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do', 'double', ...
124
2,614
qutip
qutip/_mkl/spsolve.py
.py
import sys import numpy as np import scipy.sparse as sp from ctypes import c_int, byref from numpy.ctypeslib import ndpointer import time from qutip.settings import settings as qset # Load solver functions from mkl_lib pardiso = qset.mkl_lib.pardiso pardiso_delete = qset.mkl_lib.pardiso_handle_delete if sys.maxsize > ...
407
12,901
scikit-bio
skbio/diversity/alpha/tests/test_chao1.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. # --------------------------------------------...
83
2,937
hydra
tests/test_apps/app_with_unicode_in_config/my_app.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import sys from omegaconf import DictConfig, OmegaConf import hydra @hydra.main(config_path=".", config_name="config") def my_app(cfg: DictConfig) -> None: sys.stdout.reconfigure(encoding="utf-8") # type: ignore print(OmegaConf.to_yaml(...
17
368
pyro
tests/distributions/test_categorical.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 from unittest import TestCase import numpy as np import pytest import scipy.stats as sp import torch import pyro.distributions as dist from tests.common import assert_equal class TestCategorical(TestCase): """ Tests met...
117
3,591
openvino
thirdparty/itt_collector/runtool/sea_runtool.py
.py
# Intel® Single Event API # # This file is provided under the BSD 3-Clause license. # Copyright (c) 2021, Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: # Redistri...
2,149
86,325
mlflow
mlflow/transformers/model_io.py
.py
from __future__ import annotations import logging import pathlib import shutil from typing import TYPE_CHECKING, Any from mlflow.environment_variables import ( MLFLOW_HUGGINGFACE_DISABLE_ACCELERATE_FEATURES, MLFLOW_HUGGINGFACE_MODEL_MAX_SHARD_SIZE, ) from mlflow.exceptions import MlflowException from mlflow.p...
367
14,413
beam
sdks/python/apache_beam/io/localfilesystem.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...
372
11,306
saleor
saleor/graphql/product/tests/mutations/test_category_delete.py
.py
import json from unittest.mock import MagicMock, patch import graphene import pytest from django.core.files import File from django.utils.functional import SimpleLazyObject from freezegun import freeze_time from .....attribute.models import AttributeValue from .....attribute.utils import associate_attribute_values_to...
340
11,155
biopython
Scripts/update_ncbi_codon_table.py
.py
# This code is part of the Biopython distribution and governed by its # license. Please see the LICENSE file that should have been included # as part of this package. """Helper script to update Codon tables from the NCBI. These tables are based on parsing the NCBI file: ftp://ftp.ncbi.nih.gov/entrez/misc/data/gc.prt ...
128
4,691
saleor
saleor/app/tests/test_app_actions.py
.py
import json from unittest.mock import Mock, patch import graphene from ...core.models import EventDelivery, EventPayload from ...webhook.event_types import WebhookEventAsyncType from ...webhook.models import Webhook from ..actions import delete_app from ..models import App def test_delete_app_soft_deletes_and_calls...
116
3,531
mlflow
tests/metrics/genai/test_prompt_template.py
.py
from mlflow.metrics.genai.prompt_template import PromptTemplate def test_prompt_template_flat_str_no_variables(): prompt = PromptTemplate(template_str="Say {foo}") assert prompt.format(foo="bar") == "Say bar" prompt = PromptTemplate(template_str="Say {foo} {baz}") assert prompt.format(foo="bar") == "...
58
2,228
bazel
tools/ctexplain/ctexplain_types.py
.py
# Copyright 2020 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
88
3,447
openvino
src/frontends/paddle/tests/paddle_pip_check.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import re import sys import os from importlib.metadata import PackageNotFoundError, version as _installed_version from packaging.requirements import Requirement req_file=sys.argv[1] constraints = {} constraints_path = [] requirements ...
79
2,972
bazel
third_party/py/abseil/setup.py
.py
# Copyright 2017 The Abseil 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 ...
75
2,533
saleor
saleor/graphql/account/mutations/staff/customer_create.py
.py
from urllib.parse import urlencode from django.core.exceptions import ValidationError from django.db import IntegrityError, transaction from .....account import events as account_events from .....account import models from .....account.notifications import send_set_password_notification from .....account.search impor...
183
7,153
attrs
tests/test_setattr.py
.py
# SPDX-License-Identifier: MIT import pickle import pytest import attr from attr import setters from attr.exceptions import FrozenAttributeError from attr.validators import instance_of, matches_re @attr.s(frozen=True) class Frozen: x = attr.ib() @attr.s class WithOnSetAttrHook: x = attr.ib(on_setattr=l...
648
16,349
pdm
src/pdm/resolver/python.py
.py
""" Special requirement and candidate classes to describe a requires-python constraint """ from __future__ import annotations from collections.abc import Iterable, Iterator, Mapping from typing import cast from pdm.models.candidates import Candidate from pdm.models.requirements import NamedRequirement, Requirement f...
48
1,605
pyro
pyro/contrib/oed/eig.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import math import warnings import torch import pyro from pyro import poutine from pyro.contrib.oed.search import Search from pyro.contrib.util import lexpand from pyro.infer import SVI, EmpiricalMarginal, Importance from pyro.in...
1,200
44,795
python-prompt-toolkit
src/prompt_toolkit/keys.py
.py
from __future__ import annotations from enum import Enum __all__ = [ "Keys", "ALL_KEYS", ] class Keys(str, Enum): """ List of keys for use in key bindings. Note that this is an "StrEnum", all values can be compared against strings. """ value: str Escape = "escape" # Also Cont...
223
4,916
pdm
tests/cli/test_run.py
.py
import json import os import signal import subprocess import sys import textwrap from pathlib import Path from tempfile import TemporaryDirectory import pytest from pdm import termui from pdm.cli import actions from pdm.cli.utils import get_pep582_path from pdm.utils import cd @pytest.fixture def _args(project): ...
1,331
48,436
pyfilesystem2
fs/tarfs.py
.py
"""Manage the filesystem in a Tar archive. """ from __future__ import print_function, unicode_literals import typing from typing import IO, cast import os import six import tarfile from collections import OrderedDict from . import errors from ._url_tools import url_quote from .base import FS from .compress import w...
494
15,498
jupyterlab
galata/test/jupyterlab/notebooks/code_script.py
.py
a = 1 b = 2 c = a + b print(c == (a + b))
5
42
kombu
kombu/pidbox.py
.py
"""Generic process mailbox.""" from __future__ import annotations import socket import warnings from collections import defaultdict, deque from contextlib import contextmanager from copy import copy from itertools import count from time import time from . import Consumer, Exchange, Producer, Queue from .clocks impor...
433
15,698
confluent-kafka-python
tests/integration/producer/test_transactions.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...
222
6,721
saleor
saleor/graphql/page/tests/mutations/test_page_delete.py
.py
from functools import partial from unittest import mock from unittest.mock import ANY import graphene import pytest from django.utils.functional import SimpleLazyObject from .....attribute.models import AttributeValue from .....attribute.utils import associate_attribute_values_to_instance from .....product.search imp...
322
9,971
saleor
saleor/graphql/query_cost_map.py
.py
"""Costs map used by query complexity validator. It's three levels deep dict of dicts: - Type - Fields - Complexity To set complexity cost for querying a field "likes" on type "User": { "User": { "likes": {"complexity": 2} } } Querying above field will not increase query complexity by 1. If field'...
455
16,735
black
tests/data/cases/generics_wrapping.py
.py
# flags: --minimum-version=3.12 def plain[T, B](a: T, b: T) -> T: return a def arg_magic[T, B](a: T, b: T,) -> T: return a def type_param_magic[T, B,](a: T, b: T) -> T: return a def both_magic[T, B,](a: T, b: T,) -> T: return a def plain_multiline[ T, B ]( a: T, b: T ) -> T: ret...
308
3,888
beam
sdks/python/apache_beam/tools/coders_microbenchmark.py
.py
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use ...
354
11,452
probability
tensorflow_probability/python/glm/family.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...
546
19,861
biopython
Bio/SearchIO/_model/hsp.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 objects...
1,226
48,206
django-cms
cms/test_utils/project/cms_urls_for_apphook_tests.py
.py
from django.conf import settings from django.urls import re_path from cms.apphook_pool import apphook_pool from cms.views import details if settings.APPEND_SLASH: reg = re_path(r'^(?P<slug>[0-9A-Za-z-_.//]+)/$', details, name='pages-details-by-slug') else: reg = re_path(r'^(?P<slug>[0-9A-Za-z-_.//]+)$', detai...
24
715
ipython
tests/test_tokenutil.py
.py
"""Tests for tokenutil""" # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. import io import sys import textwrap import tokenize import pytest from IPython.utils.tokenutil import ( generate_tokens_catch_errors, line_at_cursor, token_at_cursor, ) def e...
222
6,612
pyro
tests/contrib/funsor/test_enum_funsor.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import logging import os import pyroapi import pytest import torch from torch.autograd import grad from torch.distributions import constraints from pyro.ops.indexing import Vindex from pyro.util import torch_isnan from tests.common i...
1,946
71,964
kombu
kombu/transport/gcpubsub.py
.py
"""GCP Pub/Sub transport module for kombu. More information about GCP Pub/Sub: https://cloud.google.com/pubsub Features ======== * Type: Virtual * Supports Direct: Yes * Supports Topic: No * Supports Fanout: Yes * Supports Priority: No * Supports TTL: No Connection String ================= Connection string has the...
889
31,102
coremltools
deps/protobuf/python/google/protobuf/__init__.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...
34
1,705
pymc
tests/step_methods/test_slicer.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...
53
1,611
beam
sdks/python/apache_beam/runners/interactive/sql/beam_sql_magics_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...
159
6,710
rq
rq/group.py
.py
from __future__ import annotations from collections.abc import Iterable from uuid import uuid4 from redis import Redis from redis.client import Pipeline from . import Queue from .exceptions import NoSuchGroupError from .job import Job from .queue import EnqueueData from .utils import as_text class Group: """A ...
129
4,745
wagtail
wagtail/admin/ui/autosave.py
.py
from wagtail.admin.ui.components import Component class AutosaveIndicator(Component): template_name = "wagtailadmin/shared/autosave/indicator.html"
6
154
qutip
qutip/piqs/piqs.py
.py
"""Permutational Invariant Quantum Solver (PIQS) This module calculates the Liouvillian for the dynamics of ensembles of identical two-level systems (TLS) in the presence of local and collective processes by exploiting permutational symmetry and using the Dicke basis. It also allows to characterize nonlinear functions...
1,920
53,204
clearml
examples/frameworks/tensorflow/legacy/tensorflow_mnist_with_summaries.py
.py
# Copyright 2015 The TensorFlow 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
223
9,808
sphinx
sphinx/versioning.py
.py
"""Implements the low-level algorithms Sphinx uses for versioning doctrees.""" from __future__ import annotations import pickle from itertools import product, zip_longest from operator import itemgetter from typing import TYPE_CHECKING from uuid import uuid4 from sphinx.transforms import SphinxTransform if TYPE_CHE...
185
6,251
beam
learning/katas/python/Streaming/Triggers/Early Triggers/generate_event.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...
59
4,386
sphinx
tests/roots/test-ext_static_dir/staticdirext/__init__.py
.py
"""Test extension that registers a static directory.""" from pathlib import Path HERE = Path(__file__).resolve().parent def setup(app): app.add_static_dir(HERE / 'static') app.add_js_file('js/myext.js') app.add_css_file('css/myext.css') return { 'version': '1.0', 'parallel_read_safe'...
17
371
pyfilesystem2
fs/_ftp_parse.py
.py
from __future__ import absolute_import, print_function, unicode_literals import re import time import unicodedata from datetime import datetime try: from datetime import timezone except ImportError: from ._tzcompat import timezone # type: ignore from .enums import ResourceType from .permissions import Permi...
202
5,098
loguru
tests/exceptions/source/backtrace/chaining_first.py
.py
import sys from loguru import logger logger.remove() logger.add(sys.stderr, format="", colorize=False, backtrace=True, diagnose=False) @logger.catch def a_decorated(): b() def a_not_decorated(): b() def b(): c() def c(): 1 / 0 a_decorated() with logger.catch(): a_not_decorated() try: ...
36
393
conda
tests/shards/conftest.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """ Sharded repodata test fixtures and utilities. Adapted from conda-libmamba-solver/tests """ from __future__ import annotations import contextlib import hashlib import http.server import logging import queue import socket import tempfile im...
435
13,264
sqlmap
plugins/dbms/firebird/__init__.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ from lib.core.enums import DBMS from lib.core.settings import FIREBIRD_SYSTEM_DBS from lib.core.unescaper import unescaper from plugins.dbms.firebird.enumeration import Enumeratio...
30
928
beam
sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximateunique.py
.py
# coding=utf-8 # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License");...
53
1,578
onnxruntime
orttraining/orttraining/python/training/utils/hooks/_subscriber_base.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import sys import torch from onnxruntime.training.utils import ORTMod...
211
9,095
structlog
tests/helpers.py
.py
# SPDX-License-Identifier: MIT OR Apache-2.0 # This file is dual licensed under the terms of the Apache License, Version # 2.0, and the MIT License. See the LICENSE file in the root of this # repository for complete details. """ Shared test utilities. """ from unittest.mock import Mock, seal from structlog._log_lev...
47
975
httpie
httpie/uploads.py
.py
import sys import os import zlib import functools import threading from typing import Any, Callable, IO, Iterable, Optional, Tuple, Union, TYPE_CHECKING from urllib.parse import urlencode import requests from requests.utils import super_len if TYPE_CHECKING: from requests_toolbelt import MultipartEncoder from .c...
270
7,744
mlflow
tests/utils/test_async_logging_queue.py
.py
import contextlib import io import pickle import random import threading import time import uuid from unittest.mock import MagicMock, patch import pytest import mlflow.utils.async_logging.async_logging_queue from mlflow import MlflowException from mlflow.entities.metric import Metric from mlflow.entities.param import...
440
15,131
saleor
saleor/graphql/giftcard/tests/deprecated/test_gift_card_query.py
.py
import datetime import graphene from ....tests.utils import assert_no_permission, get_graphql_content QUERY_GIFT_CARD_BY_ID = """ query giftCard($id: ID!) { giftCard(id: $id){ id code last4CodeChars user { email } end...
59
1,639
onnxruntime
orttraining/orttraining/test/python/orttraining_test_ortmodule_onnx_ops.py
.py
""" @brief test log(time=3s) """ import copy import unittest import numpy as np import torch from onnxruntime.training.ortmodule import ORTModule class TestOnnxOpsOrtModule(unittest.TestCase): def assert_values_are_close(self, tensor, other, rtol=1e-05, atol=1e-06): are_close = torch.allclose(tens...
186
7,827
mlflow
tests/llama_index/sample_code/with_model_config.py
.py
""" Sample code to define a chat engine and save it with model config (dictionary). """ from llama_index.core import Document, VectorStoreIndex from llama_index.core.chat_engine.types import ChatMode from llama_index.llms.openai import OpenAI import mlflow model_config = mlflow.models.ModelConfig() model_name = mode...
21
698
pyomo
pyomo/common/tests/test_unittest.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...
579
19,752
mlflow
tests/pytorch/iris_data_module.py
.py
import pytorch_lightning as pl import torch from sklearn.datasets import load_iris from torch.utils.data import DataLoader, TensorDataset, random_split class IrisDataModuleBase(pl.LightningDataModule): def __init__(self): super().__init__() self.columns = None def _get_iris_as_tensor_dataset(...
53
1,616
saleor
saleor/graphql/order/tests/mutations/test_order_mark_as_paid.py
.py
import graphene import pytest from prices import Money, TaxedMoney from .....channel import MarkAsPaidStrategy from .....order import OrderStatus from .....order import events as order_events from .....order.actions import MARK_AS_PAID_TRANSACTION_NAME from .....order.error_codes import OrderErrorCode from .....paymen...
455
16,416
biopython
Bio/PDB/mmtf/mmtfio.py
.py
# Copyright 2019 Joe Greener. 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. """Write a MMTF file.""" impo...
280
11,174
mlflow
tests/utils/test_providers.py
.py
import json from unittest import mock import pytest from mlflow.exceptions import MlflowException from mlflow.utils.providers import ( _fetch_remote_provider, _flatten_catalog_entry, _get_remote_cache, _list_provider_names, _load_bundled_provider, _load_provider, _normalize_provider, c...
571
20,028
black
tests/data/cases/preview_remove_multiline_lone_list_item_parens.py
.py
# flags: --unstable items = [(x for x in [1])] items = [ ( {"key1": "val1", "key2": "val2", "key3": "val3"} if some_var == "long strings" else {"key": "val"} ) ] items = [ ( {"key1": "val1", "key2": "val2"} if some_var == "" else {"key": "val"} ) ] items...
247
5,456
pyro
examples/contrib/autoname/tree_data.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import argparse import torch from torch.distributions import constraints import pyro import pyro.distributions as dist from pyro.contrib.autoname import named from pyro.infer import SVI, Trace_ELBO from pyro.optim import Adam # ...
112
3,560
probability
tensorflow_probability/python/internal/auto_composite_tensor_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...
792
29,057
textual
tests/tree/test_node_refresh.py
.py
from rich.style import Style from rich.text import Text from textual.app import App, ComposeResult from textual.widgets import Tree from textual.widgets.tree import TreeNode class HistoryTree(Tree): def __init__(self) -> None: super().__init__("Root") self.counter = 0 self.render_hits: se...
65
2,462
metrics
src/torchmetrics/audio/sdr.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...
400
15,295
mlflow
mlflow/tracing/sampling.py
.py
import contextvars from opentelemetry.sdk.trace.sampling import ( Sampler, SamplingResult, TraceIdRatioBased, ) # Context variable to override the sampling ratio for a specific trace. # When set, the sampler uses this ratio instead of the default. _SAMPLING_RATIO_OVERRIDE = contextvars.ContextVar("samplin...
49
1,579
pyomo
pyomo/contrib/pyros/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...
3,614
132,810
pyomo
pyomo/common/sorting.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...
135
5,113
wandb
wandb/integration/tensorboard/__init__.py
.py
"""wandb integration tensorboard module.""" from .log import _log, log, reset_state, tf_summary_to_dict from .monkeypatch import patch, unpatch __all__ = [ "patch", "unpatch", "log", ]
11
199
pyomo
pyomo/dataportal/plugins/sheet.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...
240
8,033
django-cms
cms/test_utils/project/template_backends.py
.py
from django.template.backends.django import DjangoTemplates class CustomDjangoTemplates(DjangoTemplates): """ A custom template engine that inherits from DjangoTemplates """ pass class NonDjangoTemplates: """ A mock template backend that doesn't inherit from DjangoTemplates """ def...
23
458
python-prompt-toolkit
src/prompt_toolkit/contrib/regular_languages/__init__.py
.py
r""" Tool for expressing the grammar of an input as a regular language. ================================================================== The grammar for the input of many simple command line interfaces can be expressed by a regular language. Examples are PDB (the Python debugger); a simple (bash-like) shell with "pw...
81
3,279
saleor
saleor/warehouse/tests/test_preorder_complete.py
.py
from django.db.models.aggregates import Sum from ...product.models import ProductVariantChannelListing from ..management import deactivate_preorder_for_variant from ..models import Allocation, PreorderAllocation, Stock def test_deactivate_preorder_for_variant( preorder_variant_global_and_channel_threshold, p...
149
4,871
onnxruntime
onnxruntime/python/tools/quantization/quant_utils.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- from __fut...
1,286
51,725
httpie
tests/test_parser_schema.py
.py
from httpie.cli.options import ParserSpec, Qualifiers def test_parser_serialization(): small_parser = ParserSpec("test_parser") group_1 = small_parser.add_group("group_1") group_1.add_argument("regular_arg", help="regular arg", short_help="short") group_1.add_argument( "variadic_arg", ...
64
2,085
pyomo
pyomo/_archive/sets.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...
22
762
gunicorn
tests/docker/asgi_framework_compat/tests/test_http_messages.py
.py
""" HTTP Message Type Tests Tests ASGI 3.0 HTTP request/response message handling. """ import pytest pytestmark = pytest.mark.http class TestHttpRequestBody: """Test HTTP request body handling.""" async def test_echo_empty_body(self, http_client): """Echo endpoint handles empty body.""" r...
129
4,643
mlflow
mlflow/tracking/context/databricks_repo_context.py
.py
from mlflow.tracking.context.abstract_context import RunContextProvider from mlflow.utils import databricks_utils from mlflow.utils.mlflow_tags import ( MLFLOW_DATABRICKS_GIT_REPO_COMMIT, MLFLOW_DATABRICKS_GIT_REPO_PROVIDER, MLFLOW_DATABRICKS_GIT_REPO_REFERENCE, MLFLOW_DATABRICKS_GIT_REPO_REFERENCE_TYPE...
44
1,952
bazel
third_party/py/abseil/absl/testing/_bazelize_command.py
.py
# Copyright 2017 The Abseil 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 ...
69
2,302
conda
conda/plugins/environment_exporters/explicit.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Built-in conda explicit environment exporter plugin. This module implements the explicit format defined in CEP 23: Files with @EXPLICIT marker and package URLs for reproducible installs. """ from __future__ import annotations from typing i...
97
3,727
luigi
test/optional_parameter_test.py
.py
import datetime import warnings import mock from helpers import LuigiTestCase, with_config import luigi class OptionalParameterTest(LuigiTestCase): def actual_test(self, cls, default, expected_value, expected_type, bad_data=None, **kwargs): class TestConfig(luigi.Config): param = cls(defaul...
148
7,729
pyomo
pyomo/contrib/aslfunctions/plugins.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...
16
766
openvino
src/bindings/python/tests/test_graph/test_eye.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import openvino.opset10 as ov import numpy as np import pytest from openvino.utils.types import get_element_type_str from openvino.utils.types import get_element_type @pytest.mark.parametrize( ("num_rows", ...
91
3,630