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 |
|---|---|---|---|---|---|
openvino | src/bindings/python/src/openvino/frontend/pytorch/ov_custom_ops.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Register OpenVINO custom ops via torch.library for use with torch.export.
When converting quantized PyTorch models, module forwards are replaced with
calls to these custom ops. During ``torch.export``, the op... | 238 | 10,967 |
beam | sdks/python/apache_beam/ml/anomaly/univariate/perf_test.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 86 | 2,976 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_Reshape.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shape': [2, 6], 'out_shape': [2, 3, 2]},
{'shape': [2, 4, 6], 'out_shape': [2, -1]},
{'shape': [1], 'out_shape': []},
]
class TestTFLiteReshapeLayerTest(TFLiteLayerTest):
inputs = ["Inp... | 35 | 1,237 |
onnxruntime | onnxruntime/test/python/onnxruntime_test_python_backend.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# -*- coding: UTF-8 -*-
import os
import tempfile
import unittest
import numpy as np
from helper import get_name
from numpy.testing import assert_allclose
import onnxruntime as onnxrt
import onnxruntime.backend as backend
... | 194 | 10,107 |
saleor | saleor/warehouse/availability.py | .py | from collections import defaultdict
from collections.abc import Iterable
from typing import (
TYPE_CHECKING,
Any,
NamedTuple,
NoReturn,
Optional,
)
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db.models import F, QuerySet, Sum
from django.db.models... | 624 | 21,992 |
onnxruntime | orttraining/orttraining/python/training/ort_triton/_codegen.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
"""
Generate code for each IR node.
Mostly, Nodes are classified into tw... | 525 | 24,895 |
voila | tests/app/show_traceback_test.py | .py | import pytest
NOTEBOOK_PATH = "syntax_error.ipynb"
@pytest.fixture(params=[True, False])
def show_tracebacks(request):
return request.param
@pytest.fixture
def notebook_show_traceback_path(base_url):
return base_url + f"voila/render/{NOTEBOOK_PATH}"
@pytest.fixture
def voila_args(notebook_directory, voil... | 39 | 1,130 |
astropy | astropy/wcs/wcsapi/high_level_wcs_wrapper.py | .py | from .high_level_api import HighLevelWCSMixin
from .low_level_api import BaseLowLevelWCS
from .utils import wcs_info_str
__all__ = ["HighLevelWCSWrapper"]
class HighLevelWCSWrapper(HighLevelWCSMixin):
"""
Wrapper class that can take any :class:`~astropy.wcs.wcsapi.BaseLowLevelWCS`
object and expose the h... | 86 | 2,332 |
voila | tests/app/no_metadata.py | .py | import pytest
NOTEBOOK_PATH = "no_metadata.ipynb"
@pytest.fixture
def non_existing_notebook_metadata(base_url):
return base_url + f"voila/render/{NOTEBOOK_PATH}"
@pytest.fixture
def voila_args(notebook_directory, voila_args_extra):
return ["--VoilaTest.root_dir=%r" % notebook_directory, *voila_args_extra]
... | 22 | 610 |
beam | sdks/python/apache_beam/dataframe/partitionings.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... | 255 | 7,113 |
sphinx | tests/test_addnodes.py | .py | """Test the non-trivial features in the :mod:`sphinx.addnodes` module."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from sphinx import addnodes
if TYPE_CHECKING:
from collections.abc import Iterator
@pytest.fixture
def sig_elements() -> Iterator[set[type[addnodes.desc_... | 58 | 2,072 |
lemur | lemur/tests/test_api_keys.py | .py | import json
import pytest
from lemur.api_keys.views import * # noqa
from .vectors import (
VALID_ADMIN_API_TOKEN,
VALID_ADMIN_HEADER_TOKEN,
VALID_USER_HEADER_TOKEN,
)
@pytest.mark.parametrize(
"token,status",
[
(VALID_USER_HEADER_TOKEN, 200),
(VALID_ADMIN_HEADER_TOKEN, 200),
... | 402 | 9,920 |
pyomo | pyomo/core/tests/unit/kernel/test_expression.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... | 762 | 24,595 |
mkdocs-material | material/overrides/hooks/translations.py | .py | # Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
# 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, including without limitation the
# rights to use, c... | 198 | 6,234 |
gunicorn | tests/requests/valid/rfc9110_body_framing_get_cl_nonzero_01.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# RFC 9110 section 8.6: a GET with a non-zero Content-Length is
# "discouraged" but not forbidden; the body must be preserved.
request = {
"method": "GET",
"uri": uri("/foo"),
"version": (1, 1),
"he... | 17 | 427 |
probability | tensorflow_probability/python/experimental/vi/surrogate_posteriors_test.py | .py | # Copyright 2019 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... | 794 | 29,848 |
scikit-bio | skbio/stats/composition/_base.py | .py | # ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# --------------------------------------------... | 1,769 | 56,281 |
saleor | saleor/tests/e2e/checkout/discounts/vouchers/test_only_one_voucher_per_checkout.py | .py | import pytest
from ....product.utils.preparing_product import prepare_product
from ....shop.utils import prepare_default_shop
from ....utils import assign_permissions
from ....vouchers.utils import (
create_voucher,
create_voucher_channel_listing,
get_voucher,
)
from ...utils import (
checkout_add_prom... | 223 | 6,942 |
kombu | examples/rpc-tut6/rpc_server.py | .py | #!/usr/bin/env python3
from __future__ import annotations
from kombu import Connection, Queue
from kombu.mixins import ConsumerProducerMixin
rpc_queue = Queue('rpc_queue')
def fib(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fib(n - 1) + fib(n - 2)
class Worker(C... | 60 | 1,332 |
wagtail | wagtail/admin/blocks.py | .py | import warnings
from wagtail.blocks import * # noqa: F403
warnings.warn(
"wagtail.admin.blocks has moved to wagtail.blocks", UserWarning, stacklevel=2
)
| 8 | 160 |
conda | tests/shards/test_shardfetch.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Tests for "ShardFetch". This code is part of the "bfs" algorithm, which helps to
provide an important baseline and comparison but is not executed during the
default "pipelined" shard traversal.
"""
from __future__ import annotations
import... | 180 | 6,383 |
onnx | onnx/reference/ops/aionnxml/op_one_hot_encoder.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.ops.aionnxml._op_run_aionnxml import OpRunAiOnnxMl
class OneHotEncoder(OpRunAiOnnxMl):
def _run(self, x, cats_int64s=None, cats_strings=None, zeros=None):
... | 54 | 1,913 |
coremltools | docs/conf.py | .py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 96 | 2,989 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/runinference_sklearn_keyed_model_handler.py | .py | # coding=utf-8
#
# 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");... | 70 | 2,499 |
readthedocs.org | readthedocs/search/apps.py | .py | from django.apps import AppConfig
class SearchConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "readthedocs.search"
def ready(self):
import readthedocs.search.signals # noqa
| 10 | 228 |
probability | tensorflow_probability/python/distributions/matrix_normal_linear_operator.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... | 345 | 12,370 |
mlflow | tests/models/test_signature.py | .py | import json
from dataclasses import asdict, dataclass
import numpy as np
import pandas as pd
import pydantic
import pyspark
import pytest
from sklearn.ensemble import RandomForestRegressor
import mlflow
from mlflow.exceptions import MlflowException
from mlflow.models import Model, ModelSignature, infer_signature, rag... | 387 | 13,706 |
astropy | astropy/coordinates/tests/test_frames.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import re
import typing
from copy import deepcopy
import numpy as np
import pytest
from astropy import units as u
from astropy.coordinates import (
EarthLocation,
SkyCoord,
galactocentric_frame_defaults,
)
from astropy.coordinates import rep... | 1,796 | 58,888 |
pyomo | pyomo/contrib/cp/plugins.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... | 15 | 686 |
saleor | saleor/graphql/shipping/resolvers.py | .py | from prices import MoneyRange
from ...shipping import models
from ...shipping.interface import ShippingMethodData
from ..core import ResolveInfo
from ..core.context import ChannelQsContext, get_database_connection_name
from ..translations.resolvers import resolve_translation
def resolve_shipping_zones(info, channel_... | 38 | 1,313 |
cvxpy | cvxpy/tests/test_conic_solvers.py | .py | """
Copyright 2019, the 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, ... | 3,663 | 137,838 |
openvino | src/bindings/python/src/openvino/properties/_properties.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import sys
from types import BuiltinFunctionType, ModuleType
from typing import Any, Union
from collections.abc import Callable
class Property(str):
"""This class allows to make a string object callable. Cal... | 60 | 2,326 |
cvxpy | cvxpy/atoms/elementwise/kl_div.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... | 100 | 3,023 |
metrics | src/torchmetrics/functional/image/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... | 150 | 5,546 |
pyomo | doc/OnlineDocs/src/data/param2.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... | 24 | 829 |
clearml | examples/pipeline/pipeline_from_decorator.py | .py | from clearml.automation.controller import PipelineDecorator
from clearml import TaskTypes
# Make the following function an independent pipeline component step
# notice all package imports inside the function will be automatically logged as
# required packages for the pipeline execution step
@PipelineDecorator.compone... | 125 | 5,936 |
pyfilesystem2 | tests/test_ftpfs.py | .py | # coding: utf-8
from __future__ import absolute_import, print_function, unicode_literals
import calendar
import datetime
import os
import platform
import shutil
import socket
import tempfile
import time
import unittest
import uuid
try:
from unittest import mock
except ImportError:
import mock
from ftplib imp... | 395 | 13,572 |
cvxpy | cvxpy/reductions/solution.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... | 101 | 3,265 |
mlflow | dev/clint/src/clint/rules/unsafe_version_parse.py | .py | import ast
from typing import TYPE_CHECKING
from clint.rules.base import Rule
if TYPE_CHECKING:
from clint.resolver import Resolver
class UnsafeVersionParse(Rule):
# Names/attributes that hold a raw Databricks runtime (DBR) version string. These are NOT
# PEP 440 (e.g. "18.x-aarch64-photon-scala2") and ... | 68 | 2,501 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_BatchMatmul.py | .py | import pytest
import tensorflow as tf
import numpy as np
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shapes': ((None, 4, 5), (None, 5, 6), (3, 4, 5), (3, 5, 6)), 'adjoint_a': True, 'adjoint_b': True},
{'shapes': ((None, 1, 3, 4), (None, 4, 2), (2, 1, 3, 4), (5, 4, 2)), 'adjoin... | 66 | 2,856 |
textual | tests/test_query.py | .py | import pytest
from textual.app import App, ComposeResult
from textual.color import Color
from textual.containers import Container
from textual.css.query import (
DeclarationError,
InvalidQueryFormat,
NoMatches,
TooManyMatches,
WrongType,
)
from textual.widget import Widget
from textual.widgets impo... | 405 | 12,655 |
sphinx | tests/test_command_line.py | .py | from __future__ import annotations
import sys
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from sphinx._cli.util.errors import strip_escape_sequences
from sphinx.cmd import make_mode
from sphinx.cmd.build import get_parser
from sphinx.cmd.make_mode import run_make_mode
if TYPE_CHECKING:
... | 238 | 6,160 |
sphinx | tests/roots/test-ext-autodoc/target/instance_variable.py | .py | class Foo:
def __init__(self):
self.attr1 = None #: docstring foo
self.attr2 = None #: docstring foo
class Bar(Foo):
def __init__(self):
self.attr2 = None #: docstring bar
self.attr3 = None #: docstring bar
self.attr4 = None
| 12 | 279 |
pyomo | pyomo/solvers/plugins/solvers/SAS.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... | 813 | 34,431 |
clearml | clearml/binding/absl_bind.py | .py | """ absl-py FLAGS binding utility functions """
from typing import Any
from ..backend_interface.task.args import _Arguments
from ..config import running_remotely
class PatchAbsl:
_original_DEFINE_flag = None
_original_FLAGS_parse_call = None
_current_task = None
__patched = False
@classmethod
... | 143 | 5,140 |
probability | tensorflow_probability/python/experimental/distributions/mvn_precision_factor_linop_test.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... | 219 | 8,227 |
beam | sdks/python/apache_beam/ml/rag/ingestion/cloudsql_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... | 1,015 | 39,187 |
saleor | saleor/core/utils/date_time.py | .py | import datetime
def convert_to_utc_date_time(date) -> None | datetime.datetime:
"""Convert date into utc date time."""
if date is None:
return None
return datetime.datetime.combine(
date, datetime.datetime.min.time(), tzinfo=datetime.UTC
)
| 11 | 274 |
wandb | tests/unit_tests/test_wandb_clean.py | .py | import pathlib
from datetime import datetime
from typing import NoReturn
import pytest
from click.testing import CliRunner
from wandb.cli import clean
@pytest.fixture
def wandb_dir(
tmp_path: pathlib.Path,
monkeypatch: pytest.MonkeyPatch,
) -> pathlib.Path:
monkeypatch.chdir(tmp_path)
monkeypatch.set... | 189 | 6,010 |
saleor | saleor/tests/e2e/product/utils/product_attribute_assignment_update.py | .py | from ...utils import get_graphql_content
PRODUCT_ATTRIBUTE_ASSIGNMENT_UPDATE_MUTATION = """
mutation ProductAttributeAssignmentUpdate(
$operations: [ProductAttributeAssignmentUpdateInput!]!, $id: ID!) {
productAttributeAssignmentUpdate(operations: $operations, productTypeId: $id) {
errors {
field
... | 51 | 1,132 |
loguru | tests/exceptions/source/backtrace/too_many_arguments.py | .py | import sys
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="", colorize=False, backtrace=True, diagnose=False)
@logger.catch
def decorated():
pass
def not_decorated():
pass
decorated(1)
with logger.catch():
not_decorated(2)
try:
not_decorated(3)
except TypeError:
lo... | 27 | 339 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_Tile.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shape': [2], 'multiples': [2]},
{'shape': [2, 3], 'multiples': [1, 2]},
{'shape': [2, 3, 1], 'multiples': [5, 1, 3]},
]
class TestTFLiteTileLayerTest(TFLiteLayerTest):
inputs = ["Input"... | 33 | 1,079 |
mlflow | mlflow/genai/judges/prompts/guidelines.py | .py | from mlflow.genai.prompts.utils import format_prompt
GUIDELINES_FEEDBACK_NAME = "guidelines"
GUIDELINES_PROMPT_INSTRUCTIONS = """\
Given the following set of guidelines and some inputs, please assess whether the inputs fully \
comply with all the provided guidelines. Only focus on the provided guidelines and not the... | 51 | 1,814 |
confluent-kafka-python | tests/test_topic_partition.py | .py | #!/usr/bin/env python
from confluent_kafka import TopicPartition
def test_sort():
"""TopicPartition sorting (rich comparator)"""
# sorting uses the comparator
correct = [
TopicPartition('topic1', 3),
TopicPartition('topic3', 0),
TopicPartition('topicA', 5),
TopicPartition... | 60 | 1,612 |
returns | tests/test_context/test_requires_context_result/test_requires_context_result_bind.py | .py | from returns.context import RequiresContext
from returns.context import RequiresContextResult as RCR # noqa: N817
from returns.result import Failure, Result, Success
def test_bind():
"""Ensures that bind works."""
def factory(inner_value: int) -> RCR[float, str, int]:
if inner_value > 0:
... | 88 | 2,593 |
returns | tests/test_primitives/test_asserts/test_assert_equal.py | .py | from collections.abc import Sequence
import pytest
from returns.context import (
Reader,
ReaderFutureResult,
ReaderIOResult,
ReaderResult,
)
from returns.contrib.pytest import ReturnsAsserts
from returns.future import Future, FutureResult
from returns.io import IO, IOResult
from returns.maybe import M... | 81 | 2,289 |
pyomo | examples/gdp/simple1.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 49 | 1,558 |
saleor | saleor/payment/tests/fixtures/transaction_event.py | .py | from collections.abc import Callable
from decimal import Decimal
import pytest
from ....payment.models import TransactionEvent, TransactionItem
@pytest.fixture
def transaction_events_generator() -> Callable[
[list[str], list[str], list[Decimal], TransactionItem], list[TransactionEvent]
]:
def factory(
... | 34 | 954 |
saleor | saleor/giftcard/tests/test_tasks.py | .py | import datetime
import pytest
from django.utils import timezone
from .. import GiftCardEvents
from ..models import GiftCard
from ..tasks import deactivate_expired_cards_task, update_gift_cards_search_vector_task
def test_update_gift_cards_search_vector_task(gift_card):
# given
gift_card.search_index_dirty =... | 90 | 2,500 |
pyomo | pyomo/contrib/parmest/utils/ipopt_solver_wrapper.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 74 | 2,759 |
pyomo | pyomo/common/config.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... | 2,970 | 101,742 |
mlflow | tests/server/test_gateway_api.py | .py | import json
from pathlib import Path
from typing import Any
from unittest import mock
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
import zstandard
from fastapi import FastAPI, HTTPException
from fastapi.responses import StreamingResponse
from starlette.testclient import TestClient
import mlflo... | 3,878 | 141,071 |
python-prompt-toolkit | src/prompt_toolkit/formatted_text/pygments.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from prompt_toolkit.styles.pygments import pygments_token_to_classname
from .base import StyleAndTextTuples
if TYPE_CHECKING:
from pygments.token import Token
__all__ = [
"PygmentsTokens",
]
class PygmentsTokens:
"""
Turn a pygme... | 33 | 780 |
returns | tests/test_result/test_result_error.py | .py | from returns.result import Failure, ResultE, Success
def test_result_error_success():
"""Ensures that ResultE can be typecasted to success."""
container: ResultE[int] = Success(1)
assert container.unwrap() == 1
def test_result_error_failure():
"""Ensures that ResultE can be typecasted to failure."""... | 14 | 419 |
hydra | plugins/hydra_joblib_launcher/tests/test_joblib_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from collections.abc import Iterator
from contextlib import contextmanager
from pathlib import Path
from typing import Any, cast
from hydra.core.plugins import Plugins
from hydra.core.utils import JobReturn
from hydra.plugins.launcher import Launch... | 329 | 9,669 |
sqlmap | tests/test_dialectdbms.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Operator/typing-dialect DBMS heuristic (lib/utils/dialect.py). Locks in the empirical 8-probe truth
table: each measured signature maps to its expected back-end DBMS, and every other ... | 208 | 11,412 |
astropy | astropy/wcs/tests/test_tabprm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from copy import deepcopy
import numpy as np
def test_wcsprm_tab_basic(tab_wcs_2di):
assert len(tab_wcs_2di.wcs.tab) == 1
t = tab_wcs_2di.wcs.tab[0]
assert tab_wcs_2di.wcs.tab[0] is not t
def test_tabprm_coord(tab_wcs_2di_f):
t = tab_... | 135 | 3,064 |
sqlmap | plugins/dbms/mysql/__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 MYSQL_SYSTEM_DBS
from lib.core.unescaper import unescaper
from plugins.dbms.mysql.enumeration import Enumeration
from... | 36 | 1,112 |
openvino | src/bindings/python/tests/test_runtime/test_sync_infer_request.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from contextlib import nullcontext as does_not_raise
from copy import deepcopy
import numpy as np
import os
import pytest
import datetime
import openvino.properties as props
import openvino.opset13 as ops
from op... | 842 | 30,566 |
mlflow | tests/cli/test_skills.py | .py | from pathlib import Path
from unittest import mock
import pytest
from click.testing import CliRunner
from mlflow.assistant.skill_installer import BundledSkill
from mlflow.cli.skills import commands
@pytest.fixture
def runner():
return CliRunner()
@pytest.fixture
def mock_bundled_skills():
with mock.patch(... | 80 | 2,576 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_sin.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# tanh paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle
import sys
data_type = 'float32'
def sin(name:str, x):
paddle.enable_static()
with paddle.static.program_guard(paddle.static.P... | 41 | 1,050 |
mlflow | mlflow/genai/scorers/ragas/registry.py | .py | from __future__ import annotations
from dataclasses import dataclass
from mlflow.exceptions import MlflowException
@dataclass(frozen=True)
class MetricConfig:
classpath: str
is_agentic_or_multiturn: bool = False
requires_embeddings: bool = False
requires_llm_in_constructor: bool = True
requires_... | 160 | 6,163 |
mlflow | mlflow/environment_variables.py | .py | """
This module defines environment variables used in MLflow.
MLflow's environment variables adhere to the following naming conventions:
- Public variables: environment variable names begin with `MLFLOW_`
- Internal-use variables: For variables used only internally, names start with `_MLFLOW_`
"""
import os
import war... | 1,705 | 80,170 |
mlflow | mlflow/tracing/destination.py | .py | """
Trace destination classes are DEPRECATED. Use mlflow.entities.trace_location.TraceLocation instead.
"""
from __future__ import annotations
import logging
from contextvars import ContextVar
from dataclasses import dataclass
import mlflow
from mlflow.entities.trace_location import (
MlflowExperimentLocation,
... | 164 | 6,247 |
pyomo | pyomo/contrib/parmest/tests/test_graphics.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... | 67 | 2,075 |
beam | learning/tour-of-beam/learning-content/introduction/introduction-concepts/creating-collections/reading-from-csv/python-example/csvExample.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"); y... | 69 | 2,116 |
openvino | tests/model_hub_tests/pytorch/test_torchbench.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import subprocess
import pytest
import torch
import tempfile
from torch_utils import process_pytest_marks, get_models_list, TestTorchConvertModel
# To make tests reproducible we seed the random generator
torch.manu... | 59 | 2,025 |
wandb | wandb/automations/_validators.py | .py | from __future__ import annotations
from enum import Enum
from typing import Annotated, Any, TypeVar
from pydantic import BeforeValidator, Json, PlainSerializer
from wandb._filters import And, MongoLikeFilter, Or, simplify_expr
from wandb._pydantic import to_json
T = TypeVar("T")
def ensure_json(v: Any) -> Any:
... | 170 | 5,499 |
textual | docs/examples/styles/height.py | .py | from textual.app import App
from textual.widget import Widget
class HeightApp(App):
CSS_PATH = "height.tcss"
def compose(self):
yield Widget()
if __name__ == "__main__":
app = HeightApp()
app.run()
| 15 | 227 |
textual | docs/examples/guide/input/mouse01.py | .py | from textual import events
from textual.app import App, ComposeResult
from textual.widgets import RichLog, Static
class Ball(Static):
pass
class MouseApp(App):
CSS_PATH = "mouse01.tcss"
def compose(self) -> ComposeResult:
yield RichLog()
yield Ball("Textual")
def on_mouse_move(self... | 25 | 539 |
mlflow | tests/autologging/fixtures.py | .py | import os
import sys
import pytest
from mlflow.environment_variables import _MLFLOW_AUTOLOGGING_TESTING
from mlflow.utils import logging_utils
from mlflow.utils.autologging_utils import is_testing
PATCH_DESTINATION_FN_DEFAULT_RESULT = "original_result"
# Fixture to run the test case with and without async logging ... | 118 | 3,324 |
mlflow | mlflow/assistant/skill_installer.py | .py | """
Manage skill installation
Skills are maintained in the mlflow/assistant/skills subtree in the MLflow repository,
which points to the https://github.com/mlflow/skills repository.
"""
import shutil
from dataclasses import dataclass
from importlib import resources
from pathlib import Path
from mlflow.ai_commands.ai... | 107 | 3,239 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_Pool.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
from common.utils.tflite_utils import parametrize_tests
test_ops = [
{'op_name': 'AVERAGE_POOL_2D', 'op_func': 'tf.nn.avg_pool2d'},
{'op_name': 'MAX_POOL_2D', 'op_func': 'tf.nn.max_pool2d'},
]
test_params = [
... | 44 | 1,816 |
hatch | tests/backend/builders/test_custom.py | .py | import re
import zipfile
import pytest
from hatchling.builders.custom import CustomBuilder
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT
def test_target_config_not_table(isolation):
config = {"tool": {"hatch": {"build": {"targets": {"custom": 9000}}}}}
with pytest.raises(TypeError, match="Fiel... | 344 | 10,647 |
confluent-kafka-python | examples/avro_producer_encryption.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... | 212 | 7,596 |
hatch | src/hatch/env/lock.py | .py | """
Resolve and write environment lockfiles (PEP 751 ``pylock.toml``) via pluggable **lockers**.
Lockers are registered with ``hatch_register_locker``; built-ins ``uv`` and ``pip`` delegate to
``uv pip compile`` / ``pip lock``. See ``docs/how-to/environment/lockfiles.md``.
"""
from __future__ import annotations
from... | 300 | 10,548 |
scikit-bio | skbio/stats/ordination/tests/test_util.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.
# --------------------------------------------... | 128 | 4,845 |
mlflow | tests/tracking/fluent/test_create_experiment_trace_location.py | .py | from unittest import mock
import pytest
import mlflow
import mlflow.tracking.fluent as fluent_module
from mlflow.entities import Experiment
from mlflow.entities.experiment_tag import ExperimentTag
from mlflow.entities.trace_location import UnityCatalog
from mlflow.exceptions import MlflowException
def _experiment(e... | 142 | 4,872 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_fused_adam_cpu_fallback.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Unit tests for FusedAdam CPU fallback (issue #17403).
These tests patch torch.cuda.is_available to return False so they run
deterministically on both CPU-only and CUDA machines.
Import strategy:
* Load ``_multi_tensor_a... | 212 | 9,501 |
readthedocs.org | docs/_ext/djangodocs.py | .py | def setup(app):
app.add_crossref_type(
directivename="setting",
rolename="setting",
indextemplate="pair: %s; setting",
)
return {
"version": "builtin",
"parallel_read_safe": True,
"parallel_write_safe": True,
}
| 13 | 276 |
saleor | saleor/graphql/checkout/tests/mutations/test_checkout_complete.py | .py | from datetime import timedelta
from unittest import mock
import graphene
import pytest
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from prices import Money, TaxedMoney
from .....checkout import calculations
from .....checkout.error_codes import Checkou... | 839 | 27,811 |
lemur | lemur/api_keys/schemas.py | .py | """
.. module: lemur.api_keys.schemas
:platform: Unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Eric Coan <kungfury@instructure.com>
"""
from flask import g
from marshmallow import fields
from lemur.common.schema import Lemu... | 64 | 1,832 |
wagtail | wagtail/tests/test_views.py | .py | from unittest import mock
from django.test import TestCase
from django.urls import reverse
from wagtail.coreutils import get_dummy_request
from wagtail.models import Site
from wagtail.test.testapp.models import SimplePage
from wagtail.test.utils import Page, PageFixturesMixin, WagtailTestUtils
from wagtail.views impo... | 101 | 4,056 |
wagtail | wagtail/users/models.py | .py | import os
import uuid
from django.conf import settings
from django.db import models
from django.utils.translation import get_language
from django.utils.translation import gettext_lazy as _
from wagtail.admin.localization import get_available_admin_languages
def upload_avatar_to(instance, filename):
filename, ex... | 138 | 4,226 |
wagtail | wagtail/admin/views/pages/ordering.py | .py | import swapper
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from django.views import View
Page = swapper.load_model("wagtailcore", "Page")
class SetPagePositionView(View):
def post(self, request, page_to_move_id, *args, **... | 47 | 1,743 |
wandb | wandb/sdk/lib/proto_util.py | .py | #
from __future__ import annotations
import json
from typing import TYPE_CHECKING, Any
from wandb.proto import wandb_internal_pb2 as pb
if TYPE_CHECKING: # pragma: no cover
from google.protobuf.internal.containers import RepeatedCompositeFieldContainer
from google.protobuf.message import Message
from w... | 85 | 2,684 |
openvino | docs/optimization_guide/nncf/ptq/code/ptq_torch_fx.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#! [dataset]
import nncf
import torch
calibration_loader = torch.utils.data.DataLoader(...)
def transform_fn(data_item):
images, _ = data_item
return images
calibration_dataset = nncf.Dataset(calibration_loader, transform_fn)
... | 42 | 1,197 |
pyro | tests/distributions/test_shapes.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
import pyro.distributions as dist
def test_categorical_shape():
probs = torch.ones(3, 2) / 2
d = dist.Categorical(probs)
assert d.batch_shape == (3,)
assert d.event_shape == ()
assert d.shape() =... | 96 | 2,509 |
openvino | tests/layer_tests/pytorch_tests/test_and.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestAnd(PytorchLayerTest):
def _prepare_input(self):
return self.input_data
def create_model_tensor_input(self)... | 84 | 2,882 |
mlflow | tests/server/auth/test_issue_authorization.py | .py | # Unit tests for the issue authorization validators' request-body handling.
import json
from types import SimpleNamespace
import flask
import mlflow.server.auth as a
def _run(monkeypatch, validator, body, *, can_update=False, can_read=False):
monkeypatch.setattr(a, "authenticate_request", lambda: SimpleNamespa... | 41 | 1,786 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.