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 |
|---|---|---|---|---|---|
confluent-kafka-python | src/confluent_kafka/serializing_producer.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2020 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... | 155 | 7,104 |
coremltools | coremltools/converters/mil/mil/types/type_globals_pseudo_type.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 .type_spec import Type
class globals_pseudo_type:
@classmethod
def __type_info__(cls):... | 13 | 370 |
pyomo | pyomo/contrib/mpc/data/convert.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... | 169 | 6,589 |
openvino | tests/model_hub_tests/performance_tests/test_tf_hub_performance_model.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import gc
import os
import shutil
from collections import namedtuple
from enum import Enum
import pytest
import tensorflow_hub as hub
from models_hub_common.test_performance_model import TestModelPerformance
import models_hub_common.ut... | 88 | 3,284 |
saleor | saleor/tests/settings.py | .py | import re
from re import Pattern
from django.utils.functional import SimpleLazyObject
from ..settings import * # noqa: F403
def lazy_re_compile(regex, flags=0):
"""Lazily compile a regex with flags."""
def _compile():
# Compile the regex if it was not passed pre-compiled.
if isinstance(reg... | 110 | 4,176 |
onnx | onnx/reference/ops/op_acos.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.ops._op import OpRunUnaryNum
class Acos(OpRunUnaryNum):
def _run(self, x):
return (np.arccos(x),)
| 14 | 269 |
textual | src/textual/demo/game.py | .py | """
An implementation of the "Sliding Tile" puzzle.
Textual isn't a game engine exactly, but it wasn't hard to build this.
"""
from __future__ import annotations
from asyncio import sleep
from collections import defaultdict
from dataclasses import dataclass
from itertools import product
from random import choice
fr... | 590 | 19,438 |
textual | src/textual/renderables/styled.py | .py | from typing import TYPE_CHECKING
from rich.measure import Measurement
from rich.segment import Segment
if TYPE_CHECKING:
from rich.console import Console, ConsoleOptions, RenderableType, RenderResult
from rich.style import StyleType
class Styled:
"""A renderable which allows you to apply a style before ... | 51 | 1,937 |
wandb | tests/unit_tests/test_lib/test_auth_validation.py | .py | import pytest
from wandb.sdk.lib.wbauth import validation
@pytest.mark.parametrize(
"key, problems",
(
("", "API key is empty."),
("some_prefix-" + "A" * 39, "API key must have 40+ characters, has 39."),
("some_prefix-" + "A" * 40, None),
("some_prefix-" + "A" * 60, None),
... | 22 | 550 |
beam | learning/tour-of-beam/learning-content/io/rest-api/python-example/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... | 93 | 3,416 |
textual | tests/snapshot_tests/snapshot_apps/remove_auto.py | .py | from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import Header, Footer, Label
class VerticalRemoveApp(App[None]):
CSS = """
Vertical {
border: round green;
height: auto;
}
Label {
border: round yellow;
background: ... | 39 | 862 |
confluent-kafka-python | tests/schema_registry/test_encrypt_executor.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... | 87 | 3,232 |
pyomo | examples/pyomobook/pyomo-components-ch/rangeset.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... | 28 | 827 |
httpie | tests/test_tokens.py | .py | """
The ideas behind these test and the named templates is to ensure consistent output
across all supported different scenarios:
TODO: cover more scenarios
* terminal vs. redirect stdout
* different combinations of `--print=HBhb` (request/response headers/body)
* multipart requests
* streamed uploads
"""
from .ut... | 119 | 3,992 |
saleor | saleor/graphql/product/tests/test_variant_with_filtering.py | .py | import datetime
import pytest
from django.utils import timezone
from freezegun import freeze_time
from ....product.models import Product, ProductVariant
from ....product.search import update_products_search_vector
from ...tests.utils import get_graphql_content
QUERY_VARIANTS_FILTER = """
query variants($filter: Prod... | 242 | 7,175 |
eve | eve/auth.py | .py | # -*- coding: utf-8 -*-
"""
eve.auth
~~~~~~~~
Allow API endpoints to be secured via BasicAuth and derivates.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
from functools import wraps
from flask import abort
from flask import current_app as app
from flas... | 331 | 11,761 |
marshmallow | tests/conftest.py | .py | """Pytest fixtures that are available in all test modules."""
import pytest
from tests.base import Blog, User, UserSchema
@pytest.fixture
def user():
return User(name="Monty", age=42.3, homepage="http://monty.python.org/")
@pytest.fixture
def blog(user):
col1 = User(name="Mick", age=123)
col2 = User(n... | 28 | 566 |
gunicorn | gunicorn/http/errors.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# We don't need to call super() in __init__ methods of our
# BaseException and Exception classes because we also define
# our own __str__ methods so there is no need to pass 'message'
# to the base class to get a m... | 175 | 4,141 |
gunicorn | tests/requests/valid/099.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
request = {
"method": "POST",
"uri": uri("/test-form"),
"version": (1, 1),
"headers": [
("HOST", "0.0.0.0:5000"),
("USER-AGENT", "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:25.0) Gecko/2... | 279 | 9,241 |
django-cms | cms/test_utils/project/pluginapp/plugins/link/cms_plugins.py | .py | from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from .models import Link
class LinkPlugin(CMSPluginBase):
model = Link
name = 'Link'
text_enabled = True
allow_children = True
render_template = 'pluginapp/link/link.html'
def render(self, context, instance, pl... | 31 | 820 |
scikit-optimize | examples/interruptible-optimization.py | .py | """
================================================
Interruptible optimization runs with checkpoints
================================================
Christian Schell, Mai 2018
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
Problem statement
=================
Optimization runs can take a very long ... | 124 | 4,670 |
confluent-kafka-python | examples/json_producer.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2020 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... | 175 | 5,789 |
hatch | src/hatch/env/utils.py | .py | from __future__ import annotations
import os
from hatch.config.constants import AppEnvVars
def get_env_var(*, plugin_name: str, option: str) -> str:
return f"{AppEnvVars.ENV_OPTION_PREFIX}{plugin_name}_{option.replace('-', '_')}".upper()
def get_env_var_option(*, plugin_name: str, option: str, default: str = ... | 67 | 2,163 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_softshrink.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# softshrink paddle model generator
#
import numpy as np
import sys
from save_model import saveModel
def softshrink(name: str, x, threshold):
import paddle
paddle.enable_static()
node_x = paddle.static.data(name="x", sh... | 57 | 1,381 |
pdm | src/pdm/models/repositories/__init__.py | .py | from pdm.models.repositories.base import BaseRepository as BaseRepository
from pdm.models.repositories.base import CandidateMetadata as CandidateMetadata
from pdm.models.repositories.lock import LockedRepository as LockedRepository
from pdm.models.repositories.lock import Package as Package
from pdm.models.repositories... | 6 | 366 |
mlflow | mlflow/store/tracking/mcp_server_registry/abstract_mixin.py | .py | from __future__ import annotations
from typing import Any, Literal, TypedDict
from typing_extensions import NotRequired
from mlflow.entities.mcp_access_endpoint import MCPAccessEndpoint
from mlflow.entities.mcp_server import MCPRemoteTransportType, MCPServer, MCPStatus, MCPTool
from mlflow.entities.mcp_server_versio... | 419 | 15,267 |
saleor | saleor/discount/tests/test_utils/test_get_customer_email_for_voucher_usage.py | .py | from ...utils.voucher import get_customer_email_for_voucher_usage
def test_get_customer_email_for_voucher_usage_for_checkout_info_without_user_data(
checkout_info, customer_user
):
# given
checkout_info.user = None
checkout_info.checkout.email = None
checkout_info.checkout.user = None
# when
... | 132 | 3,112 |
lemur | lemur/tests/test_domains.py | .py | import pytest
from lemur.domains.views import * # noqa
from .vectors import (
VALID_ADMIN_API_TOKEN,
VALID_ADMIN_HEADER_TOKEN,
VALID_USER_HEADER_TOKEN,
)
@pytest.mark.parametrize(
"token,status",
[
(VALID_USER_HEADER_TOKEN, 200),
(VALID_ADMIN_HEADER_TOKEN, 200),
(VALID_... | 155 | 3,510 |
openvino | tests/model_hub_tests/models_hub_common/constants.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import tempfile
'''
@brief Time in seconds of measurement performance on each of the networks. This time doesn't include
loading and heating and includes measurement only one of 2 models - got through c... | 33 | 1,441 |
coremltools | coremltools/converters/mil/mil/types/type_mapping.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 collections import namedtuple
from typing import Optional, Union
import numpy as _np
import num... | 613 | 18,296 |
wandb | wandb/integration/weave/__init__.py | .py | """Weave integration for W&B."""
from .interface import RunPath, active_run_path
from .weave import (
build_project_path,
ensure_version,
init_weave,
init_weave_if_imported,
)
__all__ = (
"active_run_path",
"RunPath",
"build_project_path",
"ensure_version",
"init_weave",
"init_... | 19 | 342 |
wagtail | wagtail/users/views/users.py | .py | import django_filters
from django.contrib.auth import (
get_user_model,
update_session_auth_hash,
)
from django.contrib.auth.models import Group
from django.core.exceptions import FieldDoesNotExist, PermissionDenied
from django.forms import CheckboxSelectMultiple
from django.urls import reverse
from django.util... | 395 | 12,602 |
probability | tensorflow_probability/python/internal/backend/numpy/test_lib.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... | 46 | 1,188 |
python-prompt-toolkit | src/prompt_toolkit/widgets/__init__.py | .py | """
Collection of reusable components for building full screen applications.
These are higher level abstractions on top of the `prompt_toolkit.layout`
module.
Most of these widgets implement the ``__pt_container__`` method, which makes it
possible to embed these in the layout like any other container.
"""
from __futu... | 64 | 1,218 |
wandb | wandb/integration/diffusers/pipeline_resolver.py | .py | from collections.abc import Sequence
from typing import Any
from wandb.sdk.integration_utils.auto_logging import Response
from .resolvers import (
SUPPORTED_MULTIMODAL_PIPELINES,
DiffusersMultiModalPipelineResolver,
)
class DiffusersPipelineResolver:
"""Resolver for `DiffusionPipeline` request and respo... | 52 | 1,855 |
cvxpy | cvxpy/reductions/dcp2cone/canonicalizers/matrix_frac_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... | 39 | 1,313 |
jupytext | tests/functional/simple_notebooks/test_read_simple_python.py | .py | import pytest
from nbformat.v4.nbbase import (
new_code_cell,
new_markdown_cell,
new_notebook,
new_raw_cell,
)
import jupytext
from jupytext.compare import compare, compare_notebooks
def test_read_simple_file(
pynb="""# ---
# title: Simple file
# ---
# Here we have some text
# And below we have ... | 1,188 | 25,334 |
textual | docs/examples/styles/content_align_all.py | .py | from textual.app import App
from textual.widgets import Label
class AllContentAlignApp(App):
CSS_PATH = "content_align_all.tcss"
def compose(self):
yield Label("left top", id="left-top")
yield Label("center top", id="center-top")
yield Label("right top", id="right-top")
yield ... | 23 | 710 |
saleor | saleor/graphql/product/tests/queries/test_categories_query.py | .py | import pytest
from .....product.models import Category, Product
from .....tests.utils import dummy_editorjs
from ....tests.utils import (
get_graphql_content,
)
LEVELED_CATEGORIES_QUERY = """
query leveled_categories($level: Int) {
categories(level: $level, first: 20) {
edges {
... | 159 | 4,841 |
mlflow | mlflow/tracking/context/databricks_job_context.py | .py | from mlflow.entities import SourceType
from mlflow.tracking.context.abstract_context import RunContextProvider
from mlflow.utils import databricks_utils
from mlflow.utils.mlflow_tags import (
MLFLOW_DATABRICKS_JOB_ID,
MLFLOW_DATABRICKS_JOB_RUN_ID,
MLFLOW_DATABRICKS_JOB_TYPE,
MLFLOW_DATABRICKS_WEBAPP_URL... | 52 | 2,037 |
wagtail | wagtail/contrib/redirects/tests/test_tmp_storages.py | .py | from django.core.cache import cache
from django.test import TestCase
from wagtail.contrib.redirects.tmp_storages import CacheStorage
class CacheStorageTests(TestCase):
def test_cache_storage_save_and_remove(self):
name = "testfile.txt"
content = b"hello world"
storage = CacheStorage(name)... | 21 | 573 |
black | tests/data/cases/trailing_comma.py | .py | e = {
"a": fun(msg, "ts"),
"longggggggggggggggid": ...,
"longgggggggggggggggggggkey": ..., "created": ...
# "longkey": ...
}
f = [
arg1,
arg2,
arg3, arg4
# comment
]
g = (
arg1,
arg2,
arg3, arg4
# comment
)
h = {
arg1,
arg2,
arg3, arg4
# comment
}
# outpu... | 56 | 655 |
beam | sdks/python/apache_beam/examples/inference/online_clustering/clustering_pipeline/pipeline/options.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... | 64 | 2,356 |
astropy | astropy/samp/tests/test_hub_proxy.py | .py | import platform
import pytest
from astropy.samp import conf
from astropy.samp.hub import SAMPHubServer
from astropy.samp.hub_proxy import SAMPHubProxy
def setup_module(module):
conf.use_internet = False
@pytest.mark.skipif(platform.system() == "Darwin", reason="Takes too long on OSX")
class TestHubProxy:
... | 54 | 1,381 |
pyro | pyro/distributions/testing/fakes.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from pyro.distributions.torch import Beta, Dirichlet, Gamma, Normal
class NonreparameterizedBeta(Beta):
has_rsample = False
class NonreparameterizedDirichlet(Dirichlet):
has_rsample = False
class NonreparameterizedGam... | 21 | 421 |
ipython | IPython/utils/_process_emscripten.py | .py | """Emscripten-specific implementation of process utilities.
This file is only meant to be imported by process.py, not by end-users.
"""
from ._process_common import arg_split
def system(cmd):
raise OSError("Not available")
def getoutput(cmd):
raise OSError("Not available")
def check_pid(cmd):
raise ... | 23 | 503 |
onnxruntime | tools/python/upload_and_run_browserstack_tests.py | .py | import argparse
import os
import sys
import time
from pathlib import Path
import requests
script_description = """
After building ONNXRuntime for Android or iOS, use this script to upload the app and test files to BrowserStack then
run the tests on the specified devices.
Find the Android test app in the repo here (a... | 179 | 5,988 |
mlflow | tests/genai/judges/utils/test_formatting_utils.py | .py | import pytest
from mlflow.genai.judges.utils.formatting_utils import format_available_tools, format_tools_called
from mlflow.genai.utils.type import FunctionCall
from mlflow.types.chat import (
ChatTool,
FunctionParams,
FunctionToolDefinition,
ParamProperty,
)
@pytest.mark.parametrize(
("tools", ... | 225 | 7,260 |
wandb | tests/unit_tests/test_lib/test_service_client.py | .py | from __future__ import annotations
import asyncio
import struct
import threading
from typing import Literal
import pytest
from wandb.proto import wandb_server_pb2 as spb
from wandb.sdk import mailbox
from wandb.sdk.lib import asyncio_manager
from wandb.sdk.lib.service.service_client import ServiceClient
class _Fake... | 218 | 6,242 |
coremltools | coremltools/test/optimize/torch/test_utils/test_k_means.py | .py | # Copyright (c) 2024, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import time
import pytest
import torch
from coremltools.optimize.torch._utils.k_means import (
... | 302 | 11,629 |
sphinx | tests/roots/test-ext-autodoc/target/abstractmethods.py | .py | from abc import abstractmethod
class Base:
def meth(self):
pass
@abstractmethod
def abstractmeth(self):
pass
@staticmethod
@abstractmethod
def staticmeth():
pass
@classmethod
@abstractmethod
def classmeth(cls):
pass
@property
@abstractmet... | 30 | 426 |
sphinx | sphinx/domains/cpp/_symbol.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from sphinx.domains.cpp._ast import (
ASTDeclaration,
ASTNestedName,
ASTNestedNameElement,
)
from sphinx.locale import __
from sphinx.util import logging
if TYPE_CHECKING:
from collections.abc import Callable, Iterable, Iterator, Seq... | 1,333 | 51,517 |
coremltools | coremltools/optimize/torch/pruning/magnitude_pruner.py | .py | # Copyright (c) 2024, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import copy as _copy
import logging as _logging
from collections import OrderedDict as _OrderedDict
f... | 552 | 24,571 |
pyomo | pyomo/contrib/mindtpy/tests/test_mindtpy.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... | 545 | 21,091 |
sqlmap | plugins/dbms/sybase/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 | 970 |
mlflow | tests/store/fs2db/test_migration.py | .py | import math
from pathlib import Path
from unittest import mock
import pytest
from sqlalchemy import create_engine, text
from mlflow.entities import Experiment, Run, ViewType
from mlflow.store.fs2db import migrate
from mlflow.tracking import MlflowClient
from mlflow.utils.file_utils import local_file_uri_to_path
Clie... | 292 | 12,207 |
saleor | saleor/__init__.py | .py | from .celeryconf import app as celery_app
__all__ = ["celery_app"]
__version__ = "3.24.0-a.0"
class PatchedSubscriberExecutionContext:
__slots__ = "exe_context", "errors"
def __init__(self, exe_context):
self.exe_context = exe_context
self.errors = self.exe_context.errors
def reset(self... | 24 | 563 |
pyomo | pyomo/core/tests/unit/test_numeric_expr_dispatcher.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... | 6,402 | 265,446 |
attrs | tests/test_packaging.py | .py | # SPDX-License-Identifier: MIT
from importlib import metadata
import pytest
import attr
import attrs
@pytest.fixture(name="mod", params=(attr, attrs))
def _mod(request):
return request.param
class TestLegacyMetadataHack:
def test_version(self, mod, recwarn):
"""
__version__ returns the c... | 43 | 1,033 |
textual | docs/examples/guide/layout/vertical_layout_scrolled.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Static
class VerticalLayoutScrolledExample(App):
CSS_PATH = "vertical_layout_scrolled.tcss"
def compose(self) -> ComposeResult:
yield Static("One", classes="box")
yield Static("Two", classes="box")
yield Static("Th... | 17 | 426 |
pyomo | pyomo/core/expr/expr_common.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... | 232 | 6,924 |
beam | sdks/java/container/license_scripts/pull_licenses_java.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... | 384 | 14,567 |
hypercorn | tests/asyncio/test_task_group.py | .py | from __future__ import annotations
import asyncio
from collections.abc import Callable
import pytest
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.config import Config
from hypercorn.typing import HTTPScope, Scope
@pytest.mark.asyncio
async def tes... | 46 | 1,535 |
coremltools | coremltools/converters/mil/test/test_input_types.py | .py | import numpy as np
import pytest
from coremltools.converters.mil.mil import types
from coremltools.converters.mil.input_types import RangeDim, TensorType
def test_rangedim_default_within_bounds():
dim = RangeDim(lower_bound=0, upper_bound=10, default=5)
assert dim.default == 5
def test_rangedim_default_falls... | 41 | 1,522 |
openvino | tests/layer_tests/pytorch_tests/test_celu.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import torch.nn.functional as F
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
class aten_celu(torch.nn.Module):
def __init__(self, alpha, dtype, inplace):
super().__init__... | 45 | 1,511 |
mlflow | mlflow/models/evaluation/artifacts.py | .py | import json
import pathlib
import pickle
from json import JSONDecodeError
from typing import NamedTuple
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from mlflow.environment_variables import MLFLOW_ALLOW_PICKLE_DESERIALIZATION
from mlflow.exceptions import MlflowException
from mlflow.models.e... | 204 | 7,197 |
astropy | astropy/table/serialize.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import itertools
from collections import OrderedDict
from copy import deepcopy
from importlib import import_module
import numpy as np
from astropy.units.quantity import QuantityInfo
from astropy.utils.data_info import MixinInfo
from .column import Colum... | 539 | 22,677 |
readthedocs.org | readthedocs/projects/admin.py | .py | """Django administration interface for `projects.models`."""
from django.conf import settings
from django.contrib import admin
from django.contrib import messages
from django.contrib.admin.actions import delete_selected
from django.db.models import Exists
from django.db.models import IntegerField
from django.db.models... | 543 | 17,654 |
sphinx | tests/roots/test-markup-rubric/conf.py | .py | latex_documents = [
(
'index',
'test.tex',
'The basic Sphinx documentation for testing',
'Sphinx',
'report',
)
]
latex_toplevel_sectioning = 'section'
| 11 | 199 |
metrics | tests/unittests/audio/test_pit.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... | 255 | 9,840 |
wagtail | wagtail/images/admin.py | .py | from django.conf import settings
from django.contrib import admin
from wagtail.images.models import Image
if (
hasattr(settings, "WAGTAILIMAGES_IMAGE_MODEL")
and settings.WAGTAILIMAGES_IMAGE_MODEL != "wagtailimages.Image"
):
# This installation provides its own custom image class;
# to avoid confusion... | 16 | 441 |
readthedocs.org | readthedocs/config/tests/test_find.py | .py | import os
from readthedocs.config.find import find_one
from .utils import apply_fs
def test_find_no_files(tmpdir):
with tmpdir.as_cwd():
path = find_one(os.getcwd(), r"readthedocs.yml")
assert path == ""
def test_find_at_root(tmpdir):
apply_fs(tmpdir, {"readthedocs.yml": "", "otherfile.txt": "... | 19 | 468 |
pyomo | pyomo/util/config_domains.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... | 71 | 2,585 |
metrics | tests/unittests/image/test_ergas.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... | 148 | 5,993 |
black | tests/data/cases/type_expansion.py | .py | # flags: --minimum-version=3.12
def f1[T: (int, str)](a,): pass
def f2[T: (int, str)](a: int, b,): pass
def g1[T: (int,)](a,): pass
def g2[T: (int, str, bytes)](a,): pass
def g3[T: ((int, str), (bytes,))](a,): pass
def g4[T: (int, (str, bytes))](a,): pass
def g5[T: ((int,),)](a: int, b,): pass
# output
def f1[... | 61 | 666 |
wandb | wandb/sdk/data_types/trace_tree.py | .py | """This module contains the `WBTraceTree` media type, and the supporting dataclasses.
A `WBTraceTree` is a media object containing a root span and an
arbitrary model dump as a serializable dictionary. Logging such media type will
result in a W&B Trace Debugger panel being created in the workspace UI.
"""
from __futur... | 442 | 14,693 |
mlflow | tests/tracing/export/test_async_export_queue.py | .py | import multiprocessing
import threading
import time
from concurrent.futures import ThreadPoolExecutor
from unittest import mock
from mlflow.tracing.export.async_export_queue import AsyncTraceExportQueue, Task
from tests.tracing.helper import skip_when_testing_trace_sdk
def test_async_queue_handle_tasks():
queue... | 132 | 3,898 |
coremltools | coremltools/optimize/torch/layerwise_compression/_quant.py | .py | # Copyright (c) 2024, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
# Original implementation from https://github.com/IST-DASLab/sparsegpt
# Copyright 2023 IST Austria D... | 212 | 7,474 |
saleor | saleor/core/tests/commands/test_clearorders.py | .py | import pytest
from django.core.management import call_command
from ....checkout.models import Checkout, CheckoutDelivery
@pytest.mark.django_db
@pytest.mark.parametrize(
("_case", "assign_delivery"),
[
# These two cases cause two different types of FK-checks
# which can cause PostgreSQL to re... | 37 | 1,162 |
saleor | saleor/graphql/account/tests/mutations/authentication/test_token_refresh.py | .py | import datetime
import pytest
from django.urls import reverse
from freezegun import freeze_time
from ......account.error_codes import AccountErrorCode
from ......core.jwt import (
JWT_ACCESS_TYPE,
JWT_REFRESH_TOKEN_COOKIE_NAME,
create_access_token,
create_access_token_for_app,
create_refresh_token... | 422 | 15,051 |
mlflow | mlflow/tracing/provider.py | .py | """
This module provides a set of functions to manage the global tracer provider for MLflow tracing.
Every tracing operation in MLflow *MUST* be managed through this module, instead of directly
using the OpenTelemetry APIs. This is because MLflow needs to control the initialization of the
tracer provider and ensure th... | 1,107 | 44,109 |
biopython | Bio/Align/substitution_matrices/__init__.py | .py | # Copyright 2019 by Michiel de Hoon.
#
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been included as part of this
# package.
"""Substitution matrices."""
import os
impo... | 509 | 17,563 |
coremltools | coremltools/test/blob/test_weights.py | .py | # Copyright (c) 2021, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import os
import shutil
import tempfile
import numpy as np
import pytest
import coremltools as ct
from... | 290 | 11,884 |
wandb | wandb/sdk/lib/service/service_port_file.py | .py | """Module for figuring out how to connect to the service process."""
from __future__ import annotations
import os
import pathlib
import re
import subprocess
import time
import wandb
from . import ipc_support, service_token
# Time functions are monkeypatched in unit tests.
_MONOTONIC = time.monotonic
_SLEEP = time.... | 107 | 2,992 |
mlflow | mlflow/protos/internal_pb2.py | .py |
import google.protobuf
from packaging.version import Version
if Version(google.protobuf.__version__).major >= 5:
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: internal.proto
# Protobuf Python Version: 5.26.0
"""Generated protocol buffer code."""
from google.pr... | 78 | 3,536 |
textual | tests/input/test_input_restrict.py | .py | import re
import pytest
from textual.app import App, ComposeResult
from textual.widgets import Input
from textual.widgets._input import _RESTRICT_TYPES
def test_input_number_type():
"""Test number type regex, value should be number or the prefix of a valid number"""
number = _RESTRICT_TYPES["number"]
as... | 165 | 5,386 |
openvino | tests/layer_tests/pytorch_tests/test_bitwise_ops.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from packaging.version import parse as parse_version
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
class TestBitwiseOp(PytorchLayerTest):
def _prepare_input(sel... | 206 | 7,633 |
saleor | saleor/tests/e2e/checkout/test_logged_in_customer_should_not_be_able_to_buy_unavailable_product.py | .py | import pytest
from ..product.utils import (
create_category,
create_product,
create_product_type,
create_product_variant,
create_product_variant_channel_listing,
raw_create_product_channel_listing,
)
from ..shop.utils.preparing_shop import prepare_default_shop
from ..utils import assign_permiss... | 119 | 3,044 |
beam | sdks/python/apache_beam/ml/gcp/videointelligenceml.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... | 224 | 8,144 |
mlflow | mlflow/types/responses_helpers.py | .py | import warnings
from typing import Any
from pydantic import BaseModel, ConfigDict, Field, model_validator
"""
Classes are inspired by classes for Response and ResponseStreamEvent in openai-python
https://github.com/openai/openai-python/blob/ed53107e10e6c86754866b48f8bd862659134ca8/src/openai/types/responses/response... | 430 | 12,574 |
pyro | tests/optim/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/optim"):
if "stage" not in item.keywords:
item.add_marker(pytest.mark.stage("unit... | 24 | 747 |
voila | tests/app/tree_test.py | .py | # test tree rendering
import pytest
@pytest.fixture
def preheat_mode():
return False
@pytest.fixture
def voila_args(notebook_directory, voila_args_extra):
return ["--VoilaTest.root_dir=%r" % notebook_directory, *voila_args_extra]
@pytest.fixture
def voila_args_extra():
return [
'--VoilaConfigu... | 35 | 982 |
saleor | saleor/app/tests/fixtures/webhooks/payment_app.py | .py | import pytest
from .....app.models import App
from .....webhook.event_types import WebhookEventSyncType
from .....webhook.models import Webhook, WebhookEvent
from .....webhook.tests.subscription_webhooks import subscription_queries
@pytest.fixture
def payment_app(db, permission_manage_payments):
app = App.object... | 303 | 9,899 |
pdm | src/pdm/cli/commands/publish/repository.py | .py | from __future__ import annotations
import os
from collections.abc import Iterable, Iterator
from typing import TYPE_CHECKING, Any, cast
from urllib.parse import urlparse, urlunparse
import httpx
from id import AmbientCredentialError, detect_credential
from rich.progress import (
BarColumn,
DownloadColumn,
... | 177 | 7,037 |
saleor | saleor/graphql/checkout/tests/deprecated/test_checkout_promo_codes.py | .py | import graphene
from .....checkout.error_codes import CheckoutErrorCode
from ....tests.utils import get_graphql_content
MUTATION_CHECKOUT_ADD_PROMO_CODE = """
mutation($checkoutId: ID, $token: UUID, $promoCode: String!) {
checkoutAddPromoCode(
checkoutId: $checkoutId, token: $token, promoCode:... | 167 | 5,394 |
openvino | tests/layer_tests/pytorch_tests/test_device.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 TestDevice(PytorchLayerTest):
def _prepare_input(self):
input_data = self.random.randint(127, size=(1, 3, 224, 224))
return (in... | 72 | 2,165 |
beam | sdks/python/apache_beam/io/gcp/bigquery_read_perf_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... | 138 | 5,023 |
saleor | saleor/graphql/page/tests/mutations/test_page_types_bulk_delete.py | .py | from unittest import mock
import graphene
import pytest
from .....attribute.models import AttributeValue
from .....attribute.utils import associate_attribute_values_to_instance
from .....page.models import Page
from .....product.search import update_products_search_vector
from ....tests.utils import assert_no_permiss... | 314 | 9,131 |
metrics | tests/unittests/wrappers/test_running.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... | 162 | 6,295 |
textual | docs/examples/widgets/pretty.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Pretty
DATA = {
"title": "Back to the Future",
"releaseYear": 1985,
"director": "Robert Zemeckis",
"genre": "Adventure, Comedy, Sci-Fi",
"cast": [
{"actor": "Michael J. Fox", "character": "Marty McFly"},
{"actor"... | 25 | 547 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.