repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
mlflow | tests/claude_code/test_plugin.py | .py | import json
import subprocess
from unittest import mock
import click
import pytest
from mlflow.claude_code.plugin import disable_tracing_plugin, ensure_plugin_installed
def test_disable_tracing_plugin_removes_env_only(tmp_path):
settings_path = tmp_path / ".claude" / "settings.json"
settings_path.parent.mkd... | 50 | 1,753 |
saleor | saleor/tests/e2e/orders/test_cancel_unpaid_order.py | .py | import pytest
from .. import DEFAULT_ADDRESS
from ..product.utils.preparing_product import prepare_product
from ..shop.utils.preparing_shop import prepare_default_shop
from ..utils import assign_permissions
from .utils import (
draft_order_complete,
draft_order_create,
draft_order_update,
order_cancel,... | 96 | 2,872 |
luigi | test/task_status_message_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... | 42 | 1,223 |
saleor | saleor/plugins/webhook/tests/test_payment_method_initialize_tokenization.py | .py | import json
from unittest import mock
import graphene
import pytest
from ....core.models import EventDelivery
from ....payment import TokenizedPaymentFlow
from ....payment.interface import (
ListStoredPaymentMethodsRequestData,
PaymentMethodInitializeTokenizationRequestData,
PaymentMethodTokenizationRespo... | 536 | 17,757 |
pyro | examples/inclined_plane.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import argparse
import numpy as np
import torch
import pyro
from pyro.distributions import Normal, Uniform
from pyro.infer import EmpiricalMarginal, Importance
"""
Samantha really likes physics---but she likes Pyro even more. I... | 153 | 5,455 |
mkdocs-material | material/plugins/tags/structure/mapping/manager/__init__.py | .py | # Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, c... | 255 | 8,402 |
sqlmap | plugins/dbms/access/fingerprint.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.common import Backend
from lib.core.common import Format
from lib.core.common import getCurrentThreadData
from lib.core.common import randomStr
from lib.c... | 194 | 5,852 |
textual | tests/test_binding.py | .py | from string import ascii_lowercase
import pytest
from textual.app import App
from textual.binding import (
Binding,
BindingError,
BindingsMap,
InvalidBinding,
NoBinding,
)
from textual.screen import Screen
BINDING1 = Binding("a,b", action="action1", description="description1")
BINDING2 = Binding(... | 140 | 3,992 |
pyro | tests/poutine/test_trace_struct.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import itertools
import pytest
from pyro.poutine import Trace
from tests.common import assert_equal
EDGE_SETS = [
# 1
# / \
# 2 3
# / \
# 4 5
# / \
# 6 7
[(1, 2), (1, 3), (3, 4), (3... | 70 | 1,742 |
python-prompt-toolkit | tests/test_utils.py | .py | from __future__ import annotations
import itertools
import pytest
from prompt_toolkit.utils import take_using_weights
def test_using_weights():
def take(generator, count):
return list(itertools.islice(generator, 0, count))
# Check distribution.
data = take(take_using_weights(["A", "B", "C"], [... | 79 | 1,624 |
pyomo | pyomo/gdp/tests/test_util.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... | 257 | 9,396 |
more-itertools | docs/conf.py | .py | #
# more-itertools documentation build configuration file, created by
# sphinx-quickstart on Mon Jun 25 20:42:39 2012.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration va... | 287 | 9,041 |
beam | sdks/python/apache_beam/io/gcp/experimental/spannerio.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... | 1,319 | 48,565 |
wagtail | wagtail/test/routablepage/apps.py | .py | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class WagtailRoutablePageTestsAppConfig(AppConfig):
name = "wagtail.test.routablepage"
label = "routablepagetests"
verbose_name = _("Wagtail routable page tests")
| 9 | 266 |
probability | tensorflow_probability/python/bijectors/kumaraswamy_cdf_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... | 143 | 5,625 |
mlflow | tests/langchain/test_langchain_model_export.py | .py | import inspect
import json
import os
import shutil
from operator import itemgetter
from typing import Any, Iterator
from unittest import mock
import langchain
import pytest
import yaml
from langchain_community.document_loaders import TextLoader
from langchain_community.embeddings.fake import FakeEmbeddings
from langch... | 2,307 | 83,653 |
pyomo | pyomo/solvers/tests/mip/test_scip_log_data.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... | 280 | 7,594 |
pyomo | pyomo/contrib/mindtpy/extended_cutting_plane.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 E... | 172 | 6,968 |
luigi | luigi/contrib/opener.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... | 251 | 7,047 |
mlflow | tests/test_exceptions.py | .py | import json
import pickle
import pytest
from mlflow.exceptions import MlflowException, RestException
from mlflow.protos.databricks_pb2 import (
ENDPOINT_NOT_FOUND,
INTERNAL_ERROR,
INVALID_PARAMETER_VALUE,
INVALID_STATE,
IO_ERROR,
RESOURCE_ALREADY_EXISTS,
)
def test_error_code_constructor():
... | 213 | 7,849 |
textual | src/textual/document/_document_navigator.py | .py | import re
from bisect import bisect, bisect_left, bisect_right
from typing import Any, Sequence
from textual._cells import cell_len
from textual.document._document import Location
from textual.document._wrapped_document import WrappedDocument
from textual.geometry import Offset, clamp
class DocumentNavigator:
""... | 471 | 18,340 |
openvino | src/frontends/onnx/tests/tests_python/test_onnx_external_data.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import numpy as np
from openvino import Core
import shutil
import pytest
from tests.runtime import get_runtime
external_data_model_current_folder_path = "external_data.onnx"
external_data_model_full_p... | 46 | 1,561 |
openvino | tests/layer_tests/pytorch_tests/test_masked_fill.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import torch
from packaging.version import parse as parse_version
import pytest
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
class TestMaskedFill(PytorchLayerTest):
def _prepare_input(se... | 77 | 3,334 |
hypercorn | tests/test_logging.py | .py | from __future__ import annotations
import logging
import os
import time
import pytest
from hypercorn.config import Config
from hypercorn.logging import AccessLogAtoms, Logger
from hypercorn.typing import HTTPScope, ResponseSummary
@pytest.mark.parametrize(
"target, expected_name, expected_handler_type",
[
... | 116 | 3,976 |
conda | tests/gateways/disk/test_permissions.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import errno
import os
import uuid
from contextlib import contextmanager
from errno import EACCES, ENOENT, EPERM, EROFS
from os.path import isfile, join, lexists
from shutil import rmtree
from stat import (
S_IRWXG,
S_IRWXO,
S_IRWXU,... | 165 | 4,687 |
openvino | tests/layer_tests/jax_tests/test_device_put.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import jax
import numpy as np
import pytest
from jax import lax
from jax import numpy as jnp
from jax_layer_test_class import JaxLayerTest
rng = np.random.default_rng(233454)
class TestDevicePut(JaxLayerTest):
def _prepare_input(... | 46 | 1,452 |
dirty-equals | dirty_equals/_dict.py | .py | from __future__ import annotations
from collections.abc import Container
from typing import Any, Callable, overload
from ._base import DirtyEquals, DirtyEqualsMeta
from ._utils import get_dict_arg
NotGiven = object()
class IsDict(DirtyEquals[dict[Any, Any]]):
"""
Base class for comparing dictionaries. By d... | 235 | 8,285 |
pyro | pyro/contrib/funsor/infer/traceenum_elbo.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import contextlib
import funsor
from funsor.adjoint import AdjointTape
from funsor.sum_product import _partition
from pyro.contrib.funsor import to_data, to_funsor
from pyro.contrib.funsor.handlers import enum, plate, replay, trace
f... | 284 | 12,731 |
mlflow | tests/genai/test_agent_server.py | .py | import contextvars
from typing import Any, AsyncGenerator
from unittest.mock import AsyncMock, Mock, patch
import httpx
import pytest
from fastapi.testclient import TestClient
from mlflow.genai.agent_server import (
AgentServer,
get_invoke_function,
get_request_headers,
get_stream_function,
invoke... | 1,325 | 44,175 |
pyro | pyro/contrib/easyguide/easyguide.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import re
import weakref
from abc import ABCMeta, abstractmethod
from contextlib import ExitStack
import torch
from torch.distributions import biject_to
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine... | 345 | 12,922 |
onnx | onnx/reference/ops/op_non_zero.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
class NonZero(OpRun):
def _run(self, x):
if x.ndim == 0:
return (np.empty((0, np.count_nonzero(x)), dtype=np.int64),)... | 18 | 451 |
saleor | saleor/graphql/checkout/mutations/checkout_lines_add.py | .py | import graphene
from django.core.exceptions import ValidationError
from ....checkout.actions import call_checkout_info_event
from ....checkout.error_codes import CheckoutErrorCode
from ....checkout.fetch import (
fetch_checkout_info,
fetch_checkout_lines,
)
from ....checkout.utils import add_variants_to_checko... | 292 | 10,386 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_qordered_attention.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
import numpy as np
from fusion_attention... | 421 | 16,717 |
saleor | saleor/product/utils/variants.py | .py | from collections.abc import Iterable
from typing import TYPE_CHECKING
from django.conf import settings
from django.db.models import QuerySet
from ...attribute import AttributeType
from ...discount.models import PromotionRule
from ...discount.utils.promotion import update_rule_variant_relation
from ..models import Pro... | 75 | 2,621 |
mlflow | tests/utils/test_unity_catalog_utils.py | .py | import pytest
from mlflow.entities.logged_model_parameter import LoggedModelParameter as ModelParam
from mlflow.entities.metric import Metric
from mlflow.entities.model_registry import (
ModelVersion,
ModelVersionDeploymentJobState,
ModelVersionTag,
RegisteredModel,
RegisteredModelAlias,
Regist... | 556 | 18,255 |
pyro | pyro/infer/mcmc/util.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import functools
import traceback as tb
import warnings
from collections import OrderedDict, defaultdict
from functools import partial, reduce
from itertools import product
import torch
from opt_einsum import shared_intermediates
... | 843 | 33,005 |
cvxpy | cvxpy/reductions/complex2real/canonicalizers/aff_canon.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... | 141 | 4,648 |
beam | sdks/python/apache_beam/examples/inference/pytorch_image_object_detection.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... | 518 | 17,191 |
textual | tests/text_area/test_setting_themes.py | .py | import pytest
from textual._text_area_theme import TextAreaTheme
from textual.app import App, ComposeResult
from textual.widgets import TextArea
from textual.widgets._text_area import ThemeDoesNotExist
class TextAreaApp(App[None]):
def compose(self) -> ComposeResult:
yield TextArea("print('hello')", lang... | 57 | 1,561 |
openvino | src/bindings/python/src/openvino/opset12/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino.opset1.ops import absolute
from openvino.opset1.ops import absolute as abs
from openvino.opset1.ops import acos
from openvino.opset4.ops import acosh
from openvino.opset8.ops import adaptive_avg_pool... | 181 | 7,636 |
textual | src/textual/widgets/_list_item.py | .py | """Provides a list item widget for use with `ListView`."""
from __future__ import annotations
from textual import events, on
from textual.message import Message
from textual.reactive import reactive
from textual.widget import Widget
class ListItem(Widget, can_focus=False):
"""A widget that is an item within a `... | 40 | 1,199 |
saleor | saleor/checkout/tests/fixtures/checkout_with_prices.py | .py | import datetime
from decimal import Decimal
import pytest
from django.utils import timezone
from ....plugins.manager import get_plugins_manager
from ... import base_calculations
from ...fetch import fetch_checkout_info, fetch_checkout_lines
from ...models import CheckoutLine
@pytest.fixture
def checkout_with_prices... | 157 | 5,269 |
pyro | tests/ops/einsum/test_adjoint.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import gc
import itertools
import pytest
import torch
from pyro.ops.einsum import contract
from pyro.ops.einsum.adjoint import require_backward
from tests.common import assert_equal
EQUATIONS = [
"->",
"w->",
",w->",... | 144 | 4,420 |
mlflow | tests/utils/test_async_artifacts_logging_queue.py | .py | import io
import pickle
import random
import threading
import time
import pytest
from PIL import Image
from mlflow import MlflowException
from mlflow.utils.async_logging.async_artifacts_logging_queue import AsyncArtifactsLoggingQueue
TOTAL_ARTIFACTS = 5
class RunArtifacts:
def __init__(self, throw_exception_on... | 281 | 9,308 |
conda | tests/shards/http_server.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Custom HTTP server utilities for serving sharded repodata in tests.
"""
from __future__ import annotations
import contextlib
import http.server
import queue
import socket
import threading
from pathlib import Path
from typing import TYPE_CH... | 112 | 3,635 |
mlflow | tests/utils/test_resources/dummy_package/operator.py | .py | # This module is meant to test shadowing of the built-in operator module
raise Exception(
"This package should not have been imported! "
"This means that the sys.path was not configured correctly"
)
| 6 | 207 |
saleor | saleor/tests/e2e/orders/discounts/test_order_with_shipping_voucher_and_manual_order_discount.py | .py | from decimal import Decimal
import pytest
from ... import DEFAULT_ADDRESS
from ...product.utils.preparing_product import prepare_product
from ...shop.utils.preparing_shop import prepare_default_shop
from ...utils import assign_permissions
from ...vouchers.utils import create_voucher, create_voucher_channel_listing
fr... | 178 | 6,220 |
openvino | tests/e2e_tests/test_utils/reshape_pipeline_executers.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
from e2e_tests.test_utils.modify_configs import ie_sbs_reshape_config, ie_reshape_config, mo_reshape_config
from e2e_tests.common.common.pipeline import Pipeline
def ie_pipeline_runner(instance_ie_pipeline, shape... | 26 | 950 |
saleor | saleor/graphql/shop/tests/queries/test_shop.py | .py | import re
import graphene
import pytest
from django_countries import countries
from ..... import __version__
from .....core.tests.test_taxes import app_factory, tax_app_factory # noqa: F401
from .....payment.gateway import (
GIFT_CARD_PAYMENT_GATEWAY_ID,
GIFT_CARD_PAYMENT_GATEWAY_NAME,
)
from .....permission... | 880 | 22,245 |
tomli | tests/test_error.py | .py | # SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2021 Taneli Hukkinen
# Licensed to PSF under a Contributor Agreement.
from __future__ import annotations
from typing import Any
import unittest
from . import tomllib
class TestError(unittest.TestCase):
def test_line_and_col(self):
with self.asser... | 105 | 3,852 |
astropy | astropy/wcs/docstrings.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# It gets to be really tedious to type long docstrings in ANSI C
# syntax (since multi-line string literals are not valid).
# Therefore, the docstrings are written here in doc/docstrings.py,
# which are then converted by setup.py into docstrings.h, which ... | 3,002 | 82,617 |
onnxruntime | tools/doc/rename_folders.py | .py | """
Github publishes the markdown documentation with jekyll enabled.
This extension does not publish any folder starting with `_`.
These folders need to be renamed.
"""
import os
import re
def rename_folder(root):
"""
Renames all folder starting with `_`.
Returns the list of renamed folders.
"""
... | 86 | 2,681 |
django-cms | cms/test_utils/project/pluginapp/plugins/style/models.py | .py | from django.db import models
from cms.models import CMSPlugin
CLASS_CHOICES = ['container', 'content', 'teaser']
CLASS_CHOICES = tuple((entry, entry) for entry in CLASS_CHOICES)
TAG_CHOICES = [
'div', 'article', 'section', 'header', 'footer', 'aside', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
]
TAG_CHOICES = tuple((ent... | 65 | 1,952 |
ipython | examples/Embedding/embed_function.py | .py | """Embed IPython using the simple embed function rather than the class API."""
from IPython import embed
a = 10
b = 20
embed(header="First time", banner1="")
c = 30
d = 40
try:
raise Exception("adsfasdf")
except:
embed(header="The second time")
| 17 | 258 |
tqdm | tests/tests_gui.py | .py | """Test `tqdm.gui`."""
from .tests_tqdm import importorskip
def test_gui_import():
"""Test `tqdm.gui` import"""
importorskip('tqdm.gui')
| 8 | 147 |
coremltools | coremltools/converters/mil/input_types.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 enum import Enum
from typing import Optional
import numpy as np
from coremltools import _logge... | 650 | 23,255 |
confluent-kafka-python | tests/avro/test_cached_client.py | .py | #!/usr/bin/env python
#
# Copyright 2016 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... | 268 | 9,854 |
onnxruntime | onnxruntime/python/tools/transformers/models/stable_diffusion/engine_builder_ort_trt.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import gc
import logging
import os
import torch
from cuda import cudar... | 289 | 11,163 |
dirty-equals | dirty_equals/_sequence.py | .py | import sys
from collections.abc import Container, Sized
from typing import TYPE_CHECKING, Any, Optional, TypeVar, Union, overload
from ._base import DirtyEquals
from ._utils import Omit, plain_repr
if TYPE_CHECKING:
from typing import TypeAlias
if sys.version_info >= (3, 10):
from types import EllipsisType
e... | 284 | 10,220 |
lemur | lemur/endpoints/models.py | .py | """
.. module: lemur.endpoints.models
:platform: unix
:synopsis: This module contains all of the models need to create an authority within Lemur.
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.c... | 124 | 3,973 |
saleor | saleor/plugins/admin_email/tests/conftest.py | .py | from unittest.mock import patch
import dj_email_url
import pytest
from ....plugins.models import EmailTemplate, PluginConfiguration
from ...email_common import DEFAULT_EMAIL_VALUE
from ...manager import get_plugins_manager
from ..constants import (
CSV_EXPORT_FAILED_DEFAULT_SUBJECT,
CSV_EXPORT_FAILED_SUBJECT_... | 170 | 6,659 |
textual | tests/snapshot_tests/snapshot_apps/text_area_line_number_start.py | .py | from textual.app import App, ComposeResult
from textual.widgets import TextArea
TEXT = """\
Foo
Bar
Baz
"""
class LineNumbersReactive(App[None]):
START_LINE_NUMBER = 9999
def compose(self) -> ComposeResult:
yield TextArea(
TEXT,
soft_wrap=True,
show_line_numbers=T... | 26 | 460 |
astropy | astropy/nddata/tests/test_nddata.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pickle
import textwrap
from itertools import chain, permutations
import numpy as np
import pytest
from numpy.testing import assert_array_equal
from astropy import units as u
from astropy.nddata import NDDataArray
from astropy.nddata import _test... | 708 | 22,202 |
coremltools | coremltools/converters/mil/frontend/tensorflow/test/test_tf_conversion_api.py | .py | # Copyright (c) 2022, 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 itertools
import os
import tempfile
import numpy as np
import pytest
import coremltools as c... | 1,500 | 66,131 |
gunicorn | tests/requests/valid/017.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
request = {
"method": "GET",
"uri": uri("/stuff/here?foo=bar"),
"version": (1, 0),
"headers": [
("IF-MATCH", "bazinga!"),
("IF-MATCH", "large-sound")
],
"body": b""
}
| 15 | 313 |
probability | tensorflow_probability/python/bijectors/weibull_cdf.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... | 164 | 6,297 |
conda | tests/core/test_portability.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import os
import re
import subprocess
import pytest
from conda.auxlib.ish import dals
from conda.base.constants import PREFIX_PLACEHOLDER
from conda.common.compat import on_mac, on_win
from conda.core.portability import (
MAX_SHEBANG_LENGT... | 306 | 10,472 |
cvxpy | cvxpy/tests/test_clarabel_warm_start.py | .py | import numpy as np
import cvxpy as cp
def test_clarabel_warm_start_sparsity_change():
"""
Test that Clarabel gracefully falls back to new_solver() if sparsity changes
during a warm start, preventing a Data formatting error. (Issue #2800)
"""
x = cp.Variable(2)
p = cp.Parameter(2)
# Using... | 29 | 949 |
onnx | onnx/backend/test/case/node/stft.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 STFT(Base):
@staticmethod
def export() -> None:
signal... | 71 | 2,400 |
kafka | docker/test/docker_sanity_test.py | .py | #!/usr/bin/env python
# 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 "Lice... | 253 | 12,163 |
gunicorn | tests/requests/invalid/rfc9110_trailer_forbidden_te_01.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# RFC 9110 section 6.5.1: Transfer-Encoding in trailers alters framing
# and must not be accepted.
from gunicorn.http.errors import InvalidHeaderName
request = InvalidHeaderName
| 9 | 284 |
onnx | onnx/backend/test/report/base.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
class ReporterBase:
pass
| 9 | 147 |
onnxruntime | onnxruntime/test/python/quantization/test_op_argmax.py | .py | #!/usr/bin/env python
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# ---------------------------------------------------------------... | 199 | 7,331 |
marshmallow | src/marshmallow/orderedset.py | .py | # OrderedSet
# Copyright (c) 2009 Raymond Hettinger
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merg... | 90 | 2,953 |
jupytext | tests/functional/simple_notebooks/test_read_simple_go.py | .py | import jupytext
from jupytext.compare import compare
def test_read_simple_file(
go="""// -*- coding: utf-8 -*-
// ---
// jupyter:
// kernelspec:
// display_name: Go (gonb)
// language: go
// name: gonb
// ---
// A notebook that use [GoNB](https://github.com/janpfeifer/gonb)
// the code below comes... | 157 | 3,169 |
wagtail | wagtail/admin/views/page_privacy.py | .py | import swapper
from django.core.exceptions import PermissionDenied
from django.shortcuts import get_object_or_404
from django.urls import reverse
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from django.views.generic.edit ... | 135 | 4,947 |
wagtail | wagtail/images/api/v3/router.py | .py | from typing import cast
from django.http import HttpRequest
from django.shortcuts import get_object_or_404
from ninja import Body, File, Form, Query, Router, Status, UploadedFile
from ninja.pagination import paginate
from pydantic import BaseModel
from wagtail.actions import action_registry
from wagtail.api.v3.auth i... | 158 | 5,301 |
deap | tests/test_multiproc.py | .py | import multiprocessing
from deap import base
from deap import creator
def _evalOneMax(individual):
return sum(individual),
def test_multiproc():
creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", list, fitness=creator.FitnessMax)
toolbox = base.Toolbox()
to... | 26 | 644 |
wagtail | wagtail/tests/test_page_queryset.py | .py | import unittest
from io import StringIO
from unittest import mock
import swapper
from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType
from django.core import management
from django.db.models import Count, Q
from django.test import TestCase, TransactionTestCase, tag
... | 1,384 | 52,789 |
readthedocs.org | readthedocs/subscriptions/tests/test_products.py | .py | from django.test import TestCase
from readthedocs.subscriptions.constants import TYPE_AUDIT_LOGS, TYPE_CONCURRENT_BUILDS
from readthedocs.subscriptions.products import RTDProductFeature
class TestRTDProductFeature(TestCase):
def test_add_feature(self):
feature_a = RTDProductFeature(TYPE_CONCURRENT_BUILDS... | 53 | 2,073 |
wandb | tests/unit_tests/test_lib/test_runid.py | .py | import multiprocessing as mp
import random
from concurrent.futures import ProcessPoolExecutor
from pytest import fixture, mark
from wandb.sdk.lib.runid import generate_fast_id, generate_id
def test_generate_id_is_base36():
# Given reasonable randomness assumptions, generating an 1000-digit string should
# hi... | 57 | 1,730 |
beam | sdks/python/apache_beam/ml/inference/xgboost_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... | 386 | 13,476 |
mlflow | dev/clint/src/clint/rules/redundant_mock_return_value.py | .py | import ast
from clint.resolver import Resolver
from clint.rules.base import Rule
class RedundantMockReturnValue(Rule):
def _message(self) -> str:
return (
"Do not pass `return_value=MagicMock()` or `return_value=Mock()` to `patch()`. "
"The default return value of a mock is alread... | 37 | 1,181 |
wagtail | wagtail/api/v2/signal_handlers.py | .py | from django.db.models.signals import post_delete, post_save
from django.urls import reverse
from wagtail.api.utils import get_base_url
from wagtail.contrib.frontend_cache.utils import purge_url_from_cache
from wagtail.documents import get_document_model
from wagtail.images import get_image_model
from wagtail.models im... | 61 | 2,177 |
mlflow | tests/store/artifact/test_databricks_sdk_models_artifact_repo.py | .py | import io
from types import SimpleNamespace
from unittest import mock
import pytest
from databricks.sdk import WorkspaceClient
from databricks.sdk.errors.platform import NotFound
from databricks.sdk.service.files import DirectoryEntry, DownloadResponse
from mlflow.entities.file_info import FileInfo
from mlflow.entiti... | 283 | 11,267 |
wandb | tests/unit_tests/test_launch/test_registry/test_gcp_artifact_registry.py | .py | from unittest.mock import MagicMock
import google.api_core.exceptions
import pytest
from wandb.sdk.launch.registry.google_artifact_registry import GoogleArtifactRegistry
from wandb.sdk.launch.utils import LaunchError
@pytest.fixture
def mock_gcp_default_credentials(monkeypatch):
"""Mock the default credentials f... | 170 | 5,526 |
pyro | pyro/poutine/replay_messenger.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from typing import TYPE_CHECKING, Dict, Optional
from pyro.poutine.messenger import Messenger
if TYPE_CHECKING:
import torch
from pyro.poutine.runtime import Message
from pyro.poutine.trace_struct import Trace
clas... | 91 | 3,310 |
pyomo | pyomo/util/blockutil.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... | 38 | 1,387 |
onnxruntime | onnxruntime/python/tools/quantization/fusions/fusion_gelu.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from __fut... | 273 | 10,375 |
mlflow | tests/server/auth/test_review_queue_auth.py | .py | # Unit tests for the review-queue / label-schema authorization validators: they
# exercise the gate decisions in ``mlflow.server.auth`` directly by mocking the
# request / store / experiment-permission boundary, so no live auth server is
# needed. End-to-end routing is covered by the broader auth client tests.
import j... | 521 | 21,897 |
beam | sdks/python/apache_beam/ml/anomaly/base.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... | 225 | 7,487 |
wagtail | wagtail/images/tests/test_image_operations.py | .py | from io import BytesIO
from pathlib import Path
from unittest.mock import patch
from django.test import TestCase, override_settings
from wagtail import hooks
from wagtail.images import image_operations
from wagtail.images.exceptions import (
InvalidFilterSpecError,
UnknownOutputImageFormatError,
)
from wagtai... | 1,102 | 33,245 |
hatch | backend/src/hatchling/builders/hooks/custom.py | .py | from __future__ import annotations
import os
from typing import Any
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from hatchling.plugin.utils import load_plugin_from_script
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT
class CustomBuildHook:
PLUGIN_NAME = "custom"
de... | 42 | 1,378 |
gunicorn | gunicorn/ctl/server.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Control Socket Server
Runs in the arbiter process and accepts commands via Unix socket.
Uses asyncio in a background thread to handle client connections.
Fork Safety:
This server uses os.register_at_fork(... | 420 | 13,827 |
sqlmap | plugins/generic/databases.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.agent import agent
from lib.core.common import arrayizeValue
from lib.core.common import Backend
from lib.core.common import filterNone
from lib.core.comm... | 1,242 | 64,420 |
pyomo | examples/pyomo/quadratic/example2.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... | 39 | 1,214 |
tablib | src/tablib/formats/__init__.py | .py | """ Tablib - formats
"""
__lazy_modules__ = {
"functools",
"importlib",
"importlib.util",
"tablib.exceptions",
"tablib.formats._csv",
"tablib.formats._json",
"tablib.formats._tsv",
"tablib.utils",
}
from functools import partialmethod
from importlib import import_module
from importlib.... | 145 | 5,400 |
mlflow | examples/gateway/openai/example.py | .py | from mlflow.deployments import get_deploy_client
def main():
client = get_deploy_client("http://localhost:7000")
print(f"OpenAI endpoints: {client.list_endpoints()}\n")
print(f"OpenAI endpoint info: {client.get_endpoint(endpoint='completions')}\n")
# Completions example
response_completions = cl... | 48 | 1,414 |
sphinx | tests/roots/test-latex-labels-before-module/conf.py | .py | import sys
from pathlib import Path
sys.path.insert(0, str(Path.cwd().resolve()))
extensions = ['sphinx.ext.autodoc']
nitpicky = True
| 9 | 137 |
pyomo | doc/OnlineDocs/src/data/ABCD6.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... | 23 | 886 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.