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 |
|---|---|---|---|---|---|
onnxruntime | tools/nuget/validate_package.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import glob
import os
import re
import shutil
import subprocess
import sys
import zipfile # Available Python 3.2 or higher
linux_gpu_package_libraries = [
"libonnxruntime_providers_shared.so",
"libon... | 407 | 14,704 |
probability | tensorflow_probability/python/layers/masked_autoregressive_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... | 80 | 3,270 |
wandb | wandb/sdk/lib/file_stream_utils.py | .py | #
from collections.abc import Iterable
from typing import Any
def split_files(
files: dict[str, Any], max_bytes: int = 10 * 1024 * 1024
) -> Iterable[dict[str, dict]]:
"""Split a file's dict (see `files` arg) into smaller dicts.
Each smaller dict will have at most `MAX_BYTES` size.
This method is u... | 121 | 4,040 |
mlflow | tests/spark/autologging/datasource/test_spark_disable_autologging.py | .py | import time
import mlflow
import mlflow.spark
from tests.spark.autologging.utils import (
_assert_spark_data_logged,
_assert_spark_data_not_logged,
)
# Note that the following tests run one-after-the-other and operate on the SAME spark_session
# (it is not reset between tests)
def test_autologging_disabl... | 100 | 2,955 |
pyomo | pyomo/contrib/gdpopt/ldsda.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... | 655 | 26,536 |
saleor | saleor/tests/e2e/orders/test_app_can_create_order_from_checkout.py | .py | import pytest
from ..checkout.utils import checkout_create, checkout_delivery_method_update
from ..product.utils.preparing_product import prepare_product
from ..shop.utils.preparing_shop import prepare_default_shop
from ..utils import assign_permissions
from .utils import order_create_from_checkout
@pytest.mark.e2e
... | 86 | 2,551 |
mlflow | tests/langgraph/test_langgraph_autolog.py | .py | import json
import pytest
import mlflow
from mlflow.entities.span import SpanType
from mlflow.entities.span_status import SpanStatusCode
from mlflow.tracing.constant import TokenUsageKey, TraceMetadataKey
from mlflow.version import IS_TRACING_SDK_ONLY
from tests.tracing.helper import get_traces, skip_when_testing_tr... | 289 | 11,022 |
saleor | saleor/asgi/gzip_compression.py | .py | # adapted from Starlette's GZipMiddleware
# Starlette does not work with Django's case-sensitive headers
import gzip
import io
import secrets
from asgiref.typing import (
ASGI3Application,
ASGIReceiveCallable,
ASGISendCallable,
ASGISendEvent,
HTTPResponseStartEvent,
Scope,
)
def _get_random_... | 166 | 6,988 |
biopython | Tests/test_Entrez_parser.py | .py | # Copyright 2008-2010 by Michiel de Hoon. All rights reserved.
# Revisions copyright 2009-2016 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.
"""Testing code for ... | 8,917 | 422,732 |
sqlmap | lib/techniques/nosql/inject.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import json
import re
import time
from collections import namedtuple
from collections import OrderedDict
from lib.core.common import beep
from lib.core.common import randomStr
f... | 1,325 | 73,984 |
saleor | saleor/graphql/product/filters/product_type.py | .py | import django_filters
import graphene
from django.db.models import Q
from saleor.graphql.warehouse.types import DEPRECATED_IN_3X_INPUT
from ....product.models import ProductType
from ...core.doc_category import DOC_CATEGORY_PRODUCTS
from ...core.filters import (
EnumFilter,
FilterInputObjectType,
GlobalID... | 78 | 2,430 |
clearml | examples/reporting/pandas_reporting.py | .py | # ClearML - Example of manual graphs and statistics reporting
#
import pandas as pd
from clearml import Task, Logger
def report_table(logger, iteration=0):
# type: (Logger, int) -> ()
"""
reporting tables to the plots section
:param logger: The task.logger to use for sending the plots
:param it... | 69 | 2,170 |
pyomo | pyomo/core/tests/unit/test_taylor_series.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... | 64 | 2,659 |
astropy | astropy/cosmology/_src/traits/darkmatter.py | .py | """Trait for dark matter component of cosmology."""
__all__ = ("DarkMatterComponent",)
from collections.abc import Callable
from typing import Any
import numpy as np
from numpy.typing import ArrayLike, NDArray
from astropy.cosmology._src.typing import FArray
from astropy.cosmology._src.utils import aszarr
from astr... | 51 | 1,463 |
confluent-kafka-python | tests/test_enums.py | .py | #!/usr/bin/env python
import confluent_kafka
def test_enums():
"""Make sure librdkafka error enums are reachable directly from the
KafkaError class without an instantiated object."""
print(confluent_kafka.KafkaError._NO_OFFSET)
print(confluent_kafka.KafkaError.REBALANCE_IN_PROGRESS)
def test_tstype... | 26 | 844 |
probability | spinoffs/fun_mc/fun_mc/types.py | .py | # Copyright 2024 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... | 69 | 1,884 |
sphinx | sphinx/domains/python/_annotations.py | .py | from __future__ import annotations
import ast
import functools
import operator
import token
from collections import deque
from inspect import Parameter
from itertools import chain, islice
from typing import TYPE_CHECKING
from docutils import nodes
from sphinx import addnodes
from sphinx.addnodes import pending_xref,... | 631 | 25,912 |
returns | returns/contrib/mypy/_structures/types.py | .py | from typing import TypeAlias
from mypy.plugin import FunctionContext, MethodContext
#: We treat them equally when working with functions or methods.
CallableContext: TypeAlias = FunctionContext | MethodContext
| 7 | 212 |
scikit-bio | skbio/binaries/_util.py | .py | # ----------------------------------------------------------------------------
# Copyright (c) 2025--, 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.
# --------------------------------------------... | 179 | 4,580 |
onnx | onnx/backend/test/case/node/optionalgetelement.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
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
def optional_get_element_reference_implementation(op... | 81 | 2,546 |
textual | docs/examples/widgets/loading_indicator.py | .py | from textual.app import App, ComposeResult
from textual.widgets import LoadingIndicator
class LoadingApp(App):
def compose(self) -> ComposeResult:
yield LoadingIndicator()
if __name__ == "__main__":
app = LoadingApp()
app.run()
| 13 | 252 |
beam | sdks/python/apache_beam/testing/analyzers/__init__.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... | 22 | 875 |
wandb | tests/unit_tests/test_file_stats.py | .py | import pytest
from wandb.filesync import stats
@pytest.mark.parametrize(
["init_file_kwargs", "expected_stats"],
[
(
{"save_name": "foo", "size": 10},
stats.FileCountsByCategory(artifact=0, wandb=0, media=0, other=1),
),
(
{"save_name": "foo", "size"... | 97 | 3,011 |
saleor | saleor/graphql/account/tests/queries/test_customers_sorting.py | .py | import pytest
from .....account.models import User
from .....order.models import Order
from ....tests.utils import get_graphql_content
QUERY_CUSTOMERS_WITH_SORT = """
query ($sort_by: UserSortingInput!) {
customers(first:5, sortBy: $sort_by) {
edges{
node{
... | 178 | 5,883 |
mlflow | mlflow/data/digest_utils.py | .py | import hashlib
from typing import Any
from packaging.version import Version
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
MAX_ROWS = 10000
def compute_pandas_digest(df) -> str:
"""Computes a digest for the given Pandas DataFrame.
Args:
... | 108 | 2,924 |
black | src/black/concurrency.py | .py | """
Formatting many files at once via multiprocessing. Contains entrypoint and utilities.
NOTE: this module is only imported if we need to format several files at once.
"""
from __future__ import annotations
import asyncio
import logging
import os
import signal
import sys
import traceback
from collections.abc import... | 237 | 8,111 |
beam | sdks/python/apache_beam/examples/inference/anomaly_detection/anomaly_detection_pipeline/config.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... | 50 | 1,783 |
bazel | third_party/py/abseil/absl/app.py | .py | # Copyright 2017 The Abseil 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 ... | 481 | 15,352 |
probability | tensorflow_probability/python/experimental/nn/util/convolution_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... | 966 | 37,464 |
pdm | src/pdm/models/in_process/env_spec.py | .py | from __future__ import annotations
import json
import platform
import site
import sys
import sysconfig
def get_current_env_spec() -> dict[str, str | bool]:
from dep_logic.tags import Platform
python_version = f"{sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]}"
return {
"requires... | 26 | 704 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_round.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# round paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle
import sys
data_type = 'float32'
def paddle_round(name:str, x):
paddle.enable_static()
with paddle.static.program_guard(paddl... | 41 | 1,073 |
openvino | src/bindings/python/src/openvino/frontend/frontend.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from typing import Union
from openvino._pyopenvino import FrontEnd as FrontEndBase
from openvino._pyopenvino import FrontEndManager as FrontEndManagerBase
from openvino._pyopenvino import InputModel
from openvino... | 45 | 1,401 |
slimit | src/slimit/ast.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... | 416 | 10,841 |
returns | tests/test_io/test_ioresult_container/test_ioresult_map.py | .py | from returns.io import IOFailure, IOSuccess
def test_map_iosuccess():
"""Ensures that IOSuccess is mappable."""
assert IOSuccess(5).map(str) == IOSuccess('5')
def test_alt_iofailure():
"""Ensures that IOFailure is mappable."""
assert IOFailure(5).map(str) == IOFailure(5)
assert IOFailure(5).alt(... | 18 | 466 |
saleor | saleor/graphql/channel/tests/mutations/test_channel_delete.py | .py | import json
from unittest import mock
import graphene
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....channel.error_codes import ChannelErrorCode
from .....channel.models import Channel
from .....checkout.models import Checkout
from .....core.utils.json_serializer impo... | 379 | 11,997 |
mlflow | mlflow/utils/promptlab_utils.py | .py | import json
import os
import tempfile
import time
from datetime import datetime, timezone
from mlflow.entities.param import Param
from mlflow.entities.run_status import RunStatus
from mlflow.entities.run_tag import RunTag
from mlflow.utils.file_utils import make_containing_dirs, write_to
from mlflow.utils.mlflow_tags ... | 147 | 5,598 |
httpie | httpie/cli/constants.py | .py | """Parsing and processing of CLI input (args, auth credentials, files, stdin).
"""
import enum
import re
URL_SCHEME_RE = re.compile(r'^[a-z][a-z0-9.+-]*://', re.IGNORECASE)
HTTP_POST = 'POST'
HTTP_GET = 'GET'
HTTP_OPTIONS = 'OPTIONS'
# Various separators used in args
SEPARATOR_HEADER = ':'
SEPARATOR_HEADER_EMPTY =... | 135 | 3,246 |
saleor | saleor/core/auth.py | .py | from django.http import HttpRequest
SALEOR_AUTH_HEADER = "HTTP_AUTHORIZATION_BEARER"
DEFAULT_AUTH_HEADER = "HTTP_AUTHORIZATION"
AUTH_HEADER_PREFIXES = ["JWT", "BEARER"]
def get_token_from_request(request: HttpRequest) -> str | None:
auth_token: str | None = request.META.get(SALEOR_AUTH_HEADER)
if not auth_t... | 17 | 528 |
mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | .py | import base64
import functools
import json
import logging
import os
import re
import shutil
from contextlib import contextmanager
from dataclasses import dataclass
from typing import Any
import google.protobuf.empty_pb2
from pydantic import BaseModel
import mlflow
from mlflow.entities import Run
from mlflow.entities.... | 1,903 | 78,511 |
openvino | src/bindings/python/tests/test_graph/test_proposal.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import openvino.opset8 as ov
from openvino import Shape, Type
def test_proposal_props():
float_dtype = np.float32
batch_size = 1
post_nms_topn = 20
probs = ov.parameter(Shape([... | 38 | 1,343 |
beam | sdks/python/apache_beam/io/gcp/datastore/v1new/types_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... | 242 | 8,704 |
hatch | tests/helpers/templates/sdist/standard_default.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
def get_files(**kwargs):
relative_root = kwargs.get("relative_root", "")
files = [File(Path(relative_root, f.pa... | 25 | 627 |
black | tests/data/cases/pep_604.py | .py | def some_very_long_name_function() -> my_module.Asdf | my_module.AnotherType | my_module.YetAnotherType | None:
pass
def some_very_long_name_function() -> my_module.Asdf | my_module.AnotherType | my_module.YetAnotherType | my_module.EvenMoreType | None:
pass
# output
def some_very_long_name_function() -> ... | 26 | 583 |
pyomo | pyomo/core/kernel/conic.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,027 | 30,235 |
astropy | astropy/nddata/utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module includes helper functions for array operations.
"""
import functools
from collections.abc import Callable
from copy import deepcopy
from typing import Literal, TypeAlias, TypeVar, overload
import numpy as np
from numpy.typing import NDArr... | 955 | 34,850 |
mlflow | mlflow/utils/server_info.py | .py | from __future__ import annotations
import os
import threading
import time
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import Any
from mlflow.utils.rest_utils import MlflowHostCreds, http_request
SERVER_INFO_ENDPOINT = "/api/3.0/mlflow/server-info"
SERVER_INFO_STORE_TYPE ... | 154 | 4,769 |
gunicorn | gunicorn/glogging.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import base64
import binascii
import json
import time
import logging
logging.Logger.manager.emittedNoHandlerWarning = 1 # noqa
from logging.config import dictConfig
from logging.config import fileConfig
import os
... | 484 | 15,569 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_OneHot.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from common.tf_layer_test_class import CommonTFLayerTest
class TestOneHot(CommonTFLayerTest):
@staticmethod
def create_one_hot_net(shape, depth, on_value, off_value, axis):
import tensorflow as tf
... | 49 | 1,912 |
probability | tensorflow_probability/python/distributions/kumaraswamy.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... | 280 | 10,824 |
openvino | tests/layer_tests/pytorch_tests/test_expand.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import random
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestExpand(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(1, 3),)
def create_model(self, dim, op_type="ex... | 195 | 6,809 |
wagtail | wagtail/contrib/settings/jinja2tags.py | .py | from weakref import WeakKeyDictionary
import jinja2
from django.utils.encoding import force_str
from jinja2.ext import Extension
from wagtail.contrib.settings.models import BaseGenericSetting, BaseSiteSetting
from wagtail.contrib.settings.registry import registry
from wagtail.models import Site
# Settings are cached... | 93 | 2,836 |
probability | tensorflow_probability/python/internal/tensorshape_util.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... | 367 | 11,935 |
onnxruntime | onnxruntime/test/testdata/transform/fusion/gemm_transpose_gen_2.py | .py | import onnx
from onnx import OperatorSetIdProto, TensorProto, helper
onnxdomain = OperatorSetIdProto()
onnxdomain.version = 12
# The empty string ("") or absence of this field implies the operator set that is defined as part of the ONNX specification.
onnxdomain.domain = ""
msdomain = OperatorSetIdProto()
msdomain.ver... | 71 | 2,750 |
luigi | luigi/cmdline_parser.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 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 a... | 148 | 5,159 |
mlflow | mlflow/metrics/genai/base.py | .py | from dataclasses import dataclass
from mlflow.metrics.genai.prompt_template import PromptTemplate
@dataclass
class EvaluationExample:
"""
Stores the sample example during few shot learning during LLM evaluation
Args:
input: The input provided to the model
output: The output generated by ... | 99 | 3,819 |
saleor | saleor/graphql/discount/mutations/sale/sale_update.py | .py | import datetime
import graphene
from django.core.exceptions import ValidationError
from django.db.models import Exists, OuterRef
from .....core.tracing import traced_atomic_transaction
from .....discount import models
from .....discount.error_codes import DiscountErrorCode
from .....discount.utils.promotion import CA... | 259 | 9,390 |
metrics | src/torchmetrics/regression/kendall.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... | 213 | 8,278 |
textual | docs/examples/styles/background_transparency.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Static
class BackgroundTransparencyApp(App):
"""Simple app to exemplify different transparency settings."""
CSS_PATH = "background_transparency.tcss"
def compose(self) -> ComposeResult:
yield Static("10%", id="t10")
y... | 26 | 736 |
readthedocs.org | readthedocs/redirects/models.py | .py | """Django models for the redirects app."""
import re
import structlog
from django.db import models
from django.utils.translation import gettext
from django.utils.translation import gettext_lazy as _
from readthedocs.core.resolver import Resolver
from readthedocs.projects.models import Project
from readthedocs.projec... | 337 | 11,282 |
saleor | saleor/giftcard/notifications.py | .py | from typing import TYPE_CHECKING
from ..account.notifications import get_default_user_payload
from ..core.notification.utils import get_site_context
from ..core.notify import NotifyEventType, NotifyHandler
from ..core.prices import quantize_price
from ..graphql.core.utils import to_global_id_or_none
if TYPE_CHECKING:... | 56 | 1,673 |
deap | examples/gp/spambase.py | .py | # This file is part of EAP.
#
# EAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# EAP is distributed in ... | 113 | 4,043 |
beam | sdks/python/apache_beam/transforms/error_handling_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... | 149 | 5,501 |
readthedocs.org | readthedocs/rtd_tests/tests/test_restapi_client.py | .py | from django.test import TestCase
from readthedocs.api.v2.client import DrfJsonSerializer
class TestDrfJsonSerializer(TestCase):
data = {
"proper": "json",
}
serialized_data = '{"proper":"json"}'
def test_serializer_loads_json(self):
serializer = DrfJsonSerializer()
data = ser... | 21 | 608 |
saleor | saleor/warehouse/tests/fixtures/allocation.py | .py | from decimal import Decimal
import pytest
from ....core.postgres import FlatConcatSearchVector
from ....core.prices import Money, TaxedMoney
from ....order.models import Order, OrderLine
from ....order.search import prepare_order_search_vector_value
from ....tax.utils import get_tax_class_kwargs_for_order_line
from .... | 97 | 3,577 |
onnxruntime | onnxruntime/test/testdata/sparse_initializer_as_output.py | .py | import argparse
import sys
import traceback
import numpy as np
import onnx
from onnx import (
TensorProto,
ValueInfoProto,
helper,
)
from onnx.helper import make_opsetid
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument("--node_name", required=True, type=str, help="Con... | 128 | 4,110 |
cvxpy | cvxpy/tests/nlp_tests/stress_tests_diff_engine/test_affine_matrix_atoms.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
... | 190 | 7,033 |
coremltools | coremltools/converters/mil/test/test_rms_norm.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
#
# Test suite for RMSNorm feature (Issue #2585)
import pytest
from coremltools._deps import _HAS... | 193 | 6,064 |
saleor | saleor/graphql/page/tests/mutations/test_page_attribute_unassign.py | .py | import graphene
from ....tests.utils import assert_no_permission, get_graphql_content
PAGE_UNASSIGN_ATTR_QUERY = """
mutation PageAttributeUnassign(
$pageTypeId: ID!, $attributeIds: [ID!]!
) {
pageAttributeUnassign(
pageTypeId: $pageTypeId, attributeIds: $attributeIds
) {
... | 131 | 3,958 |
mlflow | mlflow/genai/scorers/scorer_utils.py | .py | # This file contains utility functions for scorer functionality.
import ast
import inspect
import json
import logging
import re
from textwrap import dedent
from typing import TYPE_CHECKING, Any, Callable
from mlflow.exceptions import INVALID_PARAMETER_VALUE, MlflowException
if TYPE_CHECKING:
from mlflow.genai.ut... | 333 | 11,981 |
cvxpy | cvxpy/atoms/affine/unary_operators.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... | 125 | 3,773 |
conda | conda/cli/main_env_vars.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""CLI implementation for `conda-env config vars`.
Allows for configuring conda-env's vars.
"""
from argparse import (
ArgumentParser,
Namespace,
_SubParsersAction,
)
from os.path import lexists
from ..base.context import context,... | 170 | 4,619 |
returns | tests/test_laws.py | .py | from returns.context import (
Reader,
ReaderFutureResult,
ReaderIOResult,
ReaderResult,
)
from returns.contrib.hypothesis.laws import check_all_laws
from returns.future import Future, FutureResult
from returns.io import IO, IOResult
from returns.maybe import Maybe
from returns.result import Result
chec... | 26 | 578 |
wagtail | wagtail/api/v3/urls.py | .py | """
URL mounting helper for the Wagtail v3 API, to match v2 ergonomics.
Projects mount the API with::
from wagtail.api.v3.urls import api
urlpatterns = [
path("api/v3/", api.urls),
]
Routers must be registered on the ``api`` instance before ``api.urls`` is
accessed (Django Ninja raises ``ConfigE... | 19 | 398 |
openvino | tests/e2e_tests/common/ref_collector/score_pytorch_onnx_runtime.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
import os
import sys
from e2e_tests.common.multiprocessing_utils import multiprocessing_run
from utils.path_utils import resolve_dir_path
from e2e_tests.common.ref_collector.score_onnx_runtime import ONNXRuntimeRun... | 150 | 7,063 |
openvino | tools/ovc/openvino/tools/ovc/get_ov_update_message.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import datetime
msg_fmt = 'Check for a new version of Intel(R) Distribution of OpenVINO(TM) toolkit here {0} ' \
'or on https://github.com/openvinotoolkit/openvino'
def get_compression_message():
link = "https://docs.ope... | 17 | 739 |
wandb | wandb/sdk/artifacts/storage_handlers/gcs_handler.py | .py | """GCS storage handler."""
from __future__ import annotations
from pathlib import PurePosixPath
from typing import TYPE_CHECKING, Optional
from urllib.parse import ParseResult, urlparse
from pydantic.dataclasses import dataclass as pydantic_dataclass
from typing_extensions import Never, Self
import wandb
from wandb... | 260 | 9,140 |
pyomo | pyomo/contrib/sensitivity_toolbox/examples/rooney_biegler.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... | 85 | 3,093 |
openvino | src/bindings/python/src/openvino/frontend/tensorflow/__init__.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""
Package: openvino
Low level wrappers for the FrontEnd C++ API.
"""
# flake8: noqa
try:
from openvino.frontend.tensorflow.py_tensorflow_frontend import _FrontEndPyGraphIterator as GraphIterator
from openvino.frontend.tensorf... | 17 | 669 |
metrics | src/torchmetrics/functional/clustering/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... | 83 | 2,602 |
pyro | tests/infer/mcmc/test_rwkernel.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
import pyro
import pyro.distributions as dist
from pyro.infer.mcmc.api import MCMC
from pyro.infer.mcmc.rwkernel import RandomWalkKernel
from tests.common import assert_equal
def test_beta_bernoulli():
alpha = t... | 41 | 1,308 |
wagtail | wagtail/images/image_operations.py | .py | import inspect
from wagtail.images.exceptions import InvalidFilterSpecError
from wagtail.images.rect import Rect, Vector
from wagtail.images.utils import parse_color_string
class Operation:
def __init__(self, method, *args):
self.method = method
self.args = args
# Check arguments
... | 434 | 13,413 |
saleor | saleor/graphql/order/tests/test_order_clean.py | .py | from unittest.mock import MagicMock
import pytest
from django.core.exceptions import ValidationError
from ....order import FulfillmentStatus, OrderStatus
from ....order.error_codes import OrderErrorCode
from ....payment.models import Payment
from ..mutations.order_cancel import clean_order_cancel
from ..mutations.ord... | 105 | 3,027 |
pyomo | examples/gdp/farm_layout/farm_layout.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... | 286 | 10,191 |
wandb | tests/system_tests/test_launch/test_launch_add.py | .py | import os
from unittest import mock
import pytest
import wandb
from wandb.apis.public import Api as PublicApi
from wandb.sdk.internal.internal_api import Api as InternalApi
from wandb.sdk.launch._launch_add import launch_add
from wandb.sdk.launch.utils import LAUNCH_DEFAULT_PROJECT, LaunchError
class MockBranch:
... | 553 | 15,392 |
openvino | tests/layer_tests/pytorch_tests/test_addcmul.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 TestAddCMul(PytorchLayerTest):
def _prepare_input(self):
return (self.random.uniform(0, 50, 3, dtype=self.input_type),
... | 53 | 1,632 |
probability | tensorflow_probability/python/distributions/triangular_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... | 403 | 14,645 |
beam | learning/katas/python/Core Transforms/Side Output/Side Output/tests/test_task.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not... | 45 | 1,516 |
onnxruntime | orttraining/orttraining/python/training/ortmodule/torch_cpp_extensions/install.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import os
import subprocess
import sys
from glob import glob
from shutil... | 102 | 4,121 |
sqlmap | plugins/dbms/raima/__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 RAIMA_SYSTEM_DBS
from lib.core.unescaper import unescaper
from plugins.dbms.raima.enumeration import Enumeration
from... | 30 | 898 |
probability | tensorflow_probability/python/internal/special_math_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... | 335 | 12,474 |
pyro | pyro/distributions/logistic.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import math
import torch
from torch.distributions import constraints
from torch.distributions.utils import broadcast_all
from torch.nn.functional import logsigmoid
from .torch_distribution import TorchDistribution
class Logistic(To... | 159 | 5,474 |
hatch | tests/cli/env/test_run.py | .py | import os
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
def test_filter_not_mapping(hatch, helpers, temp_dir, config_file):
config_file.model.template.plugins["default"]["tests"] = False
config_file.save()
... | 309 | 9,220 |
voila | voila/static_file_handler.py | .py | #############################################################################
# Copyright (c) 2018, Voilà Contributors #
# Copyright (c) 2018, QuantStack #
# #
# Distri... | 114 | 4,642 |
sphinx | sphinx/search/__init__.py | .py | """Create a full-text search index for offline search."""
from __future__ import annotations
import dataclasses
import functools
import html
import json
import os
import pickle
import re
from importlib import import_module
from typing import TYPE_CHECKING
from docutils import nodes
from docutils.nodes import Element... | 648 | 24,572 |
beam | sdks/python/apache_beam/ml/anomaly/thresholds.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... | 185 | 6,384 |
readthedocs.org | readthedocs/conftest.py | .py | import pytest
from django.core.cache import cache
from rest_framework.test import APIClient
pytest_plugins = ("sphinx.testing.fixtures",)
@pytest.fixture
def api_client():
return APIClient()
@pytest.fixture(autouse=True)
def clear_cache():
"""
Clear the cache after each test.
We don't usually want... | 26 | 571 |
pyomo | pyomo/common/tests/test_docutils.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... | 78 | 2,551 |
textual | docs/examples/styles/margin.py | .py | from textual.app import App
from textual.widgets import Label
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its path.
Where th... | 23 | 550 |
wagtail | wagtail/actions/edit.py | .py | from django.core.exceptions import PermissionDenied
from wagtail.actions.base import BaseAction
from wagtail.log_actions import log
from wagtail.utils.forms import FormValidationError
class EditPermissionError(PermissionDenied):
"""
Raised when editing an object is not permitted.
"""
pass
class Ed... | 151 | 6,045 |
black | tests/data/cases/string_quotes_escaped_trailing_quote.py | .py | # Regression test for quote normalisation of triple-quoted strings whose body
# already ends in an escaped double quote.
x = '''\'''\"'''
y = b'''\'''\"'''
z = '''a\"'''
# Here the backslashes escape each other, so the trailing quote is bare and
# escaping it would add an escape - the original quotes are kept.
w = '''\... | 22 | 687 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.