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 |
|---|---|---|---|---|---|
sphinx | sphinx/ext/linkcode.py | .py | """Add external links to module code in Python object descriptions."""
from __future__ import annotations
from types import FunctionType, NoneType
from typing import TYPE_CHECKING
from docutils import nodes
import sphinx
from sphinx import addnodes
from sphinx.errors import SphinxError
from sphinx.locale import _
... | 101 | 3,040 |
astropy | astropy/units/decorators.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ["quantity_input"]
import contextlib
import inspect
import typing as T
from collections.abc import Sequence
from functools import wraps
from numbers import Number
import numpy as np
from .core import Unit, UnitBase, add_enabled_equivalencies,... | 348 | 12,517 |
hypercorn | src/hypercorn/protocol/http_stream.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable
from enum import auto, Enum
from time import time
from urllib.parse import unquote
from .events import (
Body,
EndBody,
Event,
InformationalResponse,
Request,
Response,
StreamClosed,
Trailers,
)
from ..c... | 262 | 10,018 |
beam | sdks/python/apache_beam/typehints/schemas_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... | 980 | 40,025 |
pyro | tutorial/source/cleannb.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import argparse
import io # for py2/py3 compatible
import nbformat
def cleannb(nbfile):
with io.open(nbfile, "r", encoding="utf8") as f:
nb = nbformat.read(f, as_version=nbformat.NO_CONVERT)
nb["metadata"]["ker... | 33 | 1,002 |
wagtail | wagtail/utils/version.py | .py | # This file is heavily inspired by django.utils.version
def get_version(version):
"""Return a PEP 440-compliant version number from VERSION."""
version = get_complete_version(version)
# Now build the two parts of the version number:
# main = X.Y[.Z]
# sub = .devN - for pre-alpha releases
# ... | 55 | 1,654 |
deap | doc/code/tutorials/part_2/2_2_1_list_of_floats.py | .py | ## 2.2.1 List of floats
import random
import array
import numpy
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", list, fitness=creator.FitnessMax)
IND_SIZE=10
toolbox = base.Toolbox()
toolbox.register("attr_... | 21 | 617 |
colorama | colorama/tests/initialise_test.py | .py | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
import sys
from unittest import TestCase, main, skipUnless
from unittest.mock import patch, Mock
from ..ansitowin32 import StreamWrapper
from ..initialise import init, just_fix_windows_console, _wipe_internal_state_for_tests
from .utils import ... | 186 | 6,678 |
sphinx | tests/test_util/intersphinx_data.py | .py | from __future__ import annotations
import zlib
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Final
INVENTORY_V1: Final[bytes] = b"""\
# Sphinx inventory version 1
# Project: foo
# Version: 1.0
module mod foo.html
module.cls class foo.html
"""
INVENTORY_V2: Final[bytes] = b"""\
# Sphinx i... | 74 | 2,280 |
pyro | pyro/ops/welford.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
class WelfordCovariance:
"""
Implements Welford's online scheme for estimating (co)variance (see :math:`[1]`).
Useful for adapting diagonal and dense mass structures for HMC.
**References**
[1] ... | 102 | 3,409 |
sqlmap | tests/test_wordlist.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Wordlist iterator (lib/core/wordlist.py).
Backs dictionary attacks (--common-tables, password cracking, brute force): a
lazy iterator that streams words across one or more files (and... | 97 | 2,626 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_average.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasAverage(CommonTF2LayerTest):
def create_keras_average_net(self, input_names, input_shapes, input_type, ir_version):
... | 78 | 4,052 |
django-cms | cms/cms_wizards.py | .py | from django.utils.translation import gettext_lazy as _
from cms.models import Page
from cms.utils.page_permissions import user_can_add_page, user_can_add_subpage
from .forms.wizards import CreateCMSPageForm, CreateCMSSubPageForm
from .wizards.wizard_base import Wizard
class CMSPageWizard(Wizard):
def user_has_... | 57 | 1,910 |
conda | conda/plugins/subcommands/doctor/health_checks/missing_files.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Health check: Missing files in packages."""
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
from .....base.constants import OK_MARK, X_MARK
from .....cli.install import reinstall_packages
from .... | 87 | 3,031 |
mlflow | tests/genai/test_mcp_tool_discovery.py | .py | from __future__ import annotations
import asyncio
import socket
import sys
import threading
import time
from types import SimpleNamespace
from typing import Any
from unittest import mock
import pytest
from mlflow.entities.mcp_server import MCPRemoteTransportType, MCPTool
from mlflow.exceptions import MlflowException... | 416 | 13,857 |
saleor | saleor/tests/e2e/orders/test_draft_order_complete_with_transaction.py | .py | import pytest
from .. import DEFAULT_ADDRESS
from ..product.utils.preparing_product import prepare_product
from ..shop.utils.preparing_shop import prepare_default_shop
from ..transactions.utils import create_transaction
from ..utils import assign_permissions
from .utils import (
draft_order_complete,
draft_ord... | 117 | 3,435 |
pdm | src/pdm/formats/uv.py | .py | from __future__ import annotations
import tempfile
from collections.abc import Iterator
from contextlib import ExitStack, contextmanager
from dataclasses import dataclass, field
from functools import cached_property
from pathlib import Path
from typing import Any, cast
import tomlkit
from pdm.models.candidates impor... | 276 | 11,653 |
beam | sdks/python/apache_beam/ml/anomaly/thresholds_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... | 79 | 3,186 |
python-prompt-toolkit | src/prompt_toolkit/layout/menus.py | .py | from __future__ import annotations
import math
from collections.abc import Callable, Iterable, Sequence
from itertools import zip_longest
from typing import TYPE_CHECKING, TypeVar, cast
from weakref import WeakKeyDictionary
from prompt_toolkit.application.current import get_app
from prompt_toolkit.buffer import Compl... | 750 | 27,222 |
kafka | release/git.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... | 141 | 4,004 |
onnx | onnx/backend/test/case/node/convtranspose.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 ConvTranspose(Base):
@staticmethod
def export() -> None:
... | 533 | 21,372 |
saleor | saleor/core/notification/mutation_handler.py | .py | def get_external_notification_payload(objects, extra_payload, payload_function):
return [
_get_extracted_payload_input(payload_input, extra_payload, payload_function)
for payload_input in objects
]
def send_notification(
manager, external_event_type, payloads, channel_slug=None, plugin_id=... | 36 | 1,263 |
mlflow | mlflow/server/auth/db/utils.py | .py | from pathlib import Path
from alembic.command import stamp, upgrade
from alembic.config import Config
from alembic.migration import MigrationContext
from alembic.script import ScriptDirectory
from sqlalchemy import inspect
from sqlalchemy.engine.base import Engine
INITIAL_REVISION = "8606fa83a998"
def _get_alembic_... | 79 | 2,942 |
probability | tensorflow_probability/python/experimental/distribute/sharded_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... | 489 | 18,702 |
conda | tests/plugins/test_solvers.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import logging
import pytest
from conda import plugins
from conda.base.context import context, reset_context
from conda.core import solve
from conda.exceptions import PluginError
from conda.plugins.hookspec import CondaSpecs
from conda.plugins... | 145 | 4,195 |
returns | returns/interfaces/specific/reader_future_result.py | .py | from __future__ import annotations
from abc import abstractmethod
from collections.abc import Awaitable, Callable, Sequence
from typing import TYPE_CHECKING, ClassVar, TypeVar, final
from returns.interfaces.specific import future_result, reader, reader_ioresult
from returns.primitives.asserts import assert_equal
from... | 154 | 4,204 |
confluent-kafka-python | tests/schema_registry/_async/test_config.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2020 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... | 439 | 15,474 |
conda | conda/gateways/disk/read.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Disk utility functions for reading and processing file contents."""
from __future__ import annotations
import hashlib
import os
from base64 import b64encode
from collections import namedtuple
from errno import ENOENT
from functools import p... | 246 | 8,103 |
beam | learning/tour-of-beam/learning-content/io/kafka-io/kafka-write/python-example/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... | 56 | 1,832 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_multi_tensor_split.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import paddle
import numpy as np
import sys
import os
from save_model import saveModel
if paddle.__version__ >= '2.6.0':
import paddle.base as fluid
else:
from paddle import fluid
def create_multi_output_model():
paddle.en... | 47 | 1,483 |
clearml | examples/frameworks/pytorch/pytorch_tensorboard.py | .py | # ClearML - Example of pytorch with tensorboard>=v1.14
#
from __future__ import print_function
import argparse
import os
from tempfile import gettempdir
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
from torch.autograd impor... | 143 | 6,227 |
voila | voila/tornado/execution_request_handler.py | .py | import asyncio
import json
from typing import Awaitable, Union
from jupyter_server.base.handlers import JupyterHandler
from tornado.websocket import WebSocketHandler
from tornado.web import HTTPError
try:
JUPYTER_SERVER_2 = True
from jupyter_server.base.websocket import WebSocketMixin
except ImportError:
J... | 145 | 6,017 |
dirty-equals | dirty_equals/_other.py | .py | from __future__ import annotations
import json
import re
from dataclasses import fields, is_dataclass
from enum import Enum
from functools import lru_cache
from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network, ip_network
from typing import TYPE_CHECKING, Any, Callable, Literal, TypeVar, Union, over... | 590 | 19,070 |
conda | conda/gateways/disk/create.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Disk utility functions for creating new files or directories."""
import os
import sys
import tempfile
import warnings as _warnings
from errno import EACCES, EPERM, EROFS
from logging import getLogger
from os.path import dirname, isdir, isfil... | 524 | 16,949 |
pyomo | pyomo/_archive/template_expr.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... | 17 | 725 |
beam | sdks/python/apache_beam/examples/dataframe/flight_delays.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... | 141 | 4,790 |
onnxruntime | onnxruntime/test/python/onnxruntime_test_python_cudagraph.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import unittest
import numpy as np
from helper import get_name
import onnxruntime as onnxrt
class CudaGraphHelper:
def __init__(
self,
ort_session: onnxrt.InferenceSession,
input_and_output_sha... | 265 | 12,418 |
beam | examples/notebooks/beam-ml/rag_usecase/redis_connector.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... | 349 | 10,852 |
returns | returns/primitives/tracing.py | .py | import types
from collections.abc import Callable, Iterator
from contextlib import AbstractContextManager, contextmanager
from inspect import FrameInfo, stack
from typing import TypeVar, overload
from returns.result import Failure
_FunctionType = TypeVar('_FunctionType', bound=Callable)
@overload
def collect_traces... | 94 | 3,078 |
saleor | saleor/graphql/attribute/tests/mutations/test_attribute_create.py | .py | import json
from unittest import mock
import graphene
import pytest
from django.utils.functional import SimpleLazyObject
from django.utils.text import slugify
from freezegun import freeze_time
from .....attribute import AttributeType
from .....attribute.error_codes import AttributeErrorCode
from .....attribute.models... | 1,932 | 58,625 |
ipython | IPython/core/formatters.py | .py | """Display formatters.
This module defines the base instances in order to implement custom
formatters/mimetypes
got objects:
As we want to see internal IPython working we are going to use the following
function to diaply objects instead of the normal print or display method:
>>> ip = get_ipython()
>>> ip.dis... | 1,090 | 36,429 |
metrics | src/torchmetrics/image/ssim.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... | 454 | 19,532 |
beam | sdks/python/apache_beam/io/gcp/datastore/v1new/rampup_throttling_fn.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... | 102 | 3,682 |
onnxruntime | onnxruntime/test/python/transformers/conftest.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
"""Confi... | 57 | 2,203 |
saleor | saleor/core/utils/lazyobjects.py | .py | import functools
from collections.abc import Callable
from typing import Any
from django.utils.functional import LazyObject, SimpleLazyObject, empty
def lazy_no_retry(func: Callable) -> SimpleLazyObject:
"""Wrap SimpleLazyObject while ensuring it is never re-evaluated on failure.
Wraps a given function into... | 41 | 1,275 |
sqlmap | tests/test_tamper.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Tamper scripts (all ~70): contract, robustness on a payload battery, known
transforms, and documented fragile cases.
NOTE (flagged for author - real minor bugs surfaced by this suite... | 183 | 8,550 |
pyro | pyro/infer/energy_distance.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import operator
from collections import OrderedDict
from functools import reduce
import torch
import pyro
import pyro.poutine as poutine
from pyro.distributions.util import scale_and_mask
from pyro.infer.elbo import ELBO
from pyr... | 230 | 10,044 |
black | tests/data/cases/function2.py | .py | def f(
a,
**kwargs,
) -> A:
with cache_dir():
if something:
result = (
CliRunner().invoke(black.main, [str(src1), str(src2), "--diff", "--check"])
)
limited.append(-limited.pop()) # negate top
return A(
very_long_argument_name1=very_long_value_for... | 122 | 2,419 |
kombu | kombu/asynchronous/debug.py | .py | """Event-loop debugging tools."""
from __future__ import annotations
from kombu.utils.eventio import ERR, READ, WRITE
from kombu.utils.functional import reprcall
def repr_flag(flag):
"""Return description of event loop flag."""
return '{}{}{}'.format('R' if flag & READ else '',
'W... | 68 | 1,773 |
black | tests/data/cases/remove_except_types_parens_pre_py314.py | .py | # flags: --minimum-version=3.11
# SEE PEP 758 FOR MORE DETAILS
# remains unchanged
try:
pass
except:
pass
# remains unchanged
try:
pass
except ValueError:
pass
try:
pass
except* ValueError:
pass
# parenthesis are removed
try:
pass
except (ValueError):
pass
try:
pass
except* (Valu... | 226 | 2,962 |
pyomo | pyomo/common/envvar.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... | 58 | 2,343 |
pdm | src/pdm/environments/python.py | .py | from __future__ import annotations
import os
from typing import TYPE_CHECKING
from pdm.environments.base import BaseEnvironment
from pdm.models.in_process import get_sys_config_paths
from pdm.models.working_set import WorkingSet
if TYPE_CHECKING:
from pdm.project import Project
class PythonEnvironment(BaseEnvi... | 65 | 2,365 |
coremltools | coremltools/converters/mil/experimental/passes/generic_pass_infrastructure.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 itertools
import warnings
from functools import partial
from coremltools.converters.mil.mil i... | 231 | 10,314 |
onnxruntime | onnxruntime/test/python/onnxruntime_test_python_nv_tensorrt_rtx_ep_tests.py | .py | # Copyright (c) NVIDIA Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
import sys
import unittest
from collections.abc import Sequence
import numpy as np
import torch
from autoep_helper import AutoEpTestCase
from helper import get_name
from numpy.testing import a... | 473 | 19,444 |
saleor | saleor/graphql/webhook/mutations/webhook_update.py | .py | import graphene
from django.db.models import Exists, OuterRef
from ....app.models import App
from ....permission.auth_filters import AuthorizationFilters
from ....permission.enums import AppPermission
from ....webhook import models
from ....webhook.validators import HEADERS_LENGTH_LIMIT, HEADERS_NUMBER_LIMIT
from ...a... | 122 | 4,541 |
astropy | astropy/table/tests/test_table.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import copy
import gc
import os
import pathlib
import pickle
import sys
from collections import OrderedDict
from contextlib import nullcontext
from inspect import currentframe, getframeinfo
from io import StringIO
import numpy as np
import pytest
from nu... | 3,412 | 113,994 |
probability | tensorflow_probability/python/internal/test_util_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... | 353 | 11,974 |
metrics | src/torchmetrics/functional/retrieval/recall.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... | 66 | 2,593 |
beam | learning/tour-of-beam/learning-content/io/text-io/text-io-local-read/python-example/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... | 39 | 1,235 |
clearml | clearml/backend_api/services/v2_20/queues.py | .py | """
queues service
Provides a management API for queues of tasks waiting to be executed by workers deployed anywhere (see Workers Service).
"""
from typing import List, Optional, Any
import six
from datetime import datetime
from dateutil.parser import parse as parse_datetime
from clearml.backend_api.session import (
... | 2,832 | 92,952 |
confluent-kafka-python | tests/schema_registry/data/proto/example_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: example.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_d... | 39 | 2,021 |
returns | tests/test_functions/test_compose.py | .py | from returns.functions import compose
def _first(argument: int) -> str:
return str(argument)
def _second(argument: str) -> bool:
return bool(argument)
def test_function_composition():
"""Ensures that functions can be composed and return type is correct."""
second_after_first = compose(_first, _sec... | 18 | 408 |
black | tests/data/cases/docstring_tabs.py | .py | def test():
"""
Test of indentation
Testing indentation
Yes this is testing
Testing again
Shocking!
Wow!
More interesting information
"""
# output
def test():
"""
Test of indentation
Testing indentation
Yes this is testing
Testing again
Shocking!
... | 25 | 378 |
probability | tensorflow_probability/python/distributions/variational_gaussian_process_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... | 464 | 20,811 |
openvino | tests/e2e_tests/common/preprocessors/preprocessors.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Data preprocessors applied to target layers in given data dictionary."""
import logging as log
import sys
# pylint:disable=no-member
import cv2
import numpy as np
from e2e_tests.test_utils.path_utils import resolve_file_path
from .p... | 502 | 18,334 |
saleor | saleor/channel/utils.py | .py | import warnings
from django.conf import settings
from .exceptions import ChannelNotDefined, NoDefaultChannel
from .models import Channel
DEPRECATION_WARNING_MESSAGE = (
"Default channel used in a query. Please make sure that channel is explicitly "
"provided. This behavior works only when a one channel exist... | 48 | 1,785 |
astropy | astropy/timeseries/tests/test_downsample.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import sys
import warnings
import numpy as np
import pytest
from numpy.testing import assert_equal
from astropy import units as u
from astropy.table import MaskedColumn
from astropy.time import Time
from astropy.timeseries.downsample import (
aggreg... | 437 | 15,535 |
django-cms | cms/signals/permissions.py | .py | from django.contrib.auth import get_user_model
from cms.cache.permissions import clear_user_permission_cache
from cms.models import PageUser, PageUserGroup
from menus.menu_pool import menu_pool
User = get_user_model()
def post_save_user(instance, raw, created, **kwargs):
"""Signal called when new user is create... | 116 | 3,348 |
mlflow | examples/flower_classifier/score_images_spark.py | .py | """
Example of scoring images with MLflow model produced by running this project in Spark.
The MLflow model is loaded to Spark using ``mlflow.pyfunc.spark_udf``. The images are read as binary
data and represented as base64 encoded string column and passed to the model. The results are
returned as a column with predict... | 98 | 2,997 |
saleor | saleor/graphql/menu/tests/mutations/test_menu_delete.py | .py | import json
from unittest import mock
import graphene
import pytest
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....core.utils.json_serializer import CustomJsonEncoder
from .....webhook.event_types import WebhookEventAsyncType
from .....webhook.payloads import generate... | 88 | 2,552 |
coremltools | coremltools/converters/mil/mil/tests/test_debug.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 itertools
import os
import tempfile
import numpy as np
import pytest
import coremltools as c... | 382 | 13,646 |
pyomo | pyomo/scripting/pyomo_main.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... | 111 | 3,196 |
ipython | tests/test_payload.py | .py | """Tests for IPython.core.payload and IPython.core.payloadpage."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import pytest
from IPython.core import payloadpage
from IPython.core.payload import PayloadManager
# -----------------------------------------------... | 143 | 4,228 |
probability | tensorflow_probability/python/sts/components/dynamic_regression_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... | 164 | 6,018 |
astropy | astropy/utils/metadata/exceptions.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Metadata exceptions and warnings."""
from astropy.utils.exceptions import AstropyWarning
__all__ = ["MergeConflictError", "MergeConflictWarning"]
class MergeConflictError(TypeError):
pass
class MergeConflictWarning(AstropyWarning):
pass
| 15 | 318 |
saleor | saleor/graphql/translations/dataloaders.py | .py | from collections import defaultdict
from typing import TypeVar
from ...attribute import models as attribute_models
from ...discount import models as discount_models
from ...menu import models as menu_models
from ...page import models as page_models
from ...product import models as product_models
from ...shipping impor... | 149 | 5,427 |
hydra | examples/tutorials/basic/your_first_hydra_app/1_simple_cli/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, OmegaConf
import hydra
@hydra.main()
def my_app(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))
if __name__ == "__main__":
my_app()
| 14 | 258 |
hydra | tests/test_examples/test_advanced_config_search_path.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import re
from pathlib import Path
from typing import List, Optional
from omegaconf import OmegaConf
from pytest import mark
from hydra.test_utils.test_utils import (
chdir_hydra_root,
run_python_script,
run_with_error,
)
chdir_hydra_... | 49 | 1,338 |
probability | tensorflow_probability/python/experimental/mcmc/expectations_reducer_test.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 92 | 3,556 |
sphinx | tests/roots/test-stylesheets/conf.py | .py | html_theme = 'classic'
templates_path = ['_templates']
def setup(app):
app.add_css_file('persistent.css')
app.add_css_file('default.css', title='Default')
app.add_css_file('alternate1.css', title='Alternate', rel='alternate stylesheet')
app.add_css_file('alternate2.css', rel='alternate stylesheet')
| 10 | 318 |
confluent-kafka-python | src/confluent_kafka/kafkatest/verifiable_producer.py | .py | #!/usr/bin/env python
#
# Copyright 2016 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... | 168 | 5,700 |
wagtail | wagtail/locales/api/v3/__init__.py | .py | from .router import router
__all__ = [
"router",
]
| 6 | 56 |
mlflow | mlflow/tracing/trace_archival_service.py | .py | from __future__ import annotations
import logging
import random
import threading
import time
from contextlib import nullcontext
from dataclasses import dataclass
from mlflow.entities.workspace import TraceArchivalConfig
from mlflow.environment_variables import (
MLFLOW_ENABLE_WORKSPACES,
)
from mlflow.exceptions ... | 213 | 8,102 |
luigi | test/visualiser/visualiser_test.py | .py | """
Test the visualiser's javascript using PhantomJS.
"""
import os
import subprocess
import sys
import threading
import time
import unittest
from selenium import webdriver
import luigi
here = os.path.dirname(__file__)
# Patch-up path so that we can import from the directory above this one.r
# This seems to be ne... | 442 | 14,943 |
biopython | Tests/test_Entrez.py | .py | # Copyright 2015 by Carlos Pena. 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.
"""Offline tests for two Entrez features.
(1) the URL construction of NCBI's Entrez services.
(... | 459 | 16,226 |
onnxruntime | orttraining/orttraining/python/training/utils/torch_type_map.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import torch
# Mapping from pytorch scalar type to onnx scalar type.
_... | 65 | 2,935 |
kafka | tests/kafkatest/tests/end_to_end.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 ... | 162 | 7,213 |
sphinx | tests/test_ext_autodoc/test_ext_autodoc.py | .py | """Test the autodoc extension.
This tests mainly the Documenters; the auto directives are tested in a test
source file translated by test_build.
"""
from __future__ import annotations
import itertools
import logging
import pathlib
import sys
from typing import TYPE_CHECKING
from warnings import catch_warnings
impor... | 3,222 | 99,802 |
luigi | luigi/worker.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 1,284 | 51,163 |
saleor | saleor/graphql/order/bulk_mutations/draft_orders.py | .py | from collections.abc import Iterable
from uuid import UUID
import graphene
from django.conf import settings
from django.core.exceptions import ValidationError
from ....channel import models as channel_models
from ....discount.tasks import release_voucher_code_usage_of_draft_orders
from ....discount.utils.voucher impo... | 204 | 7,514 |
mamba | micromamba/tests/test_clean.py | .py | import os
import platform
from .helpers import * # noqa: F403
from . import helpers
def test_clean_all_removes_shard_cache(tmp_home, tmp_root_prefix):
cache_home = tmp_home / ".cache"
os.environ["XDG_CACHE_HOME"] = str(cache_home)
shard_cache_dir = cache_home / "conda" / "pkgs" / "cache" / "shards"
... | 139 | 5,327 |
readthedocs.org | readthedocs/invitations/tests/test_views.py | .py | from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils import timezone
from django_dynamic_fixture import get
from readthedocs.audit.models import AuditLog
from readthedocs.invitations.models import Invitation
from readthedocs.o... | 608 | 23,408 |
onnx | onnx/backend/test/case/node/averagepool.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,... | 696 | 21,173 |
metrics | src/torchmetrics/functional/image/d_lambda.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... | 153 | 5,623 |
attrs | tests/test_version_info.py | .py | # SPDX-License-Identifier: MIT
import pytest
from attr import VersionInfo
@pytest.fixture(name="vi")
def _vi():
return VersionInfo(19, 2, 0, "final")
class TestVersionInfo:
def test_from_string_no_releaselevel(self, vi):
"""
If there is no suffix, the releaselevel becomes "final" by defau... | 64 | 1,608 |
saleor | saleor/tests/e2e/orders/test_unable_to_void_order_marked_as_paid.py | .py | import pytest
from .. import DEFAULT_ADDRESS
from ..product.utils.preparing_product import prepare_product
from ..shop.utils.preparing_shop import prepare_default_shop
from ..utils import assign_permissions
from .utils import (
draft_order_complete,
draft_order_create,
draft_order_update,
mark_order_pa... | 115 | 2,972 |
pymc | tests/sampling/test_mcmc_external.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... | 510 | 18,245 |
probability | tensorflow_probability/python/experimental/sequential/ensemble_adjustment_kalman_filter.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... | 175 | 7,398 |
jupytext | src/jupytext/pandoc.py | .py | """Jupyter notebook to Markdown and back, using Pandoc"""
import os
import subprocess
import tempfile
# Copy nbformat reads and writes to avoid them being patched in the contents manager!!
from nbformat import reads as ipynb_reads
from nbformat import writes as ipynb_writes
from packaging.version import parse
class... | 119 | 3,673 |
python-prompt-toolkit | examples/choices/frame-and-bottom-toolbar.py | .py | from __future__ import annotations
from prompt_toolkit.filters import is_done
from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.shortcuts import choice
from prompt_toolkit.styles import Style
def main() -> None:
style = Style.from_dict(
{
"frame.border": "#ff4444",
... | 41 | 1,190 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.