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 | pyro/contrib/gp/kernels/isotropic.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.distributions import constraints
from pyro.contrib.gp.kernels.kernel import Kernel
from pyro.nn.module import PyroParam
def _torch_sqrt(x, eps=1e-12):
"""
A convenient function to avoid the NaN gr... | 185 | 5,740 |
mlflow | tests/tracking/conftest.py | .py | import pytest
import mlflow
from mlflow.environment_variables import MLFLOW_ENABLE_ASYNC_TRACE_LOGGING
from mlflow.tracing.fluent import _flush_pending_async_trace_writes
@pytest.fixture(autouse=True)
def enable_async_trace_logging(monkeypatch):
"""Enable async trace logging for all tests in tests/tracking/ to e... | 26 | 769 |
hatch | tests/cli/python/conftest.py | .py | import secrets
import pytest
from hatch.utils.shells import detect_shell
@pytest.fixture(autouse=True)
def default_shells(platform):
return [] if platform.windows else [detect_shell(platform)[0]]
@pytest.fixture(autouse=True)
def isolated_python_directory(config_file):
config_file.model.dirs.python = "iso... | 33 | 769 |
sqlmap | plugins/dbms/monetdb/takeover.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.exception import SqlmapUnsupportedFeatureException
from plugins.generic.takeover import Takeover as GenericTakeover
class Takeover(GenericTakeover):
def osCmd(s... | 29 | 974 |
beam | sdks/python/apache_beam/dataframe/io.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... | 902 | 30,015 |
scikit-optimize | skopt/tests/test_transformers.py | .py | import pytest
import numbers
import numpy as np
from numpy.testing import assert_raises
from numpy.testing import assert_array_equal
from numpy.testing import assert_equal
from numpy.testing import assert_raises_regex
from skopt.space import LogN, Normalize
from skopt.space.transformers import StringEncoder, LabelEncod... | 121 | 4,017 |
openvino | tests/layer_tests/ovc_python_api_tests/conftest.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import inspect
from common.layer_test_class import get_params
def pytest_generate_tests(metafunc):
test_gen_attrs_names = list(inspect.signature(get_params).parameters)
params = get_params()
metafunc.parametrize(test_gen_... | 14 | 359 |
saleor | saleor/plugins/webhook/tests/test_payment_method_process_tokenization.py | .py | import json
from unittest import mock
import graphene
import pytest
from ....core.models import EventDelivery
from ....payment.interface import (
ListStoredPaymentMethodsRequestData,
PaymentMethodProcessTokenizationRequestData,
PaymentMethodTokenizationResponseData,
PaymentMethodTokenizationResult,
)
... | 546 | 17,633 |
probability | tensorflow_probability/python/bijectors/softplus_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... | 190 | 7,150 |
saleor | saleor/graphql/product/tests/queries/variants_where/test_over_multiple_arguments.py | .py | import pytest
from ......attribute import AttributeEntityType, AttributeInputType, AttributeType
from ......attribute.models.base import Attribute, AttributeValue
from ......attribute.utils import associate_attribute_values_to_instance
from ......page.models import Page
from ......product.models import Product
from ..... | 410 | 13,394 |
mlflow | mlflow/langchain/utils/chat.py | .py | import json
import logging
import time
from collections import defaultdict
from collections.abc import Iterator
from typing import Any
import pydantic
from langchain_core.messages import (
AIMessage,
BaseMessage,
FunctionMessage,
HumanMessage,
SystemMessage,
ToolMessage,
)
from langchain_core.m... | 510 | 18,554 |
saleor | saleor/graphql/tax/mutations/tax_exemption_manage.py | .py | from typing import Final
import graphene
from django.core.exceptions import ValidationError
from ....checkout.fetch import fetch_checkout_info, fetch_checkout_lines
from ....checkout.models import Checkout
from ....checkout.utils import invalidate_checkout
from ....graphql.core.mutations import BaseMutation
from ....... | 117 | 4,315 |
scikit-bio | skbio/alignment/__init__.py | .py | r"""Sequence Alignments (:mod:`skbio.alignment`)
============================================
.. currentmodule:: skbio.alignment
This module provides functionality for computing and manipulating sequence
alignments. DNA, RNA, and protein sequences can be aligned, as well as
sequences with or without custom alphabets.... | 457 | 15,036 |
onnx | onnx/reference/ops/op_deform_conv.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
from onnx.reference.ops import op_grid_sample
def _deform_conv_implementation(
X, W, offset, B, mask, dilations, group, kernel_shape, of... | 182 | 6,291 |
pyro | tests/conftest.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import os
import warnings
import pytest
import torch
import pyro
DTYPE = getattr(torch, os.environ.get("PYRO_DTYPE", "float64"))
torch.set_default_dtype(DTYPE)
torch.set_default_device(os.environ.get("PYRO_DEVICE", "cpu"))
def... | 116 | 3,380 |
pyomo | pyomo/core/tests/unit/test_obj.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... | 850 | 25,852 |
mlflow | tests/projects/test_databricks.py | .py | import filecmp
import json
import os
import shutil
from unittest import mock
import pytest
import mlflow
from mlflow import MlflowClient, cli
from mlflow.entities import RunStatus
from mlflow.environment_variables import MLFLOW_TRACKING_URI
from mlflow.exceptions import MlflowException
from mlflow.legacy_databricks_c... | 499 | 18,404 |
coveragepy | coverage/sysmon.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
"""Callback functions and support for sys.monitoring data collection."""
from __future__ import annotations
import collections
import functools
import inspect
i... | 504 | 19,627 |
beam | sdks/python/apache_beam/examples/complete/juliaset/juliaset/juliaset_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... | 94 | 3,033 |
wagtail | wagtail/contrib/settings/context_processors.py | .py | from wagtail.contrib.settings.models import BaseGenericSetting, BaseSiteSetting
from wagtail.models import Site
from .registry import registry
class SettingProxy(dict):
"""
Get a SettingModuleProxy for an app using proxy['app_label']
"""
def __init__(self, request_or_site):
self.request_or_s... | 76 | 2,467 |
saleor | saleor/graphql/discount/tests/mutations/test_voucher_catalogues_add.py | .py | import json
from unittest.mock import patch
import graphene
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....core.utils.json_serializer import CustomJsonEncoder
from .....discount.error_codes import DiscountErrorCode
from .....webhook.event_types import WebhookEventAsyn... | 230 | 7,187 |
deap | doc/code/examples/nsga3_ref_points_combined_plot.py | .py | import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy
from deap import tools
NOBJ = 3
P = [2, 1]
SCALES = [1, 0.5]
fig = plt.figure(figsize=(7, 7))
ax = fig.add_subplot(111, projection="3d")
# the coordinate origin
ax.scatter(0, 0, 0, c="k", marker="+", s=100)
# reference points
# Pa... | 43 | 1,086 |
onnx | onnx/backend/test/case/node/clip.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
class Clip(Base):
@staticmethod
def export() -> None:
node =... | 145 | 4,582 |
confluent-kafka-python | tests/schema_registry/_async/test_bearer_field_provider.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2025 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 319 | 11,686 |
conda | tests/plugins/test_settings.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import json
import logging
from contextlib import nullcontext
import pytest
from pytest import MonkeyPatch
from ruamel.yaml import YAML
from conda import plugins
from conda.base.context import context, reset_context
from conda.common.configura... | 603 | 17,565 |
httpie | httpie/cli/utils.py | .py | import argparse
from typing import Any, Callable, Generic, Iterator, Iterable, Optional, TypeVar
T = TypeVar('T')
class Manual(argparse.Action):
def __init__(
self,
option_strings,
dest=argparse.SUPPRESS,
default=argparse.SUPPRESS,
help=None
):
super().__init__... | 80 | 2,151 |
biopython | Tests/test_ExPASy.py | .py | # Copyright 2017 by Peter Cock. 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.
"""Testing Bio.ExPASy online code."""
import unittest
import requires_internet
# We want to te... | 90 | 2,960 |
readthedocs.org | readthedocs/storage/s3_storage.py | .py | """
AWS S3 Storage backends.
We override the backends provided by django-storages to add some small pieces
that we need to make our project to work as we want. For example, using
ManifestFilesMixin for static files and OverrideHostnameMixin to make it work
in our Docker Development environment.
"""
# Disable abstract... | 174 | 6,285 |
clearml | clearml/utilities/pyhocon/exceptions.py | .py | class ConfigException(Exception):
def __init__(self, message, ex=None):
super(ConfigException, self).__init__(message)
self._exception = ex
class ConfigMissingException(ConfigException, KeyError):
pass
class ConfigSubstitutionException(ConfigException):
pass
class ConfigWrongTypeExcep... | 18 | 352 |
readthedocs.org | readthedocs/core/management/commands/contact_owners.py | .py | import sys
from pathlib import Path
import structlog
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand
from readthedocs.core.permissions import AdminPermission
from readthedocs.core.utils.contact import contact_users
from readthedocs.or... | 208 | 6,851 |
onnxruntime | onnxruntime/python/tools/transformers/models/whisper/whisper_jump_times.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import ... | 480 | 19,560 |
cvxpy | cvxpy/reductions/dgp2dcp/canonicalizers/gmatmul_canon.py | .py | def gmatmul_canon(expr, args):
return expr.A @ args[0], []
| 3 | 63 |
beam | sdks/python/apache_beam/transforms/cy_combiners.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... | 431 | 11,209 |
python-prompt-toolkit | examples/tutorial/sqlite-cli.py | .py | #!/usr/bin/env python
import sqlite3
import sys
from pygments.lexers.sql import SqlLexer
from prompt_toolkit import PromptSession
from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.lexers import PygmentsLexer
from prompt_toolkit.styles import Style
sql_completer = WordCompleter(
[
"a... | 185 | 3,600 |
beam | sdks/python/apache_beam/io/gcp/healthcare/dicomio_integration_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... | 251 | 9,220 |
mlflow | mlflow/gateway/providers/litellm.py | .py | from __future__ import annotations
import importlib.util
import json
from typing import Any, AsyncIterable
from mlflow.exceptions import MlflowException
from mlflow.gateway.config import EndpointConfig, LiteLLMConfig
from mlflow.gateway.providers.anthropic import _normalize_anthropic_input_tokens
from mlflow.gateway.... | 597 | 24,036 |
textual | tests/snapshot_tests/snapshot_apps/screen_switch.py | .py | from textual.app import App, ComposeResult
from textual.screen import Screen
from textual.widgets import Static, Header, Footer
class ScreenA(Screen):
BINDINGS = [("b", "switch_to_b", "Switch to screen B")]
def compose(self) -> ComposeResult:
yield Header()
yield Static("A")
yield Foo... | 39 | 838 |
mlflow | examples/pytorch/HPOExample/hpo_mnist.py | .py | """
Hyperparameter Optimization Example with Pure PyTorch and MLflow
This example demonstrates:
- Using MLflow to track hyperparameter optimization trials
- Parent/child run structure for organizing HPO experiments
- Pure PyTorch training (no Lightning dependencies)
- Simple MNIST classification with configurable hype... | 158 | 5,410 |
probability | tensorflow_probability/python/internal/backend/numpy/gen/linear_operator_block_lower_triangular.py | .py | # Copyright 2020 The TensorFlow Probability Authors. All Rights Reserved.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# THIS FILE IS AUTO-GENERATED BY `gen_linear_operators.py`.
# DO NOT MODIFY DIRECTLY.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@... | 1,023 | 44,412 |
sqlmap | tests/test_databases_enum.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Unit tests for the enumeration methods of plugins/generic/databases.py.
The injection layer (lib.request.inject.getValue) is mocked so no network or
live DBMS is required; each test ... | 774 | 28,267 |
wandb | wandb/sdk/launch/runner/sagemaker_runner.py | .py | """Implementation of the SageMakerRunner class."""
from __future__ import annotations
import asyncio
import logging
from typing import Any, cast
if False:
import boto3 # type: ignore
import wandb
from wandb.apis.internal import Api
from wandb.sdk.launch.environment.aws_environment import AwsEnvironment
from wa... | 427 | 15,241 |
mlflow | dev/update_requirements.py | .py | """
This script updates the `max_major_version` attribute of each package in a YAML dependencies
specification (e.g. requirements/core-requirements.yaml) to the maximum available version on PyPI.
"""
import asyncio
import os
import re
import urllib.error
import urllib.request
from datetime import datetime, timedelta, ... | 109 | 3,973 |
pyomo | pyomo/contrib/interior_point/linalg/base_linear_solver_interface.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... | 31 | 1,156 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/filter_test.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");... | 97 | 3,401 |
openvino | src/bindings/python/tests/test_graph/test_string_tensor_pack.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino import Type
import openvino.opset15 as ov
import pytest
@pytest.mark.parametrize(("dtype"), [
Type.i32,
Type.i64
])
@pytest.mark.parametrize(("indices_shape"), [
(4,),
(1, 3, 4),
... | 29 | 875 |
onnxruntime | tools/python/gen_contrib_doc.py | .py | #!/usr/bin/env python
# This file is copied and adapted from https://github.com/onnx/onnx repository.
# There was no copyright statement on the file at the time of copying.
import argparse
import os
import pathlib
import sys
from collections import defaultdict
import numpy as np
import onnxruntime.capi.onnxruntime_... | 399 | 13,644 |
lemur | lemur/tests/test_destinations.py | .py | import json
import pytest
from lemur.destinations.views import * # noqa
from .vectors import (
VALID_ADMIN_API_TOKEN,
VALID_ADMIN_HEADER_TOKEN,
VALID_USER_HEADER_TOKEN,
)
def test_invalid_label():
from lemur.destinations.models import Destination
with pytest.raises(ValueError) as e:
D... | 274 | 7,313 |
probability | tensorflow_probability/python/mcmc/metropolis_hastings_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... | 397 | 15,505 |
scikit-bio | skbio/stats/composition/_dirmult.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.
# --------------------------------------------... | 725 | 30,933 |
mlflow | tests/pyfunc/test_spark.py | .py | import datetime
import os
import random
import shutil
import subprocess
import sys
import threading
import time
from pathlib import Path
from typing import Any, Iterator, NamedTuple
from unittest import mock
import cloudpickle
import numpy as np
import pandas as pd
import pyspark
import pytest
from packaging.version i... | 1,779 | 64,229 |
saleor | saleor/graphql/checkout/tests/mutations/test_checkout_billing_address_update.py | .py | from unittest import mock
from unittest.mock import ANY, patch
import pytest
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from .....checkout.actions import call_checkout_info_event
from .....checkout.utils import invalidate_checkout
from .....core.model... | 991 | 31,093 |
python-prompt-toolkit | examples/full-screen/simple-demos/vertical-split.py | .py | #!/usr/bin/env python
"""
Vertical split example.
"""
from prompt_toolkit.application import Application
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout.containers import VSplit, Window
from prompt_toolkit.layout.controls import FormattedTextControl
from prompt_toolkit.layout.layout impor... | 46 | 943 |
jupytext | tests/unit/data/landing_page/notebook_percent.py | .py | # %% [markdown]
# # Quarterly Sales
# A look at Q4 revenue by region.
# %%
import pandas as pd
df = pd.read_csv("sales.csv")
# %%
df.groupby("region")["revenue"].sum().plot.bar()
| 11 | 181 |
saleor | saleor/graphql/account/tests/queries/test_me.py | .py | from decimal import Decimal
from unittest import mock
import graphene
import pytest
from django.utils import timezone
from .....checkout.calculations import _fetch_checkout_prices_if_expired
from .....checkout.fetch import fetch_checkout_lines
from .....order import OrderStatus
from .....order.models import Fulfillme... | 862 | 25,340 |
gunicorn | tests/docker/asgi_compliance/test_websocket_compliance.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
WebSocket compliance integration tests for ASGI.
Tests RFC 6455 WebSocket protocol compliance including handshake,
messaging, close codes, and subprotocol negotiation.
"""
import asyncio
import json
import p... | 703 | 29,301 |
clearml | clearml/hyperdatasets/management.py | .py | from typing import (
Optional,
Sequence,
List,
Dict,
Any,
Tuple,
Type,
TypeVar,
)
from clearml.backend_api import Session
from clearml.backend_interface.util import get_existing_project, mutually_exclusive
from clearml.backend_interface.datasets.hyper_dataset import HyperDatasetManageme... | 329 | 13,470 |
pyomo | pyomo/contrib/appsi/solvers/wntr.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... | 527 | 18,749 |
ipython | IPython/lib/backgroundjobs.py | .py | """Manage background (threaded) jobs conveniently from an interactive shell.
This module provides a BackgroundJobManager class. This is the main class
meant for public usage, it implements an object which can create and manage
new background jobs.
It also provides the actual job classes managed by these BackgroundJo... | 491 | 17,574 |
metrics | tests/unittests/regression/test_spearman.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... | 158 | 6,363 |
openvino | docs/snippets/src/main.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
#! [import]
import openvino as ov
#! [import]
#! [part1]
core = ov.Core()
#! [part1]
#! [part2_1]
compiled_model = core.compile_model("model.xml", "AUTO")
#! [part2_1]
#! [part2_2]
compiled_model = core.compile_model... | 65 | 1,640 |
onnxruntime | onnxruntime/test/python/transformers/test_phi_vision.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import ... | 305 | 11,806 |
pyomo | examples/pyomobook/scripts-ch/warehouse_print.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... | 59 | 1,765 |
conda | tests/cli/test_formats.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from conda.cli.formats import get_multiplatform_lockfile
from conda.plugins.types import CondaEnvironmentExporter, EnvironmentFormat
def test_get_multiplatform_lockfile():
# no plugins
assert get_multiplatform_lockfile({}) is None
... | 47 | 1,733 |
beam | sdks/python/apache_beam/io/gcp/bigquery_schema_tools.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... | 164 | 6,059 |
metrics | tests/unittests/audio/test_snr.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... | 120 | 4,480 |
coremltools | coremltools/test/sklearn_tests/test_random_forest_regression.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import unittest
from ..utils import load_boston
from coremltools._deps import _HAS_SKLEARN
if _HAS_SK... | 88 | 3,275 |
biopython | Tests/test_File.py | .py | # Copyright 1999 by Jeffrey Chang. 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 Bio.File module."""
import os.path
import shutil
import tempfile
import unittest
... | 127 | 4,043 |
wandb | wandb/sdk/lib/preinit.py | .py | from __future__ import annotations
from collections.abc import Callable
from typing import Any
import wandb
class PreInitObject:
def __init__(self, name: str, destination: Any | None = None) -> None:
self._name = name
if destination is not None:
self.__doc__ = destination.__doc__
... | 46 | 1,497 |
sphinx | sphinx/locale/__init__.py | .py | """Locale utilities."""
from __future__ import annotations
import locale
import sys
from gettext import NullTranslations, translation
from pathlib import Path
from typing import TYPE_CHECKING
from sphinx import package_dir
if TYPE_CHECKING:
import os
from collections.abc import Callable, Iterable
from t... | 240 | 7,326 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/django_app/views.py | .py | """
Django views for ASGI compatibility testing.
"""
import asyncio
import json
from django.http import (
HttpRequest,
HttpResponse,
JsonResponse,
StreamingHttpResponse,
)
from django.views.decorators.csrf import csrf_exempt
def serialize_scope(scope: dict) -> dict:
"""Convert ASGI scope to JSON... | 135 | 4,324 |
cvxpy | cvxpy/expressions/constants/__init__.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... | 20 | 670 |
beam | sdks/python/apache_beam/examples/inference/online_clustering/clustering_pipeline/setup.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... | 45 | 1,620 |
beam | sdks/python/apache_beam/ml/gcp/cloud_dlp_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... | 153 | 5,837 |
wagtail | wagtail/admin/views/generic/mixins.py | .py | import json
from django.conf import settings
from django.contrib.admin.utils import quote
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied
from django.db import models, transaction
from django.forms import Media
from django.http import JsonResponse
from dja... | 988 | 36,734 |
probability | tensorflow_probability/python/experimental/distributions/increment_log_prob.py | .py | # Copyright 2021 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 194 | 7,587 |
clearml | examples/frameworks/hydra/hydra_example.py | .py | # ClearML - Hydra Example
#
import hydra
from omegaconf import OmegaConf
from clearml import Task
@hydra.main(config_path="config_files", config_name="config", version_base=None)
def my_app(cfg):
# type (DictConfig) -> None
task = Task.init(project_name="examples", task_name="Hydra configuration")
logge... | 21 | 521 |
luigi | test/scheduler_visualisation_test.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... | 594 | 19,875 |
mlflow | dev/clint/tests/rules/test_prefer_os_environ.py | .py | from pathlib import Path
import pytest
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import lint_file
from clint.rules.prefer_os_environ import PreferOsEnviron
@pytest.mark.parametrize(
"code",
[
pytest.param('import os\n\nval = os.getenv("FOO")', id="os.getenv... | 39 | 1,501 |
pyro | tests/contrib/tracking/test_em.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import math
import pytest
import torch
from torch.distributions import constraints
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.contrib.tracking.assignment import MarginalA... | 228 | 8,636 |
black | tests/data/cases/import_line_collapse.py | .py | from middleman.authentication import validate_oauth_token
logger = logging.getLogger(__name__)
# case 2 comment after import
from middleman.authentication import validate_oauth_token
#comment
logger = logging.getLogger(__name__)
# case 3 comment after import
from middleman.authentication import validate_oauth_to... | 180 | 2,076 |
mlflow | mlflow/models/resources.py | .py | import os
from abc import ABC, abstractmethod
from enum import Enum
from typing import Any
import yaml
DEFAULT_API_VERSION = "1"
class ResourceType(Enum):
"""
Enum to define the different types of resources needed to serve a model.
"""
UC_CONNECTION = "uc_connection"
VECTOR_SEARCH_INDEX = "vect... | 342 | 12,220 |
beam | sdks/python/apache_beam/runners/worker/sdk_worker_main.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... | 426 | 16,197 |
openvino | tests/layer_tests/pytorch_tests/test_narrow.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 TestNarrow(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(*self.input_shape),)
def create_model(self, dim,... | 40 | 1,323 |
mlflow | dev/clint/tests/rules/test_lazy_import.py | .py | from pathlib import Path
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import Position, Range, lint_file
from clint.rules import LazyImport
def test_lazy_import(index: SymbolIndex) -> None:
code = """
def f():
# Bad
import sys
import pandas as pd
# Good
import... | 50 | 1,374 |
python-dotenv | tests/test_ipython.py | .py | import os
import sys
from unittest import mock
import pytest
pytest.importorskip("IPython")
@pytest.mark.skipif(
sys.platform == "win32", reason="This test assumes case-sensitive variable names"
)
@mock.patch.dict(os.environ, {}, clear=True)
def test_ipython_existing_variable_no_override(tmp_path):
from IPy... | 64 | 1,739 |
django-cms | cms/test_utils/project/emailuserapp/models.py | .py | from urllib.parse import quote
from django.contrib.auth.models import (
AbstractBaseUser,
BaseUserManager,
PermissionsMixin,
)
from django.core.mail import send_mail
from django.db import models
from django.utils import timezone
class EmailUserManager(BaseUserManager):
def _create_user(self, email, ... | 127 | 3,568 |
sqlmap | lib/request/websocket.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
# Native, dependency-free WebSocket client (RFC 6455), replacing the 'websocket-client' third-party
# library. Covers exactly what sqlmap needs: the client handshake, masked text ... | 231 | 8,068 |
beam | sdks/python/apache_beam/io/fileio.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... | 942 | 32,383 |
textual | src/textual/widgets/collapsible.py | .py | from textual.widgets._collapsible import CollapsibleTitle
__all__ = ["CollapsibleTitle"]
| 4 | 90 |
metrics | tests/unittests/image/test_perceptual_path_length.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... | 208 | 7,972 |
probability | spinoffs/fun_mc/fun_mc/sga_hmc_test.py | .py | # Copyright 2021 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 386 | 11,912 |
marshmallow | src/marshmallow/fields.py | .py | # ruff: noqa: SLF001
from __future__ import annotations
import abc
import collections
import copy
import datetime as dt
import decimal
import email.utils
import ipaddress
import math
import numbers
import typing
import uuid
from collections.abc import Mapping as _Mapping
from enum import Enum as EnumType
try:
fro... | 2,152 | 75,337 |
biopython | Tests/test_align_substitution_matrices.py | .py | # 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 Array in the Bio.Align.substitution_matrices module."""
try:
import numpy as np
except ImportError:
from Bio import MissingExtern... | 2,440 | 142,224 |
saleor | saleor/tests/e2e/taxes/utils/tax_class_create.py | .py | from ...utils import get_graphql_content
TAX_CLASS_CREATE_MUTATION = """
mutation TaxClassCreate($input: TaxClassCreateInput!) {
taxClassCreate(input: $input) {
errors {
field
message
code
}
taxClass {
id
name
countries {
country {
code
}
... | 45 | 893 |
wandb | wandb/proto/v5/wandb_otel_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: wandb/proto/wandb_otel.proto
# Protobuf Python Version: 5.26.0
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from goo... | 38 | 3,022 |
coveragepy | tests/test_process.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 for process behavior of coverage.py."""
from __future__ import annotations
import csv
import glob
import itertools
import json
import os
import os.path... | 1,789 | 62,846 |
clearml | examples/advanced/model_finetuning/upload_local_model.py | .py | import argparse
from clearml import OutputModel, Task
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--model-path", type=str, help="Path to the model to be uploaded to ClearML"
)
parser.add_argument(
"--model-name", type=str, help="Model name - to be display... | 25 | 701 |
loguru | loguru/_ctime_functions.py | .py | import os
def load_ctime_functions():
if os.name == "nt":
import win32_setctime
def get_ctime_windows(filepath):
return os.stat(filepath).st_ctime
def set_ctime_windows(filepath, timestamp):
if not win32_setctime.SUPPORTED:
return
try:... | 58 | 1,527 |
astropy | astropy/modeling/physical_models.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Models that have physical origins.
"""
# pylint: disable=invalid-name, no-member
import warnings
import numpy as np
from astropy import constants as const
from astropy import units as u
from astropy.utils.exceptions import AstropyUserWarning
from .... | 807 | 26,301 |
pyro | tests/distributions/test_independent.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.distributions.utils import _sum_rightmost
import pyro.distributions as dist
from pyro.util import torch_isnan
from tests.common import assert_equal
@pytest.mark.parametrize("sample_shape", [... | 152 | 5,135 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.