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 |
|---|---|---|---|---|---|
cvxpy | cvxpy/reductions/solvers/qp_solvers/qp_solver.py | .py | """
Copyright 2017 Robin Verschueren
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, softw... | 154 | 5,548 |
astropy | astropy/cosmology/_src/tests/test_core.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Testing :mod:`astropy.cosmology.core`."""
import abc
import inspect
import pickle
import numpy as np
import pytest
from numpy.typing import NDArray
import astropy.cosmology.units as cu
import astropy.units as u
from astropy.cosmology import Cosmolog... | 508 | 17,617 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_OneHot.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shape': [3], 'axis': 0, 'kwargs_to_prepare_input': 'int32_positive'},
{'shape': [4, 4], 'axis': 1, 'kwargs_to_prepare_input': 'int32_positive'},
{'shape': [1, 5, 3], 'axis': 0, 'kwargs_to_pre... | 39 | 1,677 |
wandb | tests/system_tests/test_launch/test_launch_vertex.py | .py | from unittest.mock import MagicMock
import pytest
import wandb
from wandb.apis.internal import Api
from wandb.sdk.launch import loader
from wandb.sdk.launch._project_spec import EntryPoint
from wandb.sdk.launch.environment.gcp_environment import GcpEnvironment
@pytest.fixture
def mock_vertex_environment():
"""Mo... | 148 | 4,866 |
gunicorn | tests/docker/uwsgi/app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Test WSGI application for uWSGI protocol integration tests.
This application provides various endpoints to test different aspects
of the uWSGI binary protocol when proxied through nginx.
"""
import json
def... | 227 | 6,741 |
onnx | onnx/backend/test/case/node/compress.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Compress(Base):
@staticmethod
def export_compress_0() -> None:... | 100 | 2,746 |
pyomo | examples/doc/samples/comparisons/cutstock/cutstock_pulpor.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... | 65 | 2,028 |
probability | tensorflow_probability/python/sts/components/seasonal.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... | 1,063 | 47,142 |
cvxpy | cvxpy/tests/test_nd_matmul.py | .py | """
Comprehensive tests for ND matrix multiplication in CVXPY.
Tests cover:
1. Core functionality (2D constant @ higher-dim variable)
2. Parametric tests (Parameter @ Variable)
3. Broadcasting (batch dimension size 1)
4. Edge cases (B=1, non-square, n=1, k=1, large batch, errors)
All tests are parametrized by backend... | 805 | 29,588 |
conda | tests/plugins/subcommands/doctor/health_checks/test_consistency.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Tests for the environment consistency health check."""
from __future__ import annotations
from typing import TYPE_CHECKING
from conda.base.constants import OK_MARK, X_MARK
from conda.common.serialize import yaml
if TYPE_CHECKING:
from... | 87 | 2,916 |
saleor | saleor/graphql/product/tests/queries/products_filtrations/test_over_validation.py | .py | import pytest
from .....tests.utils import get_graphql_content
from .shared import PRODUCTS_FILTER_QUERY, PRODUCTS_WHERE_QUERY
@pytest.mark.parametrize("query", [PRODUCTS_WHERE_QUERY, PRODUCTS_FILTER_QUERY])
@pytest.mark.parametrize(
"attribute_value_filter",
[{"numeric": None}, {"name": None}, {"slug": None... | 465 | 12,926 |
wandb | wandb/proto/v7/wandb_settings_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: wandb/proto/wandb_settings.proto
# Protobuf Python Version: 7.34.0
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descrip... | 59 | 19,477 |
probability | spinoffs/inference_gym/inference_gym/backends/util.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... | 50 | 1,595 |
coremltools | coremltools/proto/TextClassifier_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: TextClassifier.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import message as _message
fr... | 42 | 1,832 |
saleor | saleor/graphql/discount/inputs.py | .py | import graphene
from ..core.descriptions import PREVIEW_FEATURE
from ..core.doc_category import DOC_CATEGORY_DISCOUNTS
from ..core.scalars import JSON, PositiveDecimal
from ..core.types import BaseInputObjectType, NonNullList
from ..discount.filters import DiscountedObjectWhereInput
from ..product.filters.category imp... | 106 | 3,659 |
textual | src/textual/widgets/_markdown.py | .py | from __future__ import annotations
import asyncio
import re
import weakref
from contextlib import suppress
from functools import partial
from pathlib import Path, PurePath
from typing import Callable, Iterable, Optional
from urllib.parse import unquote
from markdown_it import MarkdownIt
from markdown_it.token import ... | 1,724 | 54,844 |
mlflow | tests/gateway/providers/test_deepseek.py | .py | from unittest import mock
import pytest
from fastapi.encoders import jsonable_encoder
from mlflow.gateway.config import EndpointConfig
from mlflow.gateway.providers.deepseek import DeepSeekProvider
from mlflow.gateway.schemas import chat
from tests.gateway.tools import MockAsyncResponse, mock_http_client
def _make... | 77 | 2,152 |
sqlmap | plugins/dbms/mssqlserver/syntax.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.convert import getOrds
from plugins.generic.syntax import Syntax as GenericSyntax
class Syntax(GenericSyntax):
@staticmethod
def escape(expression, quote=Tr... | 38 | 1,428 |
pyomo | pyomo/contrib/parmest/examples/reactor_design/multisensor_data_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... | 94 | 2,989 |
openvino | tests/model_hub_tests/pytorch/test_hf_transformers.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import platform
from PIL import Image
import pytest
import torch
from models_hub_common.constants import hf_cache_dir, clean_hf_cache_dir
from models_hub_common.utils import cleanup_dir, get_models_list, retry
from torch_util... | 590 | 31,240 |
returns | tests/test_examples/test_io/test_ioresult_container/test_ioresult_pattern_matching.py | .py | from returns.io import IOFailure, IOResult, IOSuccess
from returns.result import Success
container: IOResult[int, str] = IOSuccess(42)
match container:
# Matches if the result stored inside `IOSuccess` is `42`
# We need to use `Success` until the custom matching protocol
# is released. For more information... | 21 | 732 |
mlflow | mlflow/store/db/workspace_move.py | .py | from __future__ import annotations
from dataclasses import dataclass
from typing import Literal
import sqlalchemy as sa
from mlflow.store.db.workspace_utils import (
MODEL_CHILD_TABLES,
format_truncated_list,
get_workspace_table,
)
from mlflow.store.model_registry.dbmodels.models import (
SqlRegister... | 427 | 15,577 |
black | tests/test_trans.py | .py | from black.trans import iter_fexpr_spans
def test_fexpr_spans() -> None:
def check(
string: str, expected_spans: list[tuple[int, int]], expected_slices: list[str]
) -> None:
spans = list(iter_fexpr_spans(string))
# Checking slices isn't strictly necessary, but it's easier to verify at... | 50 | 2,219 |
tqdm | tests/tests_keras.py | .py | from .tests_tqdm import importorskip, mark
pytestmark = mark.slow
@mark.filterwarnings("ignore:.*:DeprecationWarning")
def test_keras(capsys):
"""Test tqdm.keras.TqdmCallback"""
TqdmCallback = importorskip('tqdm.keras').TqdmCallback
np = importorskip('numpy')
try:
import keras as K
except... | 92 | 2,573 |
pyfilesystem2 | tests/test_ftp_parse.py | .py | from __future__ import unicode_literals
import textwrap
import time
import unittest
from fs import _ftp_parse as ftp_parse
try:
from unittest import mock
except ImportError:
import mock
time2017 = time.struct_time([2017, 11, 28, 1, 1, 1, 1, 332, 0])
class TestFTPParse(unittest.TestCase):
@mock.patch("... | 355 | 13,670 |
wagtail | wagtail/admin/api/actions/revert_to_page_revision.py | .py | from django.core.exceptions import ValidationError as DjangoValidationError
from django.shortcuts import get_object_or_404
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 ... | 43 | 1,472 |
biopython | Tests/test_SearchIO_infernal_tab_index.py | .py | # Copyright 2024 by Samuel Prince. 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.
"""Tests for SearchIO In... | 86 | 4,467 |
wagtail | wagtail/contrib/redirects/tests/test_import_command.py | .py | import os
import tempfile
from io import StringIO
from unittest.mock import patch
from django.core.management import call_command
from django.core.management.base import CommandError
from django.test import TestCase
from wagtail.contrib.redirects.models import Redirect
from wagtail.models import Site
TEST_ROOT = os.... | 441 | 15,821 |
pyro | tests/distributions/test_constraints.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pyro.distributions import constraints
from pyro.ops.tensor_utils import safe_normalize
@pytest.mark.parametrize("dim", [2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 1000, 10000, 100000])
def test_sphere_check(dim... | 37 | 1,082 |
funcy | tests/py38_funcs.py | .py | import pytest
from funcy.funcs import autocurry
def test_autocurry_posonly():
at = autocurry(lambda a, /, b: (a, b))
assert at(1)(b=2) == (1, 2)
assert at(b=2)(1) == (1, 2)
with pytest.raises(TypeError): at(a=1)(b=2)
at = autocurry(lambda a, /, **kw: (a, kw))
assert at(a=2)(1) == (1, {'a': 2}... | 17 | 432 |
python-prompt-toolkit | examples/prompts/fancy-zsh-prompt.py | .py | #!/usr/bin/env python
"""
Example of the fancy ZSH prompt that @anki-code was using.
The theme is coming from the xonsh plugin from the xxh project:
https://github.com/xxh/xxh-plugin-xonsh-theme-bar
See:
- https://github.com/xonsh/xonsh/issues/3356
- https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1111... | 81 | 2,045 |
saleor | saleor/graphql/tax/mutations/tax_country_configuration_update.py | .py | from typing import Final
import graphene
from django.core.exceptions import ValidationError
from django.db.models import Q
from django_countries.fields import Country
from graphql import GraphQLError
from ....permission.enums import CheckoutPermissions
from ....tax import error_codes, models
from ...account.enums imp... | 243 | 9,098 |
scikit-optimize | skopt/learning/gaussian_process/kernels.py | .py | from math import sqrt
import numpy as np
from sklearn.gaussian_process.kernels import Kernel as sk_Kernel
from sklearn.gaussian_process.kernels import ConstantKernel as sk_ConstantKernel
from sklearn.gaussian_process.kernels import DotProduct as sk_DotProduct
from sklearn.gaussian_process.kernels import Exponentiation... | 422 | 14,794 |
ipython | tests/test_extension.py | .py | import os.path
from tempfile import TemporaryDirectory
import IPython.testing.tools as tt
from IPython.utils.syspathcontext import prepended_to_syspath
ext1_content = """
def load_ipython_extension(ip):
print("Running ext1 load")
def unload_ipython_extension(ip):
print("Running ext1 unload")
"""
ext2_conte... | 97 | 2,907 |
sphinx | sphinx/util/png.py | .py | """PNG image manipulation helpers."""
from __future__ import annotations
import binascii
import struct
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import os
LEN_IEND = 12
LEN_DEPTH = 22
DEPTH_CHUNK_LEN = struct.pack('!i', 10)
DEPTH_CHUNK_START = b'tEXtDepth\x00'
IEND_CHUNK = b'\x00\x00\x00\x00IEND\xae\x... | 48 | 1,548 |
hydra | tests/instantiate/test_positional_only_arguments.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any
from pytest import mark, param
from hydra.utils import UNSAFE_ALLOW_ALL_TARGETS, instantiate
from .positional_only import PosOnlyArgsClass
def unsafe_instantiate(config: Any, *args: Any) -> Any:
return instantiate(con... | 48 | 1,334 |
sphinx | tests/roots/test-ext-autodoc/target/autoclass_content.py | .py | class A:
"""A class having no __init__, no __new__"""
class B:
"""A class having __init__(no docstring), no __new__"""
def __init__(self):
pass
class C:
"""A class having __init__, no __new__"""
def __init__(self):
"""__init__ docstring"""
class D:
"""A class having no __... | 55 | 889 |
hatch | backend/src/hatchling/utils/fs.py | .py | from __future__ import annotations
import os
def locate_file(root: str, file_name: str, *, boundary: str | None = None) -> str | None:
while True:
file_path = os.path.join(root, file_name)
if os.path.isfile(file_path):
return file_path
if boundary is not None and os.path.exis... | 27 | 714 |
pymc | pymc/gp/__init__.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... | 28 | 863 |
mlflow | tests/tracing/utils/test_search.py | .py | import pytest
from mlflow.exceptions import MlflowException
from mlflow.tracing.utils.search import _FieldParser, _parse_fields, _ParsedField
@pytest.mark.parametrize(
("field", "expected"),
[
# no dot
("span.inputs", _ParsedField("span", "inputs", None)),
("span.outputs", _ParsedFiel... | 81 | 3,234 |
httpie | tests/utils/matching/__init__.py | .py | """
Utilities for testing output composition.
"""
from typing import Iterable
import pytest
from .parsing import OutputMatchingError, expect_tokens
from .tokens import Expect, ExpectSequence
__all__ = [
'assert_output_matches',
'assert_output_does_not_match',
'Expect',
'ExpectSequence',
]
def ass... | 39 | 1,004 |
conda | conda/gateways/disk/lock.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Record locking to manage potential repodata / repodata metadata file contention
between conda processes. Try to acquire a lock on a single byte in the metadat
file; modify both files; then release the lock.
"""
import time
import warnings
f... | 96 | 2,857 |
openvino | tests/layer_tests/pytorch_tests/test_logical_ops.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, skip_if_export
class TestLogicalOp(PytorchLayerTest):
def _prepare_input(self, out, unary, first_dtype, second_dtype):
x = self.random.... | 69 | 2,597 |
wagtail | wagtail/project_template/project_name/settings/base.py | .py | """
Django settings for {{ project_name }} project.
Generated by 'django-admin startproject' using Django {{ django_version }}.
For more information on this file, see
https://docs.djangoproject.com/en/{{ docs_version }}/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.c... | 185 | 5,205 |
saleor | saleor/tests/e2e/orders/discounts/test_apply_better_promotion_to_product.py | .py | import pytest
from .....product.tasks import recalculate_discounted_price_for_products_task
from ... import DEFAULT_ADDRESS
from ...product.utils import get_product
from ...product.utils.preparing_product import prepare_product
from ...promotions.utils import create_promotion, create_promotion_rule
from ...shop.utils.... | 166 | 5,363 |
coveragepy | coverage/execfile.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
"""Execute files of Python code."""
from __future__ import annotations
import importlib.machinery
import importlib.util
import inspect
import marshal
import os
... | 339 | 12,391 |
wagtail | wagtail/admin/viewsets/chooser.py | .py | import warnings
from django.db.models import ForeignKey
from django.urls import path
from django.utils.functional import cached_property
from django.utils.translation import gettext as _
from wagtail.admin.forms.models import register_form_field_override
from wagtail.admin.telepath import register as register_telepat... | 261 | 10,797 |
astropy | astropy/samp/lockfile_helpers.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# TODO: this file should be refactored to use a more thread-safe and
# race-condition-safe lockfile mechanism.
import datetime
import os
import stat
import warnings
import xmlrpc.client as xmlrpc
from contextlib import suppress
from pathlib import Path
... | 258 | 8,045 |
textual | tests/test_eta.py | .py | from textual.eta import ETA
def test_basics() -> None:
eta = ETA()
eta.add_sample(1.0, 1.0)
assert eta.first_sample == (0, 0)
assert eta.last_sample == (1.0, 1.0)
assert len(eta._samples) == 2
repr(eta)
def test_speed() -> None:
eta = ETA()
# One sample is not enough to determine spe... | 57 | 1,423 |
beam | sdks/python/apache_beam/transforms/enrichment_handlers/vertex_ai_feature_store.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... | 331 | 13,457 |
probability | tensorflow_probability/python/distributions/multivariate_student_t_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... | 486 | 18,992 |
astropy | astropy/nddata/tests/test_decorators.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import inspect
import numpy as np
import pytest
from astropy import units as u
from astropy.nddata.decorators import support_nddata
from astropy.nddata.nddata import NDData
from astropy.utils.exceptions import AstropyUserWarning
from astropy.wcs import ... | 485 | 12,516 |
probability | tensorflow_probability/python/experimental/nn/util/kernel_bias.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 ... | 262 | 9,241 |
openvino | docs/articles_en/assets/snippets/ov_properties_api.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
import openvino as ov
import openvino.properties as props
import openvino.properties.hint as hints
import openvino.properties.device as device
from utils import get_model
def main():
# [get_available_devices]
core = ov.Core(... | 65 | 2,141 |
coremltools | coremltools/test/optimize/torch/test_utils/test_report_utils.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
from collections import OrderedDict
from typing import Tuple
import pytest
import torch
from coreml... | 315 | 10,277 |
metrics | src/torchmetrics/functional/retrieval/average_precision.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... | 63 | 2,676 |
pyomo | pyomo/network/plugins/expand_arcs.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... | 236 | 9,750 |
astropy | astropy/coordinates/attributes.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# Dependencies
import numpy as np
# Project
from astropy import units as u
from astropy.time import Time
from astropy.utils import ShapedLikeNDArray
from .earth import EarthLocation
from .representation import BaseDifferential, CartesianRepresentation
... | 578 | 19,845 |
mlflow | mlflow/pydantic_ai/__init__.py | .py | import functools
import inspect
import logging
import typing
from packaging.version import Version
from mlflow.pydantic_ai.autolog import (
patched_agent_init,
patched_async_class_call,
patched_async_stream_call,
patched_capability_model_request,
patched_class_call,
patched_sync_stream_call,
)... | 259 | 9,814 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_AsString.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
from common.utils.tf_utils import run_in_jenkins
rng = np.random.default_rng()
class TestAsString(CommonTFLayerTest):
... | 72 | 2,993 |
pyomo | pyomo/repn/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 | 575 |
luigi | luigi/contrib/hdfs/abstract_client.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... | 98 | 2,824 |
scikit-bio | skbio/util/tests/test_warning.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.
# --------------------------------------------... | 109 | 3,837 |
wagtail | wagtail/admin/tests/pages/test_unpublish_page.py | .py | from unittest import mock
from django.contrib.auth.models import Permission
from django.http import HttpRequest, HttpResponse
from django.test import TestCase
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from wagtail.signals import page_unpublished
from wagtail.test.testapp.m... | 264 | 9,656 |
saleor | saleor/tests/e2e/checkout/utils/checkout_create_from_order.py | .py | from saleor.graphql.tests.utils import get_graphql_content
CHECKOUT_CREATE_FROM_ORDER_MUTATION = """
mutation CheckoutCreateFromOrder( $id: ID!){
checkoutCreateFromOrder(id: $id){
errors{
field
message
code
}
unavailableVariants{
lineId
variantId
code
message
... | 126 | 2,119 |
openvino | tools/ovc/unit_tests/moc_tf_fe/check_info_messages_test.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import argparse
import io
import os
import unittest
from contextlib import redirect_stdout
from unittest.mock import patch
from openvino.tools.ovc.main import main
from openvino.tools.ovc.get_ov_update_message import get_compression_mes... | 62 | 2,311 |
wandb | wandb/sdk/artifacts/staging.py | .py | """Manages artifact file staging.
Artifact files are copied to the staging area as soon as they are added to an artifact
in order to avoid file changes corrupting the artifact. Once the upload is complete, the
file should be moved to the artifact cache.
"""
from __future__ import annotations
import os
from wandb im... | 28 | 890 |
mlflow | tests/dspy/conftest.py | .py | import dspy
import pytest
@pytest.fixture(autouse=True)
def reset_dspy_settings():
dspy.settings.configure(callbacks=[], lm=None, adapter=None)
| 8 | 150 |
mlflow | mlflow/tracing/utils/artifact_utils.py | .py | from mlflow.entities.trace_info import TraceInfo
from mlflow.exceptions import MlflowTraceDataCorrupted
from mlflow.tracing.constant import TraceTagKey
from mlflow.utils.mlflow_tags import MLFLOW_ARTIFACT_LOCATION
TRACE_DATA_FILE_NAME = "traces.json"
def _get_trace_request_id(trace_info: TraceInfo) -> str | None:
... | 45 | 1,581 |
saleor | saleor/graphql/product/bulk_mutations/__init__.py | .py | from .category_bulk_delete import CategoryBulkDelete
from .collection_bulk_delete import CollectionBulkDelete
from .product_bulk_create import ProductBulkCreate
from .product_bulk_delete import ProductBulkDelete
from .product_media_bulk_delete import ProductMediaBulkDelete
from .product_type_bulk_delete import ProductT... | 28 | 1,118 |
sqlmap | lib/request/comparison.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from __future__ import division
import re
from lib.core.common import extractRegexResult
from lib.core.common import extractStructuralTokens
from lib.core.common import getFilte... | 286 | 13,166 |
biopython | Bio/Align/tabular.py | .py | # Copyright 2021 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... | 409 | 16,525 |
wandb | wandb/proto/v7/wandb_server_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: wandb/proto/wandb_server.proto
# Protobuf Python Version: 7.34.0
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descripto... | 81 | 8,941 |
pyro | tests/nn/test_autoregressive.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from unittest import TestCase
import pytest
import torch
from pyro.nn import AutoRegressiveNN, ConditionalAutoRegressiveNN
from pyro.nn.auto_reg_nn import create_mask
pytestmark = pytest.mark.init(rng_seed=123)
class AutoRegre... | 140 | 5,475 |
mlflow | dev/clint/tests/rules/test_implicit_optional.py | .py | from pathlib import Path
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import Position, Range, lint_file
from clint.rules import ImplicitOptional
def test_implicit_optional(index: SymbolIndex) -> None:
code = """
from typing import Optional
# Bad
bad: int = None
class Bad... | 61 | 1,671 |
saleor | saleor/order/tests/test_fetch_order_prices_tax_app.py | .py | import dataclasses
from decimal import Decimal
from unittest.mock import patch
import graphene
import pytest
from promise import Promise
from ...core.prices import quantize_price
from ...core.taxes import TaxData, TaxLineData
from ...discount import DiscountType, DiscountValueType, VoucherType
from ...discount.models... | 1,750 | 67,356 |
mlflow | mlflow/gateway/budget_tracker/redis.py | .py | """Redis-backed budget tracker implementation."""
from __future__ import annotations
import json
import logging
from dataclasses import dataclass, field
from datetime import datetime, timezone
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import redis
from mlflow.entities.gateway_budget_policy import (
... | 359 | 12,137 |
clearml | clearml/backend_api/services/v2_23/organization.py | .py | """
organization service
This service provides organization level operations
"""
from typing import List, Optional, Any
import six
from clearml.backend_api.session import Request, Response, schema_property
class GetTagsRequest(Request):
"""
Get all the user and system tags used for the company tasks and mode... | 149 | 5,225 |
mlflow | mlflow/pytest/decorator.py | .py | """``@mlflow.test`` marker.
Marks a test for the (opt-in) MLflow pytest plugin, which sets up the test run
and enables tracing for the marked test. Enable the plugin by adding
``pytest_plugins = ["mlflow.pytest.plugin"]`` to your root ``conftest.py``, or
by running pytest with ``-p mlflow.pytest.plugin``.
@mlflow... | 72 | 2,363 |
dirty-equals | tests/test_dict.py | .py | import pytest
from dirty_equals import IsDict, IsIgnoreDict, IsPartialDict, IsPositiveInt, IsStr, IsStrictDict
@pytest.mark.parametrize(
'input_value,expected',
[
({}, IsDict),
({}, IsDict()),
({'a': 1}, IsDict(a=1)),
({1: 2}, IsDict({1: 2})),
({'a': 1, 'b': 2}, IsDict... | 144 | 5,010 |
astropy | astropy/timeseries/periodograms/base.py | .py | import abc
import numpy as np
from astropy.timeseries.binned import BinnedTimeSeries
from astropy.timeseries.sampled import TimeSeries
__all__ = ["BasePeriodogram"]
class BasePeriodogram:
@abc.abstractmethod
def __init__(self, t, y, dy=None):
pass
@classmethod
def from_timeseries(
... | 62 | 1,966 |
saleor | saleor/webhook/tests/fixtures/webhook_response.py | .py | import pytest
from ....core import EventDeliveryStatus
from ....webhook.transport.utils import WebhookResponse
@pytest.fixture
def webhook_response():
return WebhookResponse(
content="test_content",
request_headers={"headers": "test_request"},
response_headers={"headers": "test_response"}... | 29 | 762 |
pyomo | pyomo/core/tests/unit/test_connector.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... | 854 | 30,323 |
coremltools | coremltools/test/optimize/torch/quantization/test_coreml_quantizer.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
from collections import OrderedDict
from typing import Dict, Optional
import pytest
import torch
im... | 238 | 8,225 |
biopython | Tests/test_Restriction.py | .py | # This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
#
"""Testing code for Restriction enzyme classes of Biopython."""
import unittest
from Bio import BiopythonWarning
from Bio.Restriction import AanI
f... | 631 | 25,561 |
django-cms | cms/page_rendering.py | .py | from django.conf import settings
from django.http import Http404, HttpResponseRedirect
from django.template.response import TemplateResponse
from django.urls import Resolver404, resolve, reverse
from cms import __version__, constants
from cms.cache.page import set_page_cache
from cms.models import EmptyPageContent
fro... | 99 | 3,664 |
clearml | clearml/utilities/config.py | .py | from __future__ import division
import json
from typing import Union, Any
import pyparsing
from .dicts import hocon_quote_key, hocon_unquote_key
from .pyhocon import ConfigFactory, HOCONConverter
from ..storage.size import parse_size
def parse_human_size(value: Any) -> Any:
if isinstance(value, str):
r... | 126 | 3,982 |
clearml | clearml/backend_interface/task/development/worker.py | .py | from typing import Optional, Callable, Union, Any
import attr
from threading import Thread
from time import time
from ....config import deferred_config
from ....backend_interface.task.development.stop_signal import TaskStopSignal
from ....backend_api.services import tasks
from ....utilities.lowlevel.threads import k... | 183 | 6,570 |
mlflow | mlflow/genai/discovery/sampling.py | .py | from __future__ import annotations
import logging
import random
import mlflow
from mlflow.entities.trace import Trace
from mlflow.genai.discovery.constants import (
SAMPLE_POOL_MULTIPLIER,
SAMPLE_RANDOM_SEED,
)
from mlflow.genai.discovery.utils import group_traces_by_session
_logger = logging.getLogger(__nam... | 65 | 1,980 |
hatch | scripts/update_distributions.py | .py | from __future__ import annotations
import re
from ast import literal_eval
from collections import defaultdict
import httpx2
from utils import ROOT
URL = "https://raw.githubusercontent.com/ofek/pyapp/master/build.rs"
OUTPUT_FILE = ROOT / "src" / "hatch" / "python" / "distributions.py"
ARCHES = {("linux", "x86"): "i68... | 83 | 2,746 |
onnxruntime | onnxruntime/python/tools/transformers/dynamo_onnx_helper.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from collections.abc import Sequence
from logging import getLogger
from t... | 206 | 7,597 |
readthedocs.org | readthedocs/rtd_tests/tests/test_subprojects.py | .py | import django_dynamic_fixture as fixture
from django.contrib.auth.models import User
from django.test import TestCase
from readthedocs.projects.forms import ProjectRelationshipForm
from readthedocs.projects.models import Project, ProjectRelationship
class SubprojectFormTests(TestCase):
def setUp(self):
s... | 307 | 10,346 |
pdm | tests/resolver/test_resolve.py | .py | import pytest
from resolvelib.resolvers import ResolutionImpossible
from pdm.cli.actions import resolve_candidates_from_lockfile
from pdm.exceptions import PackageWarning
from pdm.models.markers import EnvSpec
from pdm.models.requirements import parse_requirement
from pdm.models.specifiers import PySpecSet
from pdm.pr... | 443 | 16,425 |
pdm | tasks/release.py | .py | from __future__ import annotations
import argparse
import subprocess
import sys
from pathlib import Path
from typing import TYPE_CHECKING, Any, cast
import parver
from rich.console import Console
if TYPE_CHECKING:
from parver._typing import PreTag
_console = Console(highlight=False)
_err_console = Console(stder... | 95 | 3,256 |
pymc | docs/source/conf.py | .py | """Sphinx configuration file."""
#!/usr/bin/env python3
#
# pymc documentation build configuration file, created by
# sphinx-quickstart on Sat Dec 26 14:40:23 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in thi... | 541 | 19,424 |
confluent-kafka-python | examples/json_consumer.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... | 127 | 3,921 |
wagtail | wagtail/admin/views/i18n.py | .py | from django.views.i18n import JavaScriptCatalog
from wagtail.admin.localization import get_localized_response
js_catalog = JavaScriptCatalog.as_view(packages=["wagtail.admin"])
def localized_js_catalog(request, *args, **kwargs):
"""
Django's JavaScriptCatalog that has been decorated to ensure it is localize... | 15 | 492 |
wandb | tests/system_tests/test_sandbox/test_auth.py | .py | from __future__ import annotations
from dataclasses import dataclass, field
import cwsandbox
import cwsandbox._sandbox as cwsandbox_sandbox
import pytest
import wandb
from wandb.sandbox import Sandbox
class _FakeChannel:
async def close(self, grace=None) -> None:
_ = grace
@dataclass
class _SandboxStu... | 159 | 4,830 |
lemur | lemur/schemas.py | .py | """
.. module: lemur.schemas
:platform: unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
from marshmallow import fields, post_load, pre_load, post_dump
from marshmallow.exceptions impo... | 333 | 10,584 |
saleor | saleor/graphql/page/tests/deprecated/test_page_create.py | .py | import datetime
import graphene
from django.utils.text import slugify
from .....page.error_codes import PageErrorCode
from .....tests.utils import dummy_editorjs
from ....tests.utils import get_graphql_content
CREATE_PAGE_MUTATION = """
mutation CreatePage(
$input: PageCreateInput!
) {
pageCr... | 148 | 4,841 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.