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 |
|---|---|---|---|---|---|
mlflow | tests/store/artifact/test_s3_artifact_repo.py | .py | import json
import os
import posixpath
import tarfile
import urllib.parse
from datetime import datetime, timezone
from unittest import mock
from unittest.mock import ANY
import botocore.exceptions
import pytest
import requests
from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan
from mlflow.entities i... | 1,163 | 45,245 |
readthedocs.org | tasks.py | .py | """Read the Docs tasks."""
import os
from invoke import Collection
from invoke import task
import common.dockerfiles.tasks
import common.tasks
ROOT_PATH = os.path.dirname(__file__)
namespace = Collection()
namespace.add_collection(
Collection(
common.tasks.setup_labels,
),
name="github",
)
... | 95 | 2,169 |
wagtail | wagtail/test/customuser/tests.py | .py | import json
import unittest
from django.conf import settings
from django.db import connections
from django.test import TestCase
from wagtail.test.utils import WagtailTestUtils
from .fields import ConvertedValue, ConvertedValueField
@unittest.skipUnless(
settings.AUTH_USER_MODEL == "customuser.CustomUser", "Onl... | 48 | 1,661 |
mlflow | tests/llama_index/sample_code/external_vector_store.py | .py | """
Sample code to define an index using an external vector store (Faiss) for model-from-code logging.
Ref: https://qdrant.tech/documentation/quickstart/
"""
from llama_index.core import VectorStoreIndex
from llama_index.vector_stores.qdrant import QdrantVectorStore
from qdrant_client import QdrantClient
from qdrant_... | 37 | 1,078 |
django-cms | cms/test_utils/project/app_with_two_cms_feature_classes/apps.py | .py | from django.apps import AppConfig
class TwoCMSAppClassesConfig(AppConfig):
name = 'cms.test_utils.project.app_with_two_cms_feature_classes'
label = 'app_with_two_cms_feature_classes'
| 7 | 193 |
cvxpy | cvxpy/tests/test_parametric_bounds.py | .py | """Tests for parametric (expression) bounds on variables."""
import numpy as np
import pytest
import cvxpy as cp
import cvxpy.error as error
import cvxpy.reductions.eval_params
SOLVER = cp.CLARABEL
BOUNDED_SOLVERS = ["HIGHS", "DAQP"]
def _solver_available(solver_name):
try:
cp.Problem(cp.Minimize(0)).s... | 278 | 10,184 |
mlflow | tests/transformers/helper.py | .py | import inspect
import logging
import sys
import transformers
from packaging.version import Version
from mlflow.transformers import _PEFT_PIPELINE_ERROR_MSG, _try_import_conversational_pipeline
from mlflow.utils.logging_utils import suppress_logs
from tests.helper_functions import flaky
from tests.transformers.versio... | 341 | 11,836 |
biopython | Bio/PDB/Structure.py | .py | # Copyright (C) 2002, Thomas Hamelryck (thamelry@binf.ku.dk)
#
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been included as part of this
# package.
"""The structure cla... | 71 | 2,147 |
sphinx | sphinx/cmd/quickstart.py | .py | """Quickly setup documentation source to work with Sphinx."""
from __future__ import annotations
import argparse
import locale
import os
import os.path
import sys
import time
from typing import TYPE_CHECKING
from docutils.utils import column_width
import sphinx.locale
from sphinx import __display_version__, package... | 822 | 25,904 |
readthedocs.org | readthedocs/projects/tests/mockers.py | .py | import os
import shutil
from unittest import mock
from django.conf import settings
from readthedocs.api.v2.serializers import VersionAdminSerializer
from readthedocs.builds.constants import BUILD_STATE_TRIGGERED
from readthedocs.projects.constants import MKDOCS
from readthedocs.projects.tasks.builds import UpdateDocs... | 261 | 9,868 |
conda | tests/data/recipes/small_python_package/small_python_package/cli.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
CLI interface for small-python-package.
"""
import argparse
from . import __version__, hello
def main():
"""Main CLI entry point."""
parser = argparse.ArgumentParser(
description="A small Python package for conda testing"... | 32 | 677 |
openvino | tests/layer_tests/pytorch_tests/test_chunk.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class aten_chunk_2(torch.nn.Module):
def __init__(self, dim, unsafe=False) -> None:
torch.nn.Module.__init__(self)
self.dim = dim
... | 190 | 5,998 |
readthedocs.org | readthedocs/api/v3/proxied_views.py | .py | from readthedocs.core.mixins import ProxiedAPIMixin
from readthedocs.core.utils.extend import SettingsOverrideObject
from readthedocs.embed.v3.views import EmbedAPIBase
class ProxiedEmbedAPIBase(ProxiedAPIMixin, EmbedAPIBase):
pass
class ProxiedEmbedAPI(SettingsOverrideObject):
_default_class = ProxiedEmbed... | 12 | 328 |
lemur | lemur/constants.py | .py | """
.. module: lemur.constants
:copyright: (c) 2018 by Netflix Inc.
:license: Apache, see LICENSE for more details.
"""
from enum import IntEnum
import re
SAN_NAMING_TEMPLATE = "SAN-{subject}-{issuer}-{not_before}-{not_after}"
DEFAULT_NAMING_TEMPLATE = "{subject}-{issuer}-{not_before}-{not_after}"
NONSTANDARD_... | 151 | 5,242 |
kafka | tests/kafkatest/tests/client/consumer_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 use ... | 591 | 30,861 |
beam | learning/katas/python/Core Transforms/Composite Transform/Composite Transform/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... | 48 | 1,597 |
metrics | src/torchmetrics/regression/symmetric_mape.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... | 130 | 4,855 |
mlflow | dev/proto_to_graphql/code_generator.py | .py | import os
from autogeneration_utils import AUTOGENERATED_SCHEMA, AUTOGENERATED_SDL_SCHEMA
from parsing_utils import process_method
from schema_autogeneration import generate_schema
from mlflow.protos import model_registry_pb2, service_pb2
from mlflow.server.graphql.graphql_schema_extensions import schema
# Add proto... | 59 | 1,839 |
astropy | astropy/units/format/base.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import warnings
from collections.abc import Iterable
from typing import ClassVar, Literal, assert_never
import numpy as np
from astropy.extern.ply.lex import LexToken
from astropy.units.core import (
CompositeUnit,
NamedUnit,
Unit,
UnitB... | 335 | 11,817 |
mlflow | mlflow/pyfunc/model.py | .py | """
The ``mlflow.pyfunc.model`` module defines logic for saving and loading custom "python_function"
models with a user-defined ``PythonModel`` subclass.
"""
import bz2
import gzip
import inspect
import logging
import lzma
import os
import shutil
from abc import ABCMeta, abstractmethod
from collections.abc import Sequ... | 1,667 | 73,266 |
coremltools | coremltools/converters/mil/experimental/passes/generic_conv_scale_fusion.py | .py | # Copyright (c) 2021, 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 os
import numpy as np
from coremltools.converters.mil import Builder as mb
from coremltools.... | 245 | 8,572 |
pyro | pyro/contrib/forecast/util.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import numbers
from functools import singledispatch
import torch
from torch.distributions import transform_to, transforms
import pyro.distributions as dist
from pyro.infer.reparam import DiscreteCosineReparam, HaarReparam
from pyro.p... | 487 | 16,054 |
openvino | src/frontends/onnx/tests/runtime.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Provide a layer of abstraction for an OpenVINO runtime environment."""
import logging
from typing import Union
import numpy as np
from openvino import Core, Type
from openvino.exceptions import UserInputErr... | 193 | 9,133 |
openvino | tests/layer_tests/pytorch_tests/test_masked_scatter.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from packaging.version import parse as parse_version
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
class TestMaskedScatter(PytorchLayerTest):
def _prepare_input(self, shape, x_dty... | 85 | 4,420 |
mlflow | mlflow/server/mcp_server_api.py | .py | from __future__ import annotations
import json
from typing import TYPE_CHECKING, Any, Literal
from fastapi import APIRouter, Query, Request
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse
from pydantic import (
BaseModel,
ConfigDict,
Field,
field_valida... | 914 | 31,934 |
pymc | tests/progress_bar/test_manager.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... | 187 | 5,925 |
openvino | src/plugins/intel_cpu/tools/aggregate-average-counters/aggregate-average-counters.py | .py | #!/usr/bin/env python3
import pandas as pd
import argparse
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--format', '-f', choices=['no', 'csv', 'md'], default='no', required=False, help="print data using format")
parser.add_argument('--group_by', '-g', choices=['layerName', 'la... | 53 | 1,835 |
gunicorn | tests/requests/invalid/rfc9110_field_value_ctl_bel_01.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# RFC 9110 section 5.5: field-value characters are field-vchar (VCHAR +
# obs-text) plus SP/HTAB. Control characters other than HTAB must not
# appear, to prevent log/response injection and parser confusion.
from g... | 10 | 385 |
saleor | saleor/graphql/tax/tests/queries/test_tax_configuration.py | .py | import graphene
from saleor.tax.models import TaxConfiguration
from ....tests.utils import assert_no_permission, get_graphql_content
from ..fragments import TAX_CONFIGURATION_FRAGMENT
QUERY = (
"""
query TaxConfiguration($id: ID!) {
taxConfiguration(id: $id) {
...TaxConfiguration
... | 132 | 3,859 |
wagtail | wagtail/test/dummy_external_storage.py | .py | # This file contains a file storage backend that imitates behaviours of
# common external storage backends (S3 boto, libcloud, etc).
# The following behaviours have been added to this backend:
# - Calling .path on the storage or image file raises NotImplementedError
# - File.open() after the file has been closed rai... | 90 | 3,011 |
astropy | astropy/coordinates/matrix_utilities.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Utililies used for constructing and inspecting rotation matrices.
"""
__all__ = ["is_rotation_or_reflection", "rotation_matrix"]
import numpy as np
from astropy import units as u
from astropy.utils.decorators import deprecated
from .angles import ... | 245 | 8,056 |
metrics | src/torchmetrics/functional/image/dists.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... | 218 | 8,930 |
textual | tests/snapshot_tests/snapshot_apps/bindings_screen_overrides_show.py | .py | from textual.app import App, ComposeResult
from textual.screen import Screen
from textual.binding import Binding
from textual.widgets import Footer
class ShowBindingScreen(Screen):
BINDINGS = [
Binding("p", "app.pop_screen", "Binding shown"),
]
def compose(self) -> ComposeResult:
yield Fo... | 30 | 679 |
wandb | tests/fixtures/wandb_backend_spy/gql_match.py | .py | """GraphQL request matchers and responders."""
from __future__ import annotations
import abc
import dataclasses
import json
import re
import threading
from typing import TypeAlias
import fastapi
from typing_extensions import Any, override
# Matches queries containing an operation line, ignoring whitespace and
# Gra... | 217 | 5,452 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/pardo_dofn_methods.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");... | 85 | 2,608 |
beam | sdks/python/apache_beam/internal/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... | 132 | 4,324 |
coremltools | deps/pybind11/tests/test_eigen_tensor.py | .py | from __future__ import annotations
import sys
import pytest
np = pytest.importorskip("numpy")
eigen_tensor = pytest.importorskip("pybind11_tests.eigen_tensor")
submodules = [eigen_tensor.c_style, eigen_tensor.f_style]
try:
import eigen_tensor_avoid_stl_array as avoid
submodules += [avoid.c_style, avoid.f_st... | 291 | 9,450 |
onnxruntime | onnxruntime/test/python/quantization/test_op_slice.py | .py | #!/usr/bin/env python
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# ---------------------------------------------------------------... | 154 | 6,272 |
cvxpy | cvxpy/atoms/sum_largest.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... | 172 | 5,226 |
hatch | src/hatch/cli/application.py | .py | from __future__ import annotations
import os
import signal
import sys
from functools import cached_property
from typing import TYPE_CHECKING, cast
from hatch.cli.terminal import Terminal
from hatch.config.user import ConfigFile, RootConfig
from hatch.project.core import Project
from hatch.utils.fs import Path
from ha... | 231 | 9,156 |
beam | sdks/python/apache_beam/utils/processes_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... | 219 | 8,149 |
saleor | saleor/tax/tests/test_checkout_calculations.py | .py | from decimal import Decimal
from unittest import mock
import pytest
from prices import Money, TaxedMoney
from ...checkout import calculations
from ...checkout.fetch import fetch_checkout_info, fetch_checkout_lines
from ...checkout.tests.utils import add_variant_to_checkout
from ...core.prices import quantize_price
fr... | 1,487 | 47,301 |
confluent-kafka-python | tests/oauthbearer/aws/test_real_sts.py | .py | # Copyright 2026 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... | 377 | 16,397 |
mlflow | mlflow/utils/providers.py | .py | import functools
import importlib.resources
import json
import logging
import urllib.parse
import urllib.request
from collections.abc import Iterator
from pathlib import Path
from typing import TypedDict
import cachetools
from typing_extensions import NotRequired
from mlflow.environment_variables import MLFLOW_MODEL_... | 1,077 | 38,760 |
coremltools | deps/pybind11/tests/test_cmake_build/test.py | .py | from __future__ import annotations
import sys
import test_cmake_build
assert isinstance(__file__, str) # Test this is properly set
assert test_cmake_build.add(1, 2) == 3
print(f"{sys.argv[1]} imports, runs, and adds: 1 + 2 = 3")
| 11 | 234 |
mlflow | tests/tracing/test_distributed.py | .py | import os
import re
import subprocess
import sys
import time
from contextlib import contextmanager
from pathlib import Path
from typing import Iterator
import requests
import mlflow
from mlflow.tracing.distributed import (
get_tracing_context_headers_for_http_request,
set_tracing_context_from_http_request_hea... | 208 | 8,537 |
loguru | loguru/_logger.py | .py | """Core logging functionalities of the `Loguru` library.
.. References and links rendered by Sphinx are kept here as "module documentation" so that they can
be used in the ``Logger`` docstrings but do not pollute ``help(logger)`` output.
.. |Logger| replace:: :class:`~Logger`
.. |add| replace:: :meth:`~Logger.add(... | 2,275 | 103,485 |
sphinx | tests/test_config/test_copyright.py | .py | """Test copyright year adjustment"""
from __future__ import annotations
import time
from typing import TYPE_CHECKING
import pytest
from sphinx.config import (
Config,
correct_copyright_year,
evaluate_copyright_placeholders,
)
from sphinx.testing.util import SphinxTestApp
if TYPE_CHECKING:
from coll... | 252 | 8,369 |
returns | tests/test_iterables/test_fold/test_collect_all.py | .py | import sys
from collections.abc import Iterable, Sequence
import pytest
from returns.context import (
NoDeps,
ReaderFutureResult,
ReaderIOResult,
ReaderResult,
)
from returns.future import FutureFailure, FutureResult, FutureSuccess
from returns.io import IOFailure, IOSuccess
from returns.iterables imp... | 186 | 5,927 |
biopython | Tests/test_SeqIO_Gck.py | .py | # Copyright 2019 Damien Goutte-Gattat. 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.
"""Tests for the SeqI... | 96 | 3,547 |
biopython | Tests/test_SearchIO_hmmer3_tab.py | .py | # Copyright 2012 by Wibowo Arindrarto. 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.
"""Tests for SearchIO HmmerIO hmmer3-tab parser."""
import os
import unittest
from Bio.S... | 497 | 20,439 |
pyro | pyro/distributions/torch_patch.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import functools
import math
import warnings
import weakref
import torch
def patch_dependency(target, root_module=torch):
try:
parts = target.split(".")
assert parts[0] == root_module.__name__
module ... | 90 | 2,859 |
ipython | tools/fixup_whats_new_pr.py | .py | """
This tool is used during CI testing to make sure sphinx raise no error.
During development, we like to have whatsnew/pr/*.rst documents to track
individual new features. Unfortunately they other either:
- have no title (sphinx complains)
- are not included in any toctree (sphinx complain)
This fix-them up by ... | 41 | 1,174 |
astropy | astropy/io/fits/tests/test_fsspec.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Can `astropy.io.fits.open` access (remote) data using the fsspec package?"""
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_array_equal
from astropy.io import fits
from astropy.nddata import Cutout2D
from astropy.ta... | 147 | 6,493 |
mlflow | tests/utils/test_model_utils.py | .py | import os
import sys
from unittest import mock
import pytest
import sklearn.linear_model as logreg_module
from sklearn import datasets
import mlflow.sklearn
import mlflow.utils.model_utils as mlflow_model_utils
from mlflow.environment_variables import MLFLOW_RECORD_ENV_VARS_IN_MODEL_LOGGING
from mlflow.exceptions imp... | 129 | 5,030 |
beam | sdks/python/apache_beam/ml/rag/ingestion/alloydb.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... | 203 | 7,728 |
readthedocs.org | readthedocs/search/faceted_search.py | .py | import re
import structlog
from elasticsearch.dsl import FacetedSearch
from elasticsearch.dsl import TermsFacet
from elasticsearch.dsl.query import Bool
from elasticsearch.dsl.query import FunctionScore
from elasticsearch.dsl.query import MultiMatch
from elasticsearch.dsl.query import Nested
from elasticsearch.dsl.que... | 411 | 13,766 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/jupyter_again.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: region,endregion
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
c = '''
title: "Quick test"
output:
ioslides_presentation:
widescreen: true
smaller: true
editor_options:
chunk_output_type console
'''
impor... | 25 | 367 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_where_index.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# where paddle model generator
#
import numpy as np
from save_model import saveModel
import sys
import paddle
paddle.enable_static()
def where_index(name: str, x, force_boolean=False):
with paddle.static.program_guard(paddle.sta... | 74 | 2,308 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/sample_fixed_size_per_key.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");... | 65 | 1,970 |
astropy | astropy/io/fits/tests/test_table.py | .py | # Licensed under a 3-clause BSD style license - see PYFITS.rst
import contextlib
import copy
import gc
import pickle
import re
import sys
import warnings
import numpy as np
import pytest
try:
import objgraph
HAVE_OBJGRAPH = True
except ImportError:
HAVE_OBJGRAPH = False
from astropy.io import fits
from... | 4,532 | 177,615 |
wagtail | wagtail/admin/forms/models.py | .py | import copy
from django import VERSION as DJANGO_VERSION
from django import forms
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.utils import timezone
from django.utils.translation import gettext as _
from modelcluster.forms import ClusterForm, ClusterFormMetaclass, Cl... | 268 | 9,737 |
readthedocs.org | readthedocs/config/tests/test_config.py | .py | import os
import re
import textwrap
from collections import OrderedDict
from contextlib import nullcontext as does_not_raise
import pytest
from django.conf import settings
from django.test import override_settings
from pytest import raises
from readthedocs.config import ALL, PIP, SETUPTOOLS, UV, BuildConfigV2, load
f... | 2,571 | 88,446 |
clearml | examples/services/aws-autoscaler/aws_autoscaler.py | .py | import json
from argparse import ArgumentParser
from collections import defaultdict
from itertools import chain
from pathlib import Path
from typing import Tuple
import yaml
from clearml import Task
from clearml.automation.auto_scaler import AutoScaler, ScalerConfig
from clearml.automation.aws_driver import AWSDriver... | 321 | 11,818 |
hatch | tests/cli/version/test_version.py | .py | import os
import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
class TestNoProject:
def test_random_directory(self, hatch, temp_dir, helpers):
with temp_dir.as_cwd():
result = hatch("ve... | 463 | 13,676 |
pdm | tests/conftest.py | .py | from __future__ import annotations
import os
import shutil
from collections.abc import Iterable
from pathlib import Path
from typing import TYPE_CHECKING
from urllib.parse import unquote, urlparse
import pytest
from unearth.vcs import Git, vcs_support
os.environ.pop("FORCE_COLOR", None)
os.environ.update(
CI="1"... | 156 | 4,037 |
deap | doc/code/benchmarks/movingsc1.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
import random
rnd = random.Random()
rnd.seed(128)
from deap.benchmarks import movingpeaks
sc = movingpeaks.SCENARIO_1
sc["uniform_height"] = 0
sc["uniform_width"] = 0
mp ... | 34 | 727 |
beam | learning/katas/python/Core Transforms/CoGroupByKey/CoGroupByKey/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... | 40 | 1,480 |
scikit-bio | skbio/diversity/alpha/_base.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.
# --------------------------------------------... | 1,561 | 41,081 |
onnxruntime | onnxruntime/test/testdata/mobilenet_v3_small_excerpt_gen.py | .py | """
Run this script to recreate the original onnx model.
Example usage:
python mobilenet_v3_small_excerpt_gen.py out_model_path.onnx
The excerpt model and this script were generated from a full model by first extracting the excerpt with
onnx.utils.extract_model [1] and then generating the python script from the excerp... | 126 | 5,062 |
pyomo | pyomo/repn/tests/ampl/small7_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... | 112 | 4,035 |
probability | tensorflow_probability/examples/disentangled_vae_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... | 518 | 23,855 |
beam | infra/enforcement/sending.py | .py | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | 325 | 14,296 |
attrs | bench/test_benchmarks.py | .py | """
Benchmark attrs using CodSpeed.
"""
from __future__ import annotations
import functools
import time
import pytest
import attrs
pytestmark = pytest.mark.benchmark()
ROUNDS = 1_000
def test_create_simple_class():
"""
Benchmark creating a simple class without any extras.
"""
for _ in range(RO... | 233 | 4,281 |
beam | sdks/python/apache_beam/transforms/write_ptransform_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... | 131 | 4,233 |
hatch | tests/helpers/templates/new/feature_no_src_layout.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from ..licenses import MIT
def get_files(**kwargs):
description = kwargs.get("description", "")
return [
File(
Path("LICENSE.txt"),
MIT.replace("<year>", f"{kwargs['year']}-present", 1).replace(
"... | 135 | 3,748 |
django-cms | cms/management/djangocms.py | .py | import os
import sys
from django.core.management import load_command_class
def execute_from_command_line(argv=None):
"""Run the startcmsproject management command."""
# Prepare arguments
argv = argv or sys.argv[:]
argv[0] = os.path.basename(argv[0])
if argv[0] == "__main__.py":
argv[0] =... | 25 | 697 |
pyomo | pyomo/contrib/mcpp/build.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... | 113 | 3,906 |
saleor | saleor/graphql/discount/mutations/voucher/voucher_remove_catalogues.py | .py | from .....permission.enums import DiscountPermissions
from .....webhook.event_types import WebhookEventAsyncType
from ....core import ResolveInfo
from ....core.doc_category import DOC_CATEGORY_DISCOUNTS
from ....core.types import DiscountError
from ....core.utils import WebhookEventInfo
from ....plugins.dataloaders imp... | 61 | 2,605 |
saleor | saleor/tests/e2e/orders/utils/order_lines_create.py | .py | from saleor.graphql.tests.utils import get_graphql_content
ORDER_LINES_CREATE_MUTATION = """
mutation orderLinesCreate($id: ID!, $input: [OrderLineCreateInput!]!) {
orderLinesCreate(id: $id, input: $input) {
order {
id
shippingMethods {
id
price {
amount
}
}
... | 106 | 1,826 |
textual | docs/examples/styles/max_height.py | .py | from textual.app import App
from textual.containers import Horizontal
from textual.widgets import Placeholder
class MaxHeightApp(App):
CSS_PATH = "max_height.tcss"
def compose(self):
yield Horizontal(
Placeholder("max-height: 10w", id="p1"),
Placeholder("max-height: 999", id="... | 21 | 509 |
saleor | saleor/core/management/commands/update_search_indexes.py | .py | from django.core.management.base import BaseCommand
from ...search_tasks import (
set_order_search_document_values,
set_product_search_document_values,
set_user_search_document_values,
)
class Command(BaseCommand):
help = "Populate search indexes."
def handle(self, *args, **options):
# U... | 25 | 668 |
probability | tensorflow_probability/python/experimental/vi/surrogate_posteriors.py | .py | # Copyright 2019 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 792 | 35,035 |
cvxpy | cvxpy/tests/test_examples.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... | 630 | 20,386 |
onnx | onnx/reference/ops/op_upsample.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 Upsample(OpRun):
def _run(self, x, scale, mode=None):
if mode == "nearest" and scale.astype(np.int64).tolist() == scale.tol... | 21 | 608 |
hatch | tests/helpers/templates/wheel/standard_only_packages_artifact_override.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 53 | 1,393 |
wagtail | wagtail/contrib/redirects/models.py | .py | from urllib.parse import urlparse
import swapper
from django.db import models
from django.urls import Resolver404
from django.utils.encoding import uri_to_iri
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from wagtail.models import AbstractPage, Site
clas... | 239 | 7,758 |
beam | sdks/python/apache_beam/transforms/enrichment_handlers/bigtable_it_test.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 460 | 16,843 |
astropy | astropy/convolution/core.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains the convolution and filter functionalities of astropy.
A few conceptual notes:
A filter kernel is mainly characterized by its response function. In the 1D
case we speak of "impulse response function", in the 2D case we call it "po... | 381 | 12,110 |
openvino | tools/ovc/openvino/tools/ovc/moc_frontend/check_config.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import argparse
import os
from pathlib import Path
from openvino.tools.ovc.error import Error
def default_path():
EXT_DIR_NAME = '.'
return os.path.abspath(os.getcwd().join(EXT_DIR_NAME))
def any_extensions_used(argv: argpar... | 58 | 2,040 |
qutip | qutip/tests/solver/test_floquet.py | .py | import numpy as np
from qutip import (
sigmax, sigmay, sigmaz, sigmap, sigmam,
rand_ket, num, destroy,
mesolve, expect, sesolve,
Qobj, QobjEvo, coefficient
)
from qutip.solver.floquet import (
FloquetBasis, floquet_tensor, fmmesolve, FMESolver,
_floquet_delta_tensor, _floquet_X_matrices, fses... | 343 | 12,011 |
pyomo | pyomo/contrib/mindtpy/tests/test_mindtpy_no_discrete.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... | 769 | 28,069 |
onnxruntime | onnxruntime/python/tools/quantization/operators/norm.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from .qdq_base_operator import QDQOperatorBase
class QDQNormalization(... | 41 | 1,609 |
loguru | tests/exceptions/source/ownership/callback.py | .py | import sys
import _init
from somelib import callme, divide
from loguru import logger
def test(*, backtrace, colorize, diagnose):
logger.remove()
logger.add(sys.stderr, format="", colorize=colorize, backtrace=backtrace, diagnose=diagnose)
def callback():
divide(1, 0)
try:
callme(cal... | 27 | 650 |
textual | docs/examples/guide/widgets/hello02.py | .py | from textual.app import App, ComposeResult, RenderResult
from textual.widget import Widget
class Hello(Widget):
"""Display a greeting."""
def render(self) -> RenderResult:
return "Hello, [b]World[/b]!"
class CustomApp(App):
CSS_PATH = "hello02.tcss"
def compose(self) -> ComposeResult:
... | 22 | 403 |
eve | tests/methods/put.py | .py | import simplejson as json
from bson import ObjectId
from bson.dbref import DBRef
from eve import ETAG, ISSUES, LAST_UPDATED, STATUS, STATUS_OK
from eve.methods.put import put_internal
from tests import TestBase
from tests.test_settings import MONGO_DBNAME
from tests.utils import DummyEvent
class TestPut(TestBase):
... | 684 | 27,021 |
onnx | onnx/bin/__init__.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
| 4 | 82 |
onnxruntime | onnxruntime/test/testdata/sparse_to_dense_matmul.py | .py | import argparse
import sys
import traceback
import onnx
from onnx import (
TensorProto,
ValueInfoProto,
helper,
)
from onnx.helper import make_opsetid
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument("--output_file", required=True, type=str, help="Model file name to s... | 106 | 3,415 |
textual | docs/examples/tutorial/stopwatch02.py | .py | from textual.app import App, ComposeResult
from textual.containers import HorizontalGroup, VerticalScroll
from textual.widgets import Button, Digits, Footer, Header
class TimeDisplay(Digits):
"""A widget to display elapsed time."""
class Stopwatch(HorizontalGroup):
"""A stopwatch widget."""
def compose... | 42 | 1,203 |
astropy | astropy/units/format/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
A collection of different unit formats.
General usage is by their name in the |Unit| constructor or
in the :meth:`~astropy.units.UnitBase.to_string` method, i.e.,
these classes rarely if ever need to be imported directly.
"""
import warnings
from a... | 89 | 2,318 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.