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
astropy
astropy/table/tests/test_column.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import copy import operator import warnings from inspect import currentframe, getframeinfo import numpy as np import pytest from numpy.testing import assert_array_equal from astropy import table, time from astropy import units as u from astropy.table.co...
1,250
40,690
attrs
tests/test_make.py
.py
# SPDX-License-Identifier: MIT """ Tests for `attr._make`. """ import copy import functools import gc import inspect import itertools import pickle import sys import types import unicodedata from operator import attrgetter from typing import Generic, TypeVar import pytest from hypothesis import assume, given from ...
3,213
86,730
openvino
docs/articles_en/assets/snippets/ov_extensions.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # import openvino as ov from ov_custom_op import Identity #! [py_frontend_extension_ThresholdedReLU_header] import openvino.opset14 as ops from openvino.frontend import ConversionExtension #! [py_frontend_extension_ThresholdedReLU_heade...
86
2,634
probability
tensorflow_probability/python/math/sparse.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...
59
2,197
beam
sdks/python/apache_beam/runners/interactive/caching/write_cache_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...
82
3,036
pyomo
pyomo/core/tests/unit/test_action.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...
157
4,674
kombu
t/unit/transport/virtual/test_exchange.py
.py
from __future__ import annotations from unittest.mock import Mock import pytest from kombu import Connection from kombu.transport.virtual import exchange from t.mocks import Transport class ExchangeCase: type = None def setup_method(self): if self.type: self.e = self.type(Connection(tr...
169
5,565
saleor
saleor/graphql/product/tests/deprecated/test_collection_sorting.py
.py
import datetime import pytest from .....product.models import Collection, CollectionChannelListing from ....tests.utils import assert_graphql_error_with_message, get_graphql_content @pytest.fixture def collections_for_sorting_with_channels(channel_USD, channel_PLN): collections = Collection.objects.bulk_create(...
259
7,575
metrics
src/torchmetrics/utilities/distributed.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...
154
6,146
wandb
tests/system_tests/test_functional/multiprocessing/share_child_base.py
.py
"""Example of sharing a run object with a child process.""" import argparse import multiprocessing as mp import wandb def process_child(run): """Log to the shared run object.""" run.config.c2 = 22 run.log({"s1": 21}) # Read the summary to force the previous messages to be processed # before the...
51
1,325
saleor
saleor/graphql/channel/tests/queries/test_channel.py
.py
import graphene from prices import Money from .....channel import TransactionFlowStrategy from .....shipping.models import ShippingMethodChannelListing, ShippingZone from ....tests.utils import ( assert_no_permission, get_graphql_content, get_graphql_content_from_response, ) from ...enums import Allocation...
757
22,808
onnxruntime
onnxruntime/test/testdata/invalid_dim_param_value_repetition.py
.py
""" Run this script to recreate the original onnx model. Example usage: python invalid_dim_param_value_repetition.py """ import numpy as np import onnx def order_repeated_field(repeated_proto, key_name, order): order = list(order) repeated_proto.sort(key=lambda x: order.index(getattr(x, key_name))) def mak...
71
3,040
saleor
saleor/graphql/checkout/mutations/checkout_delete.py
.py
import graphene from django.core.exceptions import ValidationError from ....checkout.error_codes import CheckoutErrorCode from ....checkout.models import Checkout as CheckoutModel from ....checkout.utils import delete_checkouts from ....permission.enums import CheckoutPermissions from ...core import ResolveInfo from ....
59
1,929
onnxruntime
orttraining/orttraining/test/python/orttraining_test_ortmodule_deepspeed_pipeline_parallel.py
.py
import argparse import deepspeed import torch from deepspeed.pipe import PipelineModule from torch import nn from onnxruntime.training.ortmodule import ORTModule # USAGE: # pip install deepspeed # deepspeed orttraining_test_ortmodule_deepspeed_pipeline_parallel.py --deepspeed_config=orttraining_test_ortmodule_deepsp...
121
3,879
pyomo
pyomo/opt/solver/__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...
18
746
mlflow
tests/transformers/test_transformers_peft_model.py
.py
import importlib import os import re import pytest import transformers import mlflow from mlflow.exceptions import MlflowException from mlflow.models import Model from mlflow.transformers.flavor_config import FlavorKey from mlflow.transformers.peft import get_peft_base_model, is_peft_model from mlflow.utils.logging_u...
272
9,252
onnxruntime
onnxruntime/python/tools/quantization/preprocess.py
.py
# -------------------------------------------------------------------------- # Copyright (c) Microsoft, Intel Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- i...
142
4,904
gunicorn
tests/requests/invalid/004.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. from gunicorn.http.errors import InvalidHTTPVersion request = InvalidHTTPVersion
6
186
readthedocs.org
readthedocs/settings/proxito/base.py
.py
""" Base settings for Proxito Some of these settings will eventually be backported into the main settings file, but currently we have them to be able to run the site with the old middleware for a staged rollout of the proxito code. """ import structlog log = structlog.get_logger(__name__) class CommunityProxitoSett...
50
1,646
astropy
astropy/coordinates/tests/helper.py
.py
"""Test helper functions for coordinates.""" import numpy as np def skycoord_equal(sc1, sc2): """SkyCoord equality useful for testing.""" if not sc1.is_equivalent_frame(sc2): return False if sc1.representation_type is not sc2.representation_type: return False if sc1.shape != sc2.shape...
18
546
tqdm
tqdm/utils.py
.py
""" General helpers required for `tqdm.std`. """ import os import re import sys from functools import partial, partialmethod, wraps from inspect import signature # TODO consider using wcswidth third-party package for 0-width characters from unicodedata import east_asian_width from warnings import warn from weakref impo...
329
9,746
onnxruntime
onnxruntime/python/tools/transformers/fusion_options.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from argparse import ArgumentParser from enum import Enum class Attent...
341
12,386
textual
docs/examples/guide/widgets/counter01.py
.py
from textual.app import App, ComposeResult, RenderResult from textual.reactive import reactive from textual.widgets import Footer, Static class Counter(Static, can_focus=True): # (1)! """A counter that can be incremented and decremented by pressing keys.""" count = reactive(0) def render(self) -> Rende...
28
630
probability
tensorflow_probability/python/math/psd_kernels/positive_semidefinite_kernel_test.py
.py
# Copyright 2018 The TensorFlow Probability Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
552
20,518
sqlmap
plugins/dbms/derby/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.common import singleTimeWarnMessage from lib.core.data import logger from plugins.generic.enumeration import Enumeration as GenericEnumeration class Enumeration(Gen...
44
1,321
beam
learning/katas/python/Common Transforms/Aggregation/Sum/tests/test_task.py
.py
# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not...
35
1,211
beam
sdks/python/apache_beam/examples/california_housing_clustering.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...
118
4,180
wagtail
wagtail/contrib/settings/wagtail_hooks.py
.py
from django.urls import include, path from wagtail import hooks from . import urls @hooks.register("register_admin_urls") def register_admin_urls(): return [ path("settings/", include(urls, namespace="wagtailsettings")), ]
13
243
mlflow
tests/deployments/test_deployments.py
.py
from unittest import mock import pytest from mlflow import deployments from mlflow.deployments.plugin_manager import DeploymentPlugins from mlflow.exceptions import MlflowException f_model_uri = "fake_model_uri" f_endpoint_name = "fake_endpoint_name" f_deployment_id = "fake_deployment_name" f_flavor = "fake_flavor" ...
127
3,992
metrics
src/torchmetrics/image/psnr.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...
202
8,512
lemur
docker/src/lemur.conf.py
.py
import base64 import os.path import secrets import string from typing import Dict, Any, List _basedir = os.path.abspath(os.path.dirname(__file__)) # See the Lemur docs (https://lemur.readthedocs.org) for more information on configuration LOG_LEVEL = str(os.environ.get('LOG_LEVEL', 'DEBUG')) LOG_FILE = str(os.environ...
234
7,717
colorama
demos/demo03.py
.py
#!/usr/bin/python # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. # Demonstrate the different behavior when autoreset is True and False. import fixpath from colorama import init, Fore, Back, Style init(autoreset=True) print(Fore.CYAN + Back.MAGENTA + Style.BRIGHT + 'Line 1: colored, with a...
16
644
black
tests/data/cases/remove_except_parens.py
.py
# These brackets are redundant, therefore remove. try: a.something except (AttributeError) as err: raise err # This is tuple of exceptions. # Although this could be replaced with just the exception, # we do not remove brackets to preserve AST. try: a.something except (AttributeError,) as err: raise err...
80
2,025
saleor
saleor/graphql/checkout/tests/mutations/test_price_override_reason.py
.py
"""Tests for the `priceOverrideReason` field on checkout / order lines. Feature spec: .context/price-override-reason-scenarios.md An app with HANDLE_CHECKOUTS may record *why* it set a custom price on a checkout line. The reason is stored natively, carried onto the order line at completion, and readable by staff/app ...
698
21,377
sqlmap
lib/utils/versioncheck.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import sys import time PYVERSION = sys.version.split()[0] if PYVERSION < "2.7": sys.exit("[%s] [CRITICAL] incompatible Python version detected ('%s'). To successfully run sq...
29
920
beam
sdks/python/apache_beam/io/external/xlang_parquetio_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...
89
3,038
pyomo
pyomo/contrib/appsi/writers/config.py
.py
# ____________________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and Engineering # Solutions of...
14
636
deap
doc/code/tutorials/part_3/stats.py
.py
import random import numpy from deap import algorithms from deap import base from deap import creator from deap import tools random.seed(0) stats = tools.Statistics(key=lambda ind: ind.fitness.values) stats.register("avg", numpy.mean) stats.register("std", numpy.std) stats.register("min", numpy.min) stats.register(...
51
1,426
wagtail
wagtail/snippets/models.py
.py
from functools import lru_cache from django.apps import apps as global_apps from django.contrib.auth import get_permission_codename from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType from django.db import DEFAULT_DB_ALIAS, models, router from django.utils.modul...
153
5,411
mlflow
tests/genai/evaluate/test_telemetry.py
.py
from unittest import mock import pytest from mlflow.genai import Scorer, scorer from mlflow.genai.evaluation.telemetry import ( _BATCH_SIZE_HEADER, _CLIENT_NAME_HEADER, _CLIENT_VERSION_HEADER, _SESSION_ID_HEADER, emit_metric_usage_event, ) from mlflow.genai.judges import make_judge from mlflow.gen...
301
9,154
openvino
tests/layer_tests/tensorflow_lite_tests/test_tfl_Slice.py
.py
import string import numpy as np import pytest import tensorflow as tf from common.tflite_layer_test_class import TFLiteLayerTest test_params = [ # OV doesn't support string format # {'shape': [12, 2, 2, 5], 'begin': [0, 0, 0, 0], 'size': [8, 2, 2, 3], 'dtype': tf.string}, {'shape': [12, 2, 2, 5], 'begin...
58
2,401
hydra
tests/test_apps/app_without_config/my_app.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from omegaconf import DictConfig import hydra @hydra.main() def my_app(_: DictConfig) -> None: pass if __name__ == "__main__": my_app()
14
220
kombu
kombu/transport/native_delayed_delivery.py
.py
"""Native Delayed Delivery API. Only relevant for RabbitMQ. """ from __future__ import annotations from kombu import Connection, Exchange, Queue, binding from kombu.log import get_logger logger = get_logger(__name__) MAX_NUMBER_OF_BITS_TO_USE = 28 MAX_LEVEL = MAX_NUMBER_OF_BITS_TO_USE - 1 CELERY_DELAYED_DELIVERY_EX...
158
5,801
astropy
astropy/table/bst.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import operator from collections.abc import Hashable, Mapping, Sequence from numbers import Integral import numpy as np from astropy.utils.decorators import deprecated __all__ = ["BST"] class MaxValue: """ Represents an infinite value for purp...
518
15,095
pdm
src/pdm/cli/commands/remove.py
.py
from __future__ import annotations import argparse from typing import TYPE_CHECKING from pdm.cli.commands.base import BaseCommand from pdm.cli.filters import GroupSelection from pdm.cli.hooks import HookManager from pdm.cli.options import ( dry_run_option, frozen_lockfile_option, install_group, lockfi...
138
4,973
saleor
saleor/graphql/core/validators/tests/test_alias_count_limit.py
.py
import pytest from .....core.telemetry import Scope, Unit from .....tests.utils import get_metric_data from ....api import backend, schema from ....metrics import METRIC_GRAPHQL_ALIAS_COUNT from ....views import GraphQLView @pytest.mark.parametrize( ("_case", "is_valid", "query"), [ ("Alias count low...
142
4,304
hypercorn
src/hypercorn/statsd.py
.py
from __future__ import annotations from typing import Any, TYPE_CHECKING from .logging import Logger if TYPE_CHECKING: from .config import Config from .typing import ResponseSummary, WWWScope METRIC_VAR = "metric" VALUE_VAR = "value" MTYPE_VAR = "mtype" GAUGE_TYPE = "gauge" COUNTER_TYPE = "counter" HISTOGRA...
97
3,870
textual
docs/examples/widgets/selection_list_selections.py
.py
from textual.app import App, ComposeResult from textual.widgets import Footer, Header, SelectionList from textual.widgets.selection_list import Selection class SelectionListApp(App[None]): CSS_PATH = "selection_list.tcss" def compose(self) -> ComposeResult: yield Header() yield SelectionList[...
30
903
pyomo
pyomo/solvers/plugins/solvers/xpress_persistent.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...
227
8,233
onnxruntime
tools/python/wgsl_template/code_pattern.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """Built-in code patterns and indices-helper rewrite table. A :class:`CodePattern` is a single rewrite rule consumed by the PASS2 generator. ``DEFAULT_PATTERNS`` are always active; the named entries in :func:`lookup_pattern` ...
233
7,504
textual
src/textual/_context.py
.py
from __future__ import annotations from contextvars import ContextVar from typing import TYPE_CHECKING, Any, Callable if TYPE_CHECKING: from textual.app import App from textual.message import Message from textual.message_pump import MessagePump from textual.screen import Screen class NoActiveAppErro...
29
1,028
beam
sdks/python/apache_beam/runners/interactive/sql/utils_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...
124
4,755
pymc
pymc/progress_bar/marimo_progress.py
.py
# Copyright 2025 - 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...
405
13,337
onnxruntime
onnxruntime/test/testdata/dummy_whisper_model_generator.py
.py
"""Script to generate a dummy ONNX model emulating a Whisper model with BeamSearch op. The model is intentionally tiny and produces deterministic (but meaningless) outputs. Its only purpose is to exercise the WhisperBeamSearch encoder/decoder subgraph plumbing, in particular the decoder "use sequence as input ids" pat...
329
15,637
saleor
saleor/graphql/account/tests/mutations/customer_type/test_customer_type_assign_attributes.py
.py
from unittest.mock import patch import graphene from ......account.error_codes import CustomerTypeAssignAttributesErrorCode from ......attribute.models import AttributeCustomerType from .....tests.utils import assert_no_permission, get_graphql_content CUSTOMER_TYPE_ASSIGN_ATTRIBUTES_MUTATION = """ mutation Custo...
384
12,110
sphinx
tests/roots/test-html_assets/conf.py
.py
project = 'Sphinx' version = '1.4.4' html_static_path = ['static', 'subdir'] html_extra_path = ['extra', 'subdir'] html_css_files = [ 'css/style.css', ( 'https://example.com/custom.css', {'title': 'title', 'media': 'print', 'priority': 400}, ), ] html_js_files = [ 'js/custom.js', ( ...
21
464
scikit-bio
skbio/util/tests/test_misc.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. # --------------------------------------------...
249
7,854
saleor
conftest.py
.py
import os import dj_database_url import django.test import pytest from django.conf import settings from django.core.management import call_command from django.db import connections from django.test.testcases import TransactionTestCase from saleor.tests.utils import prepare_test_db_connections TEST_DATABASES = { ...
90
3,463
probability
tensorflow_probability/python/experimental/fastgp/linear_operator_sum.py
.py
# Copyright 2024 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...
127
4,642
probability
tensorflow_probability/python/experimental/fastgp/fast_gprm_test.py
.py
# Copyright 2024 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
2,858
coremltools
coremltools/converters/mil/mil/ops/tests/iOS17/test_reduction.py
.py
# Copyright (c) 2023, 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 itertools import numpy as np import pytest from coremltools.converters.mil.mil import Builde...
64
2,429
pyfilesystem2
fs/iotools.py
.py
"""Compatibility tools between Python 2 and Python 3 I/O interfaces. """ from __future__ import print_function, unicode_literals import typing import array import io from io import SEEK_CUR, SEEK_SET from .mode import Mode if typing.TYPE_CHECKING: from typing import IO, Any, Iterable, Iterator, List, Optional,...
234
6,575
gunicorn
examples/asgi/basic_app.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """ Basic ASGI application example. Run with: gunicorn -k asgi examples.asgi.basic_app:app Test with: curl http://127.0.0.1:8000/ curl http://127.0.0.1:8000/hello curl -X POST http://127.0.0.1:800...
131
3,949
lemur
lemur/logs/service.py
.py
""" .. module: lemur.logs.service :platform: Unix :synopsis: This module contains all of the services level functions used to administer logs in Lemur :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. .. moduleauthor:: Kevin Glisson <kglisson@...
107
3,081
saleor
saleor/graphql/discount/tests/queries/test_promotions.py
.py
import datetime from django.utils import timezone from ....tests.utils import assert_no_permission, get_graphql_content QUERY_PROMOTIONS = """ query { promotions(first: 10) { edges { node { id name description ...
160
4,345
mlflow
mlflow/pyfunc/scoring_server/app.py
.py
import os from mlflow.pyfunc import scoring_server app = scoring_server.init( scoring_server.load_model_with_mlflow_config(os.environ[scoring_server._SERVER_MODEL_PATH]) )
8
178
onnx
onnx/reference/ops/op_mod.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.op_run import OpRun class Mod(OpRun): def _run(self, a, b, fmod=None): fmod = fmod or self.fmod if fmod == 1: return (np.fmod(a, ...
19
482
saleor
saleor/plugins/tests/test_plugins.py
.py
from ..base_plugin import ConfigurationTypeField from ..manager import get_plugins_manager from ..tests.sample_plugins import PluginSample from ..tests.utils import get_config_value def test_update_config_items_keeps_bool_value(plugin_configuration, settings): settings.PLUGINS = ["saleor.plugins.tests.sample_plug...
233
8,346
astropy
astropy/io/misc/pyarrow/tests/test_csv.py
.py
import contextlib import datetime import decimal import io import sys import textwrap from pathlib import Path import numpy as np import pytest from numpy.testing import assert_array_equal from astropy.io.misc.pyarrow.csv import strip_comment_lines from astropy.table import Table from astropy.utils.compat.optional_de...
769
22,937
biopython
Bio/Blast/_parser.py
.py
# Copyright 1999 by Jeffrey Chang. All rights reserved. # Copyright 2000 by Bertrand Frottier. All rights reserved. # Revisions 2005-2006 copyright Michiel de Hoon # Revisions 2006-2009 copyright Peter Cock # Revisions 2023 by Michiel de Hoon. All rights reserved. # # This file is part of the Biopython distribution ...
1,227
41,603
onnx
onnx/reference/ops/op_reduce_max.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 OpRunReduceNumpy class ReduceMax_1(OpRunReduceNumpy): def _run(self, data, axes=None, keepdims=None): axes = tuple(axes) if axes is no...
47
1,605
bazel
third_party/py/mock/tests/testwith.py
.py
import sys if sys.version_info[:2] >= (2, 5): from tests._testwith import * else: from tests.support import unittest2 class TestWith(unittest2.TestCase): @unittest2.skip('tests using with statement skipped on Python 2.4') def testWith(self): pass if __name__ == '__main__': ...
17
340
mlflow
tests/langgraph/test_langgraph_model_export.py
.py
import json import mlflow from mlflow.types.schema import Object, ParamSchema, ParamSpec, Property def test_langgraph_save_as_code(): input_example = {"messages": [{"role": "user", "content": "what is the weather in sf?"}]} with mlflow.start_run(): model_info = mlflow.langchain.log_model( ...
78
3,206
lemur
lemur/plugins/bases/notification.py
.py
""" .. module: lemur.plugins.bases.notification :platform: Unix :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. .. moduleauthor:: Kevin Glisson <kglisson@netflix.com> """ from lemur.common.utils import check_validation from lemur.plugins.base impor...
70
2,158
pyomo
pyomo/contrib/mcpp/getMCPP.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...
46
1,386
cvxpy
cvxpy/reductions/dcp2cone/canonicalizers/geo_mean_canon.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...
89
2,715
textual
docs/examples/how-to/layout02.py
.py
from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Placeholder class Header(Placeholder): DEFAULT_CSS = """ Header { height: 3; dock: top; } """ class Footer(Placeholder): DEFAULT_CSS = """ Footer { height: 3; ...
38
650
biopython
Tests/test_RCSBFormats.py
.py
# Copyright 2016 Joao P. Rodrigues (j.p.g.l.m.rodrigues@gmail.com). # 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. """Unit tests to compare objects parsed by different struct...
73
2,572
onnxruntime
onnxruntime/test/python/onnxruntime_test_python_mlops.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import os # noqa: F401 # -*- coding: UTF-8 -*- import unittest import numpy as np from helper import get_name import onnxruntime as onnxrt available_providers = [ ( ep, {"enable_cann_subgraph": True},...
229
9,745
returns
returns/interfaces/applicative.py
.py
from abc import abstractmethod from collections.abc import Callable, Sequence from typing import ClassVar, Never, TypeVar, final from returns.functions import compose, identity from returns.interfaces import mappable from returns.primitives.asserts import assert_equal from returns.primitives.hkt import KindN from retu...
173
4,972
eve
docs/conf.py
.py
# -*- coding: utf-8 -*- # # Eve documentation build configuration file, created by # sphinx-quickstart on Fri Mar 1 17:24:24 2013. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All con...
296
9,519
sphinx
tests/roots/test-highlight_options/conf.py
.py
highlight_options = { 'default': {'default_option': True}, 'python': {'python_option': True}, }
5
104
saleor
saleor/menu/tests/fixtures/menu_item.py
.py
import pytest from ...models import MenuItem @pytest.fixture def menu_item(menu): return MenuItem.objects.create(menu=menu, name="Link 1", url="http://example.com/") @pytest.fixture def menu_item_list(menu): menu_item_1 = MenuItem.objects.create(menu=menu, name="Link 1") menu_item_2 = MenuItem.objects....
17
470
wagtail
wagtail/api/v3/schemas/revisions.py
.py
from datetime import datetime from typing import Optional from uuid import UUID from django.contrib.contenttypes.models import ContentType from pydantic import PositiveInt from .base import BaseSchema class ContentTypeSchema(BaseSchema): id: int name: str label: str @staticmethod def resolve_na...
45
1,188
wagtail
wagtail/models/collections.py
.py
# wagtail.models.collections was moved to wagtail.models.media in #11555; # this import is retained to accommodate migration files importing from the old location. # See #11874 from wagtail.models.media import get_root_collection_id # noqa
6
242
probability
tensorflow_probability/python/experimental/mcmc/tracing_reducer.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...
201
7,460
pyomo
pyomo/repn/tests/ampl/small4_testCase.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...
28
1,064
sqlmap
lib/parse/openapi.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import json import re from lib.core.common import getSafeExString from lib.core.data import logger from lib.core.enums import HTTP_HEADER from lib.core.settings import CUSTOM_INJ...
371
21,368
hydra
examples/tutorials/basic/running_your_hydra_app/3_working_directory/original_cwd.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import os from omegaconf import DictConfig import hydra from hydra.utils import get_original_cwd, to_absolute_path @hydra.main() def my_app(_cfg: DictConfig) -> None: print(f"Current working directory : {os.getcwd()}") print(f"Orig worki...
20
540
mlflow
examples/pytorch/MNIST/mnist_autolog_example.py
.py
# # Trains an MNIST digit recognizer using PyTorch Lightning, # and uses MLflow to log metrics, params and artifacts # NOTE: This example requires you to first install # pytorch-lightning (using pip install pytorch-lightning) # and mlflow (using pip install mlflow). # import os import lightning as L import tor...
261
7,388
textual
src/textual/renderables/digits.py
.py
from __future__ import annotations from rich.console import Console, ConsoleOptions, RenderResult from rich.measure import Measurement from rich.segment import Segment from rich.style import Style, StyleType DIGITS = " 0123456789+-^x:ABCDEF$£€()" DIGITS3X3_BOLD = """\ ┏━┓ ┃ ┃ ┗━┛ ╺┓ ┃ ╺┻╸ ╺━┓ ┏━┛ ┗━╸ ╺━┓ ━┫ ╺━┛ ...
254
3,692
onnx
onnx/backend/test/case/node/groupnormalization.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 # Group normalization's reference implementation def _group_normalization(x,...
79
2,498
mlflow
dev/clint/src/clint/rules/get_artifact_uri.py
.py
from clint.rules.base import Rule class GetArtifactUri(Rule): def _message(self) -> str: return ( "`mlflow.get_artifact_uri` should not be used in examples. " "Use the return value of `log_model` instead." )
10
254
mlflow
tests/evaluate/test_evaluation.py
.py
import hashlib import io import json import os import re import signal import subprocess import uuid from typing import Any, NamedTuple from unittest import mock import numpy as np import pandas as pd import pytest import sklearn import sklearn.compose import sklearn.datasets import sklearn.impute import sklearn.linea...
2,416
87,304
jupyterlab
jupyterlab/handlers/error_handler.py
.py
"""An error handler for JupyterLab.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from jupyter_server.base.handlers import JupyterHandler from jupyter_server.extension.handler import ExtensionHandlerMixin from tornado import web TEMPLATE = """ <!DOCTYPE HTML>...
40
970
pyomo
pyomo/contrib/cspline_external/test/test_parameter_calculation.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...
192
7,006
mlflow
tests/tracing/utils/test_otlp.py
.py
import gzip import time import zlib from collections.abc import Callable import pytest from fastapi import HTTPException import mlflow from mlflow.entities.span import SpanType from mlflow.environment_variables import MLFLOW_TRACE_ENABLE_OTLP_DUAL_EXPORT from mlflow.tracing.processor.mlflow_v3 import MlflowV3SpanProc...
332
13,052
wandb
wandb/integration/torch/wandb_torch.py
.py
"""PyTorch-specific functionality.""" from __future__ import annotations import itertools from functools import reduce from operator import mul from typing import TYPE_CHECKING import wandb from wandb import util from wandb.data_types import Node torch = None if TYPE_CHECKING: from torch import Tensor from...
557
21,546
saleor
saleor/core/units.py
.py
class DistanceUnits: MM = "mm" CM = "cm" DM = "dm" M = "m" KM = "km" FT = "ft" YD = "yd" INCH = "inch" CHOICES = [ (MM, "Millimeter"), (CM, "Centimeter"), (DM, "Decimeter"), (M, "Meter"), (KM, "Kilometers"), (FT, "Feet"), (YD, ...
108
2,415
mlflow
tests/pyfunc/test_model_export_with_class_and_artifacts.py
.py
from __future__ import annotations import importlib.metadata import json import ntpath import os import subprocess import sys import types import uuid from pathlib import Path from subprocess import PIPE, Popen from typing import Any, Dict, List from unittest import mock import cloudpickle import numpy as np import p...
2,948
110,389