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
lemur
lemur/plugins/lemur_atlas_redis/plugin.py
.py
""" .. module: lemur.plugins.lemur_atlas_redis.plugin :platform: Unix :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. .. moduleauthor:: Jay Zarfoss """ from typing import Dict, Any from redis import Redis import json from datetime import datetime ...
99
3,257
astropy
astropy/nddata/tests/test_nduncertainty.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pickle from collections import defaultdict from gc import get_objects import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_equal from astropy import units as u from astropy.nddata.ccddata import CCDData from as...
431
15,536
conda
conda/plugins/subcommands/doctor/health_checks/__init__.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Health checks for `conda doctor`. This package contains individual health check modules that are registered via the conda_health_checks plugin hook. """ from __future__ import annotations from . import ( altered_files, consistency,...
33
656
hydra
tests/instantiate/test_helpers.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import datetime import re from textwrap import dedent from typing import Any try: from _pytest.raises import RaisesExc as RaisesContext except ImportError: from _pytest.python_api import RaisesContext # type: ignore[attr-defined,no-redef] ...
260
8,190
pyro
pyro/contrib/gp/likelihoods/poisson.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import torch import pyro import pyro.distributions as dist from pyro.contrib.gp.likelihoods.likelihood import Likelihood class Poisson(Likelihood): """ Implementation of Poisson likelihood, which is used for count data. ...
53
1,884
sqlmap
plugins/dbms/hsqldb/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 unArrayizeValue from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger from lib.core.data import queries from lib...
50
1,444
sqlmap
plugins/dbms/access/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): def getBanner(self): ...
85
2,524
cvxpy
cvxpy/tests/test_semidefinite_vars.py
.py
""" Copyright 2013 Steven Diamond, Eric Chu 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...
85
3,230
mkdocs-material
material/plugins/blog/readtime/__init__.py
.py
# Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com> # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, c...
52
2,168
saleor
saleor/core/schedules.py
.py
import datetime from typing import NamedTuple, cast from celery.utils.time import maybe_timedelta, remaining from django.db.models import F, Q from django.utils import timezone from ..schedulers.customschedule import CustomSchedule class schedstate(NamedTuple): is_due: bool next: float class promotion_web...
326
12,419
cvxpy
cvxpy/atoms/harmonic_mean.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...
43
1,297
returns
returns/future.py
.py
from collections.abc import ( AsyncGenerator, AsyncIterator, Awaitable, Callable, Coroutine, Generator, ) from functools import wraps from typing import Any, TypeAlias, TypeVar, final, overload from typing_extensions import ParamSpec from returns._internal.futures import _future, _future_resul...
1,631
48,479
pdm
src/pdm/cli/commands/use.py
.py
from __future__ import annotations import argparse from typing import TYPE_CHECKING from pdm import termui from pdm.cli.commands.base import BaseCommand from pdm.cli.hooks import HookManager from pdm.cli.options import skip_option from pdm.exceptions import NoPythonVersion from pdm.models.caches import JSONFileCache ...
222
9,492
biopython
Bio/AlignIO/FastaIO.py
.py
# Copyright 2008-2016 by Peter Cock. 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.AlignIO support ...
347
13,355
saleor
saleor/graphql/app/tests/mutations/test_app_problem_create_eviction.py
.py
import datetime from unittest.mock import patch from django.utils import timezone from .....app.models import AppProblem from ....tests.utils import get_graphql_content APP_PROBLEM_CREATE_MUTATION = """ mutation AppProblemCreate($input: AppProblemCreateInput!) { appProblemCreate(input: $input) { ...
99
3,123
saleor
saleor/graphql/account/tests/mutations/account/test_confirm_account.py
.py
import functools from typing import Any from unittest import mock from unittest.mock import patch import pytest from freezegun import freeze_time from ......account.error_codes import AccountErrorCode from ......core.tokens import ( account_confirm_token_generator, legacy_account_confirm_token_generator, ...
643
22,303
pyomo
pyomo/solvers/tests/checks/test_cuopt_direct.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...
174
6,432
sqlmap
thirdparty/chardet/__init__.py
.py
######################## BEGIN LICENSE BLOCK ######################## # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later ve...
84
3,271
openvino
tools/ovc/unit_tests/ovc/convert/utils.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os def create_onnx_model(): # # Create ONNX model # import onnx from onnx import helper from onnx import TensorProto shape = [1, 3, 2, 2] input = helper.make_tensor_value_info('input', Tensor...
53
1,292
mlflow
mlflow/store/db_migrations/versions/71994744cf8e_add_evaluation_datasets.py
.py
"""add evaluation datasets Revision ID: 71994744cf8e Revises: 534353b11cbc Create Date: 2025-08-12 14:30:00.000000 """ import sqlalchemy as sa from alembic import op from sqlalchemy.dialects import mssql # revision identifiers, used by Alembic. revision = "71994744cf8e" down_revision = "534353b11cbc" branch_labels ...
130
4,814
beam
sdks/python/apache_beam/internal/dill_pickler.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...
483
15,888
hatch
backend/src/hatchling/metadata/core.py
.py
from __future__ import annotations import os import sys from contextlib import suppress from copy import deepcopy from typing import TYPE_CHECKING, Any, Generic, cast from hatchling.metadata.utils import ( format_dependency, is_valid_import_name, is_valid_project_name, normalize_project_name, norm...
1,700
65,849
scikit-optimize
skopt/optimizer/base.py
.py
""" Abstraction for optimizers. It is sufficient that one re-implements the base estimator. """ import warnings import numbers try: from collections.abc import Iterable except ImportError: from collections import Iterable import numpy as np from ..callbacks import check_callback from ..callbacks import Verb...
306
12,529
probability
tensorflow_probability/python/experimental/util/jit_public_methods.py
.py
# Copyright 2021 The TensorFlow Probability Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
141
5,174
astropy
astropy/cosmology/_src/tests/flrw/test_flrw.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Testing :mod:`astropy.cosmology.FLRW`.""" from typing import final import pytest from astropy.cosmology import FLRW from astropy.cosmology._src.core import _COSMOLOGY_CLASSES, dataclass_decorator from astropy.cosmology._src.tests.helper import get_r...
113
3,834
saleor
saleor/graphql/discount/tests/queries/test_vouchers_filtering.py
.py
import datetime import pytest from django.utils import timezone from freezegun import freeze_time from .....discount import DiscountValueType from .....discount.models import Voucher, VoucherCode from ....tests.utils import get_graphql_content QUERY_VOUCHERS_WITH_FILTER = """ query ($filter: VoucherFilterInput!,...
330
9,194
jupytext
tests/external/pre_commit/test_pre_commit_1_sync_with_config.py
.py
import pytest from git.exc import HookExecutionError from nbformat.v4.nbbase import new_markdown_cell from pre_commit.main import main as pre_commit from jupytext import TextFileContentsManager, read def test_pre_commit_hook_sync_with_config( tmpdir, cwd_tmpdir, tmp_repo, jupytext_repo_root, jupy...
82
2,678
sqlmap
plugins/dbms/clickhouse/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): def getPasswordHashes(self):...
23
637
coremltools
coremltools/models/pipeline.py
.py
# Copyright (c) 2017, 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 """ Pipeline utils for this package. """ from coremltools import proto as _proto from .. import SPECIF...
310
10,843
wagtail
wagtail/contrib/redirects/utils.py
.py
from django.conf import settings from wagtail.contrib.redirects.base_formats import DEFAULT_FORMATS from wagtail.contrib.redirects.tmp_storages import CacheStorage, TempFolderStorage def write_to_file_storage(import_file, input_format): FileStorage = get_file_storage() file_storage = FileStorage() data ...
50
1,286
openvino
src/frontends/onnx/tests/tests_python/test_ops_matmul.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import onnx from onnx.helper import make_graph, make_model, make_node, make_tensor_value_info import pytest from tests.runtime import get_runtime from tests.tests_python.utils import import_onn...
162
6,450
mlflow
examples/remote_store/remote_server.py
.py
import os import random import shutil import sys import tempfile from mlflow import ( MlflowClient, active_run, get_artifact_uri, get_tracking_uri, log_artifact, log_artifacts, log_metric, log_param, ) if __name__ == "__main__": print(f"Running {sys.argv[0]} with tracking URI {get_...
43
1,198
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/jupyter.py
.py
# --- # jupyter: # jupytext: # cell_markers: '{{{,}}}' # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # # Jupyter notebook # # This notebook is a simple jupyter notebook. It only has markdown and code cells. And it does not contain consecutive markdown cells. We sta...
26
454
beam
sdks/python/apache_beam/examples/snippets/transforms/elementwise/map_context.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");...
84
2,546
mamba
libmambapy/src/libmambapy/solver/libsolv.py
.py
# This file exists on its own rather than in `__init__.py` to make `import libmambapy.solver.libsolv` work. from libmambapy.bindings.solver.libsolv import * # noqa: F403
3
171
coveragepy
coverage/xmlreport.py
.py
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt """XML reporting for coverage.py""" from __future__ import annotations import os import os.path import sys import time import xml.dom.minidom from dataclasses i...
264
9,819
saleor
saleor/tests/e2e/orders/discounts/test_order_voucher_entire_order_cheapest_product.py
.py
import pytest from .....product.tasks import recalculate_discounted_price_for_products_task from ... import DEFAULT_ADDRESS from ...product.utils.preparing_product import prepare_product from ...shop.utils.preparing_shop import prepare_shop from ...taxes.utils import update_country_tax_rates from ...utils import assig...
273
9,742
textual
tests/notifications/test_app_notifications.py
.py
import asyncio from textual.app import App class NotificationApp(App[None]): pass async def test_app_no_notifications() -> None: """An app with no notifications should have an empty notification list.""" async with NotificationApp().run_test() as pilot: assert len(pilot.app._notifications) == 0...
54
1,917
onnxruntime
orttraining/orttraining/python/training/utils/data/sampler.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # sampler.py import math from collections.abc import Callable, Iterator import numpy as np import torch import torch.distributed as dist from torch.utils.data.dataset import Dataset from torch.utils.data.sampler import Sampl...
358
17,342
mlflow
tests/tracing/test_enablement.py
.py
from unittest import mock import pytest import mlflow from mlflow.entities.trace_location import UCSchemaLocation from mlflow.exceptions import MlflowException from mlflow.tracing.enablement import ( set_experiment_trace_location, unset_experiment_trace_location, ) from tests.tracing.helper import skip_when_...
153
6,007
astropy
astropy/cosmology/_src/setup_package.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import sys from os.path import relpath from pathlib import Path from setuptools import Extension ASTROPY_COSMOLOGY_SRC_ROOT = Path(__file__).parent if sys.platform.startswith("win"): # on windows, -Werror (and possibly -Wall too) isn't recognized ...
30
872
wandb
wandb/integration/ultralytics/callback.py
.py
from __future__ import annotations import copy from collections.abc import Callable from datetime import datetime from packaging import version try: import dill as pickle except ImportError: import pickle import wandb from wandb.sdk.lib import telemetry try: import torch import ultralytics from...
531
21,346
openvino
docs/scripts/tests/conftest.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 """ Configuration for tests. Tests for documentation utilize pytest test framework for tests execution and reports generation. Documentation generation tests process Doxygen/Sphinx log to generate test per documentation source file (.h...
140
4,967
pyomo
pyomo/contrib/piecewise/transform/nonlinear_to_pwl.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...
841
33,113
cvxpy
cvxpy/reductions/complex2real/canonicalizers/soc_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...
43
1,583
mlflow
mlflow/utils/time.py
.py
import datetime import time def get_current_time_millis(): """ Returns the time in milliseconds since the epoch as an integer number. """ return int(time.time() * 1000) def conv_longdate_to_str(longdate, local_tz=True): date_time = datetime.datetime.fromtimestamp(longdate / 1000.0) str_long_...
54
1,260
rq
rq/connections.py
.py
from redis import Connection as RedisConnection from redis import Redis class NoRedisConnectionException(Exception): pass # redis-py >= 8 may add maintenance-notification handlers and other derived # connection metadata to connection_kwargs. Those values describe the current # pool's internal state, and some co...
40
1,642
pdm
tests/models/test_locked_repository.py
.py
from __future__ import annotations import pytest from pdm.exceptions import CandidateNotFound from pdm.models.candidates import Candidate from pdm.models.markers import EnvSpec from pdm.models.repositories.lock import LockedRepository, Package from pdm.models.requirements import parse_requirement from pdm.models.spec...
189
7,700
beam
sdks/python/apache_beam/__init__.py
.py
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not us...
107
3,867
astropy
astropy/stats/bayesian_blocks.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Bayesian Blocks for Time Series Analysis. Bayesian Blocks for Time Series Analysis ======================================== Dynamic programming algorithm for solving a piecewise-constant model for various datasets. This is based on the algorithm pres...
603
21,459
saleor
saleor/tests/e2e/orders/test_able_to_update_draft_order_after_bulk_order_creation_with_line_discount.py
.py
import graphene from django.utils import timezone from .. import DEFAULT_ADDRESS from ..product.utils.preparing_product import prepare_product from ..shop.utils.preparing_shop import prepare_shop from ..taxes.utils import update_country_tax_rates from ..utils import assert_address_data, assign_permissions from .utils ...
232
7,566
saleor
saleor/graphql/checkout/tests/mutations/test_checkout_delivery_method_update.py
.py
from datetime import timedelta from decimal import Decimal from unittest import mock from unittest.mock import ANY, patch from uuid import uuid4 import graphene import pytest from django.test import override_settings from django.utils import timezone from .....account.models import Address from .....checkout.actions ...
2,210
71,649
astropy
astropy/io/ascii/mrt.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Classes to read AAS MRT table format. Ref: https://journals.aas.org/mrt-standards :Copyright: Smithsonian Astrophysical Observatory (2021) :Author: Tom Aldcroft (aldcroft@head.cfa.harvard.edu), \ Suyog Garg (suyog7130@gmail.com) """ import r...
688
28,775
pyro
pyro/distributions/transforms/spline_autoregressive.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 from functools import partial import torch from pyro.nn import AutoRegressiveNN, ConditionalAutoRegressiveNN from .. import constraints from ..conditional import ConditionalTransformModule from ..torch_transform import TransformModu...
290
11,370
eve
tests/test_prefix.py
.py
# -*- coding: utf-8 -*- RESOURCE_METHODS = ["GET", "POST"] URL_PREFIX = "prefix" DOMAIN = {"contacts": {}}
6
108
onnxruntime
onnxruntime/python/tools/quantization/CalTableFlatBuffers/KeyValue.py
.py
# automatically generated by the FlatBuffers compiler, do not modify # namespace: CalTableFlatBuffers import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class KeyValue: __slots__ = ["_tab"] @classmethod def GetRootAs(cls, buf, offset=0): # noqa: N802 n = flatbu...
79
2,172
ipython
tests/test_strdispatch.py
.py
"""Tests for IPython.utils.strdispatch.""" import pytest from IPython.utils.strdispatch import StrDispatch def test_s_matches_exact_string(): dis = StrDispatch() dis.add_s("hello", "value1") matches = list(dis.s_matches("hello")) assert "value1" in matches def test_s_matches_no_match_returns_empty...
88
2,275
luigi
luigi/util.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...
472
16,371
wandb
tests/unit_tests/test_artifacts/test_references_gcs.py
.py
from __future__ import annotations import os from pytest import fixture, raises from wandb import Artifact from wandb.sdk.artifacts.artifact_manifest_entry import ArtifactManifestEntry from wandb.sdk.artifacts.artifact_state import ArtifactState from wandb.sdk.artifacts.storage_handlers.gcs_handler import ( GCSHa...
214
6,790
wagtail
wagtail/admin/navigation.py
.py
import swapper from django.conf import settings from wagtail.permissions import policy_registry Page = swapper.load_model("wagtailcore", "Page") def get_site_for_user(user): root_page = policy_registry.get_by_type(Page).explorable_root_instance(user) if root_page: root_site = root_page.get_site() ...
25
683
cvxpy
cvxpy/atoms/affine/sum.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...
169
6,051
onnx
onnx/reference/ops/op_scatternd.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 def _scatter_nd_impl(data, indices, updates, reduction=None): output = np.copy(data) for i in np.ndindex(indices.shape[:-1]): ...
35
1,050
probability
tensorflow_probability/python/layers/masked_autoregressive.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...
146
5,529
wagtail
wagtail/admin/ui/side_panels.py
.py
import swapper from django.conf import settings from django.urls import reverse from django.utils.text import capfirst from django.utils.translation import gettext_lazy, ngettext from wagtail.admin.ui.components import Component from wagtail.admin.userbar import ( AccessibilityItem, ContentCheckerItem, app...
385
14,727
saleor
saleor/tests/e2e/orders/utils/draft_order_create.py
.py
from saleor.graphql.tests.utils import get_graphql_content DRAFT_ORDER_CREATE_MUTATION = """ mutation OrderDraftCreate($input: DraftOrderCreateInput!) { draftOrderCreate(input: $input) { errors { message field code } order { id created status user { id ...
107
1,799
tqdm
tqdm/autonotebook.py
.py
""" Automatically choose between `tqdm.notebook` and `tqdm.std`. Usage: >>> from tqdm.autonotebook import trange, tqdm >>> for i in trange(10): ... ... """ import os import sys from warnings import warn try: if 'ipykernel.zmqshell' in sys.modules: if any(i == 'QT_API' or i.startswith('SPYDER') for i i...
39
1,440
hydra
plugins/hydra_rq_launcher/hydra_plugins/hydra_rq_launcher/rq_launcher.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import logging from typing import Any, Optional, Sequence, cast from hydra.core.utils import JobReturn from hydra.plugins.launcher import Launcher from hydra.types import HydraContext, TaskFunction from omegaconf import DictConfig, OmegaConf from ...
49
1,415
python-prompt-toolkit
src/prompt_toolkit/application/current.py
.py
from __future__ import annotations from collections.abc import Generator from contextlib import contextmanager from contextvars import ContextVar from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from prompt_toolkit.input.base import Input from prompt_toolkit.output.base import Output from .applica...
197
6,236
openvino
tools/ovc/openvino/tools/ovc/convert_impl.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import argparse import datetime import logging as log import os import sys import traceback import tracemalloc from collections import OrderedDict from pathlib import Path from collections.abc import Callable, Iterable try: import o...
590
24,575
probability
tensorflow_probability/python/bijectors/bijector_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...
1,303
49,258
onnx
onnx/reference/ops/aionnxml/op_array_feature_extractor.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from onnx.reference.ops.aionnxml._op_run_aionnxml import OpRunAiOnnxMl def _array_feature_extractor(data, indices): """Implementation of operator *ArrayFeatureExtractor*.""" if len(indices.shap...
48
1,612
pyro
pyro/ops/jit.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import argparse import warnings import weakref import torch import pyro import pyro.poutine as poutine from pyro.util import ignore_jit_warnings, optional, timed def _hash(value, allow_id): try: hash(value) ...
164
5,970
conda
conda/__init__.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """OS-agnostic, system-level binary package manager.""" from __future__ import annotations import os import sys from json import JSONEncoder # noqa: TID251 from os.path import abspath, dirname from typing import TYPE_CHECKING if TYPE_CHECKIN...
256
8,079
mlflow
tests/server/jobs/test_genai_evaluate_invocation.py
.py
# End-to-end tests for `POST /ajax-api/3.0/mlflow/genai/evaluate/invoke`. import json import os import signal import subprocess import sys import threading import time from http.server import BaseHTTPRequestHandler, HTTPServer from typing import Any, Literal import pytest import requests import mlflow from mlflow.en...
312
10,798
beam
sdks/python/apache_beam/examples/snippets/transforms/elementwise/flatmap_side_inputs_dict.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");...
84
2,523
wandb
tests/unit_tests/test_data_types_box3d.py
.py
import numpy as np import pytest from hypothesis import assume, given from hypothesis.strategies import floats, tuples from wandb import data_types small_floats = floats(min_value=-1e5, max_value=1e5) quaternions = tuples( small_floats, small_floats, small_floats, small_floats, ) @given( center=t...
88
2,675
saleor
saleor/account/validators.py
.py
from django.core.exceptions import ValidationError from phonenumber_field.phonenumber import to_python from phonenumbers.phonenumberutil import is_possible_number from .error_codes import AccountErrorCode def validate_possible_number(phone, country=None): phone_number = to_python(phone, country) if ( ...
20
597
astropy
astropy/io/fits/_logical_helpers.py
.py
"""Helpers for handling FITS logical (``'L'``) variable-length array data.""" import warnings import numpy as np from astropy.utils.exceptions import AstropyDeprecationWarning _VALID_LOGICAL_BYTES = (ord("T"), ord("F"), 0) def _validate_logical_input(row): """Validate user input for a FITS logical column. ...
154
5,813
pyomo
pyomo/solvers/plugins/solvers/GUROBI.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...
840
33,044
httpie
tests/test_redirects.py
.py
"""High-level tests.""" import pytest from httpie.compat import is_windows from httpie.status import ExitStatus from .fixtures import FILE_PATH_ARG, FILE_CONTENT from .utils import http, HTTP_OK from .utils.matching import assert_output_matches, Expect, ExpectSequence # <https://developer.mozilla.org/en-US/docs/Web/...
117
3,537
astropy
astropy/utils/diff.py
.py
import difflib import functools import math import sys from textwrap import indent import numpy as np __all__ = [ "diff_values", "report_diff_values", "where_not_allclose", ] def diff_values(a, b, rtol=0.0, atol=0.0): """ Diff two scalar values. If both values are floats, they are compared to ...
214
6,225
toolz
bench/test_frequencies.py
.py
from toolz import frequencies, identity big_data = list(range(1000)) * 1000 small_data = list(range(100)) def test_frequencies(): frequencies(big_data) def test_frequencies_small(): for i in range(1000): frequencies(small_data)
15
250
scikit-bio
skbio/alignment/tests/test_pairwise.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. # --------------------------------------------...
774
35,402
mlflow
tests/server/auth/test_sqlalchemy_store.py
.py
import pytest from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import ( INVALID_PARAMETER_VALUE, RESOURCE_ALREADY_EXISTS, RESOURCE_DOES_NOT_EXIST, ErrorCode, ) from mlflow.server.auth.entities import User from mlflow.server.auth.permissions import EDIT, MANAGE, READ, USE ...
412
15,650
saleor
saleor/graphql/app/tests/test_utils.py
.py
import pytest from django.core.exceptions import ValidationError from ....app.error_codes import AppErrorCode from ....permission.enums import ( AccountPermissions, AppPermission, OrderPermissions, ProductPermissions, ) from ..utils import ensure_app_permissions_allowed def test_ensure_app_permission...
68
2,295
wagtail
wagtail/contrib/search_promotions/apps.py
.py
from django.apps import AppConfig from django.utils.translation import gettext_lazy as _ class WagtailSearchPromotionsAppConfig(AppConfig): name = "wagtail.contrib.search_promotions" label = "wagtailsearchpromotions" verbose_name = _("Wagtail search promotions") default_auto_field = "django.db.models....
10
331
wagtail
wagtail/admin/tests/ui/test_sidebar.py
.py
from unittest import TestCase from django.test import TestCase as DjangoTestCase from django.urls import reverse from wagtail.admin.search import SearchArea from wagtail.admin.telepath import JSContext from wagtail.admin.ui.sidebar import ( ActionMenuItem, LinkMenuItem, MainMenuModule, PageExplorerMen...
264
8,697
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_reduce_all.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # reduce_all paddle model generator # import numpy as np import sys from save_model import saveModel def reduce_all(name : str, x, axis=None, keepdim=False): import paddle paddle.enable_static() with paddle.static.progr...
52
1,666
mlflow
dev/clint/tests/rules/test_unknown_mlflow_function.py
.py
from pathlib import Path import pytest from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.unknown_mlflow_function import UnknownMlflowFunction def test_unknown_mlflow_function(index: SymbolIndex) -> None: code = ''' def bad(): ...
69
1,507
saleor
saleor/product/tests/fixtures/__init__.py
.py
from .category import * # noqa: F403 from .collection import * # noqa: F403 from .product import * # noqa: F403 from .product_media import * # noqa: F403 from .product_type import * # noqa: F403 from .variant import * # noqa: F403
7
237
saleor
saleor/graphql/webhook/tests/queries/test_event_delivery_filter.py
.py
import graphene from .....core import EventDeliveryStatus from ....tests.utils import get_graphql_content EVENT_DELIVERY_FILTER_QUERY = """ query webhook( $id: ID! $first: Int, $last: Int, $after: String, $before: String, $filters: EventDeliveryFilterInput! ){ webhook(id: $id){ ...
73
2,054
records
tests/conftest.py
.py
"""Shared pytest fixtures. """ import pytest import records @pytest.fixture( params=[ # request: (sql_url_id, sql_url_template) ("sqlite_memory", "sqlite:///:memory:"), # ('sqlite_file', 'sqlite:///{dbfile}'), # ('psql', 'postgresql://records:records@localhost/records') ], ...
50
1,252
saleor
saleor/graphql/core/federation/resolvers.py
.py
from typing import Any import graphene from django.core.exceptions import ValidationError from graphql.error import GraphQLError from ..utils import from_global_id_or_error def resolve_id_or_error(idx: Any, graphql_type: type[graphene.ObjectType] | str): # Note: 'graphene.GlobalID' type happens when a user prov...
36
1,267
eve
examples/security/hmac.py
.py
# -*- coding: utf-8 -*- """ Auth-HMAC ~~~~~~~~~ Securing an Eve-powered API with HMAC based Authentication. The ``eve.auth.HMACAuth`` class allows for custom Amazon S3-like authentication, which is basically a very secure custom authentication scheme built around the `Authorization` header. ...
76
2,865
probability
tensorflow_probability/python/distributions/vector_exponential_linear_operator.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...
341
12,924
wagtail
wagtail/snippets/permissions.py
.py
from django.contrib.auth import get_permission_codename from wagtail.permissions import policy_registry from wagtail.snippets.models import get_snippet_models def get_permission_name(action, model): return "{}.{}".format( model._meta.app_label, get_permission_codename(action, model._meta), ) ...
39
1,104
pyomo
pyomo/core/expr/expr_errors.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
770
mlflow
examples/pyspark_ml_connect/pipeline.py
.py
from pyspark.ml.connect.classification import LogisticRegression from pyspark.ml.connect.feature import StandardScaler from pyspark.ml.connect.pipeline import Pipeline from pyspark.sql import SparkSession from sklearn import datasets import mlflow spark = SparkSession.builder.remote("local[2]").getOrCreate() scaler ...
38
1,337
wagtail
wagtail/admin/tests/test_jinja2.py
.py
from django.contrib.auth.models import AnonymousUser from django.template import engines from django.test import TestCase from wagtail.coreutils import get_dummy_request from wagtail.models import PAGE_TEMPLATE_VAR, Site from wagtail.test.utils import Page, WagtailTestUtils class TestCoreJinja(WagtailTestUtils, Test...
50
1,586
jupytext
tests/unit/test_labconfig.py
.py
import json import pytest from jupytext_config.labconfig import LabConfig @pytest.fixture() def sample_viewer_config(): return { "@jupyterlab/docmanager-extension:plugin": { "defaultViewers": { "markdown": "Jupytext Notebook", "myst": "Jupytext Notebook", ...
54
1,646