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 |
|---|---|---|---|---|---|
confluent-kafka-python | tests/schema_registry/_sync/test_json.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2023 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... | 199 | 6,743 |
luigi | test/server_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... | 524 | 21,523 |
pyomo | doc/OnlineDocs/src/data/set4.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... | 21 | 734 |
python-prompt-toolkit | src/prompt_toolkit/application/run_in_terminal.py | .py | """
Tools for running functions on the terminal above the current application or prompt.
"""
from __future__ import annotations
from asyncio import Future, ensure_future
from collections.abc import AsyncGenerator, Awaitable, Callable
from contextlib import asynccontextmanager
from typing import TypeVar
from prompt_t... | 119 | 3,794 |
mlflow | tests/tracking/test_client_webhooks.py | .py | from pathlib import Path
from typing import Iterator
import pytest
from cryptography.fernet import Fernet
from mlflow.entities.webhook import WebhookAction, WebhookEntity, WebhookEvent, WebhookStatus
from mlflow.environment_variables import MLFLOW_WEBHOOK_SECRET_ENCRYPTION_KEY
from mlflow.exceptions import MlflowExce... | 218 | 8,862 |
mlflow | mlflow/johnsnowlabs/__init__.py | .py | """
The ``mlflow.johnsnowlabs`` module provides an API for logging and loading Spark NLP and NLU models.
This module exports the following flavors:
Johnsnowlabs (native) format
Allows models to be loaded as Spark Transformers for scoring in a Spark session.
Models with this flavor can be loaded as NluPipelines... | 892 | 34,834 |
onnx | onnx/reference/ops/op_negative_log_likelihood_loss.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
def _compute_negative_log_likelihood_loss(
x, target, weight=None, reduction="mean", ignore_index=None
):
input_shape = x.shape
i... | 85 | 2,902 |
scikit-bio | skbio/io/_iosources.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.
# --------------------------------------------... | 256 | 6,734 |
openvino | tests/model_hub_tests/transformation_tests/test_moe_transformation.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from huggingface_hub import snapshot_download
from optimum.intel import OVModelForCausalLM
import openvino as ov
from models_hub_common.utils import retry
import models_hub_common.utils as utils
import pytest
import os
from transformers ... | 362 | 15,028 |
saleor | saleor/page/tests/test_search.py | .py | import pytest
from ...attribute.models import AttributeValue
from ...attribute.utils import associate_attribute_values_to_instance
from ..models import Page
from ..search import (
update_pages_search_vector,
)
def test_update_pages_search_vector_multiple_pages(page_list):
"""Test updating search vector for m... | 125 | 4,024 |
mlflow | tests/server/jobs/test_endpoint.py | .py | import os
import signal
import subprocess
import sys
import time
from typing import Any
import pytest
import requests
import mlflow
from mlflow.server.jobs import job
pytestmark = pytest.mark.skipif(
os.name == "nt", reason="MLflow job execution is not supported on Windows"
)
@job(name="simple_job_fun", max_wo... | 362 | 11,051 |
saleor | saleor/graphql/order/tests/mutations/test_order_void.py | .py | from unittest.mock import patch
import graphene
from .....order import events as order_events
from .....order.error_codes import OrderErrorCode
from .....payment import ChargeStatus
from .....plugins.manager import PluginsManager
from ....payment.types import PaymentChargeStatusEnum
from ....tests.utils import assert... | 123 | 4,112 |
pyomo | pyomo/contrib/interior_point/interface.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... | 649 | 18,762 |
saleor | saleor/core/cleaners/html.py | .py | import json
import os
from copy import deepcopy
from dataclasses import dataclass, field
from typing import Self
import nh3
@dataclass
class HtmlCleanerSettings:
allowed_attributes: dict[str, set[str]] = field(
default_factory=lambda: deepcopy(nh3.ALLOWED_ATTRIBUTES)
)
# NOTE: nh3 doesn't expose... | 60 | 2,335 |
kafka | tests/kafkatest/tests/streams/streams_static_membership_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 ... | 468 | 18,971 |
loguru | tests/exceptions/source/modern/grouped_max_depth.py | .py | from loguru import logger
import sys
@logger.catch
def main():
nesting_left = ValueError("Left")
for i in range(100):
nesting_left = ExceptionGroup("group", [ValueError(-i), nesting_left])
nesting_right = ValueError("Right")
for i in range(100):
nesting_right = ExceptionGroup("group",... | 27 | 780 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_FakeQuantize.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from common.tf_layer_test_class import CommonTFLayerTest
class TestFakeQuantize(CommonTFLayerTest):
def _prepare_input(self, inputs_dict, kwargs):
assert len(inputs_dict) == 1
assert... | 109 | 5,446 |
beam | sdks/python/apache_beam/options/pipeline_options_context_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... | 336 | 12,136 |
mlflow | tests/evaluate/logging/utils.py | .py | import pandas as pd
from mlflow.evaluation.evaluation import EvaluationEntity as EvaluationEntity
from mlflow.evaluation.utils import (
_get_assessments_dataframe_schema,
_get_evaluations_dataframe_schema,
_get_metrics_dataframe_schema,
_get_tags_dataframe_schema,
)
from mlflow.exceptions import Mlflow... | 227 | 7,637 |
astropy | astropy/modeling/tests/test_model_sets.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module tests model set evaluation and fitting for some common use cases.
"""
import numpy as np
# pylint: disable=invalid-name
import pytest
from numpy.testing import assert_allclose
from astropy.modeling.core import Model
from astropy.modeling... | 603 | 19,353 |
metrics | examples/text/bertscore.py | .py | """BERTScore
===============================
BERTScore is a text generation metric to compute the similarity between a generated text and a reference text using a pre-trained BERT model. Instead of relying on exact token matches, BERTScore leverages contextual embeddings to capture the semantic similarity between the ... | 54 | 3,090 |
black | tests/data/cases/unstable_comment_on_optional_parens.py | .py | # Regression for https://github.com/psf/black/issues/3701
# Inline comment on optional parentheses must not migrate across formatter passes.
assert some_long_name, ( # long __________________________ comment
'long ___________________________________ string %s' % str(variable))
# Related case from https://git... | 28 | 1,058 |
mlflow | tests/store/artifact/test_ftp_artifact_repo.py | .py | import ftplib
import posixpath
from ftplib import FTP
from unittest.mock import MagicMock
import pytest
from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository
from mlflow.store.artifact.ftp_artifact_repo import FTPArtifactRepository
@pytest.fixture
def ftp_mock():
return MagicMoc... | 423 | 13,952 |
wagtail | wagtail/snippets/views/chooser.py | .py | from django.utils.translation import gettext_lazy as _
from wagtail.admin.ui.tables import LiveStatusTagColumn
from wagtail.admin.views.generic.chooser import (
BaseChooseView,
ChooseResultsViewMixin,
ChooseViewMixin,
ChosenMultipleView,
ChosenView,
CreateView,
CreationFormMixin,
)
from wag... | 103 | 3,076 |
openvino | src/bindings/python/tests/test_graph/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# openvino.dll directory path visibility is needed to use _pyopenvino module
# import below causes adding this path to os.environ["PATH"]
import openvino # noqa: F401 'imported but unused'
| 8 | 297 |
saleor | saleor/graphql/product/tests/queries/variants_where/test_over_references_products.py | .py | import graphene
import pytest
from ......attribute import AttributeEntityType, AttributeInputType, AttributeType
from ......attribute.models import Attribute, AttributeValue
from ......attribute.utils import associate_attribute_values_to_instance
from ......product.models import Product
from .....core.utils import to_... | 347 | 11,107 |
mlflow | tests/deployments/test_interface.py | .py | import pytest
import mlflow.deployments.utils
from mlflow.deployments.interface import get_deploy_client
mlflow.deployments.utils._deployments_target = None
def test_get_deploy_client_no_args():
mlflow.deployments.utils._deployments_target = None
assert get_deploy_client() is None
def test_get_deploy_clie... | 33 | 866 |
flit | tests/test_sdist.py | .py | import ast
from os.path import join as pjoin
from pathlib import Path
import pytest
from shutil import which, copytree
import sys
import tarfile
from tempfile import TemporaryDirectory
from testpath import assert_isfile, MockCommand
from flit import sdist, common
samples_dir = Path(__file__).parent / 'samples'
def t... | 95 | 2,846 |
onnxruntime | tools/python/dump_subgraphs.py | .py | import argparse
import os
import onnx
def export_and_recurse(node, attribute, output_dir, level):
name = node.name
name = name.replace("/", "_")
sub_model = onnx.ModelProto()
sub_model.graph.MergeFrom(attribute.g)
filename = "L" + str(level) + "_" + node.op_type + "_" + attribute.name + "_" + nam... | 55 | 1,806 |
astropy | astropy/coordinates/builtin_frames/equatorial.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Coordinate frames tied to the Equator and Equinox of Earth.
TEME is a True equator, Mean Equinox coordinate frame used in NORAD TLE
satellite files.
TETE is a True equator, True Equinox coordinate frame often called the
"apparent" coordinates. It is ... | 118 | 4,865 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_range.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# range paddle model generator
#
import numpy as np
from save_model import saveModel
import sys
def paddle_range(name : str, x, start, end, step, out_type):
import paddle
paddle.enable_static()
with paddle.static.program... | 52 | 1,622 |
openvino | tests/e2e_tests/common/infer/common_inference.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Inference engine runners."""
# pylint:disable=import-error
import logging as log
import os
import platform
import sys
from pprint import pformat
import numpy as np
from e2e_tests.utils.test_utils import align_input_names, get_shapes_... | 247 | 10,016 |
openvino | src/bindings/python/tests/test_graph/test_basic.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import openvino.opset8 as ops
import openvino as ov
from openvino import (
Model,
Layout,
PartialShape,
RTMap,
Shape,
Strides,
Tensor,
Type,
... | 849 | 29,597 |
sqlmap | tamper/schemasplit.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.enums import PRIORITY
__priority__ = PRIORITY.HIGHEST
def dependencies():
pass
def tamper(payload, **kwargs):
"""
Splits FROM schema identi... | 32 | 752 |
biopython | Bio/KEGG/Compound/__init__.py | .py | # Copyright 2001 by Tarjei Mikkelsen. All rights reserved.
# Copyright 2007 by Michiel de Hoon. All rights reserved.
#
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been... | 181 | 5,470 |
readthedocs.org | readthedocs/organizations/models.py | .py | """Organizations models."""
from pathlib import Path
from uuid import uuid4
import structlog
from autoslug import AutoSlugField
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.fields import GenericRelation
from django.contrib.contenttypes.models import Con... | 526 | 15,567 |
coremltools | coremltools/proto/GLMClassifier_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: GLMClassifier.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import message as _message
fro... | 59 | 3,255 |
wagtail | wagtail/admin/checks.py | .py | import os
import swapper
from django.core.checks import Error, Tags, Warning, register
@register("staticfiles")
def css_install_check(app_configs, **kwargs):
errors = []
css_path = os.path.join(
os.path.dirname(__file__), "static", "wagtailadmin", "css", "core.css"
)
if not os.path.isfile(c... | 275 | 9,377 |
metrics | src/torchmetrics/clustering/adjusted_mutual_info_score.py | .py | # Copyright The Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 129 | 5,389 |
mlflow | tests/crewai/test_crewai_autolog.py | .py | import json
from unittest.mock import ANY, Mock, patch
import crewai
import pytest
from crewai import Agent, Crew, Task
from crewai.flow.flow import Flow, start
from crewai.tools import BaseTool
from packaging.version import Version
import mlflow
from mlflow.crewai.autolog import patched_class_call, patched_standalon... | 724 | 22,567 |
onnx | onnx/reference/ops/op_isnan.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 OpRunUnary
class IsNaN(OpRunUnary):
def _run(self, data):
return (np.isnan(data),)
| 14 | 269 |
clearml | clearml/utilities/wizard/user_input.py | .py | from typing import Optional, List, Tuple
def get_input(
key: str,
description: str = "",
question: str = "Enter",
required: bool = False,
default: Optional[str] = None,
new_line: bool = False,
) -> Optional[str]:
if new_line:
print()
while True:
value = input("{} {} {}:... | 104 | 2,971 |
astropy | astropy/table/table_helpers.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Helper functions for table development, mostly creating useful
tables for testing.
"""
import string
import warnings
from itertools import cycle
import numpy as np
from astropy.io.votable.table import parse
from astropy.utils.data import get_pkg_da... | 177 | 5,190 |
probability | tensorflow_probability/python/mcmc/internal/leapfrog_integrator.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... | 397 | 14,204 |
cvxpy | cvxpy/tests/test_cone2cone.py | .py | """
Copyright 2020, 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, ... | 1,349 | 53,266 |
coremltools | coremltools/optimize/torch/__init__.py | .py | # Copyright (c) 2024, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from coremltools.optimize.torch import (
base_model_optimizer,
layerwise_compression,
opt... | 18 | 482 |
hatch | tests/helpers/templates/wheel/standard_editable_exact_extra_dependencies.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 59 | 1,754 |
pyomo | pyomo/repn/tests/test_parameterized_standard_form.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... | 520 | 18,952 |
sqlmap | tests/test_ldap.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Offline, deterministic tests for the LDAP injection engine. Mock oracles stand in for the
HTTP/LDAP layer so detection, fingerprinting, blind inference, and output formatting can
be e... | 517 | 21,615 |
mkdocs-material | material/plugins/group/config.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... | 32 | 1,513 |
saleor | saleor/shipping/postal_codes.py | .py | import re
from typing import Any
from . import PostalCodeRuleInclusionType
def group_values(pattern, *values):
result: list[tuple[Any, ...] | None] = []
for value in values:
try:
val = re.match(pattern, value)
except TypeError:
result.append(None)
else:
... | 127 | 4,168 |
beam | sdks/python/apache_beam/examples/wordcount_debugging_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... | 69 | 2,451 |
rq | tests/test_fixtures.py | .py | from rq import Queue
from rq.connections import get_connection_kwargs
from tests import RQTestCase, fixtures
class TestFixtures(RQTestCase):
def test_rpush_fixture(self):
connection_kwargs = get_connection_kwargs(self.connection)
fixtures.rpush('foo', 'bar', connection_kwargs)
assert self.... | 18 | 680 |
coremltools | coremltools/test/optimize/torch/conftest.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 os
# Needed for test_compression_for_dkm_on_non_cpu_device_with_pcs that uses mps in test/con... | 120 | 3,361 |
jupyterlab | jupyterlab/tests/mock_packages/test_no_hyphens/test_no_hyphens/__init__.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
def _jupyter_labextension_paths():
return [{"src": "labextension", "dest": "test_no_hyphens"}]
| 7 | 202 |
probability | spinoffs/inference_gym/inference_gym/version.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... | 38 | 1,409 |
conda | conda/resolve.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Low-level SAT solver wrapper/interface for the classic solver.
See conda.core.solver.Solver for the high-level API.
"""
from __future__ import annotations
import itertools
from collections import defaultdict, deque
from functools import ca... | 1,697 | 69,688 |
jupytext | tests/data/notebooks/outputs/ipynb_to_hydrogen/Notebook_with_R_magic.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 2
# language: python
# name: python2
# ---
# %% [markdown]
# # A notebook with R cells
#
# This notebook shows the use of R cells to generate plots
# %%
%load_ext rpy2.ipython
# %%
%%R
suppressMessages(require(tidyverse))
# %%
%%R
ggplot(iris, aes(... | 31 | 632 |
readthedocs.org | readthedocs/settings/test.py | .py | import os
from pathlib import Path
import textwrap
from .base import CommunityBaseSettings
class CommunityTestSettings(CommunityBaseSettings):
"""Settings for testing environment (e.g. tox)"""
SLUMBER_API_HOST = "http://localhost:8000"
# A bunch of our tests check this value in a returned URL/Domain
... | 184 | 7,991 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/tostring_kvs.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");... | 60 | 1,696 |
wandb | wandb/sdk/data_types/image.py | .py | from __future__ import annotations
import hashlib
import logging
import os
import pathlib
from collections.abc import Sequence
from io import BytesIO
from typing import TYPE_CHECKING, Any, TypeAlias, cast
from urllib import parse
from packaging.version import parse as parse_version
import wandb
from wandb import uti... | 1,108 | 40,935 |
gunicorn | tests/test_python_protocol.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Tests for PythonProtocol callback-based HTTP parser.
"""
import pytest
from gunicorn.asgi.parser import PythonProtocol, CallbackRequest, ParseError
class TestPythonProtocolBasic:
"""Test basic request pa... | 519 | 15,903 |
saleor | saleor/graphql/core/types/__init__.py | .py | from .base import (
BaseConnection,
BaseEnum,
BaseInputObjectType,
BaseInterface,
BaseObjectType,
)
from .common import (
TYPES_WITH_DOUBLE_ID_AVAILABLE,
AccountError,
AppError,
AttributeBulkCreateError,
AttributeBulkTranslateError,
AttributeBulkUpdateError,
AttributeErro... | 179 | 4,034 |
hydra | tests/test_examples/test_configure_hydra.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from pathlib import Path
from textwrap import dedent
from typing import Any
from hydra.test_utils.test_utils import (
assert_text_same,
chdir_hydra_root,
run_python_script,
)
chdir_hydra_root()
def test_custom_help(tmpdir: Path) -> N... | 133 | 3,946 |
clearml | examples/cicd/check_remotely_runnable.py | .py | import sys
import time
from clearml import Task
def check_task_status(task_id, timeout=600):
"""Make sure the task can run by checking for iteration reports."""
# Get the task object
task = Task.get_task(task_id=task_id)
start_time = time.time()
if task:
while time.time() - start_time < ti... | 36 | 1,189 |
saleor | saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_based_on_shipping_tax_class.py | .py | import pytest
from ...product.utils.preparing_product import prepare_product
from ...shipping_zone.utils import update_shipping_price
from ...shop.utils import prepare_shop
from ...taxes.utils import update_country_tax_rates
from ...utils import assign_permissions
from ..utils import (
checkout_complete,
check... | 174 | 5,873 |
beam | sdks/python/apache_beam/metrics/metric.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... | 526 | 17,733 |
toolz | examples/fib.py | .py | # / 0 if i is 0
# fib(i) = | 1 if i is 1
# \ fib(i - 1) + fib(i - 2) otherwise
def fib(n):
""" Imperative definition of Fibonacci numbers """
a, b = 0, 1
for i in range(n):
a, b = b, a + b
return a
# This is intuitive but... | 39 | 857 |
openvino | tests/layer_tests/pytorch_tests/test_all.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
class aten_all_noparam(torch.nn.Module):
def __init__(self) -> None:
torch.nn.Module.__ini... | 128 | 4,798 |
sqlmap | tests/test_dicts.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Structural invariants of the data-mapping tables in lib/core/dicts.py.
These tables drive DBMS recognition, connector selection, dummy-table dialect,
and dump formatting. They are pu... | 89 | 3,842 |
textual | docs/examples/guide/compound/byte03.py | .py | from __future__ import annotations
from textual.app import App, ComposeResult
from textual.containers import Container
from textual.geometry import clamp
from textual.message import Message
from textual.reactive import reactive
from textual.widget import Widget
from textual.widgets import Input, Label, Switch
class ... | 131 | 3,462 |
mkdocs-material | material/plugins/tags/structure/tag/reference/__init__.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... | 81 | 2,829 |
luigi | luigi/db_task_history.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... | 284 | 11,525 |
metrics | src/torchmetrics/functional/text/helper.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... | 428 | 17,004 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_UnaryOpsAllRealDomain.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import platform
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng(253512)
class TestUnaryOpsAllRealDomain(CommonTFLayerTest):
def _prepare... | 70 | 2,809 |
sphinx | sphinx/domains/__init__.py | .py | """Support for domains.
Domains are groupings of description directives
and roles describing e.g. constructs of one programming language.
"""
from __future__ import annotations
import copy
from typing import TYPE_CHECKING
from sphinx.domains._index import Index, IndexEntry
from sphinx.locale import _
if TYPE_CHECK... | 332 | 12,447 |
mlflow | mlflow/entities/trace_info.py | .py | import json
from dataclasses import dataclass, field
from typing import Any
from google.protobuf.duration_pb2 import Duration
from google.protobuf.json_format import MessageToDict
from google.protobuf.timestamp_pb2 import Timestamp
from mlflow.entities._mlflow_object import _MlflowObject
from mlflow.entities.assessme... | 266 | 10,826 |
pyomo | pyomo/contrib/gdpopt/gloa.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... | 226 | 9,387 |
metrics | tests/unittests/audio/test_pesq.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... | 137 | 5,764 |
hydra | examples/plugins/example_sweeper_plugin/hydra_plugins/example_sweeper_plugin/example_sweeper.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
import itertools
import logging
from pathlib import Path
from typing import Any, Iterable, List, Optional, Sequence
from hydra.types import HydraContext
from hydra.core.config_store import ConfigStore
from hydra.c... | 126 | 5,225 |
black | tests/data/cases/fmtskip13.py | .py | t = (
{"foo": "very long string", "bar": "another very long string", "baz": "we should run out of space by now"}, # fmt: skip
{"foo": "bar"},
)
t = (
{
"foo": "very long string",
"bar": "another very long string",
"baz": "we should run out of space by now",
}, # fmt: skip
... | 63 | 1,398 |
coremltools | deps/pybind11/tests/test_eval.py | .py | from __future__ import annotations
import os
import pytest
import env # noqa: F401
from pybind11_tests import eval_ as m
def test_evals(capture):
with capture:
assert m.test_eval_statements()
assert capture == "Hello World!"
assert m.test_eval()
assert m.test_eval_single_statement()
... | 53 | 1,179 |
beam | learning/tour-of-beam/learning-content/core-transforms/motivating-challenge-2/python-challenge/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"); y... | 57 | 1,867 |
deap | doc/code/tutorials/part_4/4_4_Using_Cpp_NSGA.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 ... | 145 | 4,932 |
saleor | saleor/order/tests/benchmark/test_fetch_order_prices.py | .py | import pytest
from ... import OrderStatus
from ...calculations import fetch_order_prices_if_expired
@pytest.mark.django_db
@pytest.mark.count_queries(autouse=False)
def test_fetch_order_prices(
order_with_lines,
plugins_manager,
django_assert_num_queries,
tax_configuration_flat_rates,
count_queri... | 23 | 556 |
mlflow | mlflow/keras/autologging.py | .py | """MLflow autologging support for Keras 3."""
import logging
import keras
import numpy as np
import mlflow
from mlflow.data.code_dataset_source import CodeDatasetSource
from mlflow.data.numpy_dataset import from_numpy
from mlflow.data.tensorflow_dataset import from_tensorflow
from mlflow.entities.logged_model_input ... | 279 | 11,143 |
conda | tests/common/test_url.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from logging import getLogger
from typing import NamedTuple
import pytest
from conda.common.url import (
Url,
add_username_and_password,
is_ip_address,
is_ipv6_address,
is_url,
maybe_... | 164 | 5,121 |
structlog | src/structlog/_base.py | .py | # SPDX-License-Identifier: MIT OR Apache-2.0
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the MIT License. See the LICENSE file in the root of this
# repository for complete details.
"""
Logger wrapper and helper class.
"""
from __future__ import annotations
import sys
fro... | 246 | 7,362 |
clearml | examples/hyperdatasets/finetune_qa_lora.py | .py | """
Fine-tune a base LLM with LoRA adapters on HyperDataset Q&A entries using Hugging Face's Trainer.
This variant keeps the ClearML multi-node bootstrap from the original script but delegates the
training loop to `transformers.Trainer` for a more compact implementation.
Example local run (single node, all GPUs):
... | 500 | 19,469 |
saleor | saleor/graphql/product/tests/queries/test_collections_query.py | .py | import datetime
import graphene
import pytest
from .....product.models import Collection, CollectionChannelListing, Product
from .....tests.utils import dummy_editorjs
from ....tests.utils import (
get_graphql_content,
)
def test_collections_query(
user_api_client,
published_collection,
unpublished_... | 440 | 13,365 |
pyomo | pyomo/solvers/tests/models/MIQP_simple.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... | 84 | 2,831 |
saleor | saleor/graphql/discount/mutations/promotion/promotion_update.py | .py | import datetime
import graphene
from django.core.exceptions import ValidationError
from django.db import transaction
from .....discount import PromotionType, events, models
from .....discount.utils.promotion import mark_catalogue_promotion_rules_as_dirty
from .....permission.enums import DiscountPermissions
from ....... | 184 | 7,016 |
wandb | wandb/sdk/data_types/table.py | .py | from __future__ import annotations
import base64
import binascii
import codecs
import datetime
import json
import logging
import os
from collections.abc import Callable, Iterable, Iterator, Sequence
from typing import TYPE_CHECKING, Any, Literal, TypeVar, cast, get_args, overload
import wandb
from wandb import util
f... | 1,604 | 58,625 |
returns | tests/test_result/test_result_equality.py | .py | from copy import copy, deepcopy
import pytest
from returns.primitives.exceptions import ImmutableStateError
from returns.result import Failure, Success
def test_equals():
"""Ensures that ``.equals`` method works correctly."""
inner_value = 1
assert Success(inner_value).equals(Success(inner_value))
... | 100 | 2,996 |
saleor | saleor/graphql/page/tests/queries/pages_with_where/test_with_where_multiple_arguments.py | .py | import pytest
from ......attribute.utils import associate_attribute_values_to_instance
from .....tests.utils import get_graphql_content
from .shared import QUERY_PAGES_WITH_WHERE
@pytest.mark.parametrize(
"attribute_filter",
[
# Non-existing attribute slug
[{"slug": "non-existing-attribute"}]... | 247 | 8,058 |
saleor | saleor/product/error_codes.py | .py | from enum import Enum
class ProductErrorCode(Enum):
ALREADY_EXISTS = "already_exists"
ATTRIBUTE_ALREADY_ASSIGNED = "attribute_already_assigned"
ATTRIBUTE_CANNOT_BE_ASSIGNED = "attribute_cannot_be_assigned"
ATTRIBUTE_VARIANTS_DISABLED = "attribute_variants_disabled"
MEDIA_ALREADY_ASSIGNED = "media_... | 73 | 2,928 |
astropy | astropy/modeling/tests/test_math_func.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.modeling import math_functions
x = np.linspace(-20, 360, 100)
@pytest.mark.filterwarnings(r"ignore:.*:RuntimeWarning")
def test_math():
for name in math_functi... | 26 | 846 |
textual | src/textual/demo/__main__.py | .py | from textual.demo.demo_app import DemoApp
if __name__ == "__main__":
app = DemoApp()
app.run()
| 6 | 104 |
lemur | lemur/dns_providers/util.py | .py | import sys
import dns
import dns.exception
import dns.name
import dns.query
import dns.resolver
import re
from sentry_sdk import capture_exception
from lemur.extensions import metrics
class DNSError(Exception):
"""Base class for DNS Exceptions."""
pass
class BadDomainError(DNSError):
"""Error for when ... | 102 | 2,894 |
mlflow | tests/store/artifact/test_azure_data_lake_artifact_repo.py | .py | import json
import os
import posixpath
from unittest import mock
from unittest.mock import ANY
import pytest
import requests
from azure.core.credentials import AzureSasCredential
from azure.storage.filedatalake import (
DataLakeDirectoryClient,
DataLakeFileClient,
DataLakeServiceClient,
FileSystemClien... | 495 | 18,165 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.