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/units/tests/test_deprecated.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import warnings
import pytest
from astropy import units as u
from astropy.units import deprecated
from astropy.utils.exceptions import AstropyDeprecationWarning
with warnings.catch_warnings(action="ignore", category=AstropyDeprecationWarning):
emu ... | 71 | 2,053 |
saleor | saleor/graphql/product/tests/queries/products_filtrations/test_over_attributes.py | .py | import graphene
import pytest
from ......attribute.utils import associate_attribute_values_to_instance
from .....tests.utils import get_graphql_content
from .shared import PRODUCTS_FILTER_QUERY, PRODUCTS_WHERE_QUERY
@pytest.mark.parametrize("query", [PRODUCTS_WHERE_QUERY, PRODUCTS_FILTER_QUERY])
def test_products_qu... | 167 | 4,626 |
saleor | saleor/graphql/page/tests/queries/test_pages_search.py | .py | import graphene
import pytest
from .....attribute.utils import associate_attribute_values_to_instance
from .....page.models import Page
from .....page.search import update_pages_search_vector
from .....tests.utils import dummy_editorjs
from ....tests.utils import get_graphql_content
QUERY_PAGES_WITH_SEARCH = """
... | 407 | 11,517 |
sqlmap | tests/test_sparql.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Offline, deterministic tests for the SPARQL injection engine. A mock oracle mirrors the boolean-blind
semantics of a real triple store (a broken-out FILTER reduced to its injected pre... | 385 | 17,536 |
mlflow | mlflow/gateway/providers/openai_compatible.py | .py | """
Base provider for OpenAI-compatible APIs.
Many LLM providers (Groq, DeepSeek, xAI, etc.) expose APIs that follow the
OpenAI chat/completions/embeddings format. This module provides a reusable
base class so that adding a new such provider requires only a config class,
a DISPLAY_NAME, and a default base URL.
"""
fr... | 386 | 13,935 |
mlflow | mlflow/deployments/cli.py | .py | import json
import sys
from inspect import signature
import click
from mlflow.deployments import interface
from mlflow.mcp.decorator import mlflow_mcp
from mlflow.utils import cli_args
from mlflow.utils.proto_json_utils import NumpyEncoder, _get_jsonable_obj
def _user_args_to_dict(user_list):
# Similar function... | 483 | 16,131 |
wagtail | wagtail/utils/urlpatterns.py | .py | from functools import update_wrapper
def decorate_urlpatterns(urlpatterns, decorator):
"""Decorate all the views in the passed urlpatterns list with the given decorator"""
for pattern in urlpatterns:
if hasattr(pattern, "url_patterns"):
# this is an included RegexURLResolver; recursively d... | 18 | 629 |
saleor | saleor/graphql/app/tests/benchmarks/test_app_extensions.py | .py | import pytest
from .....app.models import AppExtension
from ....tests.utils import get_graphql_content
@pytest.mark.count_queries(autouse=False)
def test_app_extensions(
staff_api_client,
app,
permission_manage_products,
count_queries,
):
# given
query = """
query{
appExtensions(f... | 148 | 3,697 |
hatch | release/macos/build_pkg.py | .py | """
This script must be run from the root of the repository.
At a high level, the goal is to have a directory that emulates the full path structure of the
target machine which then gets packaged by tools that are only available on macOS.
"""
from __future__ import annotations
import argparse
import shutil
import sub... | 120 | 3,959 |
sphinx | sphinx/util/fileutil.py | .py | """File utility functions for Sphinx."""
from __future__ import annotations
import os
import posixpath
from pathlib import Path
from typing import TYPE_CHECKING
from sphinx.locale import __
from sphinx.util import logging
from sphinx.util.osutil import _relative_path, copyfile, ensuredir
if TYPE_CHECKING:
from ... | 169 | 5,707 |
pyro | pyro/contrib/__init__.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
r"""
Contributed Code
================
.. warning:: Code in ``pyro.contrib`` is under various stages of development.
This code makes no guarantee about maintaining backwards compatibility.
"""
from pyro.contrib import (
a... | 43 | 693 |
confluent-kafka-python | src/confluent_kafka/aio/_AIOConsumer.py | .py | # Copyright 2025 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 required by applicable law or agreed to in writing, s... | 182 | 7,579 |
mlflow | mlflow/metrics/base.py | .py | from dataclasses import dataclass
import numpy as np
from mlflow.utils.validation import _is_numeric
def standard_aggregations(scores):
return {
"mean": np.mean(scores),
"variance": np.var(scores),
"p90": np.percentile(scores, 90),
}
@dataclass
class MetricValue:
"""
The va... | 39 | 1,015 |
sphinx | tests/roots/test-util-copyasset_overwrite/myext.py | .py | from pathlib import Path
from sphinx.util.fileutil import copy_asset
def _copy_asset_overwrite_hook(app):
css = app.outdir / '_static' / 'custom-styles.css'
# html_static_path is copied by default
css_content = css.read_text(encoding='utf-8')
assert css_content == '/* html_static_path */\n', 'invalid... | 25 | 823 |
python-prompt-toolkit | tests/test_completion.py | .py | from __future__ import annotations
import os
import re
import shutil
import tempfile
from contextlib import contextmanager
from prompt_toolkit.completion import (
CompleteEvent,
FuzzyWordCompleter,
NestedCompleter,
PathCompleter,
WordCompleter,
merge_completers,
)
from prompt_toolkit.document ... | 470 | 15,098 |
saleor | saleor/checkout/tests/fixtures/checkout_info.py | .py | import pytest
from ....plugins.manager import get_plugins_manager
from ...fetch import CheckoutInfo, fetch_checkout_info, fetch_checkout_lines
@pytest.fixture
def checkout_info(checkout_lines_info):
manager = get_plugins_manager(allow_replica=False)
checkout = checkout_lines_info[0].line.checkout
checkou... | 35 | 1,098 |
pyomo | pyomo/common/tests/test_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... | 196 | 7,173 |
readthedocs.org | readthedocs/core/templatetags/privacy_tags.py | .py | """Template tags to query projects by privacy."""
from django import template
from readthedocs.core.permissions import AdminPermission
from readthedocs.projects.models import Project
register = template.Library()
@register.filter
def is_admin(user, project):
return AdminPermission.is_admin(user, project)
@r... | 30 | 705 |
beam | sdks/python/apache_beam/runners/portability/flink_runner.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... | 127 | 4,761 |
wagtail | wagtail/tests/test_jinja2.py | .py | from django.template import engines
from django.template.loader import render_to_string
from django.test import TestCase
from django.utils.safestring import mark_safe
from wagtail import __version__, blocks
from wagtail.coreutils import get_dummy_request
from wagtail.models import Site
from wagtail.test.testapp.blocks... | 314 | 10,620 |
onnxruntime | onnxruntime/python/tools/qnn/gen_qnn_ctx_onnx_model.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import json
from argparse import ArgumentParser
import onnx
from onnx i... | 365 | 16,198 |
mlflow | mlflow/store/jobs/abstract_store.py | .py | from abc import ABC, abstractmethod
from typing import Any, Iterator
from mlflow.entities._job import Job
from mlflow.entities._job_status import JobStatus
from mlflow.utils.annotations import developer_stable
@developer_stable
class AbstractJobStore(ABC):
"""
Abstract class that defines API interfaces for s... | 189 | 6,051 |
wandb | wandb/apis/public/files.py | .py | """W&B Public API for File objects.
This module provides classes for interacting with files stored in W&B.
Example:
```python
from wandb.apis.public import Api
# Get files from a specific run
run = Api().run("entity/project/run_id")
files = run.files()
# Work with files
for file in files:
print(f"File: {file.na... | 387 | 12,417 |
jupyterlab | buildapi.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
# Custom build target that removes .js.map files for published
# dist files.
import glob
import json
import os
import subprocess
from collections.abc import Sequence
from hatch_jupyter_builder import npm_builder
from ... | 48 | 1,364 |
python-dotenv | src/dotenv/parser.py | .py | import codecs
import re
from typing import (
IO,
Iterator,
Match,
NamedTuple,
Optional,
Pattern,
Sequence,
)
def make_regex(string: str, extra_flags: int = 0) -> Pattern[str]:
return re.compile(string, re.UNICODE | extra_flags)
_newline = make_regex(r"(\r\n|\n|\r)")
_multiline_whites... | 183 | 5,202 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Concat.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from common.tf_layer_test_class import CommonTFLayerTest
class TestConcat(CommonTFLayerTest):
def create_concat_net(self, input_shapes, axis, is_v2, ir_version):
# tf.concat is equivalent to tf.raw_ops.Concat... | 99 | 4,235 |
openvino | src/frontends/tensorflow_lite/tests/test_models/gen_scripts/generate_qdq.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import tensorflow as tf
# Model:
# (float32)tensor_0[12] -> QUANTIZE -> (int8)tensor[12] -> DEQUANTIZE -> (float32)tensor_1[12]
# QUANTIZE:
# scale: 0.25
# zero point: 16
sm_path = os.path.join(sys.argv[1], "qd... | 28 | 4,691 |
cvxpy | cvxpy/reductions/chain.py | .py | from cvxpy import settings as s
from cvxpy.reductions.reduction import Reduction
def _compose_id_map(step_maps):
"""Compose a sequence of ``{old_id: [new_id, ...]}`` mappings.
Each step map comes from a reduction's ``var_id_map`` or
``param_id_map``. The result is a single mapping from the
outermost... | 162 | 5,525 |
saleor | saleor/graphql/csv/mutations/base_export.py | .py | from collections.abc import Mapping
import graphene
from django.core.exceptions import ValidationError
from ...core.enums import ExportErrorCode
from ...core.mutations import BaseMutation
from ..enums import ExportScope
from ..types import ExportFile
class BaseExportMutation(BaseMutation):
export_file = graphen... | 60 | 1,976 |
hatch | src/hatch/env/lockers/interface.py | .py | from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from hatch.env.plugin.interface import EnvironmentInterface
from hatch.utils.fs import Path
class LockerInterface(ABC):
"""
Pluggable dependency locker.
Implementations are ... | 77 | 2,323 |
ipython | tests/test_wildcard.py | .py | """Some tests for the wildcard utilities."""
import pytest
from IPython.utils import wildcard
class obj_t(object):
pass
root = obj_t()
l = ["arna", "abel", "ABEL", "active", "bob", "bark", "abbot"]
q = ["kate", "loop", "arne", "vito", "lucifer", "koppel"]
for x in l:
o = obj_t()
setattr(root, x, o)
... | 119 | 3,447 |
cvxpy | cvxpy/reductions/dgp2dcp/canonicalizers/norm1_canon.py | .py | from cvxpy.atoms.affine.sum import sum
from cvxpy.reductions.dgp2dcp.canonicalizers.sum_canon import sum_canon
def norm1_canon(expr, args):
assert len(args) == 1
tmp = sum(args[0], expr.axis, expr.keepdims)
return sum_canon(tmp, tmp.args)
| 9 | 253 |
beam | sdks/python/apache_beam/ml/rag/__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... | 26 | 1,018 |
pymc | pymc/stats/convergence.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... | 211 | 6,585 |
mlflow | mlflow/store/db_migrations/versions/c9d4e5f6a7b8_add_routing_strategy_to_endpoints.py | .py | """add routing strategy to endpoints and linkage type to mappings
Create Date: 2025-12-18 00:00:00.000000
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "c9d4e5f6a7b8"
down_revision = "5d2d30f0abce"
branch_labels = None
depends_on = None
def upgrade():
#... | 55 | 2,048 |
saleor | saleor/graphql/order/tests/queries/test_fulfillment.py | .py | from decimal import Decimal
import graphene
from .....order import FulfillmentStatus
from ....tests.utils import assert_no_permission, get_graphql_content
QUERY_FULFILLMENT = """
query fulfillment($id: ID!) {
order(id: $id) {
fulfillments {
id
fulfillmentOrder
... | 157 | 4,827 |
beam | sdks/python/apache_beam/io/filesystemio_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... | 248 | 7,688 |
pyomo | examples/pyomobook/abstract-ch/ex.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... | 21 | 719 |
sphinx | tests/test_ext_autodoc/test_ext_autodoc_mock.py | .py | """Test the autodoc extension."""
from __future__ import annotations
import abc
import sys
from importlib import import_module
from typing import Generic, TypeVar
import pytest
from sphinx.ext.autodoc._dynamic._mock import (
_MockModule,
_MockObject,
ismock,
mock,
undecorate,
)
def test_MockMo... | 190 | 5,264 |
textual | docs/examples/guide/reactivity/refresh03.py | .py | from textual.app import App, ComposeResult
from textual.reactive import reactive
from textual.widget import Widget
from textual.widgets import Input, Label
class Name(Widget):
"""Generates a greeting."""
who = reactive("name", recompose=True) # (1)!
def compose(self) -> ComposeResult: # (2)!
y... | 30 | 696 |
pyomo | examples/pyomobook/test_book_examples.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 154 | 6,535 |
wagtail | runtests.py | .py | #!/usr/bin/env python
import argparse
import os
import shutil
import sys
import warnings
from django.core.management import execute_from_command_line
os.environ["DJANGO_SETTINGS_MODULE"] = "wagtail.test.settings"
def make_parser():
parser = argparse.ArgumentParser()
parser.add_argument(
"--deprecat... | 114 | 3,889 |
sqlmap | plugins/dbms/snowflake/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 lib.core.exception import SqlmapUnsupportedFeatureException
from plugins.generic.enumeration import Enumeration as GenericEnumeration
class ... | 32 | 1,000 |
probability | tensorflow_probability/python/distributions/markov_chain_test.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... | 449 | 20,455 |
omegaconf | omegaconf/_yaml.py | .py | import os
import pathlib
import re
from typing import Any, Dict, Optional
import yaml
try:
from yaml import CSafeLoader
BaseLoader = CSafeLoader
except ImportError: # pragma: no cover
BaseLoader = yaml.SafeLoader
# This URL is also spelled out in public OmegaConf docstrings so IDE/help() views
# show i... | 311 | 12,200 |
pyro | pyro/settings.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
"""
Example usage::
# Simple getting and setting.
print(pyro.settings.get()) # print all settings
print(pyro.settings.get("cholesky_relative_jitter")) # print one
pyro.settings.set(cholesky_relative_jitter=0.5) # se... | 164 | 5,019 |
black | tests/data/cases/fstring_quotations.py | .py | # Regression tests for long f-strings, including examples from issue #3623
a = (
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
f'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"{"b"}"'
)
a = (
f'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"{"b"}"'... | 68 | 1,664 |
saleor | saleor/tax/error_codes.py | .py | from enum import Enum
class TaxExemptionManageErrorCode(Enum):
GRAPHQL_ERROR = "graphql_error"
INVALID = "invalid"
NOT_FOUND = "not_found"
NOT_EDITABLE_ORDER = "not_editable_order"
class TaxConfigurationUpdateErrorCode(Enum):
DUPLICATED_INPUT_ITEM = "duplicated_input_item"
GRAPHQL_ERROR = "g... | 49 | 1,251 |
returns | tests/test_examples/test_result/test_result_pattern_matching.py | .py | from returns.result import Failure, Success, safe
@safe
def div(first_number: int, second_number: int) -> int:
return first_number // second_number
match div(1, 0):
# Matches if the result stored inside `Success` is `10`
case Success(10):
print('Result is "10"')
# Matches any `Success` inst... | 25 | 698 |
saleor | saleor/graphql/tests/utils.py | .py | import json
from django.core.serializers.json import DjangoJSONEncoder
def get_graphql_content_from_response(response):
return json.loads(response.content.decode("utf8"))
def get_graphql_content(response, *, ignore_errors: bool = False):
"""Extract GraphQL content from the API response.
Optionally ign... | 73 | 2,370 |
cvxpy | cvxpy/tests/test_dcp2cone_cse.py | .py | """
Copyright, the CVXPY authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
... | 260 | 10,734 |
cvxpy | cvxpy/tests/test_kron_canon.py | .py | """
Copyright 2022, the CVXPY 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 law or agreed to in writing, ... | 198 | 7,580 |
pynacl | src/nacl/bindings/crypto_secretbox.py | .py | # Copyright 2013 Donald Stufft and individual contributors
#
# 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... | 157 | 4,841 |
mlflow | dev/build.py | .py | import argparse
import contextlib
import shutil
import subprocess
import sys
import zipfile
from collections.abc import Generator
from dataclasses import dataclass
from pathlib import Path
@dataclass(frozen=True)
class Package:
# name of the package on PyPI.
pypi_name: str
# type of the package, one of "d... | 141 | 4,044 |
pyomo | pyomo/common/tests/test_gc.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... | 74 | 2,573 |
scikit-bio | doc/metatag.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.
# --------------------------------------------... | 69 | 2,023 |
mlflow | mlflow/entities/_job.py | .py | import json
from typing import Any
from mlflow.entities._job_status import JobStatus
from mlflow.entities._mlflow_object import _MlflowObject
from mlflow.utils.workspace_utils import resolve_entity_workspace_name
class Job(_MlflowObject):
"""
MLflow entity representing a Job.
"""
def __init__(
... | 122 | 3,616 |
ipython | tests/test_interactivshell.py | .py | # -*- coding: utf-8 -*-
"""Tests for the TerminalInteractiveShell and related pieces."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import sys
import os
import pytest
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from IPython.testing import... | 234 | 6,825 |
openvino | tests/model_hub_tests/pytorch/conftest.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import inspect
from models_hub_common.utils import get_params
def pytest_generate_tests(metafunc):
test_gen_attrs_names = list(inspect.signature(get_params).parameters)
params = get_params()
metafunc.parametrize(test_gen_a... | 13 | 358 |
mlflow | mlflow/telemetry/events.py | .py | import inspect
import os
import sys
from collections import Counter
from enum import Enum
from typing import TYPE_CHECKING, Any
from urllib.parse import urlparse
from mlflow.entities import Feedback
from mlflow.entities.issue import IssueSeverity, IssueStatus
from mlflow.entities.mcp_server import MCPStatus
from mlflo... | 940 | 29,762 |
probability | spinoffs/fun_mc/fun_mc/fun_mc_lib.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... | 3,525 | 113,767 |
onnxruntime | tools/python/compile_contributors.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Compile Contributors Script
---------------------------
Description:
This script compiles contributor information by comparing two git branches/commits.
It identifies Pull Requests, handles cherry-picked commits (... | 519 | 20,958 |
voila | tests/app/preprocessor_test.py | .py | # tests the --template argument of Voilà
import os
import pytest
@pytest.fixture
def voila_notebook(notebook_directory):
return os.path.join(notebook_directory, "skip-voila-cell.ipynb")
@pytest.fixture
def voila_args_extra():
return ["--template=skip_template"]
async def test_markdown_preprocessor(http_s... | 23 | 570 |
scikit-optimize | conftest.py | .py | # Even if empty this file is useful so that when running from the root folder
# ./sklearn is added to sys.path by pytest. See
# https://docs.pytest.org/en/latest/pythonpath.html for more details. For
# example, this allows to build extensions in place and run pytest
# doc/modules/clustering.rst and use sklearn from th... | 84 | 2,871 |
readthedocs.org | readthedocs/constants.py | .py | """Common constants."""
import re
from readthedocs.builds.version_slug import VERSION_SLUG_REGEX
from readthedocs.projects.constants import DOWNLOADABLE_MEDIA_TYPES
from readthedocs.projects.constants import LANGUAGES_REGEX
from readthedocs.projects.constants import PROJECT_SLUG_REGEX
from readthedocs.projects.consta... | 21 | 692 |
pyomo | doc/OnlineDocs/src/data/import8.tab.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... | 25 | 1,029 |
probability | tensorflow_probability/python/internal/distribution_util.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,491 | 57,599 |
openvino | src/bindings/python/src/openvino/frontend/jax/jaxpr_decoder.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# flake8: noqa
# mypy: ignore-errors
import jax
from packaging import version
if version.parse(jax.__version__) < version.parse("0.6.0"):
import jax as jex
import jax.core
else:
import jax.extend as jex
from openvino.fron... | 304 | 11,798 |
conda | tests/cli/test_main_clean.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import json
from datetime import datetime, timezone
from logging import WARNING
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from conda.base.constants import (
CONDA_LOGS_DIR,
... | 431 | 12,490 |
beam | sdks/python/apache_beam/examples/kafkataxi/kafka_taxi.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... | 176 | 5,914 |
pyomo | pyomo/contrib/appsi/tests/test_legacy_leak.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... | 80 | 2,919 |
onnxruntime | tools/python/util/pytorch_export_helpers.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
import inspect
from collections import abc
import torch
def _parse_inputs_for_onnx_export(all_input_parameters, inputs, kwargs):
# extracted from https://github.com/microsoft/onnxrun... | 134 | 5,876 |
pyomo | pyomo/solvers/tests/mip/test_asl.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... | 145 | 4,699 |
coremltools | deps/protobuf/python/google/protobuf/message_factory.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... | 186 | 7,482 |
django-cms | cms/test_utils/util/context_managers.py | .py | import sys
from contextlib import contextmanager
from io import StringIO
from shutil import rmtree as _rmtree
from tempfile import _exists, mkdtemp, template
from django.contrib.auth import get_user_model
from django.test.utils import override_settings
from django.utils.translation import activate, get_language
from ... | 189 | 5,033 |
openvino | docs/articles_en/assets/snippets/ov_model_pass.py | .py | # ! [model_pass:ov_model_pass_py]
'''
``ModelPass`` can be used as a base class for transformation classes that take entire ``Model`` and proceed with it.
To create transformation, you need to:
1. Define a class with ``ModelPass`` as a parent.
2. Redefine the run_on_model method that will receive ``Model`` as an argum... | 47 | 1,490 |
openvino | tests/layer_tests/pytorch_tests/test_svd.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
import openvino as ov
from pytorch_layer_test_class import PytorchLayerTest
class TestSVDReconstruction(PytorchLayerTest):
"""aten::svd — batched 3x3 singular value decomposition.
... | 203 | 9,733 |
sphinx | tests/roots/test-ext-autosummary-mock_imports/foo.py | .py | import unknown
class Foo(unknown.Class):
"""Foo class"""
pass
| 8 | 73 |
mlflow | tests/store/tracking/sqlalchemy_store/test_sqlalchemy_store_traces.py | .py | import contextlib
import json
import random
import re
import threading
import time
import uuid
from collections.abc import Callable
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from unittest import mock
import pytest
import sqlalchemy
from opentelemetry import trace as trace_api
from open... | 10,762 | 388,594 |
hatch | src/hatch/utils/linehaul.py | .py | from __future__ import annotations
import json
import os
import platform
import sys
from functools import lru_cache
from typing import Any
from hatch._version import __version__
def get_linehaul_data() -> dict[str, Any]:
data: dict[str, Any] = {
"installer": {"name": "hatch", "version": __version__},
... | 137 | 3,579 |
black | tests/data/cases/slices.py | .py | slice[a.b : c.d]
slice[d :: d + 1]
slice[d + 1 :: d]
slice[d::d]
slice[0]
slice[-1]
slice[:-1]
slice[::-1]
slice[:c, c - 1]
slice[c, c + 1, d::]
slice[ham[c::d] :: 1]
slice[ham[cheese**2 : -1] : 1 : 1, ham[1:2]]
slice[:-1:]
slice[lambda: None : lambda: None]
slice[lambda x, y, *args, really=2, **kwargs: None :, None::]... | 32 | 787 |
wandb | tests/system_tests/test_launch/conftest.py | .py | import pytest
from wandb.apis.public.service_api import ServiceApi
from wandb.cli import cli
from wandb.proto.wandb_api_pb2 import (
ApiRequest,
CreateRunQueueRequest,
RunQueueOperationRequest,
)
@pytest.fixture(autouse=True)
def _clear_cli_api(monkeypatch: pytest.MonkeyPatch) -> None:
"""Reset cli._a... | 51 | 1,546 |
metrics | src/torchmetrics/detection/_mean_ap.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... | 989 | 43,130 |
sqlmap | lib/request/inject.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from __future__ import print_function
import re
import threading
import time
from lib.core.agent import agent
from lib.core.bigarray import BigArray
from lib.core.common import ... | 859 | 40,823 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_activation.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasActivation(CommonTF2LayerTest):
def create_keras_activation_net(self, activation_func, input_names, input_shapes, inpu... | 79 | 3,961 |
mlflow | dev/pypi/tests/conftest.py | .py | from collections.abc import Iterator
import pypi
import pytest
@pytest.fixture(autouse=True)
def _clear_caches() -> Iterator[None]:
pypi.clear_cache()
yield
pypi.clear_cache()
| 12 | 191 |
cvxpy | cvxpy/reductions/discrete2mixedint/valinvec2mixedint.py | .py | """
Copyright, the CVXPY authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | 87 | 2,724 |
toolz | bench/test_memoize_kwargs.py | .py | from toolz import memoize
def test_memoize_kwargs():
@memoize
def f(x, y=3):
return x
for i in range(100000):
f(3)
| 11 | 146 |
mlflow | mlflow/utils/thread_utils.py | .py | import contextvars
import os
import threading
from collections.abc import Callable, Iterable
from concurrent.futures import ThreadPoolExecutor
from typing import Any, TypeVar
T = TypeVar("T")
R = TypeVar("R")
class ThreadLocalVariable:
"""
Class for creating a thread local variable.
Args:
defaul... | 86 | 2,932 |
returns | tests/test_examples/test_your_container/test_pair3.py | .py | from abc import abstractmethod
from collections.abc import Callable
from typing import Never, TypeVar, final
from returns.interfaces import bindable, equable, lashable, swappable
from returns.primitives.container import BaseContainer, container_equality
from returns.primitives.hkt import Kind2, KindN, SupportsKind2, d... | 210 | 5,966 |
pyomo | pyomo/solvers/plugins/converter/model.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... | 260 | 10,711 |
python-prompt-toolkit | src/prompt_toolkit/styles/pygments.py | .py | """
Adaptor for building prompt_toolkit styles, starting from a Pygments style.
Usage::
from pygments.styles.tango import TangoStyle
style = style_from_pygments_cls(pygments_style_cls=TangoStyle)
"""
from __future__ import annotations
from typing import TYPE_CHECKING
from .style import Style
if TYPE_CHECK... | 71 | 1,974 |
clearml | clearml/backend_api/session/client/__init__.py | .py | from .client import APIClient, StrictSession, APIError
__all__ = ["APIClient", "StrictSession", "APIError"]
| 4 | 109 |
jupytext | src/jupytext/metadata_filter.py | .py | """Notebook and cell metadata filtering"""
from copy import copy
from .cell_metadata import _JUPYTEXT_CELL_METADATA, is_valid_metadata_key
_DEFAULT_NOTEBOOK_METADATA = ",".join(
[
# Preserve Jupytext section
"jupytext",
# Preserve kernel specs
"kernelspec",
# Kernel_info f... | 257 | 9,534 |
wagtail | wagtail/api/v3/schemas/__init__.py | .py | from .base import (
BaseMetaSchema,
BaseSchema,
ContentTypeSummarySchema,
DiscriminatedUnionSchemas,
build_union_schemas,
discriminate_meta_type,
)
from .generators import create_generator, patch_generator, read_generator
from .pages import (
BasePageSchema,
PageCreateBaseSchema,
Pag... | 41 | 937 |
clearml | examples/reporting/image_reporting.py | .py | # ClearML - Example of manual graphs and statistics reporting
#
import os
import numpy as np
from PIL import Image
from clearml import Task, Logger
def report_debug_images(logger, iteration=0):
# type: (Logger, int) -> ()
"""
reporting images to debug samples section
:param logger: The task.logger ... | 69 | 2,193 |
pyomo | pyomo/contrib/appsi/solvers/cbc.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... | 495 | 17,801 |
onnxruntime | orttraining/orttraining/python/training/ortmodule/_torch_module_ort.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# _torch_module_ort.py
from collections import OrderedDict
from collections.abc import Callable, Iterator
from logging import Logger
from typing import Optional, TypeVar
import torch
from typing_extensions import Self
from ... | 184 | 8,336 |
beam | learning/tour-of-beam/learning-content/core-transforms/map/co-group-by-key/python-example/task.py | .py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); y... | 80 | 2,638 |
textual | tests/text_area/test_edit_via_bindings.py | .py | """Tests some edits using the keyboard.
All tests in this module should press keys on the keyboard which edit the document,
and check that the document content is updated as expected, as well as the cursor
location.
Note that more extensive testing for editing is done at the Document level.
"""
import pytest
from t... | 632 | 19,915 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.