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 | examples/evaluation/evaluate_with_function.py | .py | import shap
import xgboost
from sklearn.model_selection import train_test_split
import mlflow
# Load the UCI Adult Dataset
X, y = shap.datasets.adult()
# Split the data into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
# Fit an XGBoost binary clas... | 38 | 928 |
probability | tensorflow_probability/python/experimental/mcmc/kernel_outputs_test.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 61 | 2,180 |
cvxpy | cvxpy/atoms/affine/concatenate.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
... | 99 | 3,095 |
probability | tensorflow_probability/python/bijectors/inline.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... | 149 | 6,173 |
textual | docs/examples/widgets/static.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Static
class StaticApp(App):
def compose(self) -> ComposeResult:
yield Static("Hello, world!")
if __name__ == "__main__":
app = StaticApp()
app.run()
| 13 | 245 |
conda | tests/cli/test_main_env_create.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from conda.base.context import context
from conda.cli.main_env_create import epilog as env_create_epilog
from conda.exceptions import InvalidInstaller
from cond... | 110 | 3,888 |
luigi | luigi/format.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... | 496 | 14,437 |
flit | tests/conftest.py | .py | from pathlib import Path
import pytest
from shutil import copytree
samples_dir = Path(__file__).parent / 'samples'
@pytest.fixture
def copy_sample(tmp_path):
"""Copy a subdirectory from the samples dir to a temp dir"""
def copy(dirname):
dst = tmp_path / dirname
copytree(str(samples_dir / dirn... | 16 | 372 |
wagtail | wagtail/urls.py | .py | from django.conf import settings
from django.contrib.auth import views as auth_views
from django.urls import path, re_path
from wagtail import views
from wagtail.coreutils import WAGTAIL_APPEND_SLASH
if WAGTAIL_APPEND_SLASH:
# If WAGTAIL_APPEND_SLASH is True (the default value), we match a
# (possibly empty) ... | 40 | 1,327 |
saleor | saleor/graphql/meta/tests/mutations/test_attribute.py | .py | import graphene
from .test_update_private_metadata import (
execute_update_private_metadata_for_item,
item_contains_proper_private_metadata,
)
def test_add_private_metadata_for_product_attribute(
staff_api_client, permission_manage_product_types_and_attributes, color_attribute
):
# given
attribut... | 49 | 1,356 |
saleor | saleor/graphql/giftcard/bulk_mutations/gift_card_bulk_delete.py | .py | import graphene
from django.conf import settings
from ....giftcard import models
from ....permission.enums import GiftcardPermissions
from ....webhook.event_types import WebhookEventAsyncType
from ....webhook.utils import get_webhooks_for_event
from ...core import ResolveInfo
from ...core.mutations import ModelBulkDel... | 49 | 1,803 |
pyomo | pyomo/core/plugins/transform/hierarchy.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... | 73 | 2,488 |
hydra | tests/defaults_list/test_defaults_list.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import re
from textwrap import dedent
from typing import Any, List, Optional
from pytest import mark, param, raises
from hydra._internal.defaults_list import (
_validate_paths,
_validate_self,
create_defaults_list,
)
from hydra.core.de... | 2,382 | 72,451 |
probability | tensorflow_probability/python/distributions/poisson_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... | 590 | 22,731 |
flit | flit/upload.py | .py | """Code to communicate with PyPI to register distributions and upload files.
This is cribbed heavily from distutils.command.(upgrade|register), which as part
of Python is under the PSF license.
"""
import configparser
import getpass
import hashlib
import logging
import os
from pathlib import Path
import re
import requ... | 322 | 10,472 |
astropy | astropy/cosmology/_src/tests/funcs/test_comparison.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Tests for :mod:`astropy.cosmology.comparison`"""
import re
import numpy as np
import pytest
from astropy.cosmology import Cosmology, FlatCosmologyMixin, Planck18, cosmology_equal
from astropy.cosmology._src.funcs.comparison import (
_CANT_BROADC... | 347 | 11,797 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupby_attr.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 | 2,054 |
sqlmap | lib/core/dicts.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.enums import CONTENT_TYPE
from lib.core.enums import DBMS
from lib.core.enums import OS
from lib.core.enums import POST_HINT
from lib.core.settings import ACCESS_ALI... | 743 | 21,037 |
mlflow | tests/pyfunc/test_inferred_code_path.py | .py | import os
import pickle
import numpy as np
import pytest
import sklearn.datasets
import sklearn.neighbors
import mlflow
from mlflow.models import Model
@pytest.fixture
def model_path(tmp_path):
return tmp_path / "model"
@pytest.fixture(scope="module")
def iris_data():
iris = sklearn.datasets.load_iris()
... | 150 | 4,553 |
httpie | tests/test_httpie_cli.py | .py | import pytest
import shutil
import json
from httpie.sessions import SESSIONS_DIR_NAME
from httpie.status import ExitStatus
from httpie.cli.options import PARSER_SPEC_VERSION
from tests.utils import DUMMY_HOST, httpie
from tests.fixtures import SESSION_FILES_PATH, SESSION_FILES_NEW, SESSION_FILES_OLD, read_session_file
... | 139 | 4,403 |
pyomo | examples/pyomo/amplbook2/dieti.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... | 69 | 1,715 |
astropy | astropy/convolution/tests/test_kernel_class.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_almost_equal
from astropy.convolution.convolve import convolve, convolve_fft
from astropy.convolution.kernels import (
AiryDisk2DKernel,
Box1DKernel,
Box2DKern... | 639 | 21,824 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_not_equal.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# not_equal paddle model generator
#
import numpy as np
from save_model import saveModel
import sys
def not_equal(name: str, x, y, data_type, cast_to_fp32=False):
import paddle
paddle.enable_static()
with paddle.static.pr... | 58 | 1,762 |
beam | sdks/python/apache_beam/testing/benchmarks/chicago_taxi/preprocess.py | .py | # Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 254 | 8,976 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_yolo_box.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# pool2d paddle model generator
#
import numpy as np
from save_model import saveModel
import sys
def yolo_box(name : str, x, img_size, attrs : dict):
import paddle
paddle.enable_static()
with paddle.static.program_guard(p... | 118 | 4,021 |
beam | sdks/python/apache_beam/metrics/cells_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... | 495 | 16,246 |
saleor | saleor/graphql/account/tests/queries/test_staff_users_sorting.py | .py | import pytest
from .....account.models import User
from .....order.models import Order
from ....tests.utils import get_graphql_content
QUERY_STAFF_USERS_WITH_SORT = """
query ($sort_by: UserSortingInput!) {
staffUsers(first:5, sortBy: $sort_by) {
edges{
node{
... | 75 | 2,629 |
mlflow | tests/store/artifact/test_unity_catalog_models_artifact_repo.py | .py | import json
from unittest import mock
from unittest.mock import ANY
import pytest
from google.cloud.storage import Client
from requests import Response
import mlflow
from mlflow import MlflowClient
from mlflow.entities.file_info import FileInfo
from mlflow.exceptions import MlflowException
from mlflow.protos.databric... | 527 | 22,503 |
pdm | src/pdm/project/lockfile/pylock.py | .py | from __future__ import annotations
from collections.abc import Iterable
from functools import cached_property
from pdm.exceptions import PdmUsageError
from pdm.models.repositories.lock import LockedRepository
from pdm.project.lockfile.base import (
FLAG_DIRECT_MINIMAL_VERSIONS,
FLAG_INHERIT_METADATA,
FLAG... | 71 | 2,823 |
pyomo | pyomo/version/info.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... | 93 | 3,343 |
wagtail | wagtail/tests/permission_policies/test_collection_permission_policies.py | .py | from django.contrib.auth.models import AnonymousUser, Group, Permission
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from wagtail.documents.models import Document
from wagtail.models import Collection, GroupCollectionPermission
from wagtail.permission_policies.collections... | 1,588 | 54,498 |
black | src/black/schema.py | .py | import importlib.resources
import json
from typing import Any
def get_schema(tool_name: str = "black") -> Any:
"""Get the stored complete schema for black's settings."""
assert tool_name == "black", "Only black is supported."
pkg = "black.resources"
fname = "black.schema.json"
schema = importlib... | 16 | 431 |
probability | tensorflow_probability/python/distributions/mixture_same_family_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... | 621 | 26,615 |
sphinx | tests/roots/test-ext-autosummary-template/conf.py | .py | import sys
from pathlib import Path
sys.path.insert(0, str(Path.cwd().resolve()))
extensions = ['sphinx.ext.autosummary']
autosummary_generate = True
autodoc_default_options = {'members': True}
templates_path = ['_templates']
| 10 | 228 |
hatch | tests/backend/builders/plugin/test_interface.py | .py | from os.path import sep as path_sep
import pytest
from hatchling.builders.constants import EXCLUDED_DIRECTORIES, EXCLUDED_FILES
from hatchling.metadata.core import ProjectMetadata
from hatchling.plugin.manager import PluginManager
from ..utils import MockBuilder
class TestClean:
def test_default(self, isolatio... | 390 | 14,906 |
mlflow | dev/flavors/src/flavors/__init__.py | .py | from flavors._loader import VERSIONS_YAML_PATH, load, load_or_default, load_raw
from flavors._releases import RELEASE_CUTOFF_DAYS, get_released_versions
from flavors._schema import (
DEV_NUMERIC,
DEV_VERSION,
FlavorConfig,
PackageInfo,
TestConfig,
Version,
)
__all__ = [
"DEV_NUMERIC",
"... | 26 | 541 |
sqlmap | lib/techniques/dns/use.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
import time
from lib.core.agent import agent
from lib.core.common import Backend
from lib.core.common import calculateDeltaSeconds
from lib.core.common import dataToStd... | 123 | 5,404 |
onnx | onnx/reference/ops/op_sum.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from onnx.reference.op_run import OpRun
class Sum(OpRun):
def _run(self, *args):
return (sum(args).astype(args[0].dtype),)
| 12 | 254 |
openvino | src/frontends/tensorflow_lite/tests/test_models/gen_scripts/generate_oob_quantized_dimension.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# Generate crafted .tflite model files with out-of-bounds quantized_dimension
# field values. These models test that the TFLite frontend properly validates
# the quantized_dimension field in QuantizationParameters before using it as
# a ... | 226 | 9,544 |
beam | playground/infrastructure/test_utils.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 ... | 50 | 1,964 |
beam | sdks/python/apache_beam/transforms/enrichment_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... | 42 | 1,428 |
astropy | astropy/convolution/tests/test_convolve_fft.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from contextlib import nullcontext
import numpy as np
import pytest
from numpy.testing import (
assert_allclose,
assert_array_almost_equal_nulp,
assert_array_equal,
)
from astropy import units as u
from astropy.convolution.convolve import co... | 1,079 | 40,191 |
mlflow | examples/smolagents/tracing.py | .py | """
This is an example for leveraging MLflow's auto tracing capabilities for Smolagents.
For more information about MLflow Tracing, see: https://mlflow.org/docs/latest/llms/tracing/index.html
"""
from smolagents import CodeAgent, LiteLLMModel
import mlflow
# Turn on auto tracing for Smolagents by calling mlflow.smol... | 19 | 591 |
django-cms | cms/test_utils/project/placeholderapp/urls.py | .py | from django.urls import re_path
from . import views
from .views import ClassDetail
urlpatterns = [
re_path(r'^detail/(?P<pk>[0-9]+)/$', views.detail_view, name="example_detail"),
re_path(r'^detail_char/(?P<pk>[a-z]+)/$', views.detail_view_char, name="example_detail_char"),
re_path(r'^detail/class/(?P<pk>[... | 12 | 444 |
saleor | saleor/graphql/menu/tests/mutations/test_menu_update.py | .py | import json
from unittest import mock
import graphene
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....core.utils.json_serializer import CustomJsonEncoder
from .....menu.error_codes import MenuErrorCode
from .....menu.models import Menu
from .....webhook.event_types imp... | 154 | 4,526 |
conda | conda/_private/shards/subset.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Sharded repodata subsets.
Traverse dependencies of installed and to-be-installed packages to generate a
useful subset for the solver.
The algorithm developed here is a direct result of the following CEP:
- https://conda.org/learn/ceps/cep... | 789 | 29,042 |
black | tests/data/cases/parenthesized_context_managers.py | .py | # flags: --minimum-version=3.10
with (CtxManager() as example):
...
with (CtxManager1(), CtxManager2()):
...
with (CtxManager1() as example, CtxManager2()):
...
with (CtxManager1(), CtxManager2() as example):
...
with (CtxManager1() as example1, CtxManager2() as example2):
...
with (
CtxMan... | 47 | 797 |
probability | tensorflow_probability/python/distributions/sinh_arcsinh_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... | 222 | 8,651 |
django-cms | cms/models/pagemodel.py | .py | import warnings
from logging import getLogger
from os.path import join
from django.contrib.auth import get_user_model
from django.contrib.sites.models import Site
from django.db import IntegrityError, connection, models, router
from django.db.models import Prefetch
from django.db.models.base import ModelState
from dja... | 1,277 | 49,150 |
mlflow | tests/store/tracking/test_file_store_logged_model.py | .py | import pytest
pytestmark = pytest.mark.skip(reason="FileStore is no longer supported")
import time
import uuid
from dataclasses import dataclass
from unittest import mock
import pytest
import mlflow
from mlflow.entities.logged_model_parameter import LoggedModelParameter
from mlflow.entities.logged_model_status impo... | 1,073 | 38,205 |
coremltools | coremltools/test/optimize/torch/utils.py | .py | # Copyright (c) 2024, 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 contextlib
import importlib
import inspect
import io
import logging
import os
import pathlib
i... | 253 | 6,791 |
onnxruntime | plugin-ep-cuda/python/setup.py | .py | """Minimal setup.py to produce a platform-specific wheel."""
from setuptools import setup
from setuptools.dist import Distribution
from wheel.bdist_wheel import bdist_wheel
class PlatformBdistWheel(bdist_wheel):
"""Override wheel tags to py3-none-{platform}."""
def get_tag(self):
_, _, plat = super(... | 22 | 544 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/The flavors of raw cells.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: region,endregion
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# region raw_mimetype="text/latex" active=""
# $1+1$
# endregion
# region raw_mimetype="text/restructuredtext" active=""
# :math:`1+1`
# endregion
# region... | 34 | 580 |
beam | sdks/python/apache_beam/ml/rag/ingestion/postgres_common.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... | 521 | 18,375 |
pyomo | pyomo/contrib/solver/common/solution_loader.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... | 402 | 14,037 |
qutip | qutip/core/cy/openmp/utilities.py | .py | import os
from qutip.settings import settings as qset
def check_use_openmp(options):
"""
Check to see if OPENMP should be used in dynamic solvers.
"""
# TODO: sort this out.
return False
"""
force_omp = False
if qset.has_openmp:
if options.use_openmp is None:
option... | 42 | 1,164 |
tqdm | examples/pandas_progress_apply.py | .py | import numpy as np
import pandas as pd
from tqdm.auto import tqdm
df = pd.DataFrame(np.random.randint(0, 100, (100000, 6)))
# Register `pandas.progress_apply` and `pandas.Series.map_apply` with `tqdm`
# (can use `tqdm.gui.tqdm`, `tqdm.notebook.tqdm`, optional kwargs, etc.)
tqdm.pandas(desc="my bar!")
# Now you can ... | 30 | 937 |
hypercorn | src/hypercorn/middleware/proxy_fix.py | .py | from __future__ import annotations
from collections.abc import Callable, Iterable
from copy import deepcopy
from typing import Literal
from ..typing import ASGIFramework, Scope
class ProxyFixMiddleware:
def __init__(
self,
app: ASGIFramework,
mode: Literal["legacy", "modern"] = "legacy",... | 81 | 2,691 |
onnxruntime | tools/ci_build/coverage.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
# This script generates test code coverage for Android.
# The prerequistes:
# 1. The Onnxruntime build with coverage option to compile/link the source files using --coverage optoin
# 2. The tes... | 65 | 2,315 |
pyomo | examples/pyomobook/overview-ch/wl_concrete.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... | 44 | 1,447 |
gunicorn | tests/docker/uwsgi/conftest.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
pytest fixtures for uWSGI Docker integration tests.
"""
import os
import subprocess
import time
import pytest
import requests
COMPOSE_FILE = os.path.join(os.path.dirname(__file__), 'docker-compose.yml')
NGI... | 126 | 3,249 |
omegaconf | tests/test_basic_ops_dict.py | .py | # -*- coding: utf-8 -*-
import copy
import re
import tempfile
from contextlib import nullcontext
from typing import Any, Dict, List, Optional, Union
from pytest import mark, param, raises
from omegaconf import (
MISSING,
AnyNode,
DictConfig,
DictKeyType,
ListConfig,
MissingMandatoryValue,
... | 1,337 | 40,369 |
openvino | src/bindings/python/src/openvino/test_utils/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from .test_api import compare_functions
| 6 | 147 |
hydra | tests/standalone_apps/discovery_test_plugin/hydra_plugins/discovery_test/__not_hidden_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from hydra.plugins.plugin import Plugin
class NotHiddenTestPlugin(Plugin): ...
| 6 | 152 |
onnx | onnx/backend/test/case/node/max.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.backend.test.case.utils import all_numeric_dtypes
class Max(Base):... | 67 | 2,044 |
hydra | plugins/hydra_joblib_launcher/tests/apps/multiprocessing_callable_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from pathlib import Path
import hydra
from hydra.core.hydra_config import HydraConfig
from omegaconf import DictConfig
class CallableTask:
def __init__(self, marker: str) -> None:
self.marker = marker
def __call__(self, cfg: Dict... | 26 | 631 |
django-cms | testserver.py | .py | #!/usr/bin/env python
import os
import sys
import tempfile
import warnings
import dj_database_url
from cms.exceptions import DontUsePageAttributeWarning
def gettext(s):
return s
warnings.filterwarnings("ignore", category=DontUsePageAttributeWarning)
permission = True
port = 8000
for arg in sys.argv:
if ... | 315 | 11,532 |
omegaconf | tests/test_base_config.py | .py | import copy
from contextlib import nullcontext
from typing import Any, Dict, List, Optional, Union
from pytest import mark, param, raises
from omegaconf import (
AnyNode,
Container,
DictConfig,
DictKeyType,
IntegerNode,
ListConfig,
OmegaConf,
ReadonlyConfigError,
StringNode,
Un... | 742 | 22,773 |
saleor | saleor/core/telemetry/metric.py | .py | import logging
import time
from collections.abc import Callable, Iterator, Sequence
from contextlib import contextmanager
from enum import Enum
from threading import Lock
from opentelemetry.metrics import Meter as OtelMeter
from opentelemetry.metrics import MeterProvider, Synchronous, get_meter
from opentelemetry.util... | 250 | 7,771 |
saleor | saleor/webhook/observability/buffers.py | .py | import math
import zlib
from asgiref.local import Local
from django.conf import settings
from redis import ConnectionPool, Redis
from .exceptions import ConnectionNotConfigured
KEY_TYPE = str
DEFAULT_CONNECTION_TIMEOUT = 0.5
_local = Local()
class BaseBuffer:
_compressor_preset = 6
def __init__(
s... | 208 | 6,736 |
saleor | saleor/graphql/product/tests/queries/variants_where/test_over_attributes_numeric.py | .py | import pytest
from ......attribute.utils import associate_attribute_values_to_instance
from .....tests.utils import get_graphql_content
from .shared import PRODUCT_VARIANTS_WHERE_QUERY
@pytest.mark.parametrize(
("numeric_input", "expected_count"),
[
({"slug": "num-slug", "value": {"numeric": {"eq": 1... | 89 | 2,994 |
lemur | lemur/tests/test_verify.py | .py | import pytest
import requests
import requests_mock
from unittest.mock import patch
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization, hashes
from cryptography.x509 import UniformResourceIdentifier
from lemur.certificates.veri... | 69 | 2,802 |
sqlmap | thirdparty/chardet/jpcntx.py | .py | ######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Communicator client code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights R... | 234 | 19,643 |
beam | sdks/python/container/license_scripts/upgrade_bundled_pip.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... | 77 | 2,561 |
coremltools | coremltools/converters/mil/mil/types/type_list.py | .py | # Copyright (c) 2020, 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
from . import type_int
from .annotate import annotate
from .get_type_info import get_type_info
from .... | 70 | 1,974 |
ipython | IPython/extensions/tests/test_deduperreload.py | .py | #!/usr/bin/env python
from __future__ import annotations
import ast
import os
import platform
import pytest
import random
import shutil
import sys
import tempfile
import textwrap
import time
from types import ModuleType
from IPython.extensions.autoreload import AutoreloadMagics
from IPython.extensions.deduperreload.d... | 2,311 | 57,358 |
wagtail | wagtail/contrib/redirects/tests/test_import_utils.py | .py | import hashlib
import os
from django.core.files.base import ContentFile
from django.test import TestCase, override_settings
from wagtail.contrib.redirects.utils import (
get_file_storage,
get_import_formats,
write_to_file_storage,
)
TEST_ROOT = os.path.abspath(os.path.dirname(__file__))
class TestImpor... | 58 | 2,100 |
pyfilesystem2 | tests/test_wildcard.py | .py | """Test f2s.fnmatch."""
from __future__ import unicode_literals
import unittest
from fs import wildcard
class TestFNMatch(unittest.TestCase):
"""Test wildcard."""
def test_wildcard(self):
self.assertTrue(wildcard.match("*.py", "file.py"))
self.assertTrue(wildcard.match("????.py", "????.py"... | 47 | 1,873 |
coremltools | coremltools/test/optimize/api/test_optimize_api.py | .py | # Copyright (c) 2023, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import tempfile
import pytest
from coremltools.converters.mil.testing_utils import get_op_types_in_... | 680 | 23,419 |
readthedocs.org | readthedocs/projects/tests/test_views.py | .py | import csv
from unittest import mock
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.contrib.messages import get_messages
from django.test import TestCase, override_settings
from django.urls import reverse
from django_dynamic_fixture import get
from readthedocs.... | 671 | 25,629 |
hatch | tests/helpers/templates/sdist/standard_default_build_script_extra_dependencies.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT
from ..new.feature_no_src_layout import get_files as get_template_files
def get_files(**kwargs):
relative_root = kwargs.get("rela... | 50 | 1,319 |
pyomo | examples/pyomobook/abstract-ch/param2.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... | 24 | 831 |
pyro | pyro/contrib/autoguide.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import warnings
from pyro.infer.autoguide import * # noqa F403
warnings.warn(
"pyro.contrib.autoguide has moved to pyro.infer.autoguide. "
"The contrib alias will stop working in Pyro 0.5.",
DeprecationWarning,
)
| 13 | 317 |
onnxruntime | orttraining/orttraining/python/training/ortmodule/experimental/pipe/_ort_pipeline_module.py | .py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import importlib.metadata
from functools import partial
import torch.nn as nn
from deepspeed.pipe import LayerSpec, PipelineModule, TiedLayerSpec
from deepspeed.runtime import utils as ds_utils
from deepspeed.runtime.activation_checkpointing imp... | 170 | 8,145 |
beam | sdks/python/apache_beam/io/aws/s3io_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... | 821 | 26,304 |
coveragepy | tests/osinfo.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
"""OS information for testing."""
from __future__ import annotations
import sys
if sys.platform == "win32":
# Windows implementation
def process_ram()... | 92 | 3,277 |
metrics | src/torchmetrics/functional/audio/nisqa.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... | 398 | 16,465 |
textual | docs/examples/styles/link_style_hover.py | .py | from textual.app import App
from textual.widgets import Label
class LinkHoverStyleApp(App):
CSS_PATH = "link_style_hover.tcss"
def compose(self):
yield Label(
"Visit the [link='https://textualize.io']Textualize[/link] website.",
id="lbl1", # (1)!
)
yield Label... | 30 | 763 |
wandb | tests/unit_tests/test_lib/test_hashutil.py | .py | from __future__ import annotations
import base64
import hashlib
import sys
from pathlib import Path
import pytest
from _pytest.fixtures import SubRequest
from pyfakefs.fake_filesystem import FakeFilesystem
from wandb.sdk.lib import hashutil
BYTE_STRS: tuple[bytes] = (
b"",
b"\xb7\xb7",
b"\x89\xf3\xa2\xe1... | 139 | 4,254 |
scikit-optimize | skopt/space/transformers.py | .py | from __future__ import division
import numpy as np
from sklearn.preprocessing import LabelBinarizer
from sklearn.utils import column_or_1d
class Transformer(object):
"""Base class for all 1-D transformers.
"""
def fit(self, X):
return self
def transform(self, X):
raise NotImplementedE... | 311 | 8,748 |
metrics | tests/unittests/nominal/test_cramers.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... | 172 | 6,640 |
cvxpy | cvxpy/cvxcore/python/cvxcore.py | .py | # This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.2.1
#
# Do not make changes to this file unless you know what you are doing - modify
# the SWIG interface file instead.
from sys import version_info as _swig_python_version_info
# Import the low-level C/C++ module
if __package__ or "."... | 995 | 28,678 |
scikit-bio | skbio/io/format/tests/test_phylip.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.
# --------------------------------------------... | 286 | 11,028 |
wagtail | wagtail/tests/actions/test_create.py | .py | from unittest import mock
from django.contrib.auth.models import Permission
from django.forms.models import modelform_factory
from django.test import TestCase
from wagtail.actions.create import CreateAction, CreatePermissionError
from wagtail.log_actions import registry as log_registry
from wagtail.models import Revi... | 244 | 9,553 |
mlflow | tests/entities/test_dataset_record_source.py | .py | import json
import pytest
from mlflow.entities.dataset_record_source import DatasetRecordSource, DatasetRecordSourceType
from mlflow.exceptions import MlflowException
from mlflow.protos.datasets_pb2 import DatasetRecordSource as ProtoDatasetRecordSource
def test_dataset_record_source_type_constants():
assert Da... | 236 | 9,182 |
saleor | saleor/tests/e2e/checkout/utils/checkout_lines_delete.py | .py | from ...utils import get_graphql_content
CHECKOUT_LINES_DELETE_MUTATION = """
mutation CheckoutLinesDelete($checkoutId: ID!, $linesIds: [ID!]!) {
checkoutLinesDelete(id: $checkoutId, linesIds: $linesIds) {
checkout {
discountName
discount {
amount
}
subtotalPrice {
gross {... | 73 | 1,365 |
onnxruntime | onnxruntime/python/tools/transformers/models/stable_diffusion/engine_builder_torch.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import logging
from diffusion_models import PipelineInfo
from engine_bu... | 109 | 4,198 |
textual | src/textual/_two_way_dict.py | .py | from __future__ import annotations
from typing import Generic, TypeVar
Key = TypeVar("Key")
Value = TypeVar("Value")
class TwoWayDict(Generic[Key, Value]):
"""
A two-way mapping offering O(1) access in both directions.
Wraps two dictionaries and uses them to provide efficient access to
both values ... | 73 | 2,009 |
mlflow | tests/gateway/tools.py | .py | import asyncio
import json
import os
import signal
import subprocess
import sys
import threading
import time
from pathlib import Path
from typing import Any, NamedTuple
from unittest import mock
import aiohttp
import requests
import uvicorn
import yaml
from sentence_transformers import SentenceTransformer
import mlfl... | 293 | 8,839 |
scikit-bio | skbio/io/_fileobject.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.
# --------------------------------------------... | 85 | 2,578 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.