repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
mlflow | tests/telemetry/helper_functions.py | .py | import json
from typing import Any
def validate_telemetry_record(
mock_telemetry_client,
mock_requests,
event_name: str,
params=None,
*,
status="success",
search_index=True,
check_params=True,
) -> dict[str, Any]:
"""
Validate the telemetry record at the given index.
"""
... | 40 | 1,059 |
onnxruntime | onnxruntime/python/tools/transformers/models/stable_diffusion/engine_builder_ort_cuda.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import gc
import logging
import os
import onnx
import torch
from diffu... | 388 | 15,854 |
pyomo | pyomo/common/tests/test_download.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... | 331 | 12,453 |
beam | sdks/python/apache_beam/examples/inference/milk_quality_prediction_windowing.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... | 241 | 8,561 |
kombu | kombu/asynchronous/hub.py | .py | """Event loop implementation."""
from __future__ import annotations
import errno
import threading
from contextlib import contextmanager
from copy import copy
from queue import Empty
from time import sleep
from types import GeneratorType as generator
from vine import Thenable, promise
from kombu.log import get_logge... | 404 | 12,091 |
scikit-optimize | skopt/tests/test_optimizer.py | .py | import numpy as np
import pytest
from sklearn.multioutput import MultiOutputRegressor
from numpy.testing import assert_array_equal
from numpy.testing import assert_equal
from numpy.testing import assert_raises
from skopt import gp_minimize
from skopt import forest_minimize
from skopt.benchmarks import bench1, bench1_... | 403 | 13,909 |
onnxruntime | onnxruntime/python/tools/transformers/models/t5/t5_decoder.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 ... | 438 | 16,751 |
probability | tensorflow_probability/python/mcmc/random_walk_metropolis.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... | 570 | 21,534 |
onnxruntime | onnxruntime/test/python/transformers/test_parity_linear_attention_causal_conv.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import unittest
import numpy as np
import torch
from onnx import TensorProto, checker, helper
import onnxruntime
onnxruntime.preload_dlls()
def _has_cuda_ep() -> bool:
return "CUDAExecutionProvider" in onnxruntime.ge... | 571 | 23,036 |
pyro | tests/ops/test_indexing.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import itertools
import pytest
import torch
import pyro.distributions as dist
from pyro.distributions.util import broadcast_shape
from pyro.ops.indexing import Index, Vindex
from tests.common import assert_equal
class TensorMoc... | 170 | 6,117 |
sqlmap | plugins/dbms/altibase/__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 ALTIBASE_SYSTEM_DBS
from lib.core.unescaper import unescaper
from plugins.dbms.altibase.enumeration import Enumerati... | 31 | 929 |
mlflow | mlflow/entities/multipart_upload.py | .py | from dataclasses import dataclass
from typing import Any
from mlflow.protos.mlflow_artifacts_pb2 import (
CreateMultipartUpload as ProtoCreateMultipartUpload,
)
from mlflow.protos.mlflow_artifacts_pb2 import (
MultipartUploadCredential as ProtoMultipartUploadCredential,
)
@dataclass
class MultipartUploadPart... | 75 | 1,923 |
onnx | tests/python/training_tool_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx import TensorProto, helper, numpy_helper, shape_inference
class TestTrainingTool:
def test_training_info_proto(self) -> None:
# Inference graph.
... | 96 | 3,626 |
textual | src/textual/_resolve.py | .py | from __future__ import annotations
from fractions import Fraction
from itertools import accumulate
from typing import TYPE_CHECKING, Iterable, Sequence, cast
from typing_extensions import Literal
from textual.box_model import BoxModel
from textual.css.scalar import Scalar
from textual.css.styles import RenderStyles
... | 348 | 11,050 |
mlflow | mlflow/entities/mcp_server.py | .py | from __future__ import annotations
import re
from dataclasses import dataclass, field
from enum import Enum
from typing import TYPE_CHECKING, Any
from mlflow.exceptions import MlflowException
from mlflow.utils.annotations import experimental
from mlflow.utils.workspace_utils import resolve_entity_workspace_name
if T... | 195 | 6,909 |
onnxruntime | docs/python/conf.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# pylint: disable=C0103
"""Configuration file for the Sphinx documentation builder."""
import os
import shutil
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "_common"))
# import recommonmark
# -... | 142 | 4,616 |
saleor | saleor/graphql/discount/tests/queries/test_sale.py | .py | import graphene
from saleor.discount import DiscountValueType
from ....tests.utils import (
assert_no_permission,
get_graphql_content,
get_graphql_content_from_response,
)
QUERY_SALE_BY_ID = """
query Sale($id: ID!, $channel: String) {
sale(id: $id, channel: $channel) {
id
... | 220 | 6,466 |
mlflow | tests/genai/test_mcp_servers.py | .py | from __future__ import annotations
import json
import urllib.request
from pathlib import Path
from unittest import mock
import pytest
from mlflow import genai
from mlflow.entities.mcp_server import MCPRemoteTransportType, MCPStatus, MCPTool
from mlflow.exceptions import MlflowException
from mlflow.genai.mcp_tool_dis... | 1,273 | 47,638 |
probability | tensorflow_probability/python/experimental/mcmc/progress_bar_reducer_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... | 72 | 2,654 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_attention_unet.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
import numpy as np
from fusion_base impor... | 1,308 | 55,648 |
conda | tests/models/test_match_spec.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from conda.base.constants import CONDA_PACKAGE_EXTENSION_V1, CONDA_PACKAGE_EXTENSION_V2
if TYPE_CHECKING:
from pytest_benchmark.fixture import BenchmarkFix... | 2,222 | 75,723 |
beam | sdks/python/apache_beam/transforms/external_java.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... | 190 | 7,052 |
sphinx | tests/roots/test-root/parsermod.py | .py | from docutils import nodes
from docutils.parsers import Parser
class Parser(Parser):
supported = ('foo',)
def parse(self, input, document):
section = nodes.section(ids=['id1'])
section += nodes.title('Generated section', 'Generated section')
document += section
def get_transforms... | 15 | 346 |
wagtail | wagtail/admin/tests/pages/test_copy_page.py | .py | from django.contrib.auth.models import Group, Permission
from django.http import HttpRequest, HttpResponse
from django.test import TestCase
from django.urls import reverse
from wagtail.models import GroupPagePermission
from wagtail.test.testapp.models import (
CustomCopyFormPage,
EventPage,
EventPageSpeake... | 1,215 | 45,272 |
mlflow | examples/llama_index/workflow/workflow/workflow.py | .py | import os
import qdrant_client
from llama_index.core import Settings, VectorStoreIndex
from llama_index.core.schema import NodeWithScore
from llama_index.core.workflow import Context, StartEvent, StopEvent, Workflow, step
from llama_index.postprocessor.rankgpt_rerank import RankGPTRerank
from llama_index.retrievers.bm... | 149 | 6,387 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_map_fn.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
rng = np.random.default_rng()
def fn_1(x):
return (x[0] * x[1] + x[2])
def fn_2(x):
return (x[0] + x[1] + x[... | 173 | 6,700 |
wandb | wandb/integration/sklearn/calculate/learning_curve.py | .py | from warnings import simplefilter
import numpy as np
from sklearn import model_selection
import wandb
from wandb.integration.sklearn import utils
# ignore all future warnings
simplefilter(action="ignore", category=FutureWarning)
def learning_curve(
model,
X, # noqa: N803
y,
cv=None,
shuffle=Fa... | 65 | 1,728 |
probability | tensorflow_probability/python/distributions/poisson_lognormal_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... | 169 | 6,545 |
pyro | pyro/distributions/transforms/__init__.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
# Import * to get the latest upstream transforms.
from torch.distributions.transforms import * # noqa F403
# Additionally try to import explicitly to help mypy static analysis.
try:
from torch.distributions.transforms import ... | 268 | 8,118 |
pyomo | scripts/performance/compare.py | .py | #!/usr/bin/env python
# ____________________________________________________________________________________
#
# 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 Engi... | 335 | 10,851 |
hatch | backend/src/hatchling/metadata/utils.py | .py | from __future__ import annotations
import re
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from packaging.requirements import Requirement
from hatchling.metadata.core import ProjectMetadata
# NOTE: this module should rarely be changed because it is likely to be used by other packages like Hatch
... | 88 | 3,440 |
probability | tensorflow_probability/python/experimental/mcmc/potential_scale_reduction_reducer_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... | 113 | 4,793 |
mlflow | tests/gateway/providers/test_huggingface.py | .py | from unittest import mock
import pytest
from aiohttp import ClientTimeout
from fastapi.encoders import jsonable_encoder
from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS
from mlflow.gateway.config import EndpointConfig
from mlflow.gateway.exceptions import AIGatewayException
from mlflow.ga... | 172 | 5,957 |
onnxruntime | onnxruntime/python/tools/transformers/models/torch_export_patches/onnx_export_errors.py | .py | import contextlib
import pprint
from collections.abc import Callable
from typing import Any
from .onnx_export_serialization import (
flatten_dynamic_cache,
flatten_mamba_cache,
flatten_with_keys_dynamic_cache,
flatten_with_keys_mamba_cache,
unflatten_dynamic_cache,
unflatten_mamba_cache,
)
from... | 472 | 18,236 |
mlflow | mlflow/genai/judges/prompts/conversational_role_adherence.py | .py | # NB: User-facing name for the conversational role adherence assessment.
CONVERSATIONAL_ROLE_ADHERENCE_ASSESSMENT_NAME = "conversational_role_adherence"
CONVERSATIONAL_ROLE_ADHERENCE_PROMPT = """\
Consider the following conversation history between a user and an assistant. \
Your task is to evaluate whether the assist... | 31 | 2,069 |
sphinx | tests/roots/test-ext-autodoc/target/module.py | .py | undocumented = 1
#: docstring
documented = 1
undoc_annotated: int
#: docstring
annotated: int
__special__ = 1
#: docstring
__documented_special__ = 1
| 15 | 155 |
mlflow | examples/model_config/model.py | .py | from mlflow.models import ModelConfig, set_model
def predict(model_input):
model_config = ModelConfig()
timeout = model_config.get("timeout")
return [timeout] * len(model_input)
set_model(predict)
| 11 | 213 |
probability | tensorflow_probability/python/math/psd_kernels/matern.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... | 518 | 21,618 |
metrics | tests/unittests/text/test_wip.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... | 71 | 2,567 |
clearml | setup.py | .py | """
ClearML Inc
https://github.com/clearml/clearml
"""
import os.path
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
import codecs
def read_text(filepath):
with codecs.open(filepath, "r", encoding="utf-8") as f:
return f.read()
here = os.path.dirname(__file__)
# G... | 116 | 4,238 |
readthedocs.org | readthedocs/gold/signals.py | .py | """Gold model signals."""
from django.db.models.signals import pre_delete
from django.dispatch import receiver
from readthedocs.payments import utils
from .models import GoldUser
@receiver(pre_delete, sender=GoldUser)
def delete_customer(sender, instance, **__):
"""On Gold subscription deletion, remove the cus... | 18 | 567 |
clearml | clearml/logger.py | .py | import logging
import math
import warnings
from typing import Sequence, Union, List, Optional, Tuple, Dict, TYPE_CHECKING, Any
import numpy as np
import six
from PIL import Image
from pathlib2 import Path
from .debugging.log import LoggerRoot
try:
import pandas as pd
except ImportError:
pd = None
from .back... | 1,671 | 66,503 |
tqdm | tests/tests_version.py | .py | """Test `tqdm.__version__`."""
import re
from ast import literal_eval
def test_version():
"""Test version string"""
from tqdm import __version__
version_parts = re.split('[.-]', __version__)
if __version__ != "UNKNOWN":
assert 3 <= len(version_parts), "must have at least Major.minor.patch"
... | 15 | 467 |
onnx | onnx/backend/test/case/node/squeeze.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Squeeze(Base):
@staticmethod
def export_squeeze() -> None:
... | 38 | 1,087 |
saleor | saleor/payment/__init__.py | .py | from enum import Enum
class PaymentError(Exception):
def __init__(self, message, code=None):
super().__init__(message, code)
self.message = message
self.code = code
def __str__(self):
return self.message
class GatewayError(IOError):
pass
class TransactionItemIdempotenc... | 306 | 9,624 |
clearml | clearml/utilities/pyhocon/config_parser.py | .py | import itertools
import re
import os
import socket
import contextlib
import codecs
from datetime import timedelta
from pyparsing import Forward, Keyword, QuotedString, Word, Literal, Suppress, Regex, Optional, SkipTo, ZeroOrMore, \
Group, lineno, col, TokenConverter, replaceWith, alphanums, alphas8bit, ParseSyntax... | 763 | 32,918 |
sqlmap | tests/test_safe2bin.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
safecharencode / safechardecode (lib/utils/safe2bin.py).
These make extracted DB values safe to print/store by escaping control and
non-printable characters (tab -> \\t, NUL -> \\x00... | 61 | 1,974 |
onnxruntime | onnxruntime/test/python/transformers/test_group_norm.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 s... | 541 | 16,637 |
mlflow | tests/genai/scorers/test_scorer_telemetry.py | .py | import asyncio
import json
import threading
from typing import Callable
from unittest import mock
import pytest
from pydantic import PrivateAttr
from mlflow.entities import Feedback
from mlflow.genai.scorers import scorer
from mlflow.genai.scorers.base import Scorer
from mlflow.telemetry.client import TelemetryClient... | 310 | 9,697 |
wagtail | wagtail/actions/revert_to_page_revision.py | .py | from wagtail.actions.revert_to_revision import (
RevertToRevisionAction,
RevertToRevisionPermissionError,
)
class RevertToPageRevisionError(RuntimeError):
"""
Raised when the revision revert cannot be performed for data reasons.
"""
pass
class RevertToPageRevisionPermissionError(RevertToRev... | 39 | 1,098 |
pyomo | pyomo/solvers/plugins/solvers/BARON.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... | 554 | 22,991 |
saleor | saleor/graphql/payment/mutations/payment/payment_check_balance.py | .py | import graphene
from django.core.exceptions import ValidationError
from .....payment import PaymentError
from .....payment.error_codes import PaymentErrorCode
from .....payment.gateway import get_payment_gateways, is_currency_supported
from ....channel.utils import validate_channel
from ....core import ResolveInfo
fro... | 122 | 4,412 |
black | tests/data/cases/pep_572_py39.py | .py | # Unparenthesized walruses are now allowed in set literals & set comprehensions
# since Python 3.9
{x := 1, 2, 3}
{x4 := x**5 for x in range(7)}
# We better not remove the parentheses here (since it's a 3.10 feature)
x[(a := 1)]
x[(a := 1), (b := 3)]
| 8 | 251 |
sqlmap | lib/utils/safe2bin.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import binascii
import re
import string
import sys
PY3 = sys.version_info >= (3, 0)
try:
# Py2
text_type = unicode
string_types = (basestring,)
except NameError:
... | 114 | 3,681 |
sqlmap | tamper/space2mssqlblank.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import os
import random
from lib.core.common import singleTimeWarnMessage
from lib.core.compat import xrange
from lib.core.enums import DBMS
from lib.core.enums import PRIORITY
... | 90 | 2,666 |
pyomo | pyomo/gdp/tests/models.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,603 | 50,165 |
probability | tensorflow_probability/python/experimental/fastgp/preconditioners_test.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... | 701 | 23,355 |
saleor | saleor/tests/e2e/promotions/utils/promotion_create.py | .py | from ...utils import get_graphql_content
PROMOTION_CREATE_MUTATION = """
mutation CreatePromotion($input: PromotionCreateInput!) {
promotionCreate(input: $input) {
errors {
message
field
code
}
promotion {
id
name
type
startDate
endDate
description
... | 109 | 2,050 |
readthedocs.org | readthedocs/rtd_tests/tests/test_redirects.py | .py | from django.test import TestCase
from django.test.utils import override_settings
from django_dynamic_fixture import fixture, get
from readthedocs.builds.constants import LATEST
from readthedocs.projects.constants import SINGLE_VERSION_WITHOUT_TRANSLATIONS
from readthedocs.projects.models import Project
from readthedoc... | 185 | 5,798 |
pdm | tests/cli/test_init.py | .py | import argparse
import sys
from textwrap import dedent
from unittest.mock import ANY
import pytest
from pdm.cli.commands.init import Command
from pdm.compat import tomllib
from pdm.models.python import PythonInfo
from pdm.utils import cd
PYTHON_VERSION = f"{sys.version_info[0]}.{sys.version_info[1]}"
@pytest.fixtu... | 626 | 22,825 |
beam | sdks/python/apache_beam/coders/row_coder_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... | 517 | 19,475 |
saleor | saleor/graphql/product/tests/mutations/test_product_variant_set_default.py | .py | import graphene
from .....graphql.tests.utils import get_graphql_content
from .....product.error_codes import ProductErrorCode
PRODUCT_VARIANT_SET_DEFAULT_MUTATION = """
mutation Prod($productId: ID!, $variantId: ID!) {
productVariantSetDefault(productId: $productId, variantId: $variantId) {
p... | 106 | 3,509 |
mlflow | mlflow/projects/__init__.py | .py | """
The ``mlflow.projects`` module provides an API for running MLflow projects locally or remotely.
"""
import json
import logging
import os
import yaml
import mlflow.projects.databricks
from mlflow import tracking
from mlflow.entities import RunStatus
from mlflow.exceptions import ExecutionException, MlflowExceptio... | 448 | 17,350 |
probability | tensorflow_probability/python/internal/backend/numpy/type_spec.py | .py | # Copyright 2021 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... | 29 | 845 |
mlflow | tests/haystack/test_haystack_tracing.py | .py | import sys
from unittest.mock import patch
import pytest
from haystack import Document, Pipeline, component
from haystack.components.rankers import LostInTheMiddleRanker
from haystack.components.retrievers import InMemoryBM25Retriever
from haystack.document_stores.in_memory import InMemoryDocumentStore
import mlflow
... | 228 | 7,342 |
metrics | src/torchmetrics/functional/classification/negative_predictive_value.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... | 420 | 20,655 |
scikit-bio | skbio/stats/composition/tests/test_utils.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.
# --------------------------------------------... | 324 | 12,346 |
mlflow | tests/prophet/test_prophet_model_export.py | .py | import json
import os
from datetime import date, datetime, timedelta
from pathlib import Path
from typing import Any, NamedTuple
from unittest import mock
import numpy as np
import pandas as pd
import prophet
import pytest
import yaml
from packaging.version import Version
from prophet import Prophet
import mlflow
imp... | 509 | 18,892 |
onnx | onnx/reference/ops/op_pow.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from warnings import catch_warnings, simplefilter
import numpy as np
from onnx.reference.op_run import OpRun
class Pow(OpRun):
def _run(self, a, b):
with catch_warnings():
sim... | 18 | 393 |
pyomo | examples/pyomobook/abstract-ch/param3b.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... | 35 | 1,143 |
ipython | IPython/testing/plugin/test_ipdoctest.py | .py | """Tests for the ipdoctest machinery itself.
Note: in a file named test_X, functions whose only test is their docstring (as
a doctest) and which have no test functionality of their own, should be called
'doctest_foo' instead of 'test_foo', otherwise they get double-counted (the
empty function call is counted as a test... | 93 | 1,884 |
openvino | src/bindings/python/docs/examples/openvino/mymodule/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from .myclass import MyClass
| 6 | 136 |
metrics | tests/unittests/regression/test_minkowski_distance.py | .py | from functools import partial
import pytest
import torch
from scipy.spatial.distance import minkowski as scipy_minkowski
from torchmetrics.functional import minkowski_distance
from torchmetrics.regression import MinkowskiDistance
from torchmetrics.utilities.exceptions import TorchMetricsUserError
from unittests impor... | 98 | 3,673 |
hydra | plugins/hydra_colorlog/tests/test_colorlog.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
from pathlib import Path
from hydra import initialize
from hydra.core.global_hydra import GlobalHydra
from hydra.test_utils.test_utils import chdir_plugin_root, run_python_script
chdir_plugin_root()
def test_config_installed() -> None:... | 43 | 1,378 |
jupytext | tests/data/notebooks/outputs/ipynb_to_sphinx/text_outputs_and_images.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
"""
This notebook contains outputs of many different types: text, HTML, plots and errors.
"""
###############################################################################
# # Text outputs
#
# Using `print... | 71 | 1,470 |
metrics | src/torchmetrics/utilities/exceptions.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... | 22 | 830 |
qutip | qutip/tests/core/data/test_mathematics.py | .py | import itertools
import numpy as np
import pytest
import scipy
import warnings
from qutip.core import data
from qutip.core.data import Data, Dense, CSR, Dia
from qutip.core.data.dense import OrderEfficiencyWarning
from . import conftest
# The ParameterSet is actually a pretty hidden type, so it's easiest to access
#... | 1,247 | 45,538 |
probability | tensorflow_probability/python/distributions/triangular.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... | 301 | 11,320 |
saleor | saleor/account/signals.py | .py | from ..core.tasks import delete_from_storage_task
def delete_avatar(sender, instance, **kwargs):
if avatar := instance.avatar:
delete_from_storage_task.delay(avatar.name)
| 7 | 185 |
textual | src/textual/_profile.py | .py | """
Timer context manager, only used in debug.
"""
import contextlib
from time import perf_counter
from typing import Generator
from textual import log
@contextlib.contextmanager
def timer(subject: str = "time", threshold: float = 0) -> Generator[None, None, None]:
"""print the elapsed time. (only used in debug... | 27 | 641 |
scikit-bio | skbio/io/format/tests/test_sequence_feature_vocabulary.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.
# --------------------------------------------... | 121 | 4,598 |
saleor | saleor/warehouse/tests/test_preorder_reservations_management.py | .py | import datetime
from decimal import Decimal
import pytest
from django.utils import timezone
from ...checkout.models import Checkout
from ...core.exceptions import InsufficientStock
from ...product.models import ProductVariantChannelListing
from ..models import PreorderAllocation, PreorderReservation
from ..reservatio... | 286 | 9,186 |
probability | tensorflow_probability/python/sts/regularization.py | .py | # Copyright 2021 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... | 285 | 12,469 |
readthedocs.org | readthedocs/builds/forms.py | .py | """Django forms for the builds app."""
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML
from crispy_forms.layout import Fieldset
from crispy_forms.layout import Layout
from django import forms
from django.conf import settings
from django.template.loader import render_to_string
from djang... | 122 | 4,488 |
onnx | onnx/reference/ops/op_sub.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._op import OpRunBinaryNumpy
class Sub(OpRunBinaryNumpy):
def __init__(self, onnx_node, run_params):
OpRunBinaryNumpy.__init__(self, np.subtract, ... | 14 | 343 |
astropy | astropy/visualization/mpl_style.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module contains dictionaries that can be used to set a matplotlib
# plotting style. It is no longer documented/recommended as of Astropy v3.0
# but is kept here for backward-compatibility.
__all__ = ["astropy_mpl_style", "astropy_mpl_style_1"]
# ... | 79 | 2,122 |
textual | tests/tree/test_tree_get_node_by_id.py | .py | from typing import cast
import pytest
from textual.widgets import Tree
from textual.widgets.tree import NodeID, UnknownNodeID
async def test_get_tree_node_by_id() -> None:
"""It should be possible to get a TreeNode by its ID."""
tree = Tree[None]("Anakin")
child = tree.root.add("Leia")
grandchild = ... | 19 | 626 |
pyomo | pyomo/contrib/sensitivity_toolbox/sens.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 | 28,489 |
pymc | pymc/distributions/shape_utils.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... | 493 | 16,908 |
cvxpy | cvxpy/tests/test_param_quad_prog.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
... | 187 | 7,735 |
astropy | astropy/io/ascii/tests/test_ipac_definitions.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import re
from io import StringIO
import pytest
from astropy.io import ascii
from astropy.io.ascii.core import masked
from astropy.io.ascii.ipac import IpacFormatError, IpacFormatErrorDBMS
from astropy.io.ascii.ui import read
from astropy.table import C... | 170 | 4,596 |
beam | sdks/python/apache_beam/io/external/xlang_jmsio_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... | 384 | 13,139 |
saleor | saleor/graphql/giftcard/mutations/gift_card_unassign_user.py | .py | import graphene
from django.core.exceptions import ValidationError
from ....core.tracing import traced_atomic_transaction
from ....core.utils.events import call_event
from ....giftcard import events
from ....giftcard.error_codes import GiftCardErrorCode
from ....permission.enums import GiftcardPermissions
from ....web... | 71 | 2,714 |
clearml | examples/frameworks/pytorch/pytorch_matplotlib.py | .py | # ClearML - Example of Pytorch and matplotlib integration and reporting
#
"""
Neural Transfer Using PyTorch
=============================
**Author**: `Alexis Jacq <https://alexis-jacq.github.io>`_
**Edited by**: `Winston Herring <https://github.com/winston6>`_
Introduction
------------
This tutorial explains how to im... | 484 | 19,642 |
readthedocs.org | readthedocs/organizations/signals.py | .py | """Organization signals."""
import structlog
from allauth.account.signals import user_signed_up
from django.db.models.signals import post_save
from django.db.models.signals import pre_delete
from django.dispatch import receiver
from djstripe.enums import SubscriptionStatus
from readthedocs.builds.constants import BUI... | 82 | 2,696 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_1d_transpose.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 TestKerasConv1DTranspose(CommonTF2LayerTest):
def create_keras_conv1d_transpose_net(self, params, input_names, input_shapes, in... | 71 | 3,568 |
metrics | src/torchmetrics/functional/classification/matthews_corrcoef.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... | 298 | 12,855 |
readthedocs.org | readthedocs/gold/__init__.py | .py | """
A Django app for Gold membership.
Gold membership is Read the Docs' program for recurring, monthly donations.
"""
| 6 | 119 |
saleor | saleor/graphql/order/tests/mutations/test_order_line_delete.py | .py | from unittest.mock import ANY, patch
import graphene
import pytest
from django.db.models import Sum
from django.test import override_settings
from .....core.models import EventDelivery
from .....order import OrderStatus
from .....order import events as order_events
from .....order.error_codes import OrderErrorCode
fr... | 425 | 14,054 |
openvino | src/bindings/python/src/openvino/properties/intel_auto/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# Enums
from openvino._pyopenvino.properties.intel_auto import SchedulePolicy
# Properties
import openvino._pyopenvino.properties.intel_auto as __intel_auto
from openvino.properties._properties import __make_prop... | 13 | 370 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.