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/store/artifact/test_dbfs_rest_artifact_repo.py | .py | import json
import os
from unittest import mock
from unittest.mock import Mock
import pytest
from mlflow.exceptions import MlflowException
from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository
from mlflow.store.artifact.dbfs_artifact_repo import (
DbfsRestArtifactRepository,
_... | 363 | 13,180 |
astropy | astropy/convolution/kernels.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import math
import numpy as np
from astropy.modeling import models
from astropy.modeling.core import Fittable1DModel, Fittable2DModel
from .core import Kernel, Kernel1D, Kernel2D
from .utils import KernelSizeError, has_even_axis
__all__ = [
"AiryD... | 1,051 | 33,686 |
readthedocs.org | readthedocs/gold/tests/test_signals.py | .py | import requests_mock
from unittest import mock
import django_dynamic_fixture as fixture
from django.contrib.auth.models import User
from django.test import TestCase
from ..models import GoldUser
from readthedocs.payments.tests.utils import PaymentMixin
class GoldSignalTests(PaymentMixin, TestCase):
def setUp(se... | 35 | 1,318 |
saleor | saleor/graphql/shipping/tests/mutations/test_shipping_zone_create.py | .py | import json
from unittest import mock
import graphene
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....core.utils.json_serializer import CustomJsonEncoder
from .....shipping.error_codes import ShippingErrorCode
from .....shipping.models import ShippingZone
from .....web... | 354 | 10,757 |
qutip | qutip/core/operators.py | .py | """
This module contains functions for generating Qobj representation of a variety
of commonly occuring quantum operators.
"""
# Required for Sphinx to follow autodoc_type_aliases
from __future__ import annotations
__all__ = [
'jmat', 'spin_Jx', 'spin_Jy', 'spin_Jz', 'spin_Jm', 'spin_Jp',
'spin_J_set', 'sigmap... | 1,317 | 35,255 |
mlflow | tests/resources/mlflow-test-plugin/mlflow_test_plugin/app.py | .py | """
To run a tracking server with this app, use `mlflow server --app-name custom_app`.
"""
import logging
# This would be all that plugin author is required to import
from mlflow.server import app as custom_app
# Can do custom logging on either the app or logging itself
# but you'll possibly have to clear the existi... | 40 | 1,045 |
clearml | examples/advanced/model_embedding.py | .py | import os
import sys
import argparse
import json
import requests
import numpy as np
from typing import List, Dict, Any
try:
from PyPDF2 import PdfReader
except ImportError:
raise ImportError(
"PyPDF2 is required to extract text from PDF files. Install via `pip install PyPDF2`."
)
def chunk_text(t... | 228 | 7,269 |
openvino | tests/layer_tests/pytorch_tests/test_clamp.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
class TestClamp(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(1, 3, 224, 224),)
def create_model(self, minim... | 124 | 4,953 |
python-prompt-toolkit | examples/prompts/auto-completion/autocompletion.py | .py | #!/usr/bin/env python
"""
Autocompletion example.
Press [Tab] to complete the current word.
- The first Tab press fills in the common part of all completions
and shows all the completions. (In the menu)
- Any following tab press cycles through all the possible completions.
"""
from prompt_toolkit import prompt
fr... | 62 | 1,197 |
pyomo | pyomo/solvers/plugins/solvers/XPRESS.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,542 |
pyomo | pyomo/repn/tests/ampl/small10_testCase.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... | 84 | 3,292 |
pyomo | pyomo/contrib/pyros/solve_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... | 746 | 26,171 |
pyomo | pyomo/core/tests/__init__.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... | 12 | 564 |
mlflow | dev/clint/tests/rules/test_unparameterized_generic_type.py | .py | from pathlib import Path
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import Position, Range, lint_file
from clint.rules.unparameterized_generic_type import UnparameterizedGenericType
def test_unparameterized_generic_type(index: SymbolIndex) -> None:
code = """
from typin... | 47 | 1,473 |
pyro | pyro/infer/trace_mmd.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from collections import defaultdict
import torch
import pyro
import pyro.ops.jit
from pyro import poutine
from pyro.infer.elbo import ELBO
from pyro.infer.enum import get_importance_trace
from pyro.infer.util import is_validation... | 273 | 10,876 |
biopython | Tests/test_SeqUtils.py | .py | # Copyright 2003 by Iddo Friedberg. All rights reserved.
# Copyright 2007-2009 by Peter Cock. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Tests for SeqUtils module."""
i... | 433 | 19,362 |
pyomo | pyomo/dae/integral.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... | 199 | 6,907 |
beam | sdks/python/apache_beam/runners/trivial_runner_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... | 75 | 2,847 |
openvino | tests/layer_tests/onnx_tests/test_roi_align.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import numpy as np
import pytest
pytest.importorskip("openvino.tools.mo", reason="Ticket - 157136")
from common.layer_test_class import check_ir_version
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onn... | 151 | 6,880 |
pymc | scripts/test_publish_release_notes.py | .py | # Copyright 2024 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 199 | 9,806 |
coremltools | coremltools/converters/mil/frontend/torch/torchscript_utils.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 torch
from coremltools._deps import version_lt
def _jit_pass_lower_graph(graph, torchscript... | 191 | 8,400 |
kafka | tests/kafkatest/sanity_checks/test_performance_services.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 use ... | 108 | 5,275 |
metrics | src/torchmetrics/clustering/adjusted_rand_score.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... | 128 | 5,191 |
wandb | tests/system_tests/test_functional/lightning/base.py | .py | import torch
from lightning import LightningModule
from torch.utils.data import Dataset
class RandomDataset(Dataset):
def __init__(self, size, num_samples):
self.len = num_samples
self.data = torch.randn(num_samples, size)
def __getitem__(self, index):
return self.data[index]
def... | 69 | 2,209 |
wandb | wandb/sdk/data_types/object_3d.py | .py | from __future__ import annotations
import codecs
import itertools
import os
import pathlib
from collections.abc import Sequence
from typing import TYPE_CHECKING, ClassVar, Literal, TextIO, TypeAlias, TypedDict, cast
import wandb
from wandb import util
from wandb.sdk.lib import json_util, runid
from wandb.sdk.lib.path... | 543 | 18,732 |
wandb | tests/unit_tests/test_public_api/test_sweeps.py | .py | import json
import pytest
from wandb.apis.public.sweeps import Sweep
from wandb.errors import UnsupportedError
from wandb.proto import wandb_internal_pb2 as pb
def _make_sweep(
mocker, *, feature_enabled: bool = True, graphql_response=None
) -> Sweep:
"""Build a Sweep backed by a mocked service API.
Pas... | 100 | 3,183 |
pyfilesystem2 | docs/source/conf.py | .py | # -*- coding: utf-8 -*-
#
# PyFilesystem2 documentation build configuration file, created by
# sphinx-quickstart on Tue May 10 16:45:12 2016.
#
# 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.... | 319 | 10,230 |
biopython | Bio/Pathway/__init__.py | .py | # Copyright 2001 by Tarjei Mikkelsen. 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.
"""BioPython Pathway ... | 316 | 10,800 |
textual | tests/snapshot_tests/snapshot_apps/label_widths.py | .py | from textual.app import App
from textual.widgets import Label, Static
from rich.panel import Panel
class LabelWrap(App):
CSS = """
Screen {
align: center middle;
}
#l_data {
border: blank;
background: lightgray;
}
#s_data {
border: blank;
background: l... | 48 | 917 |
onnxruntime | onnxruntime/python/tools/transformers/models/stable_diffusion/diffusion_schedulers.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# Modified from utilities.py of TensorRT demo diffusion, which has the f... | 1,180 | 48,289 |
textual | tests/command_palette/test_click_away.py | .py | from textual.app import App
from textual.command import CommandPalette, Hit, Hits, Provider
class SimpleSource(Provider):
async def search(self, query: str) -> Hits:
def goes_nowhere_does_nothing() -> None:
pass
yield Hit(1, query, goes_nowhere_does_nothing, query)
class CommandPale... | 26 | 792 |
mlflow | mlflow/store/tracking/gateway/entities.py | .py | from dataclasses import asdict, dataclass, field
from typing import Any
from mlflow.entities.gateway_endpoint import (
FallbackConfig,
FallbackStrategy,
GatewayModelLinkageType,
RoutingStrategy,
)
@dataclass
class GatewayModelConfig:
"""
Model configuration with decrypted credentials for runt... | 97 | 3,821 |
textual | tests/snapshot_tests/snapshot_apps/auto_width_input.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Header, Footer, Input
class InputWidthAutoApp(App[None]):
CSS = """
Input.auto {
width: auto;
max-width: 100%;
}
"""
def compose(self) -> ComposeResult:
yield Header()
yield Input(placeholder="T... | 21 | 439 |
probability | tensorflow_probability/python/experimental/nn/util/random_variable.py | .py | # Copyright 2020 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... | 218 | 7,723 |
onnx | onnx/reference/ops/op_identity.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from onnx.reference.op_run import OpRun
class Identity(OpRun):
def _run(self, a):
if a is None:
return (None,)
return (a.copy(),)
| 14 | 281 |
pyomo | pyomo/contrib/piecewise/transform/reduced_inner_representation_gdp.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... | 139 | 6,571 |
wandb | wandb/sdk/launch/builder/templates/_wandb_bootstrap.py | .py | from __future__ import annotations
import json
import os
import re
import subprocess
import sys
FAILED_PACKAGES_PREFIX = "ERROR: Failed to install: "
FAILED_PACKAGES_POSTFIX = ". During automated build process."
ONLY_INCLUDE = {x for x in os.getenv("WANDB_ONLY_INCLUDE", "").split(",") if x != ""}
OPTS = []
# If the b... | 190 | 7,289 |
kombu | examples/simple_send.py | .py | """
Example that sends a single message and exits using the simple interface.
You can use `simple_receive.py` (or `complete_receive.py`) to receive the
message sent.
"""
from __future__ import annotations
from kombu import Connection
#: Create connection
#: If hostname, userid, password and virtual_host is not sp... | 33 | 1,001 |
astropy | astropy/io/votable/validator/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from . import main
from .main import make_validation_report
__doc__ = main.__doc__
del main
| 7 | 157 |
pyomo | pyomo/contrib/mindtpy/tabu_list.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... | 43 | 2,026 |
coremltools | coremltools/optimize/torch/palettization/sensitive_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 copy as _copy
import logging as _logging
import tempfile as _tempfile
from collections import ... | 703 | 33,516 |
saleor | saleor/order/events.py | .py | from decimal import Decimal
from typing import TYPE_CHECKING, Optional
from ..account import events as account_events
from ..account.models import User
from ..app.models import App
from ..discount.models import OrderDiscount
from ..order.models import Fulfillment, FulfillmentLine, Order, OrderLine
from ..payment.model... | 935 | 23,539 |
saleor | saleor/product/tests/utils.py | .py | from io import BytesIO
from django.core.files.uploadedfile import SimpleUploadedFile
from PIL import Image
def create_image(image_name="product2"):
img_data = BytesIO()
image = Image.new("RGB", size=(1, 1), color=(255, 0, 0, 0))
image.save(img_data, format="JPEG")
image = SimpleUploadedFile(image_nam... | 29 | 969 |
conda | tests/plugins/test_request_headers.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from conda.common.url import urlparse
from conda.plugins import hookimpl
from conda.plugins.types import CondaRequestHeader
if TYPE_CHECKING:
from collect... | 100 | 3,340 |
textual | tests/test_highlight.py | .py | import pytest
from textual.content import Span
from textual.highlight import guess_language, highlight
def test_highlight() -> None:
"""Test simple application of highlight."""
import_this = highlight("import this", language="python")
assert import_this.plain == "import this"
print(import_this.spans)... | 34 | 980 |
sphinx | sphinx/pycode/ast.py | .py | """Helpers for AST (Abstract Syntax Tree)."""
from __future__ import annotations
import ast
from typing import TYPE_CHECKING, overload
if TYPE_CHECKING:
from typing import NoReturn
OPERATORS: dict[type[ast.AST], str] = {
ast.Add: '+',
ast.And: 'and',
ast.BitAnd: '&',
ast.BitOr: '|',
ast.BitX... | 210 | 7,043 |
pyomo | pyomo/contrib/mindtpy/tests/constraint_qualification_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... | 49 | 1,730 |
pyro | tests/contrib/tracking/test_assignment.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import pytest
import torch
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro.contrib.tracking.assignment import (
MarginalAssignment,
MarginalAssignmentPersistent,
... | 358 | 14,126 |
mlflow | dev/clint/src/clint/rules/multi_assign.py | .py | import ast
from clint.rules.base import Rule
class MultiAssign(Rule):
def _message(self) -> str:
return (
"Avoid multiple assignment (e.g., `x, y = func()`). Use separate assignments "
"instead for better readability and easier debugging."
)
@staticmethod
def chec... | 52 | 1,779 |
beam | sdks/python/apache_beam/internal/gcp/auth.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... | 196 | 7,012 |
mlflow | mlflow/entities/source_type.py | .py | class SourceType:
"""Enum for originating source of a :py:class:`mlflow.entities.Run`."""
NOTEBOOK, JOB, PROJECT, LOCAL, UNKNOWN = range(1, 6)
_STRING_TO_SOURCETYPE = {
"NOTEBOOK": NOTEBOOK,
"JOB": JOB,
"PROJECT": PROJECT,
"LOCAL": LOCAL,
"UNKNOWN": UNKNOWN,
}
... | 32 | 1,168 |
saleor | saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_payment_method_process_tokenization.py | .py | import json
import graphene
from ....payment.interface import PaymentMethodProcessTokenizationRequestData
from ...event_types import WebhookEventSyncType
from ...transport.asynchronous import create_deliveries_for_subscriptions
PAYMENT_METHOD_PROCESS_TOKENIZATION_SESSION = """
subscription{
event{
...on Paymen... | 96 | 2,658 |
conda | tests/plugins/test_pre_solves.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from conda import plugins
from conda.exceptions import DryRunExit
from conda.plugins import solvers
if TYPE_CHECKING:
from pytest_mock import MockerFixture... | 86 | 2,153 |
wagtail | wagtail/images/tests/tests.py | .py | import os
import unittest
from io import BytesIO
import willow
from django import forms, template
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.core.files.uploadedfile import InMemoryUploadedFile, TemporaryUploadedFile
from django.test import Test... | 971 | 35,272 |
sqlmap | tests/test_jitter_stress.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Adversarial JITTER stress harness for time-based blind extraction.
Drives the REAL bisection() + REAL wasLastResponseDelayed() + REAL validateChar() re-validation
against a mock orac... | 290 | 14,363 |
pyomo | pyomo/contrib/appsi/fbbt.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... | 327 | 11,517 |
marshmallow | tests/mypy_test_cases/test_class_registry.py | .py | from marshmallow import class_registry
# Works without passing `all`
class_registry.get_class("MySchema")
| 5 | 107 |
pyro | tests/optim/test_multi.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.distributions import constraints
import pyro
import pyro.distributions as dist
import pyro.optim
import pyro.poutine as poutine
from pyro.optim.multi import (
MixedMultiOptimizer,
Newt... | 90 | 2,637 |
sqlmap | plugins/dbms/spanner/fingerprint.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.common import Backend
from lib.core.common import Format
from lib.core.data import conf
from lib.core.data import kb
from lib.core.data import logger
from lib.core.e... | 94 | 2,571 |
beam | sdks/python/apache_beam/examples/cookbook/filters.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... | 106 | 3,925 |
kombu | t/unit/transport/test_base.py | .py | from __future__ import annotations
from unittest.mock import Mock
import pytest
from kombu import Connection, Consumer, Exchange, Producer, Queue
from kombu.message import Message
from kombu.transport.base import (Management, StdChannel, Transport,
to_rabbitmq_queue_arguments)
@py... | 168 | 5,631 |
luigi | test/contrib/postgres_test.py | .py | # Copyright (c) 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 or agreed to in writing, s... | 187 | 6,702 |
loguru | tests/test_exceptions_catch.py | .py | import asyncio
import site
import sys
import sysconfig
import threading
import types
import pytest
from loguru import logger
@pytest.mark.parametrize("diagnose", [False, True])
def test_caret_not_masked(writer, diagnose):
logger.add(writer, backtrace=True, diagnose=diagnose, colorize=False, format="")
@log... | 636 | 16,701 |
hatch | tests/backend/builders/hooks/test_version.py | .py | import pytest
from hatchling.builders.hooks.version import VersionBuildHook
from hatchling.metadata.core import ProjectMetadata
from hatchling.plugin.manager import PluginManager
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT
class TestConfigPath:
def test_correct(self, isolation):
config = {... | 266 | 8,966 |
textual | tests/document/test_document_delete.py | .py | import pytest
from textual.widgets.text_area import Document, EditResult
TEXT = """I must not fear.
Fear is the mind-killer.
I forgot the rest of the quote.
Sorry Will."""
@pytest.fixture
def document():
document = Document(TEXT)
return document
def test_delete_single_character(document):
replace_resu... | 147 | 4,306 |
wagtail | wagtail/contrib/redirects/filters.py | .py | import django_filters
from django import forms
from django.utils.translation import gettext as _
from wagtail.admin.filters import WagtailFilterSet
from wagtail.contrib.redirects.models import Redirect
from wagtail.models import Site
class RedirectsReportFilterSet(WagtailFilterSet):
is_permanent = django_filters... | 34 | 944 |
cvxpy | cvxpy/atoms/inv_prod.py | .py | """
Copyright, the CVXPY authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
... | 45 | 1,407 |
pyro | tests/contrib/gp/test_parameterized.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.distributions import constraints
from torch.nn import Parameter
import pyro
import pyro.distributions as dist
from pyro.contrib.gp.parameterized import Parameterized
from pyro.nn.module import PyroParam, Py... | 156 | 4,723 |
onnxruntime | onnxruntime/test/testdata/transform/computation_reduction/gather/gather_reshape.py | .py | import onnx
from onnx import OperatorSetIdProto, TensorProto, helper
hidden = 1024
head = 16
def _create_model_proto(
input_shapes, output_shapes, axis_to_gather, slice_dims, slices_values, shape_dims, shape_values, model_name
):
# inputs and outputs
inputs = [
helper.make_tensor_value_info("inpu... | 90 | 2,671 |
pyro | pyro/contrib/examples/finance.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import os
import urllib
import pandas as pd
from pyro.contrib.examples.util import _mkdir_p, get_data_directory
DATA = get_data_directory(__file__)
# https://finance.yahoo.com/quote/%5EGSPC/history/
CACHE_URL = "https://github.com/... | 27 | 705 |
pyomo | pyomo/contrib/solver/common/persistent.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... | 538 | 21,550 |
onnx | onnx/reference/ops/aionnxml/op_svm_helper.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import Any
import numpy as np
class SVMAttributes:
def __init__(self):
self._names = []
def add(self, name: str, value: Any) -> None:
if isinstance(value, list) an... | 98 | 3,080 |
wagtail | wagtail/contrib/search_promotions/views/reports.py | .py | from django.utils.translation import gettext_lazy as _
from django_filters import DateFromToRangeFilter
from wagtail.admin.auth import permission_denied
from wagtail.admin.filters import DateRangePickerWidget, WagtailFilterSet
from wagtail.admin.ui.tables import Column, NumberColumn
from wagtail.admin.views.reports im... | 57 | 1,819 |
hydra | examples/advanced/ad_hoc_composition/hydra_compose_example.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import OmegaConf
from hydra import compose, initialize
if __name__ == "__main__":
# initialize the Hydra subsystem.
# This is needed for apps that cannot have a standard @hydra.main() entry point
initialize(config_path="... | 12 | 458 |
astropy | astropy/units/format/ogip_parsetab.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This file was automatically generated from ply. To re-generate this file,
# remove it from this folder, then build astropy and run the tests in-place:
#
# python setup.py build_ext --inplace
# pytest astropy/units
#
# You can then commit the changes... | 74 | 8,533 |
mlflow | examples/transformers/sentence_transformer.py | .py | import torch
from transformers import BertModel, BertTokenizerFast, pipeline
import mlflow
sentence_transformers_architecture = "sentence-transformers/all-MiniLM-L12-v2"
task = "feature-extraction"
model = BertModel.from_pretrained(sentence_transformers_architecture)
tokenizer = BertTokenizerFast.from_pretrained(sen... | 55 | 1,836 |
pyomo | pyomo/solvers/amplfunc_merge.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... | 61 | 1,849 |
textual | tests/test_focus.py | .py | from textual.app import App, ComposeResult
from textual.containers import Container, ScrollableContainer, Vertical
from textual.widget import Widget
from textual.widgets import Button, Label
from textual.widgets._placeholder import Placeholder
class Focusable(Widget, can_focus=True):
pass
class NonFocusable(Wid... | 551 | 17,436 |
openvino | src/bindings/python/tests/test_graph/test_pooling.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import openvino.opset14 as ov
import openvino.opset16 as ov16
from openvino import Type
avg_pooling_test_params = [
(
[
[2, 2], # strides
[0... | 330 | 9,858 |
sqlmap | lib/techniques/ldap/inject.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
import time
from collections import namedtuple
from lib.core.common import beep
from lib.core.common import randomStr
from lib.core.common import removeReflectiveValue... | 868 | 35,096 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_Pad.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'op_name': 'PAD', 'shape': [1, 1, 2, 1, 1], 'paddings': [[0, 0], [0, 1], [2, 3], [0, 0], [1, 0]]},
{'op_name': 'PAD', 'shape': [2, 1, 1, 1, 1], 'paddings': [[0, 1], [0, 0], [0, 0], [2, 3], [1, 0]]... | 62 | 2,875 |
biopython | Scripts/Performance/biosql_performance_load.py | .py | #!/usr/bin/env python
# Copyright 2002 Brad Chapman. All rights reserved.
#
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Test timing of loading records into a BioSQL database."""
import time
... | 44 | 1,183 |
saleor | saleor/graphql/warehouse/mutations/warehouse_update.py | .py | import graphene
from ....permission.enums import ProductPermissions
from ....warehouse import models
from ...account.i18n import I18nMixin
from ...account.mixins import AddressMetadataMixin
from ...core import ResolveInfo
from ...core.mutations import ModelWithExtRefMutation
from ...core.types import WarehouseError
fr... | 64 | 2,456 |
saleor | saleor/graphql/account/tests/mutations/account/conftest.py | .py | from unittest import mock
import pytest
REQUEST_EMAIL_CHANGE_QUERY = """
mutation requestEmailChange(
$password: String!, $new_email: String!, $redirect_url: String!, $channel:String
) {
requestEmailChange(
password: $password,
newEmail: $new_email,
redirectUrl: $redirect_url,
... | 49 | 921 |
mlflow | mlflow/tensorflow/autologging.py | .py | import numpy as np
import tensorflow
from tensorflow.keras.callbacks import TensorBoard
from mlflow.utils.autologging_utils import (
INPUT_EXAMPLE_SAMPLE_ROWS,
ExceptionSafeClass,
)
class _TensorBoard(TensorBoard, metaclass=ExceptionSafeClass):
pass
def _extract_input_example_from_tensor_or_ndarray(
... | 181 | 6,662 |
deap | doc/code/tutorials/part_2/2_3_4_demes.py | .py | ## 2.3.4 Demes
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", list, fitness=creator.FitnessMin)
IND_SIZE=10
toolbox = base.Toolbox()
toolbox.register("indices", random.sample, range(IND_SIZE... | 21 | 585 |
wagtail | wagtail/contrib/sitemaps/sitemap_generator.py | .py | from django.contrib.sitemaps import Sitemap as DjangoSitemap
# Note: avoid importing models here. This module is imported from __init__.py
# which causes it to be loaded early in startup if wagtail.contrib.sitemaps is
# included in INSTALLED_APPS (not required, but developers are likely to add it
# anyhow) leading to ... | 55 | 1,862 |
saleor | saleor/tests/e2e/orders/discounts/test_promotion_applied_on_draft_order_with_specific_subtotal.py | .py | import pytest
from ... import DEFAULT_ADDRESS
from ...product.utils.preparing_product import prepare_product
from ...promotions.utils import create_promotion, create_promotion_rule
from ...shop.utils.preparing_shop import prepare_shop
from ...taxes.utils import update_country_tax_rates
from ...utils import assign_perm... | 259 | 8,635 |
clearml | clearml/backend_config/utils.py | .py | import base64
import os
from os.path import expandvars, expanduser
from pathlib2 import Path
from typing import List, TYPE_CHECKING, ValuesView, Dict, Any
from ..utilities.pyhocon import HOCONConverter, ConfigTree
if TYPE_CHECKING:
from .config import Config
def get_items(cls) -> Dict[str, Any]:
"""get key/... | 113 | 3,877 |
wagtail | wagtail/snippets/tests/test_api_v3/test_revisions.py | .py | from django.contrib.auth.models import Permission
from django.test import TestCase
from django.urls import reverse
from wagtail.api.v3.tests.base import TestV3Base
from wagtail.test.testapp.models import Advert, FullFeaturedSnippet
from wagtail.test.utils import WagtailTestUtils
class TestV3SnippetRevisionsBase(Test... | 323 | 11,470 |
beam | sdks/python/apache_beam/examples/ml_transform/mltransform_text_embedding.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... | 187 | 5,880 |
pyomo | pyomo/core/tests/unit/test_kernel_register_numpy_types.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... | 74 | 2,950 |
returns | returns/contrib/mypy/_typeops/inference.py | .py | from collections.abc import Iterable, Mapping
from typing import TypeAlias, cast, final
from mypy.argmap import map_actuals_to_formals
from mypy.constraints import infer_constraints_for_callable
from mypy.expandtype import expand_type
from mypy.nodes import ARG_POS, ArgKind
from mypy.plugin import FunctionContext
from... | 138 | 4,639 |
gunicorn | tests/docker/asgi_compliance/apps/streaming_app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Streaming test application for ASGI compliance testing.
Provides endpoints for testing chunked transfer encoding,
Server-Sent Events (SSE), and streaming responses.
"""
import asyncio
import json
import time
... | 477 | 13,071 |
mlflow | mlflow/store/db_migrations/versions/df50e92ffc5e_add_experiment_tags_table.py | .py | """Add Experiment Tags Table
Create Date: 2019-07-15 17:46:42.704214
"""
import sqlalchemy as sa
from alembic import op
from mlflow.store.tracking.dbmodels.models import SqlExperimentTag
# revision identifiers, used by Alembic.
revision = "df50e92ffc5e"
down_revision = "181f10493468"
branch_labels = None
depends_o... | 37 | 858 |
ipython | IPython/core/pylabtools.py | .py | """Pylab (matplotlib) support utilities."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
from io import BytesIO
from binascii import b2a_base64
from functools import partial
from IPython.core.display import _pngxy
from IPython.utils.decorators import flag_calls... | 501 | 16,932 |
pyomo | pyomo/contrib/pynumero/examples/sqp.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... | 233 | 6,919 |
beam | sdks/python/apache_beam/io/filesystemio.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... | 306 | 8,251 |
omegaconf | tests/test_readonly.py | .py | import re
from typing import Any, Callable, Dict, List, Union
from pytest import mark, param, raises
from omegaconf import DictConfig, ListConfig, OmegaConf, ReadonlyConfigError
@mark.parametrize(
"src, func, expectation",
[
param(
{},
lambda c: c.__setitem__("a", 1),
... | 240 | 6,946 |
astropy | astropy/modeling/bounding_box.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module is to contain an improved bounding box.
"""
import abc
import copy
import warnings
from collections.abc import Callable
from typing import Any, NamedTuple, Self
import numpy as np
from astropy.units import Quantity, UnitBase
__all__ = ... | 1,630 | 51,925 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.