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 |
|---|---|---|---|---|---|
astropy | astropy/table/tests/test_item_access.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Verify item access API in:
https://github.com/astropy/astropy/wiki/Table-item-access-definition
"""
import numpy as np
import pytest
from astropy.table import Row
@pytest.mark.usefixtures("table_data")
class BaseTestItems:
pass
@pytest.mark.... | 262 | 9,267 |
gunicorn | examples/celery_alternative/tests/conftest.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Pytest configuration for Celery Replacement tests.
"""
import sys
from pathlib import Path
# Add gunicorn source to path for imports
gunicorn_root = Path(__file__).parent.parent.parent.parent
sys.path.insert(... | 15 | 343 |
sqlmap | lib/utils/grpcweb.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import base64
import json
import re
import struct
from lib.core.data import conf
from lib.core.data import kb
from lib.core.enums import HTTP_HEADER
from thirdparty.six.moves.url... | 298 | 11,348 |
probability | tensorflow_probability/python/math/minimize_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... | 573 | 21,924 |
beam | sdks/python/apache_beam/io/gcp/experimental/spannerio_write_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... | 148 | 4,913 |
wandb | tests/system_tests/test_functional/dspy/dspy_callback_exception.py | .py | import dspy
import wandb
from dspy.evaluate.evaluate import EvaluationResult # type: ignore
class MinimalProgram(dspy.Module):
def __init__(self) -> None:
super().__init__()
self.predict = dspy.Predict("question: str -> answer: str")
def _build_results_stub():
ex1 = dspy.Example(question="W... | 44 | 1,230 |
readthedocs.org | readthedocs/core/settings.py | .py | """Class based settings for complex settings inheritance."""
import inspect
import sys
class Settings:
"""Class-based settings wrapper."""
@classmethod
def load_settings(cls, module_name):
"""
Export class variables and properties to module namespace.
This will export and class... | 27 | 804 |
pyomo | pyomo/util/tests/test_model_size.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... | 204 | 8,642 |
scikit-bio | setup.py | .py | #!/usr/bin/env python
"""Setup script for scikit-bio installation.
----------------------------------------------------------------------------
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 th... | 193 | 5,253 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_layer_norm.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# layer_norm paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle
import sys
if paddle.__version__ >= '2.6.0':
from paddle.base import param_attr
else:
from paddle.fluid import param_attr
... | 56 | 2,005 |
mlflow | tests/entities/test_workspace.py | .py | from mlflow.entities.workspace import Workspace
def test_workspace_to_dict_uses_nested_trace_archival_config():
workspace = Workspace(
name="team-a",
description="Team A",
default_artifact_root="s3://artifacts/team-a",
trace_archival_location="s3://archive/team-a",
trace_ar... | 40 | 1,125 |
coremltools | coremltools/test/api/__init__.py | .py | # Copyright (c) 2017 - 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
| 5 | 225 |
coremltools | coremltools/converters/mil/mil/ops/tests/iOS17/test_scatter_gather.py | .py | # Copyright (c) 2023, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import itertools
import numpy as np
import pytest
import coremltools as ct
from coremltools.convert... | 469 | 18,854 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_BatchToSpaceND.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
class TestBatchToSpaceND(CommonTFLayerTest):
def create_batch_to_space_nd_net(self, input_shape, block_shape, crops):
tf.compat.... | 34 | 1,348 |
onnxruntime | onnxruntime/test/testdata/transform/fusion/gelu_gen.py | .py | import numpy as np
import onnx
from onnx import OperatorSetIdProto, TensorProto, helper, numpy_helper
"""
Generate test model for Gelu subgraph pattern 2:
+------------------------------------+
| |
| ... | 124 | 4,004 |
wandb | wandb/automations/_generated/create_automation.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/automations/
from __future__ import annotations
from wandb._pydantic import GQLResult
from .fragments import TriggerFields
class CreateAutomation(GQLResult):
result: CreateAutomationResult | None
class CreateAutomationResult(GQLResult):
trigg... | 21 | 419 |
more-itertools | more_itertools/recipes.py | .py | """Imported from the recipes section of the itertools documentation.
All functions taken from the recipes section of the itertools library docs
[1]_.
Some backward-compatible usability improvements have been made.
.. [1] http://docs.python.org/library/itertools.html#recipes
"""
import random
from bisect import bis... | 1,622 | 46,429 |
sphinx | tests/test_builders/test_build_html_code.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
import pygments
import pytest
if TYPE_CHECKING:
from sphinx.testing.util import SphinxTestApp
@pytest.mark.sphinx(
'html',
testroot='reST-code-block',
confoverrides={'html_codeblock_linenos_style': 'table'},
)
def test_html_codeblo... | 73 | 2,189 |
coremltools | coremltools/converters/mil/backend/nn/passes/alert_return_type_cast.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 coremltools import _logger as logger
from coremltools.converters.mil.mil import Var, types
from ... | 49 | 1,698 |
astropy | astropy/cosmology/_src/flrw/w0cdm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ("FlatwCDM", "wCDM")
import numpy as np
from numpy import sqrt
from numpy.typing import ArrayLike
from astropy.cosmology._src.core import dataclass_decorator
from astropy.cosmology._src.parameter import Parameter
from astropy.cosmology._src.ty... | 395 | 13,358 |
clearml | clearml/automation/aws_driver.py | .py | import base64
from typing import Dict, Optional
import attr
from attr.validators import instance_of
from .. import Task
from ..utilities.pyhocon import ConfigFactory, ConfigTree
from .auto_scaler import CloudDriver
from .cloud_driver import parse_tags
try:
# noinspection PyPackageRequirements
import boto3
... | 209 | 8,572 |
saleor | saleor/tax/calculations/order.py | .py | from collections import defaultdict
from collections.abc import Iterable
from decimal import Decimal
from typing import TYPE_CHECKING, cast
from django.conf import settings
from prices import TaxedMoney
from ...core.prices import quantize_price
from ...core.taxes import zero_taxed_money
from ...order import base_calc... | 190 | 6,652 |
slimit | src/slimit/visitors/scopevisitor.py | .py | ###############################################################################
#
# Copyright (c) 2011 Ruslan Spivak
#
# 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, inc... | 200 | 6,754 |
sphinx | tests/test_ext_autodoc/test_ext_autodoc_autoclass.py | .py | """Test the autodoc extension.
This tests mainly the Documenters; the auto directives are tested in a test
source file translated by test_build.
"""
from __future__ import annotations
import sys
import typing
import pytest
from tests.test_ext_autodoc.autodoc_util import FakeEvents, do_autodoc
TYPE_CHECKING = Fals... | 589 | 15,344 |
pyro | tests/contrib/funsor/test_valid_models_sequential_plate.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import logging
import pytest
import torch
from pyro.ops.indexing import Vindex
# put all funsor-related imports here, so test collection works without funsor
try:
import funsor
import pyro.contrib.funsor
funsor.set_bac... | 127 | 4,418 |
cvxpy | cvxpy/expressions/expression.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... | 1,128 | 37,836 |
coremltools | coremltools/converters/mil/frontend/tensorflow2/converter.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 coremltools.converters.mil.frontend.tensorflow.basic_graph_ops import \
simple_topsort
from ... | 41 | 1,540 |
sphinx | tests/test_ext_autodoc/autodoc_util.py | .py | from __future__ import annotations
from types import SimpleNamespace
from typing import TYPE_CHECKING
from sphinx.environment import _CurrentDocument
from sphinx.events import EventManager
from sphinx.ext.autodoc._directive_options import _process_documenter_options
from sphinx.ext.autodoc._generate import _auto_docu... | 84 | 2,539 |
saleor | saleor/plugins/webhook/tests/test_webhook.py | .py | import datetime
import json
from decimal import Decimal
from functools import partial
from unittest import mock
from unittest.mock import ANY, MagicMock
from urllib.parse import urlencode
import boto3
import graphene
import pytest
from celery.exceptions import MaxRetriesExceededError
from celery.exceptions import Retr... | 2,452 | 79,549 |
metrics | src/torchmetrics/functional/image/utils.py | .py | from collections.abc import Sequence
from typing import Union
import torch
from torch import Tensor
from torch.nn import functional as F # noqa: N812
def _gaussian(kernel_size: int, sigma: float, dtype: torch.dtype, device: Union[torch.device, str]) -> Tensor:
"""Compute 1D gaussian kernel.
Args:
k... | 174 | 6,013 |
sqlmap | tests/test_dump_jsonl.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
JSONL output of the per-table dumper (Dump.dbTableValues in lib/core/dump.py).
--dump-format=JSONL writes one self-describing JSON object per row to a
<host>/dump/<db>/<table>.jsonl ... | 172 | 7,351 |
clearml | clearml/backend_interface/task/development/stop_signal.py | .py | from typing import Optional, TYPE_CHECKING
from ....config import deferred_config
if TYPE_CHECKING:
from ....backend_interface import Task
class TaskStopReason:
stopped = "stopped"
reset = "reset"
status_changed = "status_changed"
class TaskStopSignal:
enabled = deferred_config("development.su... | 74 | 2,750 |
saleor | saleor/core/pricing/interface.py | .py | from collections.abc import Iterable
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Optional, Union
from ...discount import DiscountType
if TYPE_CHECKING:
from ...channel.models import Channel
from ...checkout.models import CheckoutLine
from ...discount.models import CheckoutLi... | 62 | 1,671 |
mlflow | tests/evaluate/test_deprecated.py | .py | import warnings
from contextlib import contextmanager
from unittest.mock import patch
import pandas as pd
import pytest
import mlflow
_TEST_DATA = pd.DataFrame({"x": [1, 2, 3], "y": [4, 5, 6]})
@pytest.mark.parametrize("tracking_uri", ["databricks", "http://localhost:5000"])
def test_global_evaluate_warn_in_tracki... | 41 | 1,298 |
ipython | IPython/terminal/magics.py | .py | """Extra magics for terminal use."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
from logging import error
import os
import sys
from IPython.core.error import TryNext, UsageError
from IPython.core.magic import Magics, magics_class, line_magic
from IPython.lib... | 214 | 7,638 |
attrs | tests/test_hooks.py | .py | # SPDX-License-Identifier: MIT
from __future__ import annotations
from datetime import datetime
import pytest
import attr
class TestTransformHook:
"""
Tests for `attrs(tranform_value_serializer=func)`
"""
def test_hook_applied(self):
"""
The transform hook is applied to all attrib... | 454 | 12,789 |
wandb | wandb/sdk/artifacts/_generated/create_registry_members.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/artifacts/
from __future__ import annotations
from wandb._pydantic import GQLResult
class CreateRegistryMembers(GQLResult):
result: CreateRegistryMembersResult | None
class CreateRegistryMembersResult(GQLResult):
success: bool
CreateRegistry... | 18 | 344 |
textual | docs/examples/guide/compound/compound01.py | .py | from textual.app import App, ComposeResult
from textual.widget import Widget
from textual.widgets import Input, Label
class InputWithLabel(Widget):
"""An input with a label."""
DEFAULT_CSS = """
InputWithLabel {
layout: horizontal;
height: auto;
}
InputWithLabel Label {
pa... | 53 | 1,063 |
sphinx | tests/test_util/test_util_uri.py | .py | from __future__ import annotations
from sphinx.util._uri import encode_uri
def test_encode_uri() -> None:
expected = (
'https://ru.wikipedia.org/wiki/%D0%A1%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D0%B0_'
'%D1%83%D0%BF%D1%80%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D1%8F_'
'%D0%B1%D0%B0%D0%B7%D0%B0%D0%B... | 24 | 892 |
python-prompt-toolkit | src/prompt_toolkit/completion/deduplicate.py | .py | from __future__ import annotations
from collections.abc import Iterable
from prompt_toolkit.document import Document
from .base import CompleteEvent, Completer, Completion
__all__ = ["DeduplicateCompleter"]
class DeduplicateCompleter(Completer):
"""
Wrapper around a completer that removes duplicates. Only... | 46 | 1,445 |
luigi | luigi/lock.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... | 159 | 5,366 |
astropy | astropy/io/misc/tests/test_pickle_helpers.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pickle
import pytest
from astropy.io.misc import fnpickle, fnunpickle
from astropy.utils.exceptions import AstropyDeprecationWarning
def test_fnpickling_simple(tmp_path):
"""
Tests the `fnpickle` and `fnupickle` functions' basic operatio... | 108 | 2,876 |
saleor | saleor/graphql/payment/mutations/payment/payment_refund.py | .py | from typing import cast
from django.core.exceptions import ValidationError
from .....order import models as order_models
from .....order.actions import order_refunded
from .....payment import PaymentError, TransactionKind, gateway
from .....payment.error_codes import PaymentErrorCode
from .....permission.enums import... | 70 | 2,547 |
beam | sdks/python/apache_beam/ml/transforms/embeddings/tensorflow_hub_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... | 239 | 7,998 |
pyomo | pyomo/scripting/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... | 1,173 | 42,634 |
onnxruntime | onnxruntime/test/python/quantization/bench_matmul_8bits.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
"""
Benchmark performance of MatMulNBits for CUDA in ONNX Runtime.
"""
... | 671 | 23,257 |
mlflow | tests/resources/onnx/generate_onnx_models.py | .py | """
Generates the following test resources:
- tf_model_multiple_inputs_float32.onnx
- tf_model_multiple_inputs_float64.onnx
- sklearn_model.onnx
Usage: python generate_onnx_models.py
"""
import numpy as np
import onnx
import onnxmltools
import pandas as pd
import tensorflow.compat.v1 as tf
import tf2onnx... | 79 | 2,381 |
mlflow | mlflow/cli/demo.py | .py | import contextlib
import logging
import os
import threading
import time
import webbrowser
from collections.abc import Generator
from pathlib import Path
from urllib.parse import urljoin
import click
NOISY_LOGGERS = [
"alembic",
"mlflow.store",
"mlflow.tracking",
"mlflow.tracing",
"mlflow.genai",
... | 303 | 9,723 |
textual | docs/examples/widgets/switch.py | .py | from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Static, Switch
class SwitchApp(App):
def compose(self) -> ComposeResult:
yield Static("[b]Example switches\n", classes="label")
yield Horizontal(
Static("off: ", classes... | 36 | 991 |
omegaconf | tests/interpolation/built_in_resolvers/test_oc_decode.py | .py | import re
from typing import Any, Optional
from pytest import mark, param, raises
from omegaconf import OmegaConf
from omegaconf.errors import InterpolationResolutionError
@mark.parametrize(
"value,expected",
[
# We only test a few typical cases: more extensive grammar tests are
# found in `... | 106 | 2,973 |
python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/search.py | .py | """
Search related key bindings.
"""
from __future__ import annotations
from prompt_toolkit import search
from prompt_toolkit.application.current import get_app
from prompt_toolkit.filters import Condition, control_is_searchable, is_searching
from prompt_toolkit.key_binding.key_processor import KeyPressEvent
from ..... | 97 | 2,632 |
saleor | saleor/giftcard/lock_objects.py | .py | from django.db.models import QuerySet
from .models import GiftCard
def gift_card_qs_select_for_update() -> QuerySet[GiftCard]:
# order_by("pk") is intentional, not redundant: acquiring row locks in a
# consistent primary-key order prevents deadlocks between concurrent
# transactions that lock several row... | 12 | 491 |
saleor | saleor/graphql/discount/tests/queries/test_vouchers_pagination.py | .py | import pytest
from django.utils import timezone
from freezegun import freeze_time
from .....discount import DiscountValueType, VoucherType
from .....discount.models import Voucher, VoucherChannelListing, VoucherCode
from ....tests.utils import get_graphql_content
@pytest.fixture
@freeze_time("2020-03-18 12:00:00")
d... | 248 | 8,248 |
confluent-kafka-python | src/confluent_kafka/schema_registry/rules/dlq/__init__.py | .py | # Copyright 2026 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 agreed to in writing, s... | 14 | 574 |
coveragepy | tests/strategies.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
"""Hypothesis strategies for use in tests."""
from __future__ import annotations
from collections.abc import Sequence
from hypothesis import strategies as st
... | 98 | 3,255 |
sphinx | tests/roots/test-ext-autodoc/target/inheritance.py | .py | class Base:
#: docstring
inheritedattr = None
def inheritedmeth(self):
"""Inherited function."""
@classmethod
def inheritedclassmeth(cls):
"""Inherited class method."""
@staticmethod
def inheritedstaticmeth(cls): # NoQA: PLW0211
"""Inherited static method."""
cl... | 32 | 622 |
hatch | src/hatch/project/frontend/scripts/build_deps.py | .py | from __future__ import annotations
import json
import os
from hatchling.bridge.app import Application
from hatchling.metadata.core import ProjectMetadata
from hatchling.plugin.manager import PluginManager
RUNNER: dict = {}
def main() -> None:
project_root: str = RUNNER["project_root"]
output_dir: str = RUN... | 41 | 1,138 |
wagtail | wagtail/admin/api/actions/unpublish.py | .py | from django.core.exceptions import ValidationError as DjangoValidationError
from rest_framework import fields, status
from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.serializers import Serializer
from wagtail.actions.unpublish_page import Unpublish... | 36 | 1,148 |
biopython | Bio/Align/chain.py | .py | # Copyright 2023 by Michiel de Hoon. All rights reserved.
#
# 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.
"""Bio.Align support fo... | 268 | 9,448 |
cvxpy | cvxpy/lin_ops/lin_op.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... | 119 | 3,542 |
conda | tests/core/test_package_cache_data.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import datetime
import json
from concurrent.futures import ThreadPoolExecutor
from os.path import abspath, basename, dirname, join
from pathlib import Path
from threading import Event
from types import SimpleNamespace
import pytest
from pytest ... | 781 | 28,101 |
saleor | saleor/graphql/account/mutations/account/account_address_update.py | .py | from .....account import models
from .....webhook.event_types import WebhookEventAsyncType
from ....core.doc_category import DOC_CATEGORY_USERS
from ....core.types import AccountError
from ....core.utils import WebhookEventInfo
from ...mixins import AddressMetadataMixin
from ...types import Address
from ..base import B... | 29 | 1,024 |
onnxruntime | onnxruntime/test/python/transformers/sharded_moe/test_sharded_moe.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import unittest
import numpy as np
from onnx import TensorProto, helpe... | 424 | 11,810 |
httpie | httpie/output/ui/rich_utils.py | .py | import os
from typing import Iterator
from contextlib import contextmanager
from rich.console import Console, RenderableType
from rich.highlighter import Highlighter
from httpie.output.ui.rich_palette import _make_rich_color_theme
def render_as_string(renderable: RenderableType) -> str:
"""Render any `rich` ob... | 35 | 973 |
qutip | qutip/entropy.py | .py | __all__ = ['entropy_vn', 'entropy_linear', 'entropy_mutual', 'negativity',
'concurrence', 'entropy_conditional', 'entangling_power',
'entropy_relative']
from .core.numpy_backend import np
from .partial_transpose import partial_transpose
from . import (ptrace, tensor, sigmay, ket2dm,
... | 386 | 11,101 |
sqlmap | tamper/lowercase.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.data import kb
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.NORMAL
def dependencies():
pass
def tamper(payload, **kwargs):
"""
... | 48 | 1,034 |
openvino | tests/layer_tests/pytorch_tests/test_eq.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestEq(PytorchLayerTest):
def _prepare_input(self):
return (self.input_array.astype(self.input_type), self.other_array.astype(sel... | 49 | 1,687 |
wagtail | wagtail/api/v3/tests/test_whoami.py | .py | from django.contrib.auth.models import Group
from django.test import TestCase
from django.urls import reverse
from wagtail.api.v3.tests.base import TestV3Base
from wagtail.test.utils import WagtailTestUtils
class TestWhoAmI(TestV3Base, WagtailTestUtils, TestCase):
url = reverse("wagtailapi_v3:whoami")
def t... | 39 | 1,480 |
luigi | test/set_task_name_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... | 44 | 1,215 |
pyomo | examples/dae/run_stochpdegas_automatic.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... | 143 | 3,670 |
kombu | kombu/asynchronous/http/base.py | .py | """Base async HTTP client implementation."""
from __future__ import annotations
import sys
from http.client import responses
from typing import TYPE_CHECKING
from vine import Thenable, maybe_promise, promise
from kombu.exceptions import HttpError
from kombu.utils.compat import coro
from kombu.utils.encoding import ... | 275 | 9,592 |
textual | docs/examples/guide/layout/grid_layout2.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Static
class GridLayoutExample(App):
CSS_PATH = "grid_layout2.tcss"
def compose(self) -> ComposeResult:
yield Static("One", classes="box")
yield Static("Two", classes="box")
yield Static("Three", classes="box")
... | 21 | 566 |
conda | tests/data/build-index2-json.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import json
from os.path import abspath, dirname, join
from conda.core.subdir_data import Channel, SubdirData
DATA_DIR = abspath(join(dirname(__file__), "repodata"))
def save_data_source(url, name):
sd = SubdirData(Channel(url))
repo... | 195 | 4,490 |
ipython | IPython/core/magics/script.py | .py | """Magic functions for running cells in various scripts."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import atexit
import errno
import os
import sys
import time
import weakref
from codecs import getincrementaldecoder
from threading import Thread
from traitl... | 444 | 15,346 |
saleor | saleor/graphql/product/mutations/attributes.py | .py | from collections import Counter, defaultdict
import graphene
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.db.models import Q
from ....attribute import AttributeInputType, AttributeType
from ....attribute import models as attribute_models
from ....core.tracing import traced_atomic... | 786 | 29,312 |
saleor | saleor/graphql/account/mutations/staff/address_set_default.py | .py | import graphene
from django.core.exceptions import ValidationError
from .....account import utils
from .....account.error_codes import AccountErrorCode
from .....checkout import AddressType
from .....permission.enums import AccountPermissions
from .....webhook.event_types import WebhookEventAsyncType
from ....account.... | 69 | 2,656 |
saleor | saleor/plugins/user_email/tests/conftest.py | .py | from unittest.mock import patch
import pytest
from ....plugins.models import EmailTemplate, PluginConfiguration
from ...email_common import DEFAULT_EMAIL_VALUE
from ...manager import get_plugins_manager
from ..constants import (
ACCOUNT_CHANGE_EMAIL_CONFIRM_DEFAULT_SUBJECT,
ACCOUNT_CHANGE_EMAIL_CONFIRM_SUBJEC... | 258 | 11,387 |
coremltools | coremltools/converters/sklearn/_imputer.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
from packaging.version import Version
from coremltools import proto
from ... import SPECIFICATION_VERS... | 115 | 3,396 |
saleor | saleor/graphql/app/mutations/app_delete_failed_installation.py | .py | import graphene
from django.core.exceptions import ValidationError
from ....app import models
from ....app.error_codes import AppErrorCode
from ....core import JobStatus
from ....permission.enums import AppPermission
from ...core import ResolveInfo
from ...core.mutations import ModelDeleteMutation
from ...core.types i... | 34 | 1,173 |
mlflow | tests/genai/judges/adapters/test_utils.py | .py | from unittest import mock
import pytest
import requests
from mlflow.exceptions import MlflowException
from mlflow.genai.judges.adapters.databricks_managed_judge_adapter import (
DatabricksManagedJudgeAdapter,
)
from mlflow.genai.judges.adapters.gateway_adapter import GatewayAdapter
from mlflow.genai.judges.adapte... | 150 | 5,469 |
saleor | saleor/discount/tests/test_utils/test_fetch_promotion_rules_for_checkout.py | .py | from decimal import Decimal
from ... import RewardType, RewardValueType
from ...models import PromotionRule
from ...utils.promotion import fetch_promotion_rules_for_checkout_or_order
def test_fetch_promotion_rules_for_checkout(
checkout, checkout_for_cc, order_promotion_rule
):
# given
rule = order_promo... | 119 | 3,246 |
kombu | kombu/utils/div.py | .py | """Div. Utilities."""
from __future__ import annotations
import logging
import os
from .encoding import default_encode
logger = logging.getLogger(__name__)
def emergency_dump_state(state, open_file=open, dump=None, stderr=None):
"""Dump message state to stdout or file."""
from pprint import pformat
fr... | 45 | 1,213 |
saleor | saleor/graphql/giftcard/sorters.py | .py | from ..core.doc_category import DOC_CATEGORY_GIFT_CARDS
from ..core.types import BaseEnum, SortInputObjectType
class GiftCardSortField(BaseEnum):
PRODUCT = ["product__name", "product__slug"]
USED_BY = ["used_by__first_name", "used_by__last_name", "created_at"]
CURRENT_BALANCE = ["current_balance_amount", ... | 35 | 1,299 |
structlog | tests/test_twisted.py | .py | # SPDX-License-Identifier: MIT OR Apache-2.0
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the MIT License. See the LICENSE file in the root of this
# repository for complete details.
import json
import pytest
from structlog import ReturnLogger
from structlog._config import ... | 361 | 10,277 |
scikit-bio | skbio/table/_base.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.
# --------------------------------------------... | 39 | 1,196 |
sqlmap | plugins/dbms/db2/__init__.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.enums import DBMS
from lib.core.settings import DB2_SYSTEM_DBS
from lib.core.unescaper import unescaper
from plugins.dbms.db2.enumeration import Enumeration
from pl... | 31 | 879 |
mlflow | dev/xtest_viz.py | .py | # /// script
# dependencies = [
# "aiohttp",
# ]
# ///
"""
Script to visualize cross-version test results for MLflow autologging and models.
This script fetches scheduled workflow run results from GitHub Actions and generates
a markdown table showing the test status for different package versions across
different ... | 390 | 13,558 |
hydra | tests/test_apps/app_change_dir/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
from pathlib import Path
from omegaconf import DictConfig
import hydra
from hydra.core.hydra_config import HydraConfig
@hydra.main()
def main(_: DictConfig) -> None:
subdir = Path(HydraConfig.get().run.dir) / Path("subdir")
sub... | 22 | 458 |
pyomo | examples/dae/simulator_ode_multindex_example.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... | 120 | 3,493 |
textual | docs/examples/widgets/collapsible_custom_symbol.py | .py | from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Collapsible, Label
class CollapsibleApp(App[None]):
def compose(self) -> ComposeResult:
with Horizontal():
with Collapsible(
collapsed_symbol=">>>",
... | 26 | 672 |
beam | sdks/python/apache_beam/io/gcp/big_query_query_to_table_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... | 262 | 10,083 |
astropy | astropy/table/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import astropy.config as _config
from astropy.utils.compat import optional_deps
from .column import Column, ColumnInfo, MaskedColumn, StringTruncateWarning
__all__ = [
"BST",
"Column",
"ColumnGroups",
"ColumnInfo",
"Conf",
"JSVie... | 142 | 3,996 |
pyomo | examples/mpec/scholtes4.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... | 35 | 1,256 |
saleor | saleor/graphql/product/mutations/category/category_create.py | .py | import graphene
from django.core.exceptions import ValidationError
from .....core.editorjs import editorjs_to_text
from .....permission.enums import ProductPermissions
from .....product import models
from .....product.error_codes import ProductErrorCode
from ....core import ResolveInfo
from ....core.descriptions impor... | 109 | 4,147 |
conda | conda/exception_handler.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Error handling and error reporting."""
from __future__ import annotations
import os
import sys
from functools import cached_property, partial
from logging import getLogger
from typing import TYPE_CHECKING
from .common.compat import ensure_... | 437 | 15,454 |
saleor | saleor/graphql/meta/mutations/delete_metadata.py | .py | from typing import cast
import graphene
from ....core import models
from ...core import ResolveInfo
from ...core.types import MetadataError, NonNullList
from ..permissions import PUBLIC_META_PERMISSION_MAP
from .base import BaseMetadataMutation
from .utils import delete_metadata_keys, get_valid_metadata_instance
cl... | 43 | 1,402 |
ipython | examples/Embedding/embed_class_long.py | .py | #!/usr/bin/env python
"""An example of how to embed an IPython shell into a running program.
Please see the documentation in the IPython.Shell module for more details.
The accompanying file embed_class_short.py has quick code fragments for
embedding which you can cut and paste in your code once you understand how
thi... | 146 | 4,836 |
pyomo | pyomo/contrib/mpc/data/interpolation.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... | 81 | 2,970 |
kafka | docker/extract_docker_official_image_artifact.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... | 78 | 3,482 |
conda | tests/data/build-index5-json.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import json
from os.path import abspath, dirname, join
from pprint import pprint
from conda.core.subdir_data import SubdirData
DATA_DIR = abspath(join(dirname(__file__), "repodata"))
def save_data_source(url, name):
raw_repodata_str = Su... | 162 | 4,278 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.