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 | mlflow/genai/agent_tester.py | .py | from __future__ import annotations
import inspect
import logging
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Callable
import pydantic
import mlflow
from mlflow.genai.judges.utils.invocation_utils import get_chat_completions_with_structured_output
from mlflow.utils.annotations import expe... | 456 | 15,912 |
wagtail | wagtail/admin/ui/editing_sessions.py | .py | from django.conf import settings
from wagtail.admin.ui.components import Component
class EditingSessionsModule(Component):
template_name = "wagtailadmin/shared/editing_sessions/module.html"
def __init__(
self,
current_session,
ping_url,
release_url,
other_sessions,
... | 51 | 1,615 |
mlflow | dev/clint/src/clint/rules/use_gh_token.py | .py | import ast
from clint.resolver import Resolver
from clint.rules.base import Rule
class UseGhToken(Rule):
def _message(self) -> str:
return "Use GH_TOKEN instead of GITHUB_TOKEN for the environment variable name."
@staticmethod
def check(node: ast.Call, resolver: Resolver) -> bool:
"""
... | 25 | 774 |
mlflow | tests/tracking/_model_registry/test_model_registry_client.py | .py | from unittest import mock
from unittest.mock import ANY
import pytest
from mlflow.entities.model_registry import (
ModelVersion,
ModelVersionTag,
RegisteredModel,
RegisteredModelTag,
)
from mlflow.exceptions import MlflowException
from mlflow.store.entities.paged_list import PagedList
from mlflow.stor... | 550 | 20,253 |
mlflow | tests/spark/autologging/datasource/test_spark_datasource_autologging_unit.py | .py | from unittest import mock
import pytest
import mlflow.spark
from mlflow.exceptions import MlflowException
from mlflow.spark.autologging import PythonSubscriber, _get_current_listener
@pytest.fixture
def mock_get_current_listener():
with mock.patch(
"mlflow.spark.autologging._get_current_listener", retur... | 61 | 2,114 |
mlflow | tests/store/tracking/sqlalchemy_store/test_sqlalchemy_store_eval_datasets.py | .py | import json
import time
from unittest import mock
import pytest
from mlflow.entities.dataset_record import DatasetRecord
from mlflow.exceptions import MlflowException
from mlflow.store.tracking.dbmodels.models import SqlEvaluationDatasetRecord
from mlflow.utils import mlflow_tags
from tests.store.tracking.sqlalchemy... | 1,022 | 36,867 |
pdm | src/pdm/installers/uv.py | .py | from __future__ import annotations
import os
import subprocess
from typing import Any
from pdm._types import HiddenText
from pdm.environments.local import PythonLocalEnvironment
from pdm.exceptions import PdmUsageError, ProjectError
from pdm.installers.base import BaseSynchronizer
from pdm.models.repositories import ... | 97 | 3,965 |
wandb | wandb/integration/tensorboard/log.py | .py | from __future__ import annotations
import io
import re
import time
from typing import TYPE_CHECKING, Any
import wandb
import wandb.util
from wandb.sdk.lib import telemetry
if TYPE_CHECKING:
import numpy as np
from wandb.sdk.internal.tb_watcher import TBHistory
# We have at least the default namestep and a ... | 354 | 14,055 |
clearml | examples/frameworks/tensorflow/absl_flags.py | .py | # ClearML - example code, absl parameter logging
#
import sys
from absl import app
from absl import flags
from absl import logging
from clearml import Task
FLAGS = flags.FLAGS
flags.DEFINE_string("echo", None, "Text to echo.")
flags.DEFINE_string("another_str", "My string", "A string", module_name="test")
# Connec... | 33 | 921 |
conda | conda/cli/main_pip.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""PEP 621 compatible entry point used when `conda init` has not updated the user shell profile."""
import os
import sys
from logging import getLogger
log = getLogger(__name__)
def pip_installed_post_parse_hook(args, p):
from .. import C... | 34 | 872 |
attrs | src/attr/_version_info.py | .py | # SPDX-License-Identifier: MIT
from functools import total_ordering
from ._funcs import astuple
from ._make import attrib, attrs
@total_ordering
@attrs(eq=False, order=False, slots=True, frozen=True)
class VersionInfo:
"""
A version object that can be compared to tuple of length 1--4:
>>> attr.Version... | 90 | 2,222 |
pyomo | pyomo/opt/plugins/driver.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... | 83 | 2,710 |
coveragepy | coverage/report.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Summary reporting"""
from __future__ import annotations
import string
import sys
from collections.abc import Iterable
from typing import IO, TYPE_CHECKING, A... | 308 | 10,998 |
cvxpy | cvxpy/reductions/solvers/defines.py | .py | """
Copyright 2013 Steven Diamond
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | 132 | 6,611 |
openvino | src/frontends/tensorflow/tests/test_models/models_pbtxt/undefined_input_shape.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import tensorflow.compat.v1 as tf
tf.reset_default_graph()
with tf.Session() as sess:
x = tf.placeholder(dtype=tf.float32, shape=None, name='x')
y = tf.placeholder(dtype=tf.float32, shape=[2, 3], name='y')
z = tf.placehold... | 18 | 545 |
sphinx | tests/roots/test-add_source_parser-conflicts-with-users-setting/conf.py | .py | import sys
from pathlib import Path
sys.path.insert(0, str(Path.cwd().resolve()))
from docutils.parsers import Parser
class DummyTestParser(Parser):
supported = ('dummy',)
extensions = ['source_parser']
source_suffix = {
'.rst': 'restructuredtext',
'.test': 'restructuredtext',
}
source_parsers = {
... | 21 | 349 |
wagtail | wagtail/documents/api/v2/serializers.py | .py | from rest_framework.fields import Field
from wagtail.api.v2.serializers import BaseSerializer
from wagtail.api.v2.utils import get_full_url
class DocumentDownloadUrlField(Field):
"""
Serializes the "download_url" field for documents.
Example:
"download_url": "http://api.example.com/documents/1/my_do... | 24 | 619 |
cvxpy | cvxpy/atoms/cummax.py | .py | """
Copyright 2017 Steven Diamond
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | 106 | 2,956 |
cvxpy | cvxpy/problems/objective.py | .py | """
Copyright 2013 Steven Diamond
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | 269 | 7,838 |
wagtail | wagtail/api/v3/tests/test_sites.py | .py | import json
from django.contrib.auth.models import Permission
from django.core.cache import cache
from django.test import TestCase
from django.urls import reverse
from wagtail.api.v3.tests.base import TestV3Base
from wagtail.models import Site
from wagtail.models.sites import (
SITE_ROOT_PATHS_CACHE_KEY,
SITE... | 348 | 13,063 |
beam | sdks/python/apache_beam/typehints/trivial_inference_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... | 520 | 18,034 |
readthedocs.org | readthedocs/telemetry/tests/test_collectors.py | .py | from textwrap import dedent
from unittest import mock
from django.contrib.auth.models import User
from django.test import TestCase
from django_dynamic_fixture import get
from readthedocs.config.tests.test_config import get_build_config
from readthedocs.doc_builder.environments import DockerBuildEnvironment
from readt... | 207 | 6,645 |
returns | returns/primitives/laws.py | .py | from collections.abc import Callable, Sequence
from typing import ClassVar, Final, Generic, TypeVar, final
from returns.primitives.types import Immutable
_Caps = TypeVar('_Caps')
_ReturnType = TypeVar('_ReturnType')
_TypeArgType1 = TypeVar('_TypeArgType1')
_TypeArgType2 = TypeVar('_TypeArgType2')
_TypeArgType3 = Type... | 148 | 3,717 |
beam | sdks/python/apache_beam/coders/observable_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... | 58 | 1,796 |
textual | src/textual/renderables/tint.py | .py | from __future__ import annotations
from typing import Iterable
from rich.console import RenderableType
from rich.segment import Segment
from rich.style import Style
from rich.terminal_theme import TerminalTheme
from textual.color import TRANSPARENT, Color
from textual.filter import ANSIToTruecolor
class Tint:
... | 87 | 2,605 |
loguru | tests/test_filesink_retention.py | .py | import datetime
import os
from unittest.mock import Mock
import pytest
from loguru import logger
from .conftest import check_dir
@pytest.mark.parametrize("retention", ["1 hour", "1H", " 1 h ", datetime.timedelta(hours=1)])
def test_retention_time(freeze_time, tmp_path, retention):
i = logger.add(tmp_path / "te... | 364 | 10,233 |
onnx | onnx/reference/ops/op_argmin.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 _argmin(data, axis=0, keepdims=True):
result = np.argmin(data, axis=axis)
if keepdims and len(result.shape) < len(data.shape):
... | 43 | 1,182 |
confluent-kafka-python | src/confluent_kafka/schema_registry/rules/encryption/dek_registry/dek_registry_client.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2024 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 683 | 20,451 |
wandb | tests/system_tests/test_artifacts/test_misc2.py | .py | from __future__ import annotations
from collections.abc import Callable
import numpy as np
import wandb
from pytest import mark, raises
from wandb.sdk.artifacts.exceptions import ArtifactNotLoggedError
def test_artifact_log_with_network_error(wandb_backend_spy):
gql = wandb_backend_spy.gql
wandb_backend_spy... | 249 | 8,676 |
sphinx | sphinx/domains/c/_ast.py | .py | from __future__ import annotations
import sys
import warnings
from typing import TYPE_CHECKING, cast
from docutils import nodes
from sphinx import addnodes
from sphinx.domains.c._ids import _id_prefix, _max_id
from sphinx.util.cfamily import (
ASTBaseBase,
ASTBaseParenExprList,
UnsupportedMultiCharacterC... | 1,969 | 65,853 |
kombu | t/unit/transport/SQS/test_SQS_SNS.py | .py | """Testing module for the kombu.transport.SQS package.
NOTE: The SQSQueueMock and SQSConnectionMock classes originally come from
http://github.com/pcsforeducation/sqs-mock-python. They have been patched
slightly.
"""
from __future__ import annotations
import json
import logging
from datetime import datetime, timedelt... | 2,055 | 77,418 |
wandb | wandb/plot/__init__.py | .py | """Chart Visualization Utilities
This module offers a collection of predefined chart types, along with functionality
for creating custom charts, enabling flexible visualization of your data beyond the
built-in options.
"""
__all__ = [
"line",
"histogram",
"scatter",
"bar",
"roc_curve",
"pr_cur... | 31 | 863 |
python-prompt-toolkit | examples/telnet/toolbar.py | .py | #!/usr/bin/env python
"""
Example of a telnet application that displays a bottom toolbar and completions
in the prompt.
"""
import logging
from asyncio import run
from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.contrib.telnet.server import TelnetServer
from prompt_toolkit.shortcuts import Prom... | 46 | 1,110 |
clearml | clearml/backend_interface/task/args.py | .py | import argparse
import yaml
from enum import Enum
from inspect import isfunction
from argparse import (
_StoreAction, # noqa
ArgumentError, # noqa
_StoreConstAction, # noqa
_SubParsersAction, # noqa
_AppendAction, # noqa
SUPPRESS, # noqa
) # noqa
from copy import copy
from typing impo... | 775 | 33,563 |
probability | tensorflow_probability/python/sts/__init__.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... | 80 | 3,376 |
pyomo | pyomo/contrib/incidence_analysis/tests/test_visualize.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... | 46 | 1,897 |
hydra | tests/test_apps/app_with_config_with_free_group/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig
import hydra
@hydra.main(config_path="conf", config_name="config")
def my_app(_: DictConfig) -> None:
pass
if __name__ == "__main__":
my_app()
| 14 | 260 |
biopython | Bio/Phylo/PAML/chi2.py | .py | # Copyright (C) 2011 by Brandon Invergo (b.invergo@gmail.com)
#
# 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 included as part of this
# package.
#
# This code is ada... | 138 | 3,743 |
lemur | lemur/authorizations/models.py | .py | """
.. module: lemur.authorizations.models
:platform: unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Netflix Secops <secops@netflix.com>
"""
from sqlalchemy import Column, Integer, String
from sqlalchemy_utils import JSONType... | 35 | 1,085 |
openvino | src/frontends/tensorflow/tests/test_models/gen_scripts/__init__.py | .py | # do not print messages from TensorFlow
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' | 3 | 90 |
pyomo | pyomo/core/util.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... | 258 | 7,854 |
cvxpy | cvxpy/atoms/elementwise/exp.py | .py | """
Copyright 2013 Steven Diamond, Eric Chu
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... | 108 | 2,909 |
conda | conda/gateways/repodata/zstd.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Zstd interface for repodata."""
from __future__ import annotations
import logging
import os
import re
import shutil
import time
from contextlib import contextmanager
from typing import TYPE_CHECKING
from requests import HTTPError # noqa: ... | 316 | 9,732 |
onnx | onnx/reference/ops/experimental/op_im2col.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from onnx.reference.ops.experimental._op_run_experimental import OpRunExperimental
from onnx.reference.ops_optimized.op_conv_optimized import im2col_fast
class Im2Col(OpRunExperimental):
def _run(... | 36 | 1,406 |
qutip | qutip/_mkl/spmv.py | .py | import numpy as np
from ctypes import POINTER, c_int, c_char, byref
from numpy.ctypeslib import ndpointer
import qutip.settings as qset
zcsrgemv = qset.mkl_lib.mkl_cspblas_zcsrgemv
def mkl_spmv(A, x):
"""
sparse csr_spmv using MKL
"""
m, _ = A.shape
# Pointers to data of the matrix
data = A.d... | 39 | 1,196 |
django-cms | cms/tests/test_multilingual.py | .py | import copy
from django.contrib.sites.models import Site
from django.test.utils import override_settings
from django.urls import reverse
from cms.api import add_plugin, create_page, create_page_content
from cms.exceptions import LanguageError
from cms.forms.utils import update_site_and_page_choices
from cms.models im... | 319 | 13,845 |
mlflow | dev/clint/tests/rules/test_use_gh_token.py | .py | from pathlib import Path
import pytest
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import lint_file
from clint.rules.use_gh_token import UseGhToken
@pytest.mark.parametrize(
"code",
[
pytest.param(
'import os\n\ntoken = os.getenv("GITHUB_TOKEN")',... | 59 | 1,728 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_FloorDiv.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import platform
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng()
def list_arm_platforms():
return ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']
class TestFlo... | 128 | 4,842 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineperkey_combinefn.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");... | 85 | 2,479 |
pyomo | pyomo/contrib/piecewise/tests/test_univariate_nonlinear_decomposition.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... | 177 | 6,302 |
lemur | lemur/common/health.py | .py | """
.. module: lemur.common.health
:platform: Unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
from flask import Blueprint
from sentry_sdk import capture_exception
from lemur.database ... | 32 | 683 |
openvino | src/bindings/python/src/openvino/opset17/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# New operations added in Opset17
from openvino.opset17.ops import erfinv
from openvino.opset17.ops import grouped_matmul
# Operators from previous opsets
# TODO (ticket: 179247): Add previous opset operators at ... | 11 | 351 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_SpaceToBatchND.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
class TestSpaceToBatchND(CommonTFLayerTest):
def create_space_to_batch_nd_net(self, input_shape, block_shape, paddings):
tf.comp... | 34 | 1,374 |
onnx | onnx/reference/ops/op_conv_integer.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
from onnx.reference.ops.op_conv import _conv_implementation
class ConvInteger(OpRun):
def _run(
self,
X,
W,
... | 53 | 1,436 |
saleor | saleor/app/management/commands/create_app.py | .py | import json
from typing import Any
import graphene
from django.core.management import BaseCommand, CommandError
from django.core.management.base import CommandParser
from django.urls import reverse
from requests.exceptions import RequestException
from .... import schema_version
from ....app.headers import AppHeaders,... | 104 | 3,648 |
readthedocs.org | readthedocs/rtd_tests/fixtures/sample_repo/source/conf.py | .py | #
# sample documentation build configuration file, created by
# sphinx-quickstart on Sat Jun 18 07:17:29 2011.
#
# This file is execfile()d with the current directory set to its containing
# dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values h... | 228 | 7,030 |
readthedocs.org | readthedocs/organizations/urls/public.py | .py | """URLs that don't require login."""
from django.urls import path
from django.urls import re_path
from readthedocs.organizations.views import public as views
urlpatterns = [
path(
"verify-email/",
views.OrganizationTemplateView.as_view(template_name="organizations/verify_email.html"),
na... | 43 | 1,147 |
textual | tests/snapshot_tests/snapshot_apps/button_widths.py | .py | from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Button
class HorizontalWidthAutoApp(App[None]):
CSS = """
Horizontal {
border: solid red;
height: auto;
width: auto;
}
"""
def compose(self) -> ComposeResult:
... | 26 | 631 |
coveragepy | lab/hack_pyc.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Wicked hack to get .pyc files to do bytecode tracing instead of
line tracing.
"""
import marshal, new, opcode, sys, types
from lnotab import lnotab_numbers, ... | 99 | 2,860 |
probability | tensorflow_probability/python/math/psd_kernels/feature_transformed_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... | 212 | 8,015 |
wagtail | wagtail/admin/active_filters.py | .py | from collections import namedtuple
import django_filters
from django.core.exceptions import ImproperlyConfigured
from django.forms import BoundField, ModelChoiceField
from django.http import QueryDict
from django.utils.formats import date_format
from django.utils.translation import gettext as _
from django.utils.trans... | 219 | 6,935 |
confluent-kafka-python | tests/integration/schema_registry/data/proto/PublicTestProto_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: tests/integration/schema_registry/data/proto/PublicTestProto.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google... | 33 | 1,334 |
sphinx | tests/test_theming/test_html_theme.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from sphinx.testing.util import SphinxTestApp
@pytest.mark.sphinx('html', testroot='theming')
def test_theme_options(app: SphinxTestApp) -> None:
app.build()
result = (app.outdir / '_static' / 'document... | 51 | 1,447 |
saleor | saleor/graphql/attribute/tests/queries/test_attributes_sort.py | .py | import graphene
from .....attribute import AttributeType
from .....attribute.models import AssignedProductAttributeValue, Attribute
from .....attribute.utils import associate_attribute_values_to_instance
from ....tests.utils import get_graphql_content
ATTRIBUTES_SORT_QUERY = """
query($sortBy: AttributeSortingInp... | 224 | 7,334 |
beam | sdks/python/apache_beam/io/gcp/gcsio.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... | 757 | 26,552 |
sqlmap | tamper/space2hash.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
import string
from lib.core.common import singleTimeWarnMessage
from lib.core.compat import xrange
from lib.core.enums import DBMS
from lib.core.enums imp... | 66 | 1,989 |
hydra | tests/test_apps/user-config-dir/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, OmegaConf
import hydra
@hydra.main(config_path="conf", config_name="config")
def my_app(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))
if __name__ == "__main__":
my_app()
| 14 | 298 |
loguru | tests/exceptions/source/diagnose/indentation_error.py | .py | import sys
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="", colorize=True, backtrace=False, diagnose=True)
code = """
if True:
a = 5
print("foobar") #intentional faulty indentation here.
b = 7
"""
try:
exec(code)
except IndentationError:
logger.exception("")
| 20 | 316 |
openvino | tests/layer_tests/onnx_tests/test_where.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
pytest.importorskip("openvino.tools.mo", reason="Ticket - 157136")
from common.layer_test_class import check_ir_version
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
fro... | 104 | 4,291 |
cvxpy | cvxpy/reductions/dgp2dcp/canonicalizers/add_canon.py | .py | """
Copyright 2024 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, so... | 46 | 1,587 |
textual | docs/examples/guide/layout/horizontal_layout.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Static
class HorizontalLayoutExample(App):
CSS_PATH = "horizontal_layout.tcss"
def compose(self) -> ComposeResult:
yield Static("One", classes="box")
yield Static("Two", classes="box")
yield Static("Three", classes... | 17 | 407 |
pyomo | pyomo/core/tests/unit/test_initializer.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... | 958 | 32,480 |
pyomo | pyomo/contrib/interior_point/tests/test_inverse_reduced_hessian.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... | 173 | 5,995 |
onnxruntime | onnxruntime/test/testdata/matmul_with_dynamic_input_shape.py | .py | from pathlib import Path
import onnx
from onnx import TensorProto, helper
# This model contains a MatMul where:
# - A has shape [M, K] and `M` is a dynamic dimension.
# - B is an initializer with shape [K, N].
# - This is important for the CoreML EP which only handles the case where B is an initializer.
# M is dyn... | 35 | 1,018 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/combinevalues_multiple_arguments.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,874 |
biopython | Tests/test_PDB_binary_cif.py | .py | """
Tests for BinaryCIF code in the PDB package.
"""
import unittest
from Bio.PDB import MMCIFParser
from Bio.PDB.binary_cif import BinaryCIFParser
class TestBinaryCIFParser(unittest.TestCase):
def test_get_structure(self):
mmcif_parser = MMCIFParser(auth_chains=False)
bcif_parser = BinaryCIFPar... | 26 | 753 |
onnx | onnx/reference/ops/op_stft.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
from onnx.reference.ops.op_concat_from_sequence import _concat_from_sequence
from onnx.reference.ops.op_dft import _cfft as _dft
from onnx.refe... | 168 | 5,349 |
openvino | tests/layer_tests/pytorch_tests/test_reshape_as.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestReshapeAs(PytorchLayerTest):
def _prepare_input(self, shape1, shape2):
return (np.ones(shape1, dtype=np.float32... | 40 | 1,452 |
mlflow | mlflow/telemetry/constant.py | .py | from mlflow.ml_package_versions import GENAI_FLAVOR_TO_MODULE_NAME, NON_GENAI_FLAVOR_TO_MODULE_NAME
# NB: Kinesis PutRecords API has a limit of 500 records per request
BATCH_SIZE = 500
BATCH_TIME_INTERVAL_SECONDS = 10
MAX_QUEUE_SIZE = 1000
MAX_WORKERS = 1
CONFIG_STAGING_URL = "https://config-staging.mlflow-telemetry.i... | 98 | 2,075 |
pyro | examples/contrib/mue/ProfileHMM.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
"""
A standard profile HMM model [1], which corresponds to a constant (delta
function) distribution with a MuE observation [2]. This is a standard
generative model of variable-length biological sequences (e.g. proteins) which
does not ... | 322 | 10,356 |
wagtail | wagtail/admin/tests/test_editing_sessions.py | .py | import datetime
import swapper
from django.conf import settings
from django.contrib.admin.utils import quote
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase, override_settings
from django.urls import reverse
from djang... | 1,831 | 72,284 |
cvxpy | cvxpy/tests/test_logic.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
... | 375 | 14,233 |
probability | tensorflow_probability/python/internal/backend/numpy/linalg.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... | 113 | 5,632 |
conda | conda/env/installers/base.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Dynamic installer loading."""
import importlib
from ...exceptions import InvalidInstaller
def get_installer(name, *, file=None):
"""Load the environment installer module for the given name.
Args:
name: Installer name (e.g... | 24 | 677 |
clearml | clearml/model.py | .py | from abc import ABC, abstractmethod
import math
import os
import shutil
import zipfile
from tempfile import mkstemp
from typing import (
List,
Dict,
Union,
Optional,
Mapping,
TYPE_CHECKING,
Sequence,
Tuple,
Callable,
Any,
)
from uuid import uuid4
import numpy as np
try:
imp... | 2,771 | 103,255 |
mlflow | tests/prompt/test_promptlab_model.py | .py | from unittest import mock
import pandas as pd
from mlflow.deployments import set_deployments_target
from mlflow.entities.param import Param
from mlflow.prompt.promptlab_model import _PromptlabModel
set_deployments_target("http://localhost:5000")
def construct_model(route):
return _PromptlabModel(
"Writ... | 100 | 2,834 |
loguru | tests/exceptions/source/others/exception_in_property.py | .py | import sys
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="", diagnose=True, backtrace=True, colorize=False)
class A:
@property
def value(self):
try:
1 / 0
except:
logger.opt(exception=True).debug("test")
return None
else:
... | 23 | 373 |
toolz | toolz/sandbox/tests/test_parallel.py | .py | from toolz.sandbox.parallel import fold
from toolz import reduce
from operator import add
from pickle import dumps, loads
from multiprocessing import Pool
# is comparison will fail between this and no_default
no_default2 = loads(dumps('__no__default__'))
def test_fold():
assert fold(add, range(10), 0) == reduce... | 31 | 904 |
probability | tensorflow_probability/python/experimental/psd_kernels/additive_kernel.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... | 216 | 8,649 |
wagtail | wagtail/snippets/tests/test_management.py | .py | from django.apps import apps
from django.contrib.contenttypes.models import ContentType
from django.db import migrations
from django.test import TestCase
from wagtail.snippets.models import create_extra_permissions
class TestCreatePermissions(TestCase):
def setUp(self):
self.app_config = apps.get_app_con... | 27 | 894 |
pyro | tests/contrib/forecast/test_evaluate.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import math
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro.contrib.forecast import Forecaster, ForecastingModel, HMCForecaster, backtest
from pyro.contrib.forecast.evaluate import DEFAULT_METRICS
f... | 150 | 4,477 |
django-cms | cms/models/__init__.py | .py | # isort: skip_file
from .settingmodels import * # noqa: F401,F403
from .pagemodel import * # noqa: F401,F403
from .permissionmodels import * # noqa: F401,F403
from .placeholdermodel import * # noqa: F401,F403
from .pluginmodel import * # noqa: F401,F403
from .contentmodels import * # noqa: F401,F403
from .placeh... | 14 | 531 |
openvino | tests/model_hub_tests/jax/test_hf_transformers.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import pytest
import requests
from huggingface_hub import snapshot_download
from PIL import Image
from models_hub_common.constants import hf_cache_dir, clean_hf_cache_dir
from models_hub_common.utils import cleanup_dir, get_mod... | 78 | 3,475 |
beam | sdks/python/apache_beam/runners/dataflow/dataflow_job_service.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... | 85 | 3,074 |
saleor | saleor/graphql/product/bulk_mutations/product_variant_bulk_create.py | .py | from collections import defaultdict
from typing import cast
import graphene
from babel.core import get_global
from django.core.exceptions import ValidationError
from django.db.models import F
from graphene.utils.str_converters import to_camel_case
from ....attribute import AttributeType
from ....core.tracing import t... | 1,008 | 36,882 |
saleor | saleor/payment/interface.py | .py | import datetime
from collections.abc import Callable
from dataclasses import InitVar, dataclass, field
from decimal import Decimal
from enum import Enum
from functools import cached_property
from typing import TYPE_CHECKING, Any, Optional, Union
from ..order import FulfillmentLineData
from ..order.fetch import OrderLi... | 460 | 12,812 |
onnx | onnx/backend/test/cmd_tools.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import argparse
import json
import os
import shutil
import onnx.backend.test.case.model as model_test
from onnx import TensorProto, numpy_helper
TOP_DIR = os.path.realpath(os.path.dirname(__file__))
D... | 141 | 5,686 |
pyomo | pyomo/future.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... | 133 | 4,397 |
mlflow | mlflow/utils/doctor.py | .py | import os
import platform
import click
import importlib_metadata
import yaml
from packaging.requirements import Requirement
import mlflow
from mlflow.utils.databricks_utils import get_databricks_runtime_version
def doctor(mask_envs=False):
"""Prints out useful information for debugging issues with MLflow.
... | 124 | 3,892 |
tablib | src/tablib/exceptions.py | .py | class TablibException(Exception):
"""Tablib common exception."""
class InvalidDatasetType(TablibException, TypeError):
"""Only Datasets can be added to a Databook."""
class InvalidDimensions(TablibException, ValueError):
"""The size of the column or row doesn't fit the table dimensions."""
class Inval... | 23 | 635 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.