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 |
|---|---|---|---|---|---|
probability | spinoffs/inference_gym/inference_gym/targets/log_gaussian_cox_process.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... | 201 | 7,644 |
jupytext | src/jupytext/cell_metadata.py | .py | """
Convert between text notebook metadata and jupyter cell metadata.
Standard cell metadata are documented here:
See also https://ipython.org/ipython-doc/3/notebook/nbformat.html#cell-metadata
"""
import ast
import re
from json import dumps, loads
try:
from json import JSONDecodeError
except ImportError:
JS... | 490 | 16,823 |
httpie | tests/test_json.py | .py | import json
import pytest
import responses
from httpie.cli.constants import PRETTY_MAP
from httpie.cli.exceptions import ParseError
from httpie.cli.nested_json import NestedJSONSyntaxError
from httpie.output.formatters.colors import ColorFormatter
from httpie.utils import JsonDictPreservingDuplicateKeys
from .fixtur... | 584 | 18,699 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_multiheadattention.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasMultiHeadAttention(CommonTF2LayerTest):
def create_keras_multiheadattention_net(self,
... | 114 | 6,217 |
wagtail | wagtail/tests/streamfield_migrations/test_migration_names.py | .py | from django.test import TestCase
from wagtail.blocks.migrations.operations import (
RemoveStreamChildrenOperation,
RenameStreamChildrenOperation,
)
from wagtail.test.streamfield_migrations import models
from wagtail.test.streamfield_migrations.testutils import MigrationTestMixin
class MigrationNameTest(TestC... | 60 | 1,881 |
django-cms | cms/models/placeholdermodel.py | .py | import warnings
from collections.abc import Iterable
from datetime import datetime, timedelta
from typing import TYPE_CHECKING
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import connection, models, transaction
from django.te... | 821 | 38,563 |
saleor | saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_payment_method_initialize_tokenization.py | .py | import json
import graphene
from ....payment import TokenizedPaymentFlow
from ....payment.interface import PaymentMethodInitializeTokenizationRequestData
from ...event_types import WebhookEventSyncType
from ...transport.asynchronous import create_deliveries_for_subscriptions
PAYMENT_METHOD_INITIALIZE_TOKENIZATION_SE... | 96 | 3,017 |
bazel | third_party/py/mock/tests/testmagicmethods.py | .py | # Copyright (C) 2007-2012 Michael Foord & the mock team
# E-mail: fuzzyman AT voidspace DOT org DOT uk
# http://www.voidspace.org.uk/python/mock/
from tests.support import unittest2, inPy3k
try:
unicode
except NameError:
# Python 3
unicode = str
long = int
import inspect
import sys
from mock import M... | 487 | 14,863 |
onnxruntime | onnxruntime/test/python/quantization/test_subgraph.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import os... | 73 | 3,126 |
lemur | lemur/plugins/lemur_atlas/plugin.py | .py | """
.. module: lemur.plugins.lemur_atlas.plugin
: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>
"""
import json
from typing import Any, Dict
import requests
from requests.excep... | 111 | 3,484 |
mlflow | mlflow/genai/judges/builtin.py | .py | from functools import wraps
from typing import TYPE_CHECKING, Any
from mlflow.entities.assessment import Feedback
from mlflow.exceptions import MlflowException
from mlflow.genai.judges.constants import USE_CASE_BUILTIN_JUDGE
from mlflow.genai.judges.prompts.relevance_to_query import RELEVANCE_TO_QUERY_ASSESSMENT_NAME
... | 767 | 28,017 |
openvino | src/tests/test_utils/functional_test_utils/layer_tests_summary/merge_xmls.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import argparse
import os
import glob
import defusedxml.ElementTree as ET
from defusedxml import defuse_stdlib
from utils.conformance_utils import get_logger
from utils import stat_update_utils
from utils.constants import OP_CONFORMANC... | 184 | 9,069 |
sqlmap | tests/test_http2.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Coverage for the native HTTP/2 client in lib/request/http2.py: frame and HPACK
codecs, request/response validation, connection state, flow control, retries,
URL handling, TLS policy, ... | 905 | 35,103 |
pyro | examples/rsa/semantic_parsing.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
Combining models of RSA pragmatics and CCG-based compositional semantics.
Taken from: http://dippl.org/examples/zSemanticPragmaticMashup.html
"""
import argparse
import collections
import torch
from search_inference import B... | 358 | 8,669 |
openvino | tests/layer_tests/pytorch_tests/test_unbind.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 TestUnbind(PytorchLayerTest):
def _prepare_input(self):
return (self.random.uniform(0, 50, (3, 3, 3, 3), dtype=np.float32),)
... | 36 | 1,026 |
beam | sdks/python/apache_beam/internal/util_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... | 62 | 2,287 |
biopython | Scripts/xbbtools/xbb_blastbg.py | .py | #!/usr/bin/env python
# Copyright 2000 by Thomas Sicheritz-Ponten.
# Copyright 2016 by Markus Piotrowski.
# 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.
# Created: Sat Dec 2 ... | 145 | 4,609 |
cvxpy | cvxpy/tests/test_complex.py | .py | """
Copyright 2013 Steven Diamond
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | 1,072 | 41,544 |
eve | eve/io/mongo/geo.py | .py | # -*- coding: utf-8 -*-
"""
eve.io.mongo.geo
~~~~~~~~~~~~~~~~~~~
Geospatial functions and classes for mongo IO layer
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
from eve.utils import config
class GeoJSON(dict):
def __init__(self, json):
t... | 148 | 4,154 |
mlflow | tests/store/tracking/test_rest_store.py | .py | import json
import math
import time
from unittest import mock
import pytest
import mlflow
from mlflow.entities import (
Dataset,
DatasetInput,
EvaluationDataset,
Experiment,
ExperimentTag,
FallbackConfig,
FallbackStrategy,
GatewayEndpointModelConfig,
GatewayModelLinkageType,
Ga... | 3,990 | 142,893 |
textual | tests/animations/test_switch_animation.py | .py | """
Tests for the switch toggle animation, which is considered a basic animation.
(An animation that also plays on the level BASIC.)
"""
from textual.app import App, ComposeResult
from textual.widgets import Switch
class SwitchApp(App[None]):
def compose(self) -> ComposeResult:
yield Switch()
async def... | 70 | 2,369 |
httpie | httpie/output/formatters/colors.py | .py | import json
from typing import Optional, Type, Tuple
import pygments.formatters
import pygments.lexer
import pygments.lexers
import pygments.style
import pygments.styles
import pygments.token
from pygments.formatters.terminal import TerminalFormatter
from pygments.formatters.terminal256 import Terminal256Formatter
fro... | 389 | 13,002 |
openvino | tests/layer_tests/onnx_tests/test_scale.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
class TestScale(OnnxRuntimeLayerTest):
def create_net(self, shape, scale, ir_version):
"""
ONNX net ... | 148 | 4,245 |
wandb | noxfile.py | .py | from __future__ import annotations
import os
import pathlib
import platform
import re
import shutil
import subprocess
import textwrap
import time
from collections.abc import Callable
from contextlib import contextmanager
from typing import Any
import nox
nox.options.default_venv_backend = "uv"
_SUPPORTED_PYTHONS = ... | 870 | 27,721 |
coremltools | coremltools/test/optimize/torch/models/multi_input_net.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 torch.nn as nn
num_classes = 10
class MultiInputNet(nn.Module):
def __init__(self):
... | 61 | 1,975 |
mlflow | mlflow/gateway/schemas/completions.py | .py | from pydantic import ConfigDict
from mlflow.gateway.base_models import RequestModel, ResponseModel
from mlflow.types.chat import BaseRequestPayload
_REQUEST_PAYLOAD_EXTRA_SCHEMA = {
"example": {
"prompt": "hello",
"temperature": 0.0,
"max_tokens": 64,
"stop": ["END"],
"n": ... | 98 | 2,329 |
python-prompt-toolkit | examples/progress-bar/unknown-length.py | .py | #!/usr/bin/env python
"""
A very simple progress bar which keep track of the progress as we consume an
iterator.
"""
import time
from prompt_toolkit.shortcuts import ProgressBar
def data():
"""
A generator that produces items. len() doesn't work here, so the progress
bar can't estimate the time it will ... | 28 | 502 |
readthedocs.org | readthedocs/rtd_tests/tests/test_backend.py | .py | import os
import textwrap
from readthedocs.core.utils.filesystem import safe_rmtree
from os.path import exists
from unittest import mock
from unittest.mock import Mock, patch
import django_dynamic_fixture as fixture
from django_dynamic_fixture import get
from django.contrib.auth.models import User
from django.test imp... | 447 | 15,260 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_linspace.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# linspace paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle
import random
import sys
data_type = "float32"
def linspace(name: str, start, stop, num, type='float32'):
paddle.enable_static... | 59 | 1,899 |
onnxruntime | csharp/testdata/test_input_FLOAT16.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import onnx
from onnx import TensorProto, helper
from onnx.helper import make_opsetid
input_info = helper.make_tensor_value_info("input", TensorProto.FLOAT16, [1, 5])
output_info = helper.make_tensor_value_info("output", Ten... | 30 | 1,025 |
sphinx | tests/roots/test-ext-autodoc/target/TYPE_CHECKING.py | .py | # NoQA: N999
from __future__ import annotations
from gettext import NullTranslations # NoQA: TC003
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Iterable
from io import StringIO
class Foo:
attr1: StringIO
def spam(ham: Iterable[str]) -> tuple[NullTranslations, bool]:
... | 18 | 329 |
luigi | test/choice_parameter_test.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 63 | 2,252 |
kombu | kombu/exceptions.py | .py | """Exceptions."""
from __future__ import annotations
from socket import timeout as TimeoutError
from types import TracebackType
from typing import TYPE_CHECKING, TypeVar
from amqp import ChannelError, ConnectionError, ResourceError
if TYPE_CHECKING:
from kombu.asynchronous.http import Response
__all__ = (
... | 113 | 2,838 |
saleor | saleor/warehouse/reservations.py | .py | import datetime
from collections import defaultdict
from collections.abc import Iterable
from typing import TYPE_CHECKING, NamedTuple
from django.conf import settings
from django.db.models import F, Sum
from django.db.models.functions import Coalesce
from django.utils import timezone
from ..core.exceptions import Ins... | 438 | 14,876 |
saleor | saleor/graphql/order/resolvers.py | .py | from uuid import UUID
from django.db.models import Q
from ...channel.models import Channel
from ...core.exceptions import PermissionDenied
from ...order import OrderStatus, models
from ...order.events import OrderEvents
from ...order.utils import sum_order_totals
from ..account.utils import get_user_accessible_channe... | 138 | 5,008 |
wagtail | wagtail/api/v2/tests/tests.py | .py | from django.test import RequestFactory, TestCase, override_settings
from django.utils.encoding import force_bytes
from wagtail.api.utils import get_base_url
from wagtail.models import Site
from ..utils import (
FieldsParameterParseError,
parse_boolean,
parse_fields_parameter,
)
class DynamicBaseUrl:
... | 402 | 12,724 |
mlflow | mlflow/azure/client.py | .py | """
This module provides utilities for performing Azure Blob Storage operations without requiring
the heavyweight azure-storage-blob library dependency
"""
import logging
import urllib
from copy import deepcopy
from mlflow.utils import rest_utils
from mlflow.utils.file_utils import read_chunk
_logger = logging.getLo... | 320 | 11,509 |
saleor | saleor/graphql/app/tests/test_app_by_token_loader_use_cache.py | .py | from unittest.mock import patch
from django.utils import timezone
from ....app.models import App, AppToken
from ...context import SaleorContext
from ..dataloaders.app import AppByTokenLoader, create_app_cache_key_from_token
@patch("saleor.graphql.app.dataloaders.app.cache")
def test_app_by_token_loader_cache_token_... | 302 | 10,357 |
gunicorn | tests/config/__init__.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
| 5 | 106 |
wandb | wandb/sklearn.py | .py | from wandb.integration.sklearn import (
plot_calibration_curve,
plot_class_proportions,
plot_classifier,
plot_clusterer,
plot_confusion_matrix,
plot_elbow_curve,
plot_feature_importances,
plot_learning_curve,
plot_outlier_candidates,
plot_precision_recall,
plot_regressor,
... | 36 | 803 |
onnxruntime | onnxruntime/test/contrib_ops/multihead_attention_op_test_data_gen.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# Running this script in Linux like the following
# CUBLAS_WORKSPACE_CO... | 565 | 19,050 |
onnxruntime | onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/RuntimeOptimizationRecord.py | .py | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: fbs
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
# a single runtime optimization
# see corresponding type in onnxruntime/core/graph/runtime_optimization_record.h
class RuntimeOptimizationRecord(obj... | 106 | 3,962 |
beam | learning/katas/python/Core Transforms/Flatten/Flatten/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... | 36 | 1,269 |
beam | sdks/python/apache_beam/examples/cookbook/ordered_window_elements/batch.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... | 523 | 20,094 |
saleor | saleor/graphql/core/tests/test_scalars_weight.py | .py | import pytest
from ..scalars import WeightScalar
@pytest.mark.parametrize(
"value",
[
{"unit": "kg", "value": None},
{"unit": "g", "value": None},
{"unit": "lb", "value": None},
{"unit": "oz", "value": None},
],
)
def test_weight_scalar_parse_value_with_none_value(value):
... | 18 | 391 |
saleor | saleor/core/telemetry/utils.py | .py | import logging
from collections.abc import Callable, Sequence
from contextlib import contextmanager
from contextvars import ContextVar
from dataclasses import dataclass, field
from enum import Enum
from functools import wraps
from django.conf import settings
from opentelemetry.trace import Link, SpanContext, TraceFlag... | 162 | 5,177 |
saleor | saleor/discount/tests/test_utils/test_create_or_update_discount_objects_from_promotion_for_checkout.py | .py | import datetime
from decimal import Decimal
from unittest.mock import patch
import graphene
import pytest
from django.utils import timezone
from freezegun import freeze_time
from prices import Money, TaxedMoney
from ....checkout.base_calculations import base_checkout_total
from ....checkout.fetch import fetch_checkou... | 2,393 | 80,619 |
pymc | pymc/model/transform/conditioning.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... | 368 | 12,293 |
beam | sdks/python/apache_beam/yaml/yaml_transform_scope_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... | 325 | 10,516 |
textual | docs/examples/widgets/header.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Header
class HeaderApp(App):
def compose(self) -> ComposeResult:
yield Header()
if __name__ == "__main__":
app = HeaderApp()
app.run()
| 13 | 230 |
beam | sdks/python/apache_beam/runners/portability/requirements_cache_it_test.py | .py | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | 76 | 2,943 |
astropy | astropy/units/tests/test_units.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Regression tests for the units package."""
import itertools
import operator
import pickle
from contextlib import nullcontext
from fractions import Fraction
import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy import... | 1,344 | 39,733 |
pyomo | pyomo/contrib/parmest/examples/rooney_biegler/bootstrap_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... | 61 | 1,920 |
cvxpy | doc/sphinxext/docscrape_sphinx.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... | 249 | 8,343 |
biopython | Tests/test_PDB_DSSP.py | .py | # Copyright 2009-2011 by Eric Talevich. All rights reserved.
# Revisions copyright 2009-2013 by Peter Cock. All rights reserved.
# Revisions copyright 2013 Lenna X. Peterson. All rights reserved.
# Revisions copyright 2020 Joao Rodrigues. All rights reserved.
#
# Converted by Eric Talevich from an older unit test cop... | 276 | 10,937 |
deap | examples/es/cma_mo.py | .py | # This file is part of DEAP.
#
# DEAP 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.
#
# DEAP is distributed ... | 169 | 5,971 |
sqlmap | tamper/randomcase.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.common import randomRange
from lib.core.compat import xrange
from lib.core.data import kb
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.NOR... | 68 | 1,763 |
qutip | qutip/tests/core/data/test_norm.py | .py | from . import test_mathematics as testing
import numpy as np
import scipy.linalg
import pytest
from qutip import data
from qutip.core.data import CSR, Dense, Dia
import numbers
class TestOneNorm(testing.UnaryOpMixin):
def op_numpy(self, matrix):
return scipy.linalg.norm(matrix, 1)
specialisations = [... | 74 | 2,402 |
python-prompt-toolkit | examples/telnet/dialog.py | .py | #!/usr/bin/env python
"""
Example of a telnet application that displays a dialog window.
"""
import logging
from asyncio import Future, run
from prompt_toolkit.contrib.telnet.server import TelnetServer
from prompt_toolkit.shortcuts.dialogs import yes_no_dialog
# Set up logging
logging.basicConfig()
logging.getLogger... | 36 | 746 |
beam | sdks/python/apache_beam/ml/rag/ingestion/milvus_search_it_test.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 648 | 24,335 |
saleor | saleor/graphql/checkout/enums.py | .py | from typing import Final
import graphene
from ...checkout import CheckoutAuthorizeStatus, CheckoutChargeStatus, error_codes
from ..core.doc_category import DOC_CATEGORY_CHECKOUT, DOC_CATEGORY_ORDERS
from ..core.enums import to_enum
OrderCreateFromCheckoutErrorCode: Final[graphene.Enum] = graphene.Enum.from_enum(
... | 35 | 1,306 |
hatch | src/hatch/project/core.py | .py | from __future__ import annotations
import re
from collections import defaultdict
from contextlib import contextmanager
from functools import cached_property
from typing import TYPE_CHECKING, Any, cast
from hatch.project.env import EnvironmentMetadata
from hatch.utils.fs import Path
from hatch.utils.runner import Exec... | 501 | 19,126 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_NonMaxSupression.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
class TestNonMaxSuppression(CommonTFLayerTest):
# overload inputs generation to suit NMS use case
... | 158 | 6,138 |
ipython | tests/test_decorators_2.py | .py | from IPython.utils import decorators
def test_flag_calls():
@decorators.flag_calls
def f():
pass
assert not f.called
f()
assert f.called
| 12 | 168 |
openvino | tests/model_hub_tests/models_hub_common/utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import functools
import itertools
import os
import shutil
import time
import numpy as np
from models_hub_common.constants import test_device
def parse_list_file(file_name: str):
with open(file_name, 'r') as f_in:
for model... | 209 | 7,623 |
pyro | pyro/distributions/transforms/haar.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
from torch.distributions.transforms import Transform
from pyro.ops.tensor_utils import haar_transform, inverse_haar_transform
from .. import constraints
class HaarTransform(Transform):
"""
Discrete Haar transform.
This... | 93 | 2,883 |
coremltools | coremltools/converters/mil/mil/tests/test_programs.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
import numpy as np
import pytest
import coremltools as ct
from coremltools import _logger as logger
... | 2,103 | 82,245 |
probability | tensorflow_probability/python/experimental/tangent_spaces/simplex.py | .py | # Copyright 2023 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... | 84 | 3,908 |
flit | flit/log.py | .py | """Nicer log formatting with colours.
Code copied from Tornado, Apache licensed.
"""
# Copyright 2012 Facebook
#
# 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/licen... | 110 | 3,967 |
textual | tests/test_loading.py | .py | from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widgets import Label, Static
class LoadingApp(App[None]):
CSS = """
VerticalScroll {
height: 20;
}
"""
BINDINGS = [("l", "loading")]
def compose(self) -> ComposeResult:
with ... | 56 | 1,509 |
wagtail | wagtail/contrib/settings/views.py | .py | from functools import lru_cache
from django.core.exceptions import PermissionDenied
from django.http import Http404
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse
from django.utils.text import capfirst
from django.utils.translation import gettext as _
from django.utils.transla... | 229 | 7,993 |
confluent-kafka-python | tests/test_Messages.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2026 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 114 | 3,490 |
qutip | qutip/testing.py | .py | from .about import about
from .settings import settings as qset
def run(full=False):
"""
Run the test scripts for QuTiP.
Parameters
----------
full: bool
If True run all test (30 min). Otherwise skip few variants of the
slowest tests.
"""
# Call about to get all version inf... | 35 | 1,016 |
coremltools | coremltools/converters/sklearn/_svm_common.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
"""
Common stuff for SVMs
"""
def _set_kernel(model, spec):
"""
Takes the sklearn SVM model an... | 38 | 1,210 |
readthedocs.org | readthedocs/payments/tests/test_utils.py | .py | import requests_mock
from django.test import TestCase
from readthedocs.payments.tests.utils import PaymentMixin
from readthedocs.payments.utils import cancel_subscription
class TestUtils(PaymentMixin, TestCase):
@requests_mock.Mocker(kw="mock_request")
def test_cancel_subscription(self, mock_request):
... | 23 | 723 |
pyomo | pyomo/contrib/pynumero/examples/callback/cyipopt_callback.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... | 53 | 1,581 |
sqlmap | plugins/dbms/cratedb/connector.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
try:
import psycopg2
import psycopg2.extensions
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
psycopg2.extensions.register_type(psycopg2.extension... | 74 | 2,096 |
textual | tests/snapshot_tests/snapshot_apps/mount_style_fix.py | .py | from textual import __version__
from textual.app import App, ComposeResult
from textual.widgets import Static
# Regression test for https://github.com/Textualize/textual/issues/3858
class BrokenClassesApp(App[None]):
CSS = """
Screen {
align: center middle;
}
Static {
width: 50%;
... | 33 | 669 |
mlflow | tests/pyfunc/test_chat_agent.py | .py | import json
from typing import Any
from uuid import uuid4
import pydantic
import pytest
import mlflow
from mlflow.exceptions import MlflowException
from mlflow.models.model import Model
from mlflow.models.signature import ModelSignature
from mlflow.models.utils import load_serving_example
from mlflow.pyfunc.loaders.c... | 471 | 17,282 |
openvino | docs/optimization_guide/nncf/code/qat_torch.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#! [quantize]
model = TorchModel() # instance of torch.nn.Module
quantized_model = nncf.quantize(model, ...)
#! [quantize]
#! [tune_model]
... # fine-tuning preparations, e.g. dataset, loss, optimization setup, etc.
# tune quantized mo... | 39 | 1,196 |
saleor | saleor/graphql/app/dataloaders/app_problems.py | .py | from collections import defaultdict
from ....app.models import AppProblem
from ...core.dataloaders import DataLoader
class AppProblemsByAppIdLoader(DataLoader[int, list[AppProblem]]):
context_key = "app_problems_by_app_id"
def batch_load(self, keys):
problems = AppProblem.objects.using(self.database... | 18 | 577 |
confluent-kafka-python | tests/schema_registry/_sync/test_json_serdes.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2024 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... | 1,867 | 63,994 |
clearml | clearml/utilities/plotlympl/mplexporter/__init__.py | .py | from .exporter import Exporter
from .renderers import Renderer
__all__ = ["Renderer", "Exporter"]
| 5 | 99 |
mlflow | tests/pytorch/iris.py | .py | import tempfile
import pytorch_lightning as pl
import torch
import torch.nn.functional as F
import torch.utils.tensorboard
from packaging.version import Version
from torch import nn
tmpdir = tempfile.mkdtemp()
SUMMARY_WRITER = torch.utils.tensorboard.SummaryWriter(log_dir=tmpdir)
def create_multiclass_accuracy():
... | 140 | 4,506 |
beam | sdks/python/apache_beam/examples/inference/gemini_text_classification.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... | 122 | 4,159 |
mlflow | mlflow/utils/requirements_utils.py | .py | """
This module provides a set of utilities for interpreting and creating requirements files
(e.g. pip's `requirements.txt`), which is useful for managing ML software environments.
"""
import importlib.metadata
import json
import logging
import os
import re
import subprocess
import sys
import tempfile
from itertools i... | 709 | 26,984 |
onnx | tests/python/inference_function_test.py | .py | # SPDX-License-Identifier: Apache-2.0
# Copyright (c) ONNX Project Contributors
from __future__ import annotations
import numpy as np
import pytest
import onnx
from onnx import TensorProto, TypeProto
from onnx.checker import ValidationError
from onnx.defs import OpSchema, get_all_schemas_with_history, get_schema
fro... | 299 | 10,239 |
metrics | tests/unittests/image/test_rmse_sw.py | .py | # Copyright The PyTorch 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 i... | 86 | 3,101 |
pyomo | pyomo/contrib/benders/examples/farmer.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... | 195 | 6,536 |
saleor | saleor/graphql/attribute/mutations/attribute_reorder_values.py | .py | import graphene
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from ....attribute import models as models
from ....attribute.error_codes import AttributeErrorCode
from ....core.tracing import traced_atomic_transaction
from ....webhook.event_types import WebhookEventAsyncType
from ...core import... | 117 | 4,577 |
cvxpy | cvxpy/tests/base_test.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... | 48 | 1,497 |
cvxpy | cvxpy/reductions/dnlp2smooth/canonicalizers/__init__.py | .py | """
Copyright 2025 CVXPY 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 law or agreed to in writing, softwa... | 107 | 4,628 |
pyomo | examples/pyomo/concrete/sodacan.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... | 19 | 802 |
mlflow | mlflow/entities/dataset_record.py | .py | from __future__ import annotations
import json
from dataclasses import dataclass
from typing import Any
from google.protobuf.json_format import MessageToDict
from mlflow.entities._mlflow_object import _MlflowObject
from mlflow.entities.dataset_record_source import DatasetRecordSource, DatasetRecordSourceType
from ml... | 180 | 7,104 |
wagtail | wagtail/images/tests/__init__.py | .py | from django.test.signals import setting_changed
from wagtail.images import get_image_model, get_permission_policy
from wagtail.permissions import register_permission_policy
def update_permission_policy(signal, sender, setting, **kwargs):
"""
Register the permission policy when the `WAGTAILIMAGES_IMAGE_MODEL`... | 19 | 661 |
sphinx | tests/test_util/test_util_inventory.py | .py | """Test inventory util functions."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
import sphinx.locale
from sphinx.testing.util import SphinxTestApp
from sphinx.util.inventory import InventoryFile, _InventoryItem
from tests.test_util.intersphinx_data import (
INVENTORY_V1,
... | 121 | 4,088 |
wagtail | wagtail/images/__init__.py | .py | from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
def get_image_model_string():
"""
Get the dotted ``app.Model`` name for the image model as a string.
Useful for developers making Wagtail plugins that need to refer to the
image model, such as in foreign keys, but... | 47 | 1,558 |
coveragepy | tests/test_arcs.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
"""Tests for coverage.py's arc measurement."""
from __future__ import annotations
import textwrap
from unittest import mock
import pytest
from tests.coveraget... | 2,420 | 66,029 |
wagtail | wagtail/admin/forms/choosers.py | .py | import warnings
from django import forms
from django.core import validators
from django.forms.widgets import TextInput
from django.utils.translation import gettext_lazy as _
from wagtail.compat import URLField
from wagtail.models import Locale
from wagtail.search.backends import get_search_backend
class URLOrAbsolu... | 153 | 5,065 |
textual | tests/test_easing.py | .py | """
Test the easing functions by sampling the range [0, 1] uniformly in 21 points.
Then, a TypeScript script was used to sample all the original functions,
the data was collected, and is here tested against the Python implementation.
"""
import pytest
from textual._easing import EASING
POINTS = [
0.0,
0.05,
... | 741 | 16,367 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.