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 |
|---|---|---|---|---|---|
wandb | tests/system_tests/test_core/test_save_policies.py | .py | import os
import time
import pytest
import wandb
from wandb.filesync.dir_watcher import PolicyLive
@pytest.fixture
def mocked_live_policy(monkeypatch, user):
run = wandb.init()
fpath = os.path.join(run.dir, "test_file")
with open(fpath, "w") as fp:
fp.write("")
live_policy = PolicyLive(fpath... | 83 | 2,818 |
confluent-kafka-python | src/confluent_kafka/schema_registry/rules/encryption/kms_driver_registry.py | .py | # 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 required by applicable law or agreed to in writing, s... | 63 | 1,837 |
saleor | saleor/tests/e2e/orders/discounts/test_order_voucher_is_released_when_draft_order_is_deleted.py | .py | import pytest
from ... import DEFAULT_ADDRESS
from ...product.utils.preparing_product import prepare_product
from ...shop.utils.preparing_shop import prepare_shop
from ...utils import assign_permissions
from ...vouchers.utils import (
create_voucher,
create_voucher_channel_listing,
get_voucher,
)
from ..ut... | 135 | 4,031 |
probability | tensorflow_probability/python/internal/backend/numpy/gen/linear_operator_identity.py | .py | # Copyright 2020 The TensorFlow Probability Authors. All Rights Reserved.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# THIS FILE IS AUTO-GENERATED BY `gen_linear_operators.py`.
# DO NOT MODIFY DIRECTLY.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@... | 966 | 37,922 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_Concat.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shapes': [[1, 3], [1, 7]], 'axis': -1},
{'shapes': [[1, 3, 10], [1, 3, 56], [1, 3, 2]], 'axis': -1},
{'shapes': [[1, 3, 10, 17], [1, 3, 10, 1], [1, 3, 10, 5], [1, 3, 10, 3]], 'axis': -1},
... | 40 | 1,660 |
mlflow | mlflow/server/security.py | .py | import logging
from http import HTTPStatus
from flask import Flask, Response, request
from flask_cors import CORS
from mlflow.environment_variables import (
MLFLOW_SERVER_DISABLE_SECURITY_MIDDLEWARE,
MLFLOW_SERVER_X_FRAME_OPTIONS,
)
from mlflow.server.security_utils import (
CORS_BLOCKED_MSG,
HEALTH_E... | 127 | 4,596 |
hydra | plugins/hydra_nevergrad_sweeper/hydra_plugins/hydra_nevergrad_sweeper/nevergrad_sweeper.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import List, Optional
from hydra import TaskFunction
from hydra.plugins.sweeper import Sweeper
from hydra.types import HydraContext
from omegaconf import DictConfig
from .config import OptimConf
class NevergradSweeper(Sweeper):
"... | 38 | 1,033 |
saleor | saleor/graphql/order/mutations/fulfillment_refund_and_return_product_base.py | .py | from uuid import UUID
import graphene
from django.core.exceptions import ValidationError
from ....giftcard.utils import order_has_gift_card_lines
from ....order import FulfillmentLineData
from ....order import models as order_models
from ....order.error_codes import OrderErrorCode
from ....order.fetch import OrderLin... | 262 | 10,139 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/combinevalues_lambda.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");... | 59 | 1,754 |
openvino | tests/e2e_tests/test_utils/tf_hub_utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import tensorflow as tf
rng = np.random.default_rng(seed=56190)
type_map = {
tf.float64: np.float64,
tf.float32: np.float32,
tf.int8: np.int8,
tf.int16: np.int16,
tf.int32: np.int32,
tf.int64:... | 82 | 2,808 |
mlflow | tests/tracing/otel/test_voltagent_translator.py | .py | import json
from unittest import mock
import pytest
from mlflow.entities.span import Span, SpanType
from mlflow.tracing.constant import SpanAttributeKey
from mlflow.tracing.otel.translation import (
translate_span_type_from_otel,
translate_span_when_storing,
)
from mlflow.tracing.otel.translation.voltagent im... | 224 | 7,478 |
mlflow | dev/check_init_py.py | .py | """
Pre-commit hook to check for missing `__init__.py` files in mlflow and tests directories.
This script ensures that all directories under the mlflow package and tests directory that contain
Python files also have an `__init__.py` file. This prevents `setuptools` from excluding these
directories during package build... | 55 | 1,989 |
coremltools | coremltools/converters/mil/mil/ops/defs/iOS15/scatter_gather.py | .py | # Copyright (c) 2020, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import numpy as np
from coremltools.converters.mil.mil import Operation, types
from coremltools.conv... | 558 | 16,964 |
saleor | saleor/graphql/core/utils/__init__.py | .py | import binascii
import os
import secrets
from dataclasses import dataclass
from typing import Literal, NoReturn, overload
import graphene
from django.conf import settings
from django.core.exceptions import ValidationError
from graphene import ObjectType
from graphql import GraphQLError
from ....plugins.const import A... | 230 | 7,529 |
jupytext | tests/functional/others/test_write_does_not_modify_notebook.py | .py | from copy import deepcopy
import pytest
from jupytext import read, write, writes
from jupytext.compare import compare
from jupytext.formats import long_form_one_format
@pytest.mark.parametrize(
"fmt",
["auto:light", "auto:percent", "md", ".Rmd", ".ipynb"],
)
def test_write_notebook_does_not_change_it(ipynb_... | 25 | 672 |
scikit-optimize | skopt/tests/test_plots.py | .py | """Scikit-optimize plotting tests."""
import numpy as np
import pytest
from sklearn.datasets import load_breast_cancer
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import cross_val_score
from numpy.testing import assert_array_almost_equal
from skopt.space import Integer, Categorical
from... | 179 | 6,642 |
returns | returns/context/requires_context_future_result.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable
from typing import TYPE_CHECKING, Any, ClassVar, TypeAlias, TypeVar, final
from returns._internal.futures import _reader_future_result
from returns.context import NoDeps
from returns.future import Future, FutureResult
from returns.inte... | 1,479 | 48,174 |
kombu | t/unit/conftest.py | .py | from __future__ import annotations
import atexit
import builtins
import io
import os
import sys
import types
from unittest.mock import MagicMock
import pytest
from kombu.exceptions import VersionMismatch
_SIO_write = io.StringIO.write
_SIO_init = io.StringIO.__init__
sentinel = object()
@pytest.fixture(scope='ses... | 329 | 9,493 |
probability | tensorflow_probability/python/internal/backend/numpy/raw_ops.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... | 107 | 3,669 |
mlflow | mlflow/genai/judges/base.py | .py | from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any
from pydantic import BaseModel, Field
from mlflow.entities.trace import Trace
from mlflow.genai.judges.constants import (
_RATIONALE_FIELD_DESCRIPTION,
_RESULT_FIELD_DESCRIPTION,
)
from mlflow.genai.judges.utils imp... | 138 | 4,360 |
wandb | wandb/sdk/data_types/video.py | .py | from __future__ import annotations
import functools
import logging
import os
import pathlib
from collections.abc import Sequence
from io import BytesIO
from typing import TYPE_CHECKING, Any, Literal
import wandb
from wandb import env, util
from wandb.sdk import wandb_setup
from wandb.sdk.lib import filesystem, printe... | 305 | 10,520 |
probability | tensorflow_probability/python/math/special.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... | 2,659 | 96,830 |
clearml | clearml/binding/frameworks/catboost_bind.py | .py | import sys
from typing import Callable, Union, IO, Any
from pathlib2 import Path
from ..frameworks import WeightsFileHandler, _Empty, _patched_call
from ..frameworks.base_bind import PatchBaseModelIO
from ..import_bind import PostImportHookPatching
from ...model import Framework
class PatchCatBoostModelIO(PatchBase... | 154 | 5,915 |
beam | sdks/python/apache_beam/testing/load_tests/co_group_by_key_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... | 145 | 4,791 |
sphinx | tests/roots/test-ext-napoleon-paramtype/pkg/foo.py | .py | class Foo:
"""The foo."""
def do(
self,
*,
keyword_paramtype,
keyword_kwtype,
kwarg_paramtype,
kwarg_kwtype,
kwparam_paramtype,
kwparam_kwtype,
):
"""Some method.
:keyword keyword_paramtype: some param
:paramtype keywo... | 29 | 792 |
hatch | src/hatch/python/resolve.py | .py | from __future__ import annotations
import os
import platform
import sys
from abc import ABC, abstractmethod
from functools import cached_property
from typing import TYPE_CHECKING, Literal
from hatch.config.constants import PythonEnvVars
from hatch.errors import PythonDistributionResolutionError, PythonDistributionUnk... | 311 | 9,991 |
saleor | saleor/graphql/plugins/types.py | .py | from typing import TYPE_CHECKING
import graphene
from ..channel.types import Channel
from ..core import ResolveInfo
from ..core.connection import CountableConnection
from ..core.types import NonNullList
from .enums import ConfigurationTypeFieldEnum
if TYPE_CHECKING:
from ...plugins.base_plugin import BasePlugin
... | 85 | 2,743 |
textual | tests/snapshot_tests/snapshot_apps/fr_margins.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Label
from textual.containers import Container
# Test fr dimensions and margins work in an auto container
# https://github.com/Textualize/textual/issues/2220
class TestApp(App):
CSS = """
Container {
background: green 20%;
... | 36 | 780 |
attrs | tests/test_functional.py | .py | # SPDX-License-Identifier: MIT
"""
End-to-end tests.
"""
import copy
import inspect
import pickle
from copy import deepcopy
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._compat import PY_3_13_PLUS
from attr._make import NOTHING, Attribute
from attr.e... | 832 | 21,140 |
metrics | src/torchmetrics/functional/classification/precision_recall_curve.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... | 1,009 | 47,564 |
biopython | Bio/NMR/NOEtools.py | .py | # Copyright 2004 by Bob Bussell. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""NOEtools: For predicting NOE coordinates from assignment data.
The input and output are model... | 101 | 3,353 |
mlflow | mlflow/genai/judges/__init__.py | .py | # Make utils available as an attribute for mocking
from mlflow.genai.judges import utils # noqa: F401
from mlflow.genai.judges.base import AlignmentOptimizer, Judge
from mlflow.genai.judges.builtin import (
is_context_relevant,
is_context_sufficient,
is_correct,
is_grounded,
is_safe,
is_tool_ca... | 36 | 953 |
sqlmap | tamper/space2plus.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.compat import xrange
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.LOW
def dependencies():
pass
def tamper(payload, **kwargs):
"""
Repla... | 54 | 1,359 |
coremltools | coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/delete_asserts.py | .py | # -*- coding: utf-8 -*-
# Copyright (c) 2020, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import sys
from coremltools import _logger as logger
from ..basic_graph_ops... | 69 | 2,386 |
lemur | lemur/tests/test_messaging.py | .py | from datetime import timedelta
import arrow
import boto3
import pytest
from freezegun import freeze_time
from moto import mock_ses
from lemur.certificates.service import get_expiring_deployed_certificates
from lemur.tests.factories import AuthorityFactory, CertificateFactory, EndpointFactory
@mock_ses
def verify_se... | 352 | 13,105 |
mlflow | mlflow/store/db_migrations/versions/a5b4c3d2e1f0_add_metrics_run_key_step_index.py | .py | """add composite index on metrics (run_uuid, key, step)
Create Date: 2026-03-10 20:46:00.000000
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = "a5b4c3d2e1f0"
down_revision = "c3d6457b6d8a"
branch_labels = None
depends_on = None
def upgrade():
# Add composite index to speed up m... | 24 | 639 |
beam | sdks/python/apache_beam/io/mongodbio_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... | 171 | 5,469 |
beam | sdks/python/apache_beam/io/components/adaptive_throttler.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... | 189 | 7,249 |
scikit-bio | skbio/tree/_majority_rule.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.
# --------------------------------------------... | 289 | 10,369 |
beam | learning/katas/python/Core Transforms/Map/FlatMap/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... | 37 | 1,327 |
wandb | tools/graphql_codegen/plugin_utils.py | .py | """Custom helper functions for the GraphQL codegen plugin."""
from __future__ import annotations
import ast
from collections.abc import Iterable
from typing import Any, TypeGuard
from pydantic import BaseModel, Field, field_validator
def imported_names(stmt: ast.Import | ast.ImportFrom) -> list[str]:
"""Return... | 136 | 5,168 |
probability | tensorflow_probability/python/bijectors/gev_cdf_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... | 83 | 3,395 |
jupytext | tests/functional/simple_notebooks/test_read_simple_ocaml.py | .py | from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook
import jupytext
from jupytext.compare import compare, compare_notebooks
def test_read_simple_code(
no_jupytext_version_number,
ml="""(* %% *)
let sum x y = x + y
""",
nb=new_notebook(
cells=[
new_code_cell("... | 39 | 904 |
black | tests/data/cases/comments_in_comprehensions.py | .py | # Regression tests for https://github.com/psf/black/issues/4296.
[
x
for
# comment
x, y in ["AB",]
]
[
[
x
for x
# comment
in [
# comment
"ABC"
]
]
]
{
(
lambda
# comment
x: [
# comment
... | 92 | 948 |
saleor | saleor/graphql/checkout/mutations/checkout_add_promo_code.py | .py | import graphene
from django.core.exceptions import ValidationError
from ....checkout.actions import call_checkout_info_event
from ....checkout.error_codes import CheckoutErrorCode
from ....checkout.fetch import (
fetch_checkout_info,
fetch_checkout_lines,
)
from ....checkout.utils import (
add_promo_code_t... | 130 | 4,203 |
probability | tensorflow_probability/python/distributions/mvn_diag_plus_low_rank.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,444 |
wagtail | wagtail/api/v3/tests/test_rich_text.py | .py | import json
from django.core.serializers.json import DjangoJSONEncoder
from django.test import TestCase, override_settings
from django.urls import reverse
from wagtail.api.v3.api import api
from wagtail.api.v3.tests.base import TestV3Base
from wagtail.test.testapp.models import (
CustomRichBlockFieldPage,
Def... | 448 | 17,785 |
openvino | tests/layer_tests/pytorch_tests/test_remainder.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
@pytest.mark.parametrize(
"input_shape_rhs",
[
[2, 5, 3, 4],
[1, 5, 3, 4],
[1]
]
)
class TestRemainder(PytorchLayerTes... | 110 | 3,721 |
openvino | src/bindings/python/tests/test_runtime/test_string_infer.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.opset13 as ops
from openvino import (
CompiledModel,
InferRequest,
Model,
Type,
compile_model,
)
def create_string_compiled_model(shape):
... | 113 | 3,501 |
pyro | pyro/ops/packed.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import torch
from pyro.distributions.util import is_identically_one
from pyro.util import ignore_jit_warnings
def pack(value, dim_to_symbol):
"""
Converts an unpacked tensor to a packed tensor.
:param v... | 201 | 6,350 |
hydra | hydra/core/override_parser/overrides_parser.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import sys
from typing import Any, List, Optional
from omegaconf.vendor.antlr4.error.Errors import (
LexerNoViableAltException,
RecognitionException,
)
from hydra._internal.grammar import grammar_functions
from hydra._internal.grammar.func... | 129 | 4,985 |
probability | tensorflow_probability/python/sts/default_model.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... | 163 | 6,918 |
beam | sdks/python/apache_beam/ml/anomaly/detectors/zscore_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... | 84 | 2,394 |
pyomo | pyomo/solvers/plugins/solvers/gurobi_persistent.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... | 737 | 24,841 |
saleor | saleor/graphql/giftcard/tests/benchmark/test_gift_card_mutations.py | .py | import datetime
import graphene
import pytest
from .....giftcard.models import GiftCard
from ....tests.utils import get_graphql_content
from .test_gift_card_queries import FRAGMENT_GIFT_CARD_DETAILS
CREATE_GIFT_CARD_MUTATION = (
FRAGMENT_GIFT_CARD_DETAILS
+ """
mutation giftCardCreate(
$balance: ... | 248 | 5,938 |
pymc | pymc/tuning/__init__.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... | 21 | 788 |
saleor | saleor/graphql/shipping/enums.py | .py | from typing import Final
import graphene
from ...graphql.core.enums import to_enum
from ...shipping import PostalCodeRuleInclusionType, ShippingMethodType
from ..core.doc_category import DOC_CATEGORY_SHIPPING
ShippingMethodTypeEnum: Final[graphene.Enum] = to_enum(
ShippingMethodType, type_name="ShippingMethodTyp... | 18 | 603 |
mlflow | tests/utils/test_request_utils.py | .py | import socket
import subprocess
import sys
from unittest import mock
import pytest
from requests.adapters import HTTPAdapter
from mlflow.utils import request_utils
from mlflow.utils.request_utils import (
TCPKeepAliveHTTPAdapter,
_build_socket_options,
)
def test_request_utils_does_not_import_mlflow(tmp_pat... | 254 | 8,825 |
loguru | tests/test_add_option_kwargs.py | .py | import pytest
from loguru import logger
def test_file_mode_a(tmp_path):
file = tmp_path / "test.log"
file.write_text("base\n")
logger.add(file, format="{message}", mode="a")
logger.debug("msg")
assert file.read_text() == "base\nmsg\n"
def test_file_mode_w(tmp_path):
file = tmp_path / "test.... | 84 | 2,539 |
mlflow | tests/demo/test_evaluation_generator.py | .py | import pytest
import mlflow
from mlflow.demo.base import DEMO_EXPERIMENT_NAME, DemoFeature, DemoResult
from mlflow.demo.data import ALL_DEMO_TRACES
from mlflow.demo.generators.evaluation import EvaluationDemoGenerator
from mlflow.demo.generators.traces import TracesDemoGenerator
@pytest.fixture
def evaluation_genera... | 119 | 3,806 |
records | tests/test_records.py | .py | from collections import namedtuple
import records
from pytest import raises
IdRecord = namedtuple('IdRecord', 'id')
def check_id(i, row):
assert row.id == i
class TestRecordCollection:
def test_iter(self):
rows = records.RecordCollection(IdRecord(i) for i in range(10))
for i, row in enum... | 148 | 4,699 |
structlog | bench/test_benchmarks.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.
"""
Benchmark structlog using CodSpeed.
"""
from __future__ import annotations
import loggi... | 200 | 4,926 |
sqlmap | lib/core/testing.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import doctest
import json
import logging
import os
import random
import re
import shutil
import socket
import sqlite3
import subprocess
import sys
import tempfile
import threadin... | 800 | 46,538 |
probability | tensorflow_probability/python/internal/batch_shape_lib.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... | 370 | 16,399 |
mlflow | mlflow/store/entities/__init__.py | .py | from mlflow.store.entities.paged_list import PagedList
__all__ = ["PagedList"]
| 4 | 80 |
metrics | src/torchmetrics/classification/__init__.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... | 239 | 7,467 |
ipython | IPython/utils/docs.py | .py | import os
GENERATING_DOCUMENTATION = os.environ.get("IN_SPHINX_RUN", None) == "True"
| 4 | 86 |
beam | sdks/python/apache_beam/runners/dataflow/dataflow_metrics_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... | 404 | 14,162 |
saleor | saleor/core/tests/test_tasks.py | .py | import datetime
from django.core.files.storage import default_storage
from django.utils import timezone
from freezegun import freeze_time
from ...webhook.event_types import WebhookEventAsyncType
from .. import private_storage
from ..models import EventDelivery, EventDeliveryAttempt, EventPayload
from ..tasks import (... | 95 | 3,136 |
saleor | saleor/urls.py | .py | from django.conf import settings
from django.conf.urls.static import static
from django.contrib.staticfiles.views import serve
from django.urls import re_path
from django.views.decorators.csrf import csrf_exempt
from .core.views import jwks, serve_media_view
from .graphql.api import backend, schema
from .graphql.views... | 64 | 1,863 |
textual | tests/test_resolve.py | .py | from fractions import Fraction
import pytest
from textual._resolve import resolve, resolve_fraction_unit
from textual.css.scalar import Scalar
from textual.geometry import Size
from textual.widget import Widget
def test_resolve_empty():
assert resolve([], 10, 1, Size(20, 10), Size(80, 24)) == []
@pytest.mark.... | 169 | 4,128 |
wandb | wandb/proto/v7/wandb_telemetry_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: wandb/proto/wandb_telemetry.proto
# Protobuf Python Version: 7.34.0
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descri... | 51 | 12,294 |
httpie | httpie/client.py | .py | import argparse
import http.client
import json
import sys
from contextlib import contextmanager
from time import monotonic
from typing import Any, Dict, Callable, Iterable
from urllib.parse import urlparse, urlunparse
import requests
# noinspection PyPackageRequirements
import urllib3
from urllib3.util import SKIP_HEA... | 401 | 13,396 |
onnxruntime | onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/KernelTypeStrArgsEntry.py | .py | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: fbs
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class KernelTypeStrArgsEntry(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.enco... | 92 | 3,102 |
django-cms | menus/modifiers.py | .py | from menus.base import Modifier
from menus.menu_pool import menu_pool
class Level(Modifier):
"""
Marks all node levels.
"""
post_cut = True
def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
"""
Modify the list of nodes based on certain conditions.
... | 101 | 3,443 |
mlflow | tests/gateway/test_utils.py | .py | import pytest
from fastapi import HTTPException
from mlflow.exceptions import MlflowException
from mlflow.gateway.exceptions import AIGatewayException
from mlflow.gateway.utils import (
SearchRoutesToken,
_is_valid_uri,
assemble_uri_path,
check_configuration_route_name_collisions,
get_gateway_uri,
... | 411 | 12,323 |
sqlmap | plugins/dbms/raima/filesystem.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.exception import SqlmapUnsupportedFeatureException
from plugins.generic.filesystem import Filesystem as GenericFilesystem
class Filesystem(GenericFilesystem):
d... | 19 | 702 |
openvino | src/bindings/python/src/openvino/package_utils.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
from functools import wraps
from typing import Any, Optional
from pathlib import Path
import importlib.util
from types import ModuleType
from collections.abc import Callable
def _add_openvin... | 157 | 6,056 |
scikit-bio | doc/editmap.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.
# --------------------------------------------... | 48 | 1,064 |
pyomo | pyomo/contrib/solver/tests/solvers/test_gurobi_minlp_walker.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... | 591 | 21,284 |
astropy | astropy/config/_tempfile_shim.py | .py | __all__ = ["TemporaryDirectory"]
import sys
if sys.version_info >= (3, 12, 1):
from tempfile import TemporaryDirectory
else:
import os as _os
import shutil as _shutil
import types as _types
import warnings as _warnings
import weakref as _weakref
from tempfile import mkdtemp as _mkdtemp
... | 164 | 6,235 |
sqlmap | lib/techniques/odata/inject.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
"""
OData injection ('--odata').
An application that builds an OData '$filter' from user input (?name= -> $filter=Name eq '<name>')
hands over the whole filter expression languag... | 639 | 29,287 |
mlflow | mlflow/store/db_migrations/versions/89d3d66ed43f_add_label_schemas_table.py | .py | """add label_schemas table
Revision ID: 89d3d66ed43f
Revises: da6fb0208061
Create Date: 2026-05-26 10:00:00.000000
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "89d3d66ed43f"
down_revision = "da6fb0208061"
branch_labels = None
depends_on = None
def upgrad... | 59 | 1,915 |
biopython | Tests/test_Phylo_NeXML.py | .py | # Copyright (C) 2013 by Ben Morris (ben@bendmorris.com)
# based on code by Eric Talevich (eric.talevich@gmail.com)
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Unit tests for the NeXML and NeXML... | 110 | 3,250 |
sqlmap | tests/test_har.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Tests for lib/utils/har.py -- HAR (HTTP Archive) collector and HTTP
request/response parsing used by sqlmap's --har-file feature.
"""
import os
import sys
import unittest
sys.path.i... | 202 | 8,348 |
returns | returns/pointfree/bind_ioresult.py | .py | from __future__ import annotations
from collections.abc import Callable
from typing import TYPE_CHECKING, TypeVar
from returns.interfaces.specific.ioresult import IOResultLikeN
from returns.primitives.hkt import Kinded, KindN, kinded
if TYPE_CHECKING:
from returns.io import IOResult # noqa: WPS433
_FirstType =... | 66 | 1,868 |
hatch | src/hatch/cli/terminal.py | .py | from __future__ import annotations
import os
from abc import ABC, abstractmethod
from functools import cached_property
from textwrap import indent as indent_text
from typing import TYPE_CHECKING
import click
from rich.console import Console
from rich.style import Style
from rich.text import Text
if TYPE_CHECKING:
... | 375 | 13,075 |
astropy | astropy/uncertainty/distributions.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Built-in distribution-creation functions.
"""
from warnings import warn
import numpy as np
from astropy import units as u
from .core import Distribution
__all__ = ["normal", "poisson", "uniform"]
def normal(
center, *, std=None, var=None, i... | 207 | 6,618 |
astropy | astropy/tests/runner.py | .py | """Implements the Astropy TestRunner which is a thin wrapper around pytest."""
import copy
import glob
import inspect
import os
import shlex
import sys
import tempfile
import warnings
from functools import wraps
from importlib.util import find_spec
from astropy.utils import deprecated, find_current_module
from astrop... | 591 | 21,643 |
pymc | pymc/variational/test_functions.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... | 66 | 1,750 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Cast.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
# Testing Cast operation (Initial Implementation)
# Documentation: https://www.tensorflow.org/api_docs/python/tf/raw_ops/Cast
class TestCastOp(... | 75 | 2,967 |
scikit-optimize | examples/store-and-load-results.py | .py | """
===========================================
Store and load `skopt` optimization results
===========================================
Mikhail Pak, October 2016.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
Problem statement
=================
We often want to store optimization results in a file.... | 144 | 5,427 |
scikit-optimize | skopt/tests/test_sampler.py | .py | import pytest
import numbers
import numpy as np
import os
import yaml
from tempfile import NamedTemporaryFile
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_almost_equal
from numpy.testing import assert_array_equal
from numpy.testing import assert_equal
from numpy.testing import a... | 287 | 9,615 |
black | tests/data/cases/is_simple_lookup_for_doublestar_expression.py | .py | m2 = None if not isinstance(dist, Normal) else m** 2 + s * 2
m3 = None if not isinstance(dist, Normal) else m ** 2 + s * 2
m4 = None if not isinstance(dist, Normal) else m**2 + s * 2
m5 = obj.method(another_obj.method()).attribute **2
m6 = None if ... else m**2 + s**2
# output
m2 = None if not isinstance(dist, Normal... | 13 | 546 |
django-cms | cms/test_utils/project/nonroot_urls.py | .py | from django.conf import settings
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
from django.urls import include, re_path
from django.views.i18n import JavaScriptCatalog
from django.views.static import serve
from cms.test_utils.project.placeholderapp.views import example_view
from cms.... | 26 | 898 |
hatch | tests/cli/dep/test_dep_lock.py | .py | from contextlib import contextmanager
import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.env.virtual import VirtualEnvironment
from hatch.project.core import Project
from hatch.utils.toml import load_toml_file
@pytest.mark.usefixtures("mock_locker")
def test_dep_lock_export(hatch, helpers, te... | 251 | 7,994 |
attrs | tests/test_next_gen.py | .py | # SPDX-License-Identifier: MIT
"""
Integration tests for next-generation APIs.
"""
import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
from attr._compat import PY_3_11_PLUS
from attr._make import ClassProps
@at... | 586 | 14,246 |
clearml | examples/cicd/task_stats_to_comment.py | .py | import json
import os
import pandas as pd
from clearml import Task
from github3 import login
from tabulate import tabulate
def create_output_tables(retrieve_scalars_dict):
"""Extract data from ClearML into format for tabulation."""
data = []
for graph_title, graph_values in retrieve_scalars_dict.items():... | 106 | 4,294 |
mlflow | tests/entities/test_metric.py | .py | import re
import pytest
from mlflow.entities import Metric
from mlflow.exceptions import MlflowException
from mlflow.utils.time import get_current_time_millis
from tests.helper_functions import random_int, random_str
def _check(metric, key, value, timestamp, step):
assert type(metric) == Metric
assert metr... | 104 | 2,892 |
wagtail | wagtail/test/demosite/models.py | .py | from datetime import date
import swapper
from django.core.exceptions import ValidationError
from django.core.paginator import Paginator
from django.db import models
from modelcluster.contrib.taggit import ClusterTaggableManager
from modelcluster.fields import ParentalKey
from taggit.models import TaggedItemBase
from ... | 853 | 23,364 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.