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 |
|---|---|---|---|---|---|
jupyterlab | jupyterlab/tests/test_plugin_manager_handler.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import json
import pytest
from jupyterlab_server.config import get_static_page_config
from tornado.httpclient import HTTPClientError
from jupyterlab.commands import get_app_info, lock_extension, unlock_extension
from... | 160 | 5,665 |
kafka | tests/kafkatest/tests/client/client_compatibility_produce_consume_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 ... | 113 | 5,972 |
scikit-bio | skbio/tree/tests/test_compare.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.
# --------------------------------------------... | 224 | 7,873 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_LogicalBinaryOps.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng(23345)
class TestLogicalBinaryOps(CommonTFLayerTest):
def _prepare_input(self, inputs_in... | 55 | 2,037 |
saleor | saleor/attribute/tests/fixtures/translation.py | .py | import pytest
from ....tests.utils import dummy_editorjs
from ...models import AttributeTranslation, AttributeValueTranslation
from ...utils import associate_attribute_values_to_instance
@pytest.fixture
def translated_attribute(product):
attribute = product.product_type.product_attributes.first()
return Attr... | 68 | 2,357 |
textual | src/textual/widgets/_placeholder.py | .py | """Provides a Textual placeholder widget; useful when designing an app's layout."""
from __future__ import annotations
from itertools import cycle
from typing import TYPE_CHECKING
from weakref import WeakKeyDictionary
from typing_extensions import Literal, Self
from textual import events
if TYPE_CHECKING:
from... | 187 | 6,435 |
astropy | astropy/cosmology/_src/tests/flrw/test_w0wacdm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Testing :mod:`astropy.cosmology.w0wacdm`."""
import numpy as np
import pytest
import astropy.units as u
from astropy.cosmology import Flatw0waCDM, Planck18, w0waCDM
from astropy.cosmology._src.parameter import Parameter
from astropy.cosmology._src.te... | 285 | 10,089 |
onnxruntime | tools/ci_build/build_args.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.import argparse
import argparse
import os
import platform
import shlex
import sys
import warnings
from util import (
is_linux,
is_macOS,
is_windows,
)
def _str_to_bool(s: str) -> bool:
"""Convert string to bo... | 1,097 | 47,584 |
bazel | src/test/py/bazel/bzlmod/mod_command_test.py | .py | # pylint: disable=g-backslash-continuation
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# 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/LICEN... | 1,699 | 54,742 |
django-cms | cms/test_utils/project/sampleapp/urls_parentapp.py | .py | from django.urls import re_path
from cms.test_utils.project.sampleapp import views
urlpatterns = [
re_path(r'^(?P<path>.+)$', views.parentapp_view, name='parentapp_view'),
]
| 8 | 180 |
wagtail | wagtail/admin/utils.py | .py | import re
from types import SimpleNamespace
from urllib.parse import parse_qs, urlsplit, urlunsplit
from django.conf import settings
from django.utils.http import url_has_allowed_host_and_scheme, urlencode
from django.utils.translation import gettext
def get_admin_base_url():
"""
Gets the base URL for the wa... | 112 | 3,626 |
structlog | src/structlog/exceptions.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.
"""
Exceptions factored out to avoid import loops.
"""
from __future__ import annotations
... | 36 | 899 |
sphinx | tests/test_ext_imgconverter/test_ext_imgconverter.py | .py | """Test sphinx.ext.imgconverter extension."""
from __future__ import annotations
import subprocess
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from sphinx.testing.util import SphinxTestApp
@pytest.fixture
def _if_converter_found(app: SphinxTestApp) -> None:
image_converter = getattr(a... | 46 | 1,364 |
beam | sdks/python/apache_beam/runners/interactive/caching/reify.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... | 112 | 4,105 |
wagtail | wagtail/snippets/bulk_actions/__init__.py | .py | from .delete import DeleteBulkAction
__all__ = ["DeleteBulkAction"]
| 4 | 69 |
wagtail | wagtail/images/api/v2/serializers.py | .py | from rest_framework.fields import Field
from wagtail.api.v2.serializers import BaseSerializer
class ImageDownloadUrlField(Field):
"""
Serializes the "download_url" field for images.
Example:
"download_url": "/media/images/a_test_image.jpg"
"""
def get_attribute(self, instance):
retu... | 23 | 501 |
beam | sdks/python/apache_beam/coders/coder_impl.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... | 2,161 | 78,342 |
wagtail | wagtail/admin/viewsets/__init__.py | .py | from django.urls import include, path
from wagtail import hooks
from wagtail.admin.viewsets.base import ViewSetGroup
class ViewSetRegistry:
def __init__(self):
self.viewsets = []
def populate(self):
for fn in hooks.get_hooks("register_admin_viewset"):
viewset = fn()
i... | 54 | 1,476 |
mlflow | mlflow/store/tracking/databricks_rest_store.py | .py | import base64
import logging
import time
from collections import defaultdict
from datetime import datetime
from typing import Any
from urllib.parse import quote, urlencode
from opentelemetry.proto.collector.trace.v1.trace_service_pb2 import ExportTraceServiceRequest
from pydantic import BaseModel
from mlflow.entities... | 1,230 | 48,287 |
saleor | saleor/graphql/menu/mutations/menu_item_delete.py | .py | import graphene
from ....menu import models
from ....permission.enums import MenuPermissions
from ....webhook.event_types import WebhookEventAsyncType
from ...core import ResolveInfo
from ...core.context import ChannelContext
from ...core.mutations import ModelDeleteMutation
from ...core.types import MenuError
from ..... | 42 | 1,454 |
pdm | tests/cli/test_lock.py | .py | from datetime import datetime, timezone
from pathlib import Path
from unittest.mock import ANY
import pytest
from unearth import Link
from pdm.cli import actions
from pdm.exceptions import PdmUsageError
from pdm.models.requirements import parse_requirement
from pdm.models.specifiers import PySpecSet
from pdm.project.... | 1,196 | 48,761 |
pyomo | pyomo/common/tests/test_sorting.py | .py | # -*- coding: utf-8 -*-
# ____________________________________________________________________________________
#
# 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 En... | 117 | 3,542 |
onnx | onnx/backend/test/case/node/maxpool.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.reference.ops.op_pool_common import (
get_output_shape_auto_pad,... | 726 | 22,111 |
wagtail | wagtail/admin/search.py | .py | from django.forms import Media, MediaDefiningClass
from django.forms.utils import flatatt
from django.template.loader import render_to_string
from django.utils.functional import cached_property
from django.utils.safestring import mark_safe
from django.utils.text import slugify
from wagtail import hooks
from wagtail.ad... | 143 | 4,551 |
probability | tensorflow_probability/python/distributions/beta_binomial_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... | 388 | 15,670 |
biopython | Bio/Align/msf.py | .py | # Copyright 2019, National Marrow Donor Program (NMPD). All rights reserved.
# Written by Peter Cock, The James Hutton Institute, under contract to NMDP.
#
# 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 th... | 245 | 9,481 |
astropy | astropy/io/ascii/latex.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""An extensible ASCII table reader and writer.
latex.py:
Classes to read and write LaTeX tables
:Copyright: Smithsonian Astrophysical Observatory (2011)
:Author: Tom Aldcroft (aldcroft@head.cfa.harvard.edu)
"""
import re
from collections.abc import G... | 541 | 19,148 |
pymc | pymc/dims/__init__.py | .py | # Copyright 2025 - 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... | 55 | 1,933 |
pyomo | examples/pyomobook/scripts-ch/warehouse_script.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... | 31 | 956 |
wandb | tests/system_tests/test_launch/test_launch_cli.py | .py | import json
from unittest.mock import AsyncMock, MagicMock, Mock
import pytest
import wandb
from wandb.cli import cli
from wandb.sdk.launch.errors import LaunchError
REPO_CONST = "test-repo"
IMAGE_CONST = "fake-image"
QUEUE_NAME = "test_queue"
def _setup_agent(monkeypatch, pop_func):
monkeypatch.setattr("wandb.... | 395 | 11,833 |
returns | returns/contrib/mypy/_typeops/visitor.py | .py | from collections.abc import Iterable
from mypy.typeops import erase_to_bound
from mypy.types import (
AnyType,
CallableType,
DeletedType,
ErasedType,
Instance,
LiteralType,
NoneType,
Overloaded,
PartialType,
ProperType,
TupleType,
TypedDictType,
TypeOfAny,
TypeTy... | 144 | 4,454 |
coremltools | coremltools/test/xgboost_tests/test_boosted_trees_regression.py | .py | # Copyright (c) 2017, 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 json
import tempfile
import unittest
from ..utils import load_boston
from coremltools._deps impo... | 270 | 10,280 |
saleor | saleor/csv/tests/export/products_data/test_get_products_data.py | .py | import json
import graphene
from measurement.measures import Weight
from .....attribute.models import Attribute, AttributeValue
from .....attribute.utils import (
associate_attribute_values_to_instance,
)
from .....channel.models import Channel
from .....product.models import Product, ProductVariant, VariantMedia... | 525 | 18,023 |
textual | docs/examples/app/question_title02.py | .py | from textual.app import App, ComposeResult
from textual.events import Key
from textual.widgets import Button, Header, Label
class MyApp(App[str]):
CSS_PATH = "question02.tcss"
TITLE = "A Question App"
SUB_TITLE = "The most important question"
def compose(self) -> ComposeResult:
yield Header()... | 29 | 800 |
pyomo | pyomo/core/tests/unit/test_expr_misc.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... | 243 | 9,093 |
sphinx | sphinx/search/_stopwords/da.py | .py | # automatically generated by utils/generate-snowball.py
# from https://github.com/snowballstem/snowball-website/raw/efb4ae4d65769fb1652acbe608c0c817e746c730/algorithms/danish/stop.txt
from __future__ import annotations
DANISH_STOPWORDS = frozenset({
'ad',
'af',
'alle',
'alt',
'anden',
'at',
... | 102 | 1,337 |
pyro | tutorial/source/search_inference.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
Inference algorithms and utilities used in the RSA example models.
Adapted from: http://dippl.org/chapters/03-enumeration.html
"""
import collections
import functools
import queue
import torch
import pyro.distributions as d... | 226 | 7,589 |
conda | tests/cli/test_cli_install.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from argparse import Namespace
from typing import TYPE_CHECKING
import pytest
from conda.base.context import context, reset_context
from conda.cli.install import reinstall_packages
from conda.core.prefix_dat... | 269 | 8,265 |
python-prompt-toolkit | examples/prompts/history/persistent-history.py | .py | #!/usr/bin/env python
"""
Simple example of a CLI that keeps a persistent history of all the entered
strings in a file. When you run this script for a second time, pressing
arrow-up will go back in history.
"""
from prompt_toolkit import PromptSession
from prompt_toolkit.history import FileHistory
def main():
ou... | 27 | 728 |
sqlmap | lib/utils/tui.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 subprocess
import sys
import tempfile
try:
import curses
except ImportError:
curses = None
from lib.core.common import getSafeExString
from lib.core.com... | 934 | 35,265 |
sqlmap | plugins/dbms/presto/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 | 670 |
saleor | saleor/order/tests/test_order.py | .py | from decimal import Decimal
from unittest.mock import patch
import graphene
import pytest
from prices import Money, TaxedMoney
from ...core.utils.translations import get_translation
from ...core.weight import zero_weight
from ...discount import DiscountType, RewardValueType
from ...discount.interface import VariantPr... | 1,392 | 44,185 |
saleor | saleor/graphql/attribute/utils/shared.py | .py | import datetime
from collections import defaultdict
from dataclasses import dataclass
from typing import TYPE_CHECKING, NamedTuple
import orjson
from django.db.models import Model
from django.db.models.expressions import Exists, OuterRef
from ....account import models as account_models
from ....attribute import Attri... | 260 | 9,414 |
gunicorn | tests/requests/invalid/nonascii_01.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.config import Config
from gunicorn.http.errors import InvalidRequestMethod
cfg = Config()
request = InvalidRequestMethod
| 10 | 242 |
sphinx | tests/test_intl/test_catalogs.py | .py | """Test the base build process."""
from __future__ import annotations
import shutil
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from collections.abc import Iterator
from sphinx.testing.fixtures import _app_params
from sphinx.testing.util import SphinxTestAp... | 95 | 3,051 |
readthedocs.org | readthedocs/rtd_tests/tests/test_celery.py | .py | from unittest.mock import patch
import pytest
from allauth.socialaccount.models import SocialAccount
from django.contrib.auth.models import User
from django.test import TestCase
from django_dynamic_fixture import get
from readthedocs.allauth.providers.githubapp.provider import GitHubAppProvider
from readthedocs.build... | 317 | 12,442 |
saleor | saleor/asgi/__init__.py | .py | """ASGI config for Saleor project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
"""
import gc
import os
from django.conf import settings
from ..core.telemetry import initialize_tele... | 48 | 1,492 |
textual | src/textual/widgets/__init__.py | .py | from __future__ import annotations
import typing
from importlib import import_module
from textual.case import camel_to_snake
# For any new built-in Widget we create, not only do we have to import them here and add them to `__all__`,
# but also to the `__init__.pyi` file in this same folder - otherwise text editors a... | 117 | 3,817 |
onnxruntime | onnxruntime/python/tools/transformers/models/bart/utils/export_summarization_edinit.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import ... | 210 | 7,887 |
coremltools | coremltools/converters/mil/mil/passes/defs/optimize_repeat_ops.py | .py | # Copyright (c) 2023, 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 copy
from collections import defaultdict
from typing import List, Text, Tuple
import numpy as... | 1,826 | 76,787 |
mlflow | mlflow/utils/proto_json_utils.py | .py | import base64
import datetime
import importlib
import json
import os
from collections import defaultdict
from copy import deepcopy
from functools import partial
from json import JSONEncoder
from typing import Any
import pydantic
from google.protobuf.descriptor import FieldDescriptor
from google.protobuf.duration_pb2 i... | 736 | 28,650 |
readthedocs.org | readthedocs/analytics/apps.py | .py | """Django app config for the analytics app."""
from django.apps import AppConfig
class AnalyticsAppConfig(AppConfig):
"""Analytics app init code."""
default_auto_field = "django.db.models.BigAutoField"
name = "readthedocs.analytics"
verbose_name = "Analytics"
| 12 | 280 |
readthedocs.org | readthedocs/core/utils/url.py | .py | """URL handling utilities."""
def unsafe_join_url_path(base, *args):
"""
Joins a base URL path with one or more path components.
This does a simple join of the base path with the path components,
inserting a slash between each component.
The resulting path will always start with a slash.
.. ... | 22 | 696 |
cvxpy | cvxpy/atoms/matrix_frac.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... | 154 | 4,573 |
onnx | onnx/backend/test/case/node/qlinearmatmul.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class QLinearMatMul(Base):
@staticmethod
def export_int() -> None:
... | 152 | 5,272 |
textual | src/textual/widgets/_tree.py | .py | """Provides a tree widget."""
from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING, ClassVar, Generic, Iterable, NewType, TypeVar, cast
import rich.repr
from rich.style import NULL_STYLE, Style
from rich.text import Text, TextType
from textual import events, on
from ... | 1,602 | 51,557 |
mlflow | mlflow/store/db_migrations/versions/a8c4a736bde6_allow_nulls_for_run_id.py | .py | """allow nulls for run_id
Create Date: 2020-12-02 12:14:35.220815
"""
import sqlalchemy as sa
from alembic import op
from mlflow.store.model_registry.dbmodels.models import SqlModelVersion
# revision identifiers, used by Alembic.
revision = "a8c4a736bde6"
down_revision = "84291f40a231"
branch_labels = None
depends... | 26 | 535 |
pdm | tests/models/test_versions.py | .py | import pytest
from pdm.models.versions import InvalidPyVersion, Version
def test_unsupported_post_version() -> None:
with pytest.raises(InvalidPyVersion):
Version("3.10.0post1")
def test_support_prerelease_version() -> None:
assert not Version("3.9.0").is_prerelease
v = Version("3.9.0a4")
a... | 105 | 2,703 |
wandb | wandb/errors/term.py | .py | """Global functions for interacting with the terminal for wandb.
The functions termlog, termwarn and termerror print to stderr.
The function terminput prints to stderr and reads from stdin.
We print to stderr because wandb does not output any messages that are useful
to pipe to another program. Using stderr allows u... | 577 | 16,941 |
pyomo | pyomo/solvers/plugins/__init__.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... | 13 | 617 |
sphinx | tests/roots/test-ext-autodoc/target/autodoc_type_aliases.py | .py | from __future__ import annotations
import io # NoQA: TC003
from typing import TYPE_CHECKING, overload
if TYPE_CHECKING:
from typing import Optional
myint = int
#: docstring
variable: myint
#: docstring
variable2 = None # type: myint
#: docstring
variable3: Optional[myint] # NoQA: UP045
def read(r: io.Byt... | 51 | 743 |
onnxruntime | orttraining/orttraining/python/training/onnxblock/_training_graph_utils.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import copy
import logging
import os
import onnx
from onnxruntime import SessionOptions
from onnxruntime.capi._pybind_state import GradientGraphBuilder, get_optimized_model
def _disable_training_mode(model: onnx.ModelProt... | 243 | 9,629 |
black | tests/data/cases/bytes_docstring.py | .py | def bitey():
b" not a docstring"
def bitey2():
b' also not a docstring'
def triple_quoted_bytes():
b""" not a docstring"""
def triple_quoted_bytes2():
b''' also not a docstring'''
def capitalized_bytes():
B" NOT A DOCSTRING"
# output
def bitey():
b" not a docstring"
def bitey2():
b" a... | 34 | 511 |
pyomo | pyomo/core/tests/unit/kernel/test_sos.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... | 199 | 6,553 |
tqdm | tests/tests_notebook.py | .py | from tqdm.notebook import tqdm as tqdm_notebook
def test_notebook_disabled_description():
"""Test that set_description works for disabled tqdm_notebook"""
with tqdm_notebook(1, disable=True) as t:
t.set_description("description")
| 8 | 248 |
kombu | examples/rpc-tut6/rpc_client.py | .py | #!/usr/bin/env python3
from __future__ import annotations
from kombu import Connection, Consumer, Producer, Queue, uuid
class FibonacciRpcClient:
def __init__(self, connection):
self.connection = connection
self.callback_queue = Queue(uuid(), exclusive=True, auto_delete=True)
def on_respon... | 48 | 1,447 |
mlflow | tests/lightgbm/test_lightgbm_model_export.py | .py | import json
import os
from pathlib import Path
from typing import NamedTuple
from unittest import mock
import cloudpickle
import lightgbm as lgb
import numpy as np
import pandas as pd
import pytest
import skops
import yaml
from sklearn import datasets
from sklearn.pipeline import Pipeline
import mlflow.lightgbm
impor... | 649 | 24,341 |
wagtail | wagtail/admin/views/pages/delete.py | .py | import swapper
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.db import transaction
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.utils.translation import gettext... | 124 | 5,391 |
openvino | tests/layer_tests/pytorch_tests/test_instance_norm.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestInstanceNorm(PytorchLayerTest):
def _prepare_input(self, ndim=4):
shape5d = [3, 6, 10, 5, 2]
shape = shape5d[:ndim]
... | 69 | 2,938 |
wandb | tests/unit_tests/test_lib/test_git.py | .py | #!/usr/bin/env python
"""Tests for the `wandb.GitRepo` module."""
from __future__ import annotations
import os
import subprocess
from collections.abc import Generator
import pytest
from wandb.sdk.lib import gitlib
from wandb.sdk.lib.gitlib import GitCommandError, GitRepo, GitVersion
def run_git(cwd: str, *args: s... | 358 | 13,708 |
mlflow | tests/pyfunc/custom_model/mod1/mod2/__init__.py | .py | from .. import mod4 # noqa
__all__ = ["mod4"]
| 4 | 48 |
conda | conda/env/pip_util.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Functions related to core conda functionality that relates to pip
NOTE: This modules used to in conda, as conda/pip.py
"""
import os
import re
import sys
from logging import getLogger
from ..base.context import context
from ..common.compa... | 70 | 2,092 |
beam | sdks/python/apache_beam/examples/snippets/transforms/other/flatten_test.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");... | 54 | 1,474 |
mlflow | tests/tracking/context/test_jupyter_notebook_context.py | .py | import json
from unittest import mock
import pytest
from mlflow.entities import SourceType
from mlflow.tracking.context.jupyter_notebook_context import (
JupyterNotebookRunContext,
_get_kernel_id,
_get_notebook_name,
_get_notebook_path_from_sessions,
_get_running_servers,
_get_sessions_noteboo... | 349 | 11,792 |
conda | conda/common/url.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Common URL utilities."""
from __future__ import annotations
import codecs
import re
import socket
import struct
from collections import namedtuple
from functools import cache
from getpass import getpass
from os.path import abspath, expandus... | 508 | 15,224 |
wandb | wandb/analytics/opentelemetry/opentelemetry_proxy.py | .py | from __future__ import annotations
import contextlib
import functools
import platform
import traceback
from collections.abc import Callable
from dataclasses import dataclass, fields
from typing import TYPE_CHECKING, Concatenate
from opentelemetry._logs import SeverityNumber
from typing_extensions import Never, ParamS... | 359 | 12,850 |
onnx | tests/python/printer_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import pytest
import onnx
from onnx import parser, printer
class TestBasicFunctions:
def check_graph(self, graph: onnx.GraphProto) -> None:
assert len(graph.node) == 3
assert graph... | 90 | 3,499 |
conda | conda/exports.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Backported exports for conda-build."""
from __future__ import annotations
from builtins import input # noqa: UP029
from io import StringIO
from . import CondaError
from .base.constants import (
DEFAULT_CHANNELS,
DEFAULT_CHANNELS_U... | 390 | 9,263 |
beam | sdks/python/apache_beam/testing/benchmarks/inference/mltransform_one_hot_encoding_benchmark.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... | 151 | 5,285 |
onnxruntime | orttraining/tools/scripts/experiment.py | .py | import argparse
import os # noqa: F401
import re
import sys # noqa: F401
from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.containerregistry import ContainerRegistryManagementClient
from azureml.core import Datastore, Experiment, Run, Workspace # noqa: F401
from azureml.core.comput... | 170 | 6,205 |
pyro | tests/infer/autoguide/test_gaussian.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
from collections import OrderedDict, namedtuple
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.infer import SVI, JitTrace_ELBO, Predictive, Trace_ELBO
from pyro.infer... | 875 | 29,698 |
pyomo | pyomo/core/base/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... | 666 | 24,629 |
cvxpy | cvxpy/reductions/dcp2cone/canonicalizers/__init__.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... | 117 | 5,350 |
astropy | astropy/io/votable/tests/test_coosys.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import io
import pytest
from astropy.coordinates import FK4, FK5, ICRS, AltAz, Galactic, Supergalactic
from astropy.io.votable.exceptions import E16, W27, W57
from astropy.io.votable.table import parse
from astropy.io.votable.tree import CooSys
from astr... | 140 | 4,866 |
beam | sdks/python/apache_beam/examples/ml-orchestration/tfx/coco_captions_utils.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 ... | 88 | 2,966 |
conda | conda/cli/main_search.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""CLI implementation for `conda search`.
Query channels for packages matching the provided package spec.
"""
from __future__ import annotations
from argparse import SUPPRESS
from collections import defaultdict
from datetime import datetime, ... | 364 | 11,037 |
saleor | saleor/graphql/tax/mutations/tax_class_delete.py | .py | from typing import Final
import graphene
from ....permission.enums import CheckoutPermissions
from ....tax import error_codes, models
from ...core.doc_category import DOC_CATEGORY_TAXES
from ...core.mutations import ModelDeleteMutation
from ...core.types import Error
from ..types import TaxClass
TaxClassDeleteErrorC... | 39 | 1,211 |
pyomo | pyomo/core/tests/transform/test_add_slacks.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... | 771 | 27,582 |
textual | tests/snapshot_tests/snapshot_apps/input_percentage_width.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Input, TextArea, Static, Button, Label
class InputVsTextArea(App[None]):
CSS = """
Screen > *, Screen > *:focus {
width: 50%;
height: 1fr;
border: solid red;
}
App #ruler {
width: 1fr;
height... | 36 | 753 |
wandb | wandb/integration/keras/callbacks/__init__.py | .py | __all__ = ("WandbMetricsLogger", "WandbModelCheckpoint", "WandbEvalCallback")
from .metrics_logger import WandbMetricsLogger
from .model_checkpoint import WandbModelCheckpoint
from .tables_builder import WandbEvalCallback
| 6 | 223 |
sphinx | sphinx/util/_files.py | .py | from __future__ import annotations
import hashlib
from pathlib import Path
from typing import TYPE_CHECKING
from sphinx.util._pathlib import _StrPath
if TYPE_CHECKING:
import os
from collections.abc import Set
class FilenameUniqDict(dict[str, tuple[set[str], str]]): # NoQA: FURB189
"""A dictionary tha... | 97 | 3,152 |
readthedocs.org | readthedocs/api/v3/proxied_urls.py | .py | """
Proxied API URLs.
Served from the same domain docs are served,
so they can make use of features that require to have access to their cookies.
"""
from django.urls import path
from readthedocs.api.v3.proxied_views import ProxiedEmbedAPI
from readthedocs.search.api.v3.views import ProxiedSearchAPI
api_proxied_ur... | 20 | 500 |
pyro | pyro/contrib/examples/multi_mnist.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
This script generates a dataset similar to the Multi-MNIST dataset
described in [1].
[1] Eslami, SM Ali, et al. "Attend, infer, repeat: Fast scene
understanding with generative models." Advances in Neural Information
Processin... | 95 | 2,920 |
django-cms | cms/signals/__init__.py | .py | import warnings
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.db.models import signals
from django.dispatch import Signal
from cms.models import (
GlobalPagePermission,
PagePermission,
PageUser,
PageUserGroup,
)... | 129 | 4,510 |
biopython | Tests/test_SeqIO_index.py | .py | # Copyright 2009-2017 by Peter Cock. 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.
"""Unit tests for Bio.SeqIO.index(...) and index_db() functions."""
try:
import sqlite3
... | 805 | 31,453 |
pyomo | pyomo/solvers/tests/checks/test_cplex.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... | 372 | 13,355 |
pyomo | doc/OnlineDocs/src/data/param7b.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 24 | 837 |
ipython | tests/test_splitinput.py | .py | # coding: utf-8
import re
from IPython.core.oinspect import OInfo
from IPython.core.splitinput import split_user_input, LineInfo
import pytest
tests = [
("x=1", ("", "", "x", "=1")),
("?", ("", "?", "", "")),
("??", ("", "??", "", "")),
(" ?", (" ", "?", "", "")),
(" ??", (" ", "??", "", "")),
... | 95 | 2,977 |
sphinx | sphinx/search/_stopwords/ru.py | .py | # automatically generated by utils/generate-snowball.py
# from https://github.com/snowballstem/snowball-website/raw/efb4ae4d65769fb1652acbe608c0c817e746c730/algorithms/russian/stop.txt
from __future__ import annotations
RUSSIAN_STOPWORDS = frozenset({
'а',
'без',
'более',
'больше',
'будет',
'б... | 167 | 2,719 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_pytorch_ddp.py | .py | # This test script is a modified version of Pytorch's tutorial.
# For details, see https://pytorch.org/tutorials/intermediate/ddp_tutorial.html.
import argparse
import inspect
import logging
import os
import sys # noqa: F401
import tempfile
import torch
import torch.distributed as dist
import torch.multiprocessing as... | 280 | 9,021 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.