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 |
|---|---|---|---|---|---|
luigi | test/scheduler_api_test.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 2,202 | 107,064 |
biopython | Bio/PDB/internal_coords.py | .py | # Copyright 2019-22 by Robert T. Miller. All rights reserved.
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been included as part of this
# package.
"""Classes to suppor... | 4,942 | 188,706 |
coremltools | coremltools/converters/mil/mil/passes/pass_pipeline.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
from __future__ import annotations
from typing import Dict, List, Optional, Set, Text, Union
from t... | 509 | 22,024 |
onnxruntime | onnxruntime/test/python/transformers/test_parity_rotary_embedding.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
# Notes
# 1) The test cases in this file are for the following LLaMA-2 scenarios:
... | 490 | 21,636 |
gunicorn | tests/docker/asgi_framework_compat/tests/test_websocket_scope.py | .py | """
WebSocket Scope Compliance Tests
Tests ASGI 3.0 WebSocket scope compliance across frameworks.
"""
import asyncio
import json
import pytest
import websockets
from websockets.exceptions import ConnectionClosedOK, ConnectionClosedError
from frameworks.contract import (
ASGI_WEBSOCKET_SCOPE_REQUIRED_KEYS,
V... | 194 | 6,844 |
mlflow | mlflow/genai/scorers/online/trace_loader.py | .py | """Trace loading utilities for online scoring."""
import logging
from mlflow.entities import Trace, TraceData, TraceInfo
from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository
from mlflow.store.tracking.abstract_store import AbstractStore
from mlflow.tracing.constant import SpansLocati... | 159 | 6,071 |
textual | src/textual/fuzzy.py | .py | """
Fuzzy matcher.
This class is used by the [command palette](/guide/command_palette) to match search terms.
"""
from __future__ import annotations
from functools import lru_cache
from operator import itemgetter
from re import finditer
from typing import Iterable, Sequence
import rich.repr
from textual.cache imp... | 225 | 6,973 |
probability | tensorflow_probability/python/bijectors/shift.py | .py | # Copyright 2019 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... | 98 | 2,914 |
astropy | astropy/units/docgen.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Utilities for generating documentation for unit definition modules.
None of the functions in the module are meant for use outside of the
package.
"""
import keyword
import re
import unicodedata
from collections.abc import Iterable, Mapping
from io im... | 148 | 3,979 |
saleor | saleor/graphql/giftcard/mutations/gift_card_deactivate.py | .py | import graphene
from ....giftcard import events
from ....giftcard.utils import deactivate_gift_card
from ....permission.enums import GiftcardPermissions
from ....webhook.event_types import WebhookEventAsyncType
from ...app.dataloaders import get_app_promise
from ...core import ResolveInfo
from ...core.doc_category imp... | 56 | 2,093 |
returns | tests/test_iterables/test_fold/test_loop.py | .py | import sys
from collections.abc import Iterable
import pytest
from returns.context import (
NoDeps,
Reader,
ReaderFutureResult,
ReaderIOResult,
ReaderResult,
)
from returns.future import Future, FutureFailure, FutureResult, FutureSuccess
from returns.io import IO, IOFailure, IOSuccess
from returns... | 245 | 7,447 |
pyro | pyro/infer/autoguide/guides.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
The :mod:`pyro.infer.autoguide` module provides algorithms to automatically
generate guides from simple models, for use in :class:`~pyro.infer.svi.SVI`.
For example to generate a mean field Gaussian guide::
def model():
... | 1,289 | 49,219 |
pdm | src/pdm/__main__.py | .py | from pdm.core import main
if __name__ == "__main__":
main()
| 5 | 65 |
cvxpy | cvxpy/reductions/dgp2dcp/canonicalizers/trace_canon.py | .py | from cvxpy.atoms.affine.diag import diag
from cvxpy.reductions.dgp2dcp.canonicalizers.add_canon import add_canon
from cvxpy.reductions.dgp2dcp.util import explicit_sum
def trace_canon(expr, args):
diag_sum = explicit_sum(diag(args[0]))
return add_canon(diag_sum, diag_sum.args)
| 9 | 288 |
sqlmap | plugins/dbms/raima/connector.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.connector import Connector as GenericConnector
class Connector(GenericConnector):
def co... | 16 | 519 |
pyomo | pyomo/contrib/cspline_external/cspline_parameters.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... | 549 | 20,143 |
clearml | clearml/utilities/requests_toolbelt/multipart/encoder.py | .py | # -*- coding: utf-8 -*-
"""
requests_toolbelt.multipart.encoder
===================================
This holds all of the implementation details of the MultipartEncoder
"""
import contextlib
import io
import os
from uuid import uuid4
import requests
from .._compat import fields
class FileNotSupportedError(Except... | 658 | 20,739 |
returns | tests/test_maybe/test_maybe_conversions.py | .py | from returns.maybe import Nothing, Some
def test_some_is_true() -> None:
"""Ensures that ``Something(...)`` is ``True`` when treated as a boolean."""
assert bool(Some(123))
assert bool(Some('abc'))
def test_nothing_is_false() -> None:
"""Ensures that ``Nothing`` is ``False`` when treated as a boolea... | 24 | 653 |
lemur | lemur/tests/test_utils.py | .py | import pytest
from lemur.tests.vectors import (
SAN_CERT,
SAN_CERT_STR,
INTERMEDIATE_CERT,
ROOTCA_CERT,
EC_CERT_EXAMPLE,
ECDSA_PRIME256V1_CERT,
ECDSA_SECP384r1_CERT,
ECDSA_SECP384r1_CERT_STR,
DSA_CERT,
CERT_CHAIN_PKCS7_PEM,
ACME_CHAIN_LONG_STR,
ACME_CHAIN_X1_STR
)
def ... | 161 | 6,528 |
hatch | src/hatch/cli/env/create.py | .py | from __future__ import annotations
import os
from typing import TYPE_CHECKING
import click
from hatch.config.constants import AppEnvVars
if TYPE_CHECKING:
from hatch.cli.application import Application
@click.command(short_help="Create environments")
@click.argument("env_name", default="default")
@click.pass_o... | 50 | 1,566 |
probability | tensorflow_probability/python/distributions/half_student_t.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... | 355 | 13,226 |
probability | tensorflow_probability/python/distributions/skellam.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... | 313 | 11,978 |
textual | src/textual/_work_decorator.py | .py | """
A decorator used to create [workers](/guide/workers).
"""
from __future__ import annotations
from functools import partial, wraps
from inspect import iscoroutinefunction
from typing import TYPE_CHECKING, Callable, Coroutine, TypeVar, Union, cast, overload
from typing_extensions import ParamSpec, TypeAlias
if TY... | 159 | 5,109 |
hydra | plugins/hydra_ax_sweeper/hydra_plugins/hydra_ax_sweeper/_earlystopper.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from typing import Any, Mapping, Optional
log = logging.getLogger(__name__)
class EarlyStopper:
"""Class to implement the early stopping mechanism.
The optimization process is stopped when the performance does not
impro... | 60 | 2,158 |
sphinx | tests/roots/test-ext-autosummary-module_prefix/conf.py | .py | import sys
from pathlib import Path
sys.path.insert(0, str(Path.cwd().resolve()))
extensions = [
'sphinx.ext.autosummary',
]
| 9 | 131 |
mlflow | tests/pyfunc/sample_code/python_model_with_config.py | .py | from mlflow.models import ModelConfig, set_model
from mlflow.pyfunc import PythonModel
base_config = ModelConfig(development_config="tests/pyfunc/sample_code/config.yml")
class MyModel(PythonModel):
def predict(self, context, model_input):
timeout = base_config.get("timeout")
return f"Predict cal... | 14 | 392 |
probability | tensorflow_probability/python/experimental/mcmc/internal/test_fixtures.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... | 121 | 4,243 |
pyomo | examples/pyomo/diet/diet1.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... | 93 | 2,492 |
beam | sdks/python/apache_beam/runners/portability/stager.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 ... | 986 | 41,130 |
kafka | release/gpg.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... | 91 | 2,628 |
mkdocs-material | material/plugins/blog/readtime/parser.py | .py | # Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, c... | 75 | 2,760 |
django-cms | cms/models/placeholderpluginmodel.py | .py | from functools import cached_property
from django.db import models
from cms.models import CMSPlugin
from cms.models.fields import PlaceholderRelationField
from cms.utils.placeholder import get_placeholder_from_slot
class PlaceholderReference(CMSPlugin):
cmsplugin_ptr = models.OneToOneField(
CMSPlugin,
... | 43 | 1,242 |
openvino | tests/layer_tests/onnx_tests/test_squeeze.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
class TestSqueeze(OnnxRuntimeLayerTest):
def create_squeeze_net(self, axes, input_shape, output_shape, ir_version):
"""
... | 223 | 9,173 |
pyomo | pyomo/contrib/pynumero/algorithms/solvers/tests/test_cyipopt_interfaces.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... | 235 | 9,156 |
conda | conda/cli/main_compare.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""CLI implementation for `conda compare`.
Compare the packages in an environment with the packages listed in an environment file.
"""
from __future__ import annotations
import logging
import os
from os.path import abspath, expanduser, expand... | 148 | 4,157 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_utils.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
import numpy
from numpy import array_equa... | 322 | 13,003 |
probability | tensorflow_probability/python/experimental/mcmc/sample_sequential_monte_carlo_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... | 279 | 11,790 |
kafka | tests/kafkatest/services/trogdor/trogdor.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 ... | 355 | 15,206 |
beam | learning/katas/python/Common Transforms/Filter/ParDo/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... | 43 | 1,376 |
luigi | test/worker_task_test.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 188 | 6,351 |
luigi | test/runtests.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... | 28 | 900 |
astropy | astropy/nddata/tests/test_flag_collection.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from astropy.nddata import FlagCollection
def test_init():
FlagCollection(shape=(1, 2, 3))
def test_init_noshape():
with pytest.raises(Exception) as exc:
FlagCollection()
assert (
exc.valu... | 51 | 1,436 |
ipython | IPython/terminal/ipapp.py | .py | """
The :class:`~traitlets.config.application.Application` object for the command
line :command:`ipython` program.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import logging
import os
import sys
import warnings
from traitlets.config.loader import Config
f... | 348 | 12,464 |
readthedocs.org | readthedocs/settings/docker_compose.py | .py | import os
import socket
from .base import CommunityBaseSettings
class DockerBaseSettings(CommunityBaseSettings):
"""Settings for local development with Docker"""
DEBUG = bool(os.environ.get("RTD_DJANGO_DEBUG", False))
DOCKER_ENABLE = True
RTD_DOCKER_COMPOSE = True
RTD_DOCKER_COMPOSE_NETWORK = ... | 283 | 10,839 |
textual | src/textual/widgets/_radio_button.py | .py | """Provides a radio button widget."""
from __future__ import annotations
from textual.widgets._toggle_button import ToggleButton
class RadioButton(ToggleButton):
"""A radio button widget that represents a boolean value.
Note:
A `RadioButton` is best used within a [RadioSet][textual.widgets.RadioSet... | 34 | 1,037 |
wagtail | wagtail/tests/test_date_validators.py | .py | import datetime
from unittest.mock import patch
from django.core.exceptions import ValidationError
from django.test import TestCase
from wagtail.fields import NoFutureDateValidator
class TestNoFutureDateValidator(TestCase):
def setUp(self):
self.validator = NoFutureDateValidator()
def test_validate... | 69 | 2,512 |
pyomo | pyomo/core/tests/unit/test_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... | 207 | 6,951 |
beam | sdks/python/apache_beam/examples/wordcount_with_metrics.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... | 154 | 5,209 |
textual | docs/examples/widgets/placeholder.py | .py | from textual.app import App, ComposeResult
from textual.containers import Container, Horizontal, VerticalScroll
from textual.widgets import Placeholder
class PlaceholderApp(App):
CSS_PATH = "placeholder.tcss"
def compose(self) -> ComposeResult:
yield VerticalScroll(
Container(
... | 39 | 1,231 |
beam | sdks/python/apache_beam/ml/inference/sklearn_inference.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... | 342 | 12,939 |
sqlmap | lib/utils/search.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
import socket
from lib.core.common import getSafeExString
from lib.core.common import popValue
from lib.core.common import pushValue
from lib.core.common import urlenco... | 162 | 6,190 |
mlflow | mlflow/store/artifact/ftp_artifact_repo.py | .py | import ftplib
import os
import posixpath
import urllib.parse
from contextlib import contextmanager
from ftplib import FTP
from urllib.parse import unquote
from mlflow.entities.file_info import FileInfo
from mlflow.exceptions import MlflowException
from mlflow.store.artifact.artifact_repo import ArtifactRepository
from... | 134 | 5,316 |
kombu | kombu/transport/redis.py | .py | """Redis transport module for Kombu.
Features
========
* Type: Virtual
* Supports Direct: Yes
* Supports Topic: Yes
* Supports Fanout: Yes
* Supports Priority: Yes
* Supports Queue TTL: Yes
* Supports Message TTL: No
Connection String
=================
Connection string has the following format:
.. code-block::
... | 1,666 | 59,396 |
pymc | tests/__init__.py | .py | # Copyright 2024 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 18 | 648 |
jupytext | tests/functional/others/test_sample_notebooks_are_normalized.py | .py | import nbformat
import pytest
from packaging import version
import jupytext
@pytest.mark.skipif(
version.parse(nbformat.__version__) <= version.parse("5.7"),
reason="normalize is not available",
)
def test_sample_notebooks_are_normalized(any_nb_file):
if "myst/" in any_nb_file and not jupytext.myst.is_my... | 29 | 817 |
coremltools | deps/pybind11/pybind11/commands.py | .py | from __future__ import annotations
import os
DIR = os.path.abspath(os.path.dirname(__file__))
def get_include(user: bool = False) -> str: # noqa: ARG001
"""
Return the path to the pybind11 include directory. The historical "user"
argument is unused, and may be removed.
"""
installed_path = os.p... | 40 | 1,243 |
python-dotenv | src/dotenv/ipython.py | .py | from IPython.core.magic import Magics, line_magic, magics_class # type: ignore
from IPython.core.magic_arguments import (
argument,
magic_arguments,
parse_argstring,
) # type: ignore
from .main import find_dotenv, load_dotenv
@magics_class
class IPythonDotEnv(Magics):
@magic_arguments()
@argume... | 51 | 1,326 |
probability | tensorflow_probability/python/bijectors/unit_vector_test.py | .py | # Copyright 2022 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... | 159 | 5,927 |
cvxpy | cvxpy/tests/test_zero_sized.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
... | 320 | 12,561 |
sphinx | tests/test_util/test_util_i18n.py | .py | """Test i18n util."""
from __future__ import annotations
import datetime
import os
import time
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from babel.messages.mofile import read_mo
from sphinx.errors import SphinxError
from sphinx.util import i18n
if TYPE_CHECKING:
from sphinx.testi... | 213 | 8,353 |
mlflow | mlflow/version.py | .py | # Copyright 2018 Databricks, Inc.
import importlib.metadata
import re
VERSION = "3.15.2.dev0"
def is_release_version():
return bool(re.match(r"^\d+\.\d+\.\d+$", VERSION))
def _is_package_installed(package_name: str) -> bool:
try:
importlib.metadata.version(package_name)
return True
exce... | 30 | 974 |
probability | spinoffs/inference_gym/inference_gym/tools/stan/probit_regression.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... | 136 | 4,341 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_logical_or.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# logical_or paddle model generator
#
import numpy as np
from save_model import saveModel
import sys
def equal_logical_or(name : str, x, y, z):
import paddle
paddle.enable_static()
with paddle.static.program_guard(paddle... | 53 | 1,608 |
pyro | pyro/contrib/funsor/handlers/primitives.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pyro.poutine.runtime
from pyro.contrib.funsor.handlers.runtime import _DIM_STACK, DimRequest, DimType
@pyro.poutine.runtime.effectful(type="to_funsor")
def to_funsor(x, output=None, dim_to_name=None, dim_type=DimType.LOCAL):
... | 30 | 1,076 |
openvino | tests/e2e_tests/common/multiprocessing_utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
import os
import platform
import signal
import sys
import traceback
from logging.handlers import QueueHandler
from multiprocessing import Process, Queue, TimeoutError, ProcessError
from queue import Empty as QueueEm... | 106 | 4,058 |
clearml | clearml/backend_api/schema/service.py | .py | import itertools
import re
from typing import Dict, Set, Any
import attr
from ...utilities.pyhocon import ConfigTree
from .action import Action
class Service:
"""Service schema handler"""
__jsonschema_ref_ex = re.compile("^#/definitions/(.*)$")
@property
def default(self) -> ConfigTree:
re... | 177 | 6,671 |
onnx | onnx/reference/ops/op_and.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.ops._op import OpRunBinary
class And(OpRunBinary):
def _run(self, x, y):
return (np.logical_and(x, y),)
| 14 | 275 |
beam | sdks/python/apache_beam/io/gcp/datastore/v1new/datastoreio_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... | 524 | 20,026 |
saleor | saleor/graphql/checkout/dataloaders/checkout_infos.py | .py | from collections import defaultdict
from collections.abc import Sequence
from promise import Promise
from ....checkout.fetch import CheckoutInfo, CheckoutLineInfo
from ....core.db.connection import allow_writer_in_context
from ....discount import VoucherType
from ....discount.utils.voucher import attach_voucher_to_li... | 353 | 14,667 |
lemur | lemur/pending_certificates/views.py | .py | """
.. module: lemur.pending_certificates.views
:platform: Unix
:license: Apache, see LICENSE for more details.
.. moduleauthor:: James Chuong <jchuong@instartlogic.com>
"""
from flask import Blueprint, g, make_response, jsonify
from flask_restful import Api, reqparse, inputs
from lemur.auth.service import Aut... | 568 | 19,027 |
django-cms | cms/middleware/page.py | .py | from django.utils.functional import SimpleLazyObject
def get_page(request):
from cms.appresolver import applications_page_check
from cms.utils.page import get_page_from_request
if not hasattr(request, '_current_page_cache'):
request._current_page_cache = get_page_from_request(request)
if ... | 28 | 985 |
rq | tests/test_timeouts.py | .py | import time
from unittest.mock import patch
from rq import Queue, SimpleWorker
from rq.registry import FailedJobRegistry, FinishedJobRegistry
from rq.timeouts import (
TimerDeathPenalty,
UnixSignalDeathPenalty,
get_default_death_penalty_class,
)
from tests import RQTestCase
class TimerBasedWorker(SimpleW... | 71 | 2,731 |
mlflow | mlflow/genai/evaluation/utils.py | .py | import json
import logging
import math
from typing import TYPE_CHECKING, Any, Collection
from mlflow.entities import Assessment, Trace, TraceData
from mlflow.entities.assessment import DEFAULT_FEEDBACK_NAME, Feedback
from mlflow.entities.assessment_source import AssessmentSource, AssessmentSourceType
from mlflow.entit... | 467 | 16,696 |
astropy | astropy/wcs/tests/conftest.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
from astropy import wcs
from .helper import SimModelTAB
@pytest.fixture(scope="module")
def tab_wcs_2di():
model = SimModelTAB(nx=150, ny=200)
# generate FITS HDU list:
hdulist = model.hdulist
# create WCS object:
w... | 55 | 983 |
openvino | tests/layer_tests/pytorch_tests/test_layer_norm.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestLayerNorm(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(20, 5, 10, 10),)
def create_model(self, normalized_shape, ... | 97 | 3,707 |
sqlmap | plugins/dbms/monetdb/syntax.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.convert import getOrds
from plugins.generic.syntax import Syntax as GenericSyntax
class Syntax(GenericSyntax):
@staticmethod
def escape(expression, quote=Tr... | 24 | 734 |
cvxpy | cvxpy/utilities/__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... | 19 | 629 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_lstm.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
import tempfile
import numpy as np
import onnx
import pytest
from onnx import TensorProto, helper
import onnxruntime as ort
def sigmoid(z):
"""Computes the sigmoid of the given numpy array."""
return 1 /... | 938 | 41,743 |
httpie | tests/test_xml.py | .py | import sys
import pytest
import responses
from httpie.encoding import UTF8
from httpie.output.formatters.xml import parse_xml, pretty_xml
from .fixtures import XML_FILES_PATH, XML_FILES_VALID, XML_FILES_INVALID, XML_DATA_RAW, XML_DATA_FORMATTED
from .utils import http, DUMMY_URL
@pytest.mark.parametrize(
'opti... | 100 | 2,869 |
returns | returns/primitives/asserts.py | .py | def assert_equal(
first,
second,
*,
deps=None,
backend: str = 'asyncio',
) -> None:
"""
Custom ``assert`` function to compare two any containers.
The important note here is that
this ``assert`` should probably used in tests.
Not real application code.
It will call all ``Rea... | 55 | 1,436 |
openvino | tests/e2e_tests/test_utils/path_utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Path utils used across E2E tests framework."""
import datetime
import getpass
import hashlib
import logging as log
import math
import os
import re
import socket
import sys
import time
from contextlib import contextmanager
from glob i... | 228 | 8,570 |
openvino | src/bindings/python/tests/test_graph/test_swish.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import openvino.opset8 as ov
from openvino import Shape, Type
@pytest.mark.parametrize(("beta"), [
[],
[ov.parameter(Shape([]), dtype=np.float32, name="beta")]])
def test... | 22 | 629 |
cvxpy | cvxpy/constraints/nonpos.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
... | 277 | 8,780 |
conda | tests/plugins/reporter_backends/test_json.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from conda.common.serialize import json
from conda.plugins.reporter_backends.json import (
JSONProgressBar,
JSONReporterRenderer,
JSONSpinner,
)
def test_json_handler():
"""
Tests the JSONReporterHandler ReporterHandler cla... | 74 | 2,225 |
metrics | tests/unittests/text/test_infolm.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... | 215 | 8,364 |
saleor | saleor/attribute/tests/fixtures/attribute.py | .py | import datetime
import pytest
from ....core.editorjs import editorjs_to_text
from ....core.units import MeasurementUnits
from ....core.utils.text import safe_truncate
from ....tests.utils import dummy_editorjs
from ... import AttributeEntityType, AttributeInputType, AttributeType
from ...models import Attribute, Attr... | 981 | 29,002 |
biopython | Tests/test_PDB_Selection.py | .py | """
Run Bio.PDB.Selection tests.
Currently only tests unfold_entities.
"""
import unittest
from Bio.PDB import PDBParser
from Bio.PDB.PDBExceptions import PDBException
from Bio.PDB.Residue import Residue
from Bio.PDB.Selection import unfold_entities
def res_full_id(res: Residue):
"""Return full residue identif... | 155 | 5,947 |
sphinx | sphinx/ext/autodoc/_shared.py | .py | """Shared utilities for autodoc that don't have a better home."""
from __future__ import annotations
from typing import TYPE_CHECKING
from sphinx.util import logging
from sphinx.util.inspect import safe_getattr
if TYPE_CHECKING:
from collections.abc import Callable, Mapping, Sequence
from typing import Any,... | 163 | 6,256 |
beam | sdks/python/apache_beam/ml/rag/chunking/langchain_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... | 233 | 8,159 |
gunicorn | gunicorn/uwsgi/parser.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.http.parser import Parser
from gunicorn.uwsgi.message import UWSGIRequest
class UWSGIParser(Parser):
"""Parser for uWSGI protocol requests."""
mesg_class = UWSGIRequest
| 13 | 300 |
textual | tests/test_binary_encode.py | .py | import pytest
from textual._binary_encode import DecodeError, dump, load
@pytest.mark.parametrize(
"data",
[
None,
False,
True,
-10,
-1,
0,
1,
100,
"",
"💩",
"Hello",
b"World",
b"",
[],
(),... | 91 | 1,747 |
openvino | src/bindings/python/tests/test_transformations/test_pattern_ops.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from openvino import PartialShape, Symbol, Dimension
from openvino import opset13 as ops
from openvino.passes import Matcher, WrapType, Or, AnyInput, Optional
from openvino.passes ... | 433 | 17,911 |
openvino | tests/e2e_tests/common/hook_utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from _pytest.python import Function
from . import config
from .config import bug_ids, components_ids, req_ids
from .logger import get_logger
from .marks import MarkGeneral, MarkRunType
logger = get_logger(__name__)
_current_test_run =... | 118 | 3,979 |
saleor | saleor/graphql/discount/tests/queries/test_vouchers_sorting.py | .py | import graphene
import pytest
from django.utils import timezone
from .....discount import DiscountValueType, VoucherType
from .....discount.models import Voucher, VoucherChannelListing, VoucherCode
from ....tests.utils import assert_graphql_error_with_message, get_graphql_content
@pytest.fixture
def vouchers_for_sor... | 455 | 13,732 |
coremltools | coremltools/models/neural_network/spec_inspection_utils.py | .py | # Copyright (c) 2021, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from coremltools import proto
def _get_weight_param_summary(wp):
"""Get a summary of proto.NeuralN... | 298 | 10,766 |
beam | learning/tour-of-beam/learning-content/common-transforms/aggregation/max/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... | 52 | 1,723 |
openvino | src/bindings/python/tests/test_graph/test_scaled_dot_product_attention.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import openvino.opset13 as ops
from openvino import PartialShape, Type
@pytest.mark.parametrize(
("query", "key", "value", "attention_mask", "scale", "causal", "dtype", "boo... | 84 | 3,494 |
coremltools | coremltools/converters/mil/mil/types/global_methods.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
"""
This defines a list of all the "global methods" like len. Or type cast
operators like int, list,... | 50 | 1,468 |
saleor | saleor/graphql/discount/tests/mutations/test_promotion_create.py | .py | import datetime
from decimal import Decimal
from unittest.mock import ANY, patch
import graphene
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from .....discount import PromotionEvents
from .....discount.error_codes import PromotionCreateErrorCode
from .... | 2,114 | 69,665 |
saleor | saleor/graphql/discount/mutations/utils.py | .py | from collections import defaultdict
import graphene
from django.db.models import QuerySet
from ....discount import PromotionType
from ....discount.models import Promotion, PromotionRule
from ....discount.utils.promotion import CatalogueInfo, update_rule_variant_relation
from ....product.models import ProductVariant
... | 81 | 2,743 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.