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 |
|---|---|---|---|---|---|
pyro | tests/nn/conftest.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
def pytest_collection_modifyitems(items):
for item in items:
if item.nodeid.startswith("tests/nn"):
if "stage" not in item.keywords:
item.add_marker(pytest.mark.stage("unit"))... | 14 | 429 |
saleor | saleor/tests/fixtures.py | .py | import datetime
from contextlib import contextmanager
from functools import partial
from io import BytesIO
from unittest.mock import MagicMock
import graphene
import pytest
from django.conf import settings
from django.core.cache import cache
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db ... | 1,758 | 58,348 |
openvino | src/bindings/python/tests/test_graph/test_custom_op.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import pytest
import numpy as np
from contextlib import nullcontext as does_not_raise
from openvino import Op, OpExtension
from openvino import CompiledModel, Core, Model, Dimension, Shape, T... | 305 | 10,674 |
biopython | Tests/test_Align_chain.py | .py | # Copyright 2023 by Michiel de Hoon. 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 Align.chain module."""
import unittest
from io import StringIO
from tempfile imp... | 7,282 | 290,594 |
pymc | pymc/testing.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... | 1,435 | 52,650 |
clearml | examples/frameworks/kerastuner/keras_tuner_cifar.py | .py | """Keras Tuner CIFAR10 example for the TensorFlow blog post."""
import keras_tuner as kt
import tensorflow as tf
import tensorflow_datasets as tfds
from clearml.external.kerastuner import ClearmlTunerCallback
from clearml import Task
physical_devices = tf.config.list_physical_devices("GPU")
if physical_devices:
... | 80 | 2,628 |
textual | docs/examples/styles/dock_all.py | .py | from textual.app import App
from textual.containers import Container
from textual.widgets import Label
class DockAllApp(App):
CSS_PATH = "dock_all.tcss"
def compose(self):
yield Container(
Container(Label("left"), id="left"),
Container(Label("top"), id="top"),
Cont... | 22 | 516 |
openvino | src/frontends/onnx/tests/tests_python/test_onnx_import.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import numpy as np
import onnx
from onnx.helper import make_graph, make_model, make_node, make_tensor_value_info
from openvino import Core
from tests.runtime import get_runtime
from tests.tests_python.... | 67 | 2,120 |
probability | tensorflow_probability/python/distributions/hidden_markov_model.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,361 | 59,542 |
saleor | saleor/graphql/utils/filters.py | .py | from collections.abc import Mapping, Sequence
from decimal import Decimal
from typing import TYPE_CHECKING
from uuid import UUID
from django.db.models import Q
from django.utils import timezone
from ..core.enums import ReportingPeriod
if TYPE_CHECKING:
from django.db.models import QuerySet
Number = float | int ... | 186 | 5,661 |
pyro | pyro/contrib/forecast/forecaster.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import logging
from abc import ABCMeta, abstractmethod
from contextlib import ExitStack
import torch
import torch.nn as nn
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.infer import MCMC, NUTS... | 547 | 23,353 |
mlflow | tests/openai/conftest.py | .py | import importlib.metadata
import pytest
from packaging.version import Version
from tests.helper_functions import start_mock_openai_server
is_v1 = Version(importlib.metadata.version("openai")).major >= 1
@pytest.fixture(scope="module", autouse=True)
def mock_openai():
with start_mock_openai_server() as base_url... | 15 | 345 |
django-cms | cms/utils/compat/dj.py | .py | from functools import WRAPPER_ASSIGNMENTS
from django.apps import apps
__all__ = ['is_installed', 'installed_apps']
def is_installed(app_name):
return apps.is_installed(app_name)
def installed_apps():
return [app.name for app in apps.get_app_configs()]
def available_attrs(fn):
return WRAPPER_ASSIGNM... | 18 | 325 |
saleor | saleor/payment/tests/test_utils/test_utils.py | .py | import datetime
import logging
from decimal import Decimal
from unittest.mock import patch
import graphene
import pytest
from freezegun import freeze_time
from ....checkout import CheckoutAuthorizeStatus, calculations
from ....checkout.fetch import fetch_checkout_info, fetch_checkout_lines
from ....order import Order... | 2,714 | 85,428 |
bazel | third_party/py/abseil/absl/testing/_pretty_print_reporter.py | .py | # Copyright 2018 The Abseil 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 ... | 92 | 3,140 |
astropy | astropy/table/soco.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
The SCEngine class uses the ``sortedcontainers`` package to implement an
Index engine for Tables.
"""
from collections import OrderedDict
from collections.abc import Hashable, Mapping, Sequence
from numbers import Integral
from astropy.utils.compat.... | 196 | 5,741 |
saleor | saleor/invoice/models.py | .py | from django.conf import settings
from django.contrib.postgres.indexes import BTreeIndex
from django.db import models
from django.db.models import JSONField
from django.utils.timezone import now
from ..app.models import App
from ..core import JobStatus
from ..core.models import Job, ModelWithMetadata
from ..core.utils ... | 91 | 2,763 |
confluent-kafka-python | tests/integration/admin/test_basic_operations.py | .py | # -*- coding: utf-8 -*-
# Copyright 2022 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... | 427 | 14,992 |
attrs | tests/test_filters.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for `attr.filters`.
"""
import pytest
import attr
from attr import fields
from attr.filters import _split_what, exclude, include
@attr.s
class C:
a = attr.ib()
b = attr.ib()
class TestSplitWhat:
"""
Tests for `_split_what`.
"""
def test_splits(se... | 127 | 2,896 |
sqlmap | plugins/dbms/access/connector.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
try:
import pyodbc
except:
pass
import logging
from lib.core.common import getSafeExString
from lib.core.data import conf
from lib.core.data import logger
from lib.core.... | 70 | 2,411 |
mlflow | mlflow/utils/conda.py | .py | import hashlib
import json
import logging
import os
import yaml
from mlflow.environment_variables import MLFLOW_CONDA_CREATE_ENV_CMD, MLFLOW_CONDA_HOME
from mlflow.exceptions import ExecutionException
from mlflow.utils import process
from mlflow.utils.environment import Environment
from mlflow.utils.os import is_wind... | 358 | 13,277 |
lemur | lemur/extensions.py | .py | """
.. module: lemur.extensions
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
"""
from flask_sqlalchemy import SQLAlchemy as _BaseSQLAlchemy
class SQLAlchemy(_BaseSQLAlchemy):
def apply_pool_defaults(self, app, options):
"""
Set ... | 48 | 943 |
sphinx | tests/roots/test-ext-autosummary-filename-map/autosummary_dummy_module.py | .py | from __future__ import annotations
from os import path
from typing import Union
class Foo:
class Bar: # NoQA: D106
pass
def __init__(self):
pass
def bar(self):
pass
@property
def baz(self):
pass
def bar(x: int | str, y: int = 1) -> None:
pass
| 24 | 308 |
mlflow | examples/anthropic/tracing.py | .py | """
This is an example for leveraging MLflow's auto tracing capabilities for Anthropic.
For more information about MLflow Tracing, see: https://mlflow.org/docs/latest/llms/tracing/index.html
"""
import os
import anthropic
import mlflow
# Turn on auto tracing for Anthropic by calling mlflow.anthropic.autolog()
mlfl... | 28 | 684 |
beam | sdks/python/apache_beam/ml/inference/sklearn_inference_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... | 165 | 7,111 |
black | src/blib2to3/pgen2/pgen.py | .py | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
import os
from collections.abc import Iterator, Sequence
from typing import IO, Any, NoReturn, Union
from blib2to3.pgen2 import grammar, token, tokenize
from blib2to3.pgen2.tokenize import TokenInfo
P... | 389 | 14,131 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Swish.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng(325)
class TestSwish(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
... | 49 | 1,807 |
pyro | pyro/infer/reparam/loc_scale.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.distributions import constraints
import pyro
import pyro.distributions as dist
from pyro.distributions.util import is_identically_one, is_validation_enabled
from .reparam import Reparam
class LocScaleRep... | 101 | 3,812 |
pyro | pyro/distributions/constraints.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
# Import * to get the latest upstream constraints.
from torch.distributions.constraints import * # noqa F403
# Additionally try to import explicitly to help mypy static analysis.
try:
from torch.distributions.constraints impo... | 235 | 5,739 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_logical_not.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# logical_not paddle model generator
#
import numpy as np
from save_model import saveModel
import sys
def equal_logical_not(name : str, x, y):
import paddle
paddle.enable_static()
with paddle.static.program_guard(paddle.... | 49 | 1,396 |
mlflow | mlflow/store/db_migrations/versions/7f2a7d5fae7d_add_datasets_inputs_input_tags_tables.py | .py | """add datasets inputs input_tags tables
Create Date: 2023-03-23 09:48:27.775166
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects.mysql import MEDIUMTEXT
from mlflow.store.tracking.dbmodels.models import SqlDataset, SqlInput, SqlInputTag
# revision identifiers, used by Alembic.
revision ... | 81 | 3,046 |
wagtail | wagtail/images/checks.py | .py | import os
from functools import lru_cache
from django.core.checks import Warning, register
from willow.image import Image
@lru_cache(maxsize=None)
def has_jpeg_support():
wagtail_jpg = os.path.join(os.path.dirname(__file__), "check_files", "wagtail.jpg")
succeeded = True
with open(wagtail_jpg, "rb") as ... | 57 | 1,349 |
beam | sdks/python/apache_beam/ml/anomaly/univariate/mad.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... | 88 | 3,349 |
coremltools | deps/protobuf/examples/list_people.py | .py | #! /usr/bin/env python
# See README.txt for information and build instructions.
from __future__ import print_function
import addressbook_pb2
import sys
# Iterates though all people in the AddressBook and prints info about them.
def ListPeople(address_book):
for person in address_book.people:
print("Person ID:... | 41 | 1,205 |
saleor | saleor/graphql/product/tests/queries/products_filtrations/test_over_multiple_arguments.py | .py | 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])
@pytest.mark.parametrize(
"attri... | 263 | 8,095 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_cropping_1d.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 TestKerasCropping1D(CommonTF2LayerTest):
def create_keras_cropping_1d_net(self, cropping, input_names, input_shapes, input_type... | 38 | 1,722 |
cvxpy | cvxpy/utilities/deterministic.py | .py | def unique_list(duplicates_list):
"""
Return unique list preserving the order.
https://stackoverflow.com/a/480227
"""
used = set()
unique = [x for x in duplicates_list if not (x in used or used.add(x))]
return unique
| 9 | 245 |
jupyterlab | jupyterlab/tests/mock_packages/test-hyphens/test_hyphens/__init__.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
def _jupyter_labextension_paths():
return [{"src": "labextension", "dest": "test-hyphens"}]
| 7 | 199 |
textual | tests/snapshot_tests/snapshot_apps/width_100.py | .py | from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import Label
class Width100PCentApp(App[None]):
CSS = """
Vertical {
border: solid red;
width: auto;
Label {
border: solid green;
}
#first {
... | 37 | 735 |
pyro | tests/contrib/cevae/test_cevae.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import io
import warnings
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro.contrib.cevae import CEVAE, DistributionNet
from tests.common import assert_close
DIST_NETS = [cls.__name__.lower()[:-3... | 72 | 2,388 |
saleor | saleor/graphql/checkout/tests/test_checkout_promo_codes.py | .py | from ....checkout import calculations
from ....checkout.fetch import fetch_checkout_info, fetch_checkout_lines
from ....plugins.manager import get_plugins_manager
from ...core.utils import to_global_id_or_none
from ...tests.utils import get_graphql_content
def test_checkout_totals_use_discounts(api_client, checkout_w... | 139 | 4,246 |
structlog | tests/additional_frame.py | .py | # SPDX-License-Identifier: MIT OR Apache-2.0
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the MIT License. See the LICENSE file in the root of this
# repository for complete details.
"""
Helper function for testing the deduction of stdlib logger names.
Since the logger facto... | 16 | 488 |
confluent-kafka-python | tests/test_Admin.py | .py | #!/usr/bin/env python
import concurrent.futures
import pytest
from confluent_kafka import (
ConsumerGroupState,
ConsumerGroupTopicPartitions,
IsolationLevel,
KafkaError,
KafkaException,
TopicCollection,
TopicPartition,
)
from confluent_kafka.admin import (
AclBinding,
AclBindingFil... | 1,598 | 57,244 |
omegaconf | subprojects/omegaconf-pydevd/setup.py | .py | # type: ignore
import pathlib
import re
import setuptools
ROOT = pathlib.Path(__file__).parent.resolve()
def find_version(*file_paths: str) -> str:
with open(ROOT / pathlib.Path(*file_paths), "r", encoding="utf-8") as fp:
version_file = fp.read()
version_match = re.search(r"^__version__ = ['\"]([^'\... | 60 | 1,806 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_StridedSlice.py | .py | import numpy as np
import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shape': [12, 2, 2, 5], 'dtype': np.int32, 'strides': [2, 1, 3, 1], 'begin': [0, 0, 0, 0], 'end': [12, 2, 2, 5],
'begin_mask': None, 'end_mask': None, 'shrink_axis_mask': 4},
... | 70 | 3,373 |
beam | learning/tour-of-beam/learning-content/core-transforms/motivating-challenge-3/python-solution/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... | 91 | 3,155 |
onnxruntime | onnxruntime/python/tools/microbench/matmul.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 106 | 3,145 |
pyomo | pyomo/contrib/trustregion/funnel.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... | 136 | 5,236 |
saleor | saleor/webhook/response_schemas/taxes.py | .py | from decimal import Decimal
from typing import Annotated
from pydantic import BaseModel, Field, ValidationInfo, field_validator
from ...core.prices import MAXIMUM_PRICE
class LineCalculateTaxesSchema(BaseModel):
tax_rate: Annotated[Decimal, Field(ge=0)]
total_gross_amount: Annotated[Decimal, Field(ge=0, le=... | 37 | 1,376 |
hydra | plugins/hydra_ax_sweeper/tests/apps/polynomial_with_constraint.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any
import hydra
from omegaconf import DictConfig
@hydra.main(config_path=".", config_name="polynomial_with_constraint")
def polynomial(cfg: DictConfig) -> Any:
x = cfg.polynomial.x
y = cfg.polynomial.y
z = cfg.poly... | 23 | 548 |
onnx | onnx/backend/test/case/node/attention.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.reference.ops.op_attention import _compute_attention
class Attenti... | 2,700 | 95,721 |
hydra | plugins/hydra_optuna_sweeper/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from pathlib import Path
from read_version import read_version
from setuptools import find_namespace_packages, setup
setup(
name="hydra-optuna-sweeper",
version=read_version("hydra_plugins/hydra_optuna_sweeper", "__init__.py... | 36 | 1,334 |
metrics | src/torchmetrics/functional/detection/map.py | .py | # Copyright The PyTorch 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 i... | 221 | 9,732 |
saleor | saleor/graphql/discount/types/vouchers.py | .py | import graphene
from graphene import relay
from ....discount import models
from ....permission.enums import DiscountPermissions
from ...channel.dataloaders.by_self import ChannelByIdLoader
from ...channel.types import Channel
from ...core import ResolveInfo, types
from ...core.connection import CountableConnection, cr... | 308 | 11,335 |
textual | docs/examples/styles/links.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Static
TEXT = """\
Here is a [@click='app.bell']link[/] which you can click!
"""
class LinksApp(App):
CSS_PATH = "links.tcss"
def compose(self) -> ComposeResult:
yield Static(TEXT)
yield Static(TEXT, id="custom")
if __n... | 20 | 376 |
probability | tensorflow_probability/python/bijectors/reciprocal.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... | 90 | 2,801 |
django-cms | cms/test_utils/project/placeholderapp/cms_toolbars.py | .py | from django.utils.translation import gettext_lazy as _
from cms.cms_toolbars import ADMIN_MENU_IDENTIFIER, ADMINISTRATION_BREAK
from cms.toolbar.items import Break
from cms.toolbar_base import CMSToolbar
from cms.toolbar_pool import toolbar_pool
from cms.utils.urlutils import admin_reverse
from .models import CharPks... | 27 | 964 |
astropy | astropy/table/tests/test_mixin.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import copy
import pickle
from io import StringIO
import numpy as np
import pytest
from astropy import coordinates, time
from astropy import units as u
from astropy.coordinates import EarthLocation, SkyCoord
from astropy.coordinates.tests.test_represen... | 1,062 | 34,338 |
sphinx | tests/test_ext_autodoc/test_ext_autodoc_names.py | .py | """Test the autodoc extension. This mainly tests name resolution & parsing."""
from __future__ import annotations
import logging
from sphinx.environment import _CurrentDocument
from sphinx.ext.autodoc._names import _parse_name
TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Mapping
from... | 101 | 3,613 |
saleor | saleor/graphql/order/tests/queries/test_order_invoices.py | .py | from .....core import JobStatus
from ....tests.utils import assert_no_permission, get_graphql_content
ORDERS_WITH_INVOICES_QUERY = """
query OrdersQuery {
orders(first: 5) {
edges {
node {
invoices {
status
exte... | 92 | 2,810 |
onnxruntime | orttraining/orttraining/test/python/qat_poc_example/train.py | .py | import logging
import numpy as np
import torch
from torchvision import datasets, transforms
import onnxruntime.training.api as orttraining
def _get_dataloaders(data_dir, batch_size):
"""Preprocesses the data and returns dataloaders."""
transform = transforms.Compose([transforms.ToTensor(), transforms.Norma... | 76 | 2,522 |
mlflow | mlflow/utils/autologging_utils/logging_and_warnings.py | .py | import os
import warnings
from pathlib import Path
from threading import RLock
from threading import get_ident as get_current_thread_id
import mlflow
from mlflow.utils import logging_utils
class _WarningsController:
"""
Provides threadsafe utilities to modify warning behavior for MLflow autologging, includin... | 329 | 14,328 |
probability | tensorflow_probability/python/bijectors/batch_normalization.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... | 261 | 10,576 |
biopython | Scripts/xbbtools/xbb_search.py | .py | #!/usr/bin/env python
# Copyright 2000 by Thomas Sicheritz-Ponten.
# Copyright 2016 by Markus Piotrowski.
# 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.
# Created: Sun Dec 3 ... | 197 | 6,056 |
biopython | Tests/test_SCOP_Hie.py | .py | # Copyright 2001 by Gavin E. Crooks. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Unit test for Hie."""
import unittest
from Bio.SCOP import Hie
class HieTests(unittes... | 42 | 1,318 |
readthedocs.org | readthedocs/rtd_tests/tests/test_domains.py | .py | from unittest import mock
import dns.resolver
from django.conf import settings
from django.test import TestCase, override_settings
from django_dynamic_fixture import get
from readthedocs.projects.forms import DomainForm
from readthedocs.projects.models import Domain, Project
from readthedocs.subscriptions.constants i... | 270 | 8,485 |
openvino | tools/commit_slider/tests/test_util.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import subprocess
import re
import json
import sys
import shutil
from os import path
from utils.cfg_manager import CfgManager
from test_data import TestData
from test_data import TestError
from utils.helpers import formatJSON
... | 285 | 8,568 |
saleor | saleor/plugins/avatax/__init__.py | .py | import datetime
import json
import logging
from collections.abc import Iterator
from dataclasses import dataclass
from decimal import Decimal
from typing import TYPE_CHECKING, Any, cast
from urllib.parse import urljoin
import requests
from django.core.cache import cache
from requests.auth import HTTPBasicAuth
from ..... | 771 | 26,633 |
openvino | tests/layer_tests/pytorch_tests/test_tuple_construct.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import numpy as np
from pytorch_layer_test_class import PytorchLayerTest
class TestTupleConstruct(PytorchLayerTest):
def _prepare_input(self):
return (self.random.uniform(0, 50, (1, 10), dtype=np.float32),)
... | 232 | 7,630 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/raw_cell_with_non_dict_yaml_content.py | .py | # ---
# Content.
# jupyter:
# jupytext:
# cell_markers: region,endregion
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
print("Hello, World!")
| 13 | 197 |
wandb | tests/unit_tests/test_lib/test_json_util.py | .py | """Consistency tests for `wandb.sdk.lib.json_util`.
The wrapper delegates to `pydantic_core` for speed but must remain
behaviorally consistent with stdlib `json` for the patterns we use:
basic types, custom encoders, fallbacks, and NaN/Infinity preservation.
"""
from __future__ import annotations
import io
import js... | 249 | 7,714 |
coveragepy | coverage/parser.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
"""Code parsing for coverage.py."""
from __future__ import annotations
import ast
import collections
import os
import re
import token
import tokenize
from colle... | 1,236 | 47,683 |
beam | learning/katas/python/Core Transforms/Map/Map/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... | 36 | 1,248 |
beam | sdks/python/apache_beam/examples/cookbook/coders_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... | 84 | 2,958 |
omegaconf | subprojects/omegaconf-pydevd/version.py | .py | # Managed by bump-my-version; see pyproject.toml for bump commands.
__version__ = "2.4.0.dev16"
| 3 | 96 |
wagtail | wagtail/documents/tests/test_form_overrides.py | .py | from django import forms
from django.test import TestCase, override_settings
from taggit import models as taggit_models
from wagtail.admin import widgets
from wagtail.admin.widgets import AdminDateTimeInput
from wagtail.documents import models
from wagtail.documents.forms import (
BaseDocumentForm,
get_documen... | 107 | 4,234 |
httpie | tests/test_uploads.py | .py | import os
import json
import sys
import subprocess
import time
import contextlib
import httpie.__main__ as main
import pytest
from httpie.cli.exceptions import ParseError
from httpie.client import FORM_CONTENT_TYPE
from httpie.compat import is_windows
from httpie.status import ExitStatus
from .utils import (
Mock... | 404 | 12,843 |
beam | learning/tour-of-beam/learning-content/triggers/motivating-challenge/python-challenge/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... | 72 | 2,288 |
wandb | wandb/integration/huggingface/resolver.py | .py | from __future__ import annotations
import logging
import os
from collections.abc import Sequence
from datetime import datetime
from typing import Any
import pytz
import wandb
from wandb.sdk.integration_utils.auto_logging import Response
from wandb.sdk.lib.runid import generate_id
logger = logging.getLogger(__name__... | 217 | 7,857 |
coveragepy | tests/test_debug.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
"""Tests of coverage/debug.py"""
from __future__ import annotations
import ast
import io
import os
import re
import sys
from collections.abc import Callable, I... | 512 | 17,592 |
saleor | saleor/core/logging.py | .py | import platform
import time
from celery._state import get_current_task as get_current_celery_task
from pythonjsonlogger.jsonlogger import JsonFormatter as BaseFormatter
from .. import __version__ as saleor_version
class JsonFormatter(BaseFormatter):
converter = time.gmtime # type: ignore[assignment]
def a... | 52 | 1,958 |
pyomo | pyomo/util/tests/test_blockutil.py | .py | # -*- coding: utf-8 -*-
# ____________________________________________________________________________________
#
# 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 En... | 63 | 2,516 |
saleor | saleor/order/search.py | .py | from typing import TYPE_CHECKING
import graphene
from django.conf import settings
from django.db.models import Value, prefetch_related_objects
from ..account.search import generate_address_search_vector_value, generate_email_vector
from ..core.postgres import FlatConcatSearchVector, NoValidationSearchVector
from . im... | 263 | 8,678 |
dirty-equals | dirty_equals/_inspection.py | .py | from typing import Any, TypeVar, Union, overload
from ._base import DirtyEquals
from ._strings import IsStr
from ._utils import get_dict_arg
ExpectedType = TypeVar('ExpectedType', bound=Union[type, tuple[Union[type, tuple[Any, ...]], ...]])
class IsInstance(DirtyEquals[ExpectedType]):
"""
A type which check... | 203 | 6,514 |
pyro | tests/distributions/test_lkj.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import pytest
import torch
from torch.distributions import (
AffineTransform,
Beta,
TransformedDistribution,
biject_to,
transform_to,
)
from pyro.distributions import constraints, transforms
from p... | 150 | 4,821 |
pyomo | pyomo/scripting/driver_help.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... | 542 | 19,126 |
mlflow | mlflow/genai/scorers/trulens/utils.py | .py | from __future__ import annotations
import logging
from typing import Any
from mlflow.entities.trace import Trace
from mlflow.genai.scorers.trulens.registry import build_trulens_args
from mlflow.genai.utils.trace_utils import (
extract_retrieval_context_from_trace,
parse_inputs_to_str,
parse_outputs_to_str... | 106 | 3,380 |
saleor | saleor/tests/e2e/orders/discounts/test_order_products_from_the_same_category_on_fixed_promotion.py | .py | import pytest
from .....product.tasks import recalculate_discounted_price_for_products_task
from ... import DEFAULT_ADDRESS
from ...product.utils import (
create_category,
create_product,
create_product_channel_listing,
create_product_type,
create_product_variant,
create_product_variant_channel... | 265 | 8,892 |
openvino | tools/commit_slider/tests/__init__.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
skip_commit_slider_devtest = pytest.mark.skip(
reason="Test is used to check stability of commit_slider after development changes"
"and does not suppose regular checks.")
| 11 | 283 |
wandb | wandb/automations/_generated/get_entity_automations.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/automations/
from __future__ import annotations
from pydantic import Field
from wandb._pydantic import GQLResult
from .fragments import PageInfoFields, TriggerFields
class GetEntityAutomations(GQLResult):
scope: GetEntityAutomationsScope | None
... | 34 | 847 |
coremltools | deps/protobuf/python/google/protobuf/internal/descriptor_test.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... | 1,047 | 43,709 |
returns | tests/test_io/test_io_container/test_io_equality.py | .py | from returns.io import IO
def test_equals():
"""Ensures that ``.equals`` method works correctly."""
assert IO(1).equals(IO(1))
assert IO(1).equals(IO.from_value(1))
def test_not_equals():
"""Ensures that ``.equals`` method works correctly."""
assert not IO(1).equals(IO('a'))
def test_equality(... | 27 | 644 |
wagtail | wagtail/test/urls_multilang_non_root.py | .py | from django.conf.urls.i18n import i18n_patterns
from django.urls import include, path
from wagtail import urls as wagtail_urls
from wagtail.admin import urls as wagtailadmin_urls
urlpatterns = [
path("admin/", include(wagtailadmin_urls)),
]
urlpatterns += i18n_patterns(path("site/", include(wagtail_urls)))
| 12 | 315 |
mlflow | tests/models/test_display_utils.py | .py | from pathlib import Path
from unittest import mock
import pytest
from mlflow.models import infer_signature
from mlflow.models.display_utils import (
_generate_agent_eval_recipe,
_should_render_agent_eval_template,
)
from mlflow.models.rag_signatures import StringResponse
from mlflow.types.llm import (
Cha... | 100 | 3,391 |
pymc | pymc/step_methods/__init__.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... | 61 | 1,838 |
wandb | wandb/sdk/launch/runner/vertex_runner.py | .py | from __future__ import annotations
import asyncio
import logging
from typing import Any
if False:
from google.cloud import aiplatform # type: ignore # noqa: F401
from wandb.apis.internal import Api
from wandb.util import get_module
from .._project_spec import LaunchProject
from ..environment.gcp_environment ... | 228 | 8,183 |
scikit-bio | skbio/stats/distance/_mantel.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.
# --------------------------------------------... | 890 | 33,575 |
coremltools | coremltools/converters/_converters_entry.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 collections
from datetime import date
import gc
import os
from typing import List, Optional, Text... | 1,191 | 50,180 |
openvino | tests/e2e_tests/common/readers/provider.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import inspect
from e2e_tests.common.common.base_provider import BaseProvider, BaseStepProvider
class ClassProvider(BaseProvider):
registry = {}
@classmethod
def validate(cls):
methods = [
f[0] for f i... | 39 | 1,230 |
mlflow | mlflow/tracing/otel/translation/base.py | .py | """
Base class for OTEL semantic convention translators.
This module provides a base class that implements common translation logic.
Subclasses only need to define the attribute keys and mappings as class attributes.
"""
import json
import logging
from typing import Any
_logger = logging.getLogger(__name__)
class ... | 238 | 7,822 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.