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 |
|---|---|---|---|---|---|
saleor | saleor/core/cleaners/tests/test_urls.py | .py | import pytest
from .. import clean_mailto, clean_tel
@pytest.mark.parametrize(
"input_url",
[
# All valid inputs (should be unchanged by the cleaner)
"tel:1234567890",
"tel:+1234567890",
"tel:+1-202-555-0123",
"tel:+1(202)555.0123",
"tel:*123#",
"tel:#2... | 130 | 4,645 |
lemur | lemur/plugins/lemur_aws/tests/test_plugin.py | .py | from collections import namedtuple
from os.path import join
import boto3
from moto import mock_sts, mock_s3, mock_ec2, mock_elb, mock_elbv2, mock_acm
from pytest import raises
def test_get_certificates(app):
from lemur.plugins.base import plugins
p = plugins.get("aws-s3")
assert p
def test_s3_default_p... | 309 | 9,885 |
wagtail | wagtail/admin/icons.py | .py | import hashlib
import re
from functools import lru_cache
from django.template.loader import render_to_string
from django.urls import reverse
from wagtail import hooks
icon_comment_pattern = re.compile(r"<!--.*?-->", re.DOTALL)
@lru_cache(maxsize=None)
def get_icons():
all_icons = []
for fn in hooks.get_hoo... | 41 | 1,132 |
probability | tensorflow_probability/python/distributions/exponentially_modified_gaussian.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... | 233 | 8,861 |
onnx | onnx/reference/ops/op_reduce_sum.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 OpRunReduceNumpy
class ReduceSum_1(OpRunReduceNumpy):
def _run(self, x, axes=None, keepdims=None):
axes = tuple(axes) if axes is not N... | 36 | 1,249 |
lemur | lemur/plugins/lemur_entrust/plugin.py | .py | import json
import sys
import arrow
import requests
from flask import current_app
from random import choice
from retrying import retry
from urllib3.util.retry import Retry
from lemur.certificates.service import get_ekus
from lemur.common.utils import validate_conf, get_key_type_from_certificate
from lemur.constants i... | 492 | 18,484 |
beam | sdks/python/apache_beam/io/concat_source.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... | 273 | 10,439 |
clearml | clearml/utilities/plotlympl/mplexporter/utils.py | .py | """
Utility Routines for Working with Matplotlib Objects
====================================================
"""
import base64
import io
import itertools
import warnings
from typing import Dict, Tuple, Union, List, Iterator, Any
import matplotlib
import numpy
import numpy as np
from matplotlib import ticker
from matp... | 372 | 12,180 |
pymc | pymc/step_methods/arraystep.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... | 236 | 8,598 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_layernorm.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
from fusion_base import Fusion
from onnx ... | 490 | 20,356 |
saleor | saleor/core/utils/tests/test_metadata_manager.py | .py | import pytest
from ..metadata_manager import metadata_is_valid
@pytest.mark.parametrize(
"metadata",
[
{"key1": "value1", "key2": "value2"},
{},
{"key1": ""},
],
)
def test_metadata_is_valid_true(metadata):
# when
is_metadata_valid = metadata_is_valid(metadata)
# then... | 39 | 709 |
mlflow | mlflow/models/evaluation/_shap_patch.py | .py | import pickle
import shap
from shap._serializable import Deserializer, Serializable, Serializer
class _PatchedKernelExplainer(shap.KernelExplainer):
def save(self, out_file, model_saver=None, masker_saver=None):
"""
This patched `save` method fix `KernelExplainer.save`.
Issues in original... | 52 | 2,548 |
ipython | IPython/utils/text.py | .py | """
Utilities for working with strings and text.
Inheritance diagram:
.. inheritance-diagram:: IPython.utils.text
:parts: 3
"""
from __future__ import annotations
import builtins
import os
import re
import string
import textwrap
from string import Formatter
from pathlib import Path
from typing import (
Any... | 598 | 17,331 |
hatch | tests/cli/run/test_run.py | .py | import os
import signal
import sys
import sysconfig
import pytest
from hatch.config.constants import AppEnvVars, ConfigEnvVars
from hatch.project.core import Project
from hatch.python.core import PythonManager
from hatch.python.resolve import get_compatible_distributions, is_valid_distribution_name
from hatch.utils.f... | 2,677 | 84,150 |
probability | tensorflow_probability/python/distributions/ordered_logistic_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... | 212 | 8,659 |
sqlmap | thirdparty/chardet/sbcharsetprober.py | .py | ######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Universal charset detector code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All R... | 146 | 6,136 |
openvino | tools/ovc/openvino/tools/ovc/utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import importlib.util
import logging as log
import numpy as np
import os
import sys
from openvino.tools.ovc.error import Error
from collections.abc import Iterable
from typing import Union
try:
import openvino_telemetry as tm
fr... | 198 | 7,647 |
coveragepy | coverage/jsonreport.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Json reporting for coverage.py"""
from __future__ import annotations
import datetime
import json
import sys
from collections.abc import Iterable
from typing ... | 201 | 7,493 |
metrics | docs/source/pyplots/tracker_binary.py | .py | import matplotlib.pyplot as plt
import torch
import torchmetrics
N = 10
num_updates = 10
num_steps = 5
w = torch.tensor([0.2, 0.8])
target = lambda it: torch.multinomial((it * w).softmax(dim=-1), 100, replacement=True)
preds = lambda it: (it * torch.randn(100)).sigmoid()
confmat = torchmetrics.ConfusionMatrix(task=... | 46 | 1,328 |
onnxruntime | orttraining/orttraining/python/training/experimental/exporter.py | .py | import torch
import torch.onnx.symbolic_helper
import torch.onnx.utils
def _export_jit_graph_to_onnx_model_proto(graph: torch._C.Graph, operator_export_type: int):
from torch.onnx.symbolic_helper import ( # noqa: F401, PLC0415
_set_onnx_shape_inference,
_set_operator_export_type,
_set_ops... | 31 | 842 |
deap | examples/gp/parity.py | .py | # This file is part of EAP.
#
# EAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# EAP is distributed in ... | 93 | 2,949 |
luigi | luigi/contrib/lsf_runner.py | .py | # -*- coding: utf-8 -*-
"""
.. Copyright 2012-2015 Spotify AB
Copyright 2018
Copyright 2018 EMBL-European Bioinformatics Institute
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
... | 81 | 2,301 |
confluent-kafka-python | tests/ducktape/consumer_benchmark_metrics.py | .py | """
Consumer benchmark metrics collection and validation for Kafka performance testing.
Implements consumer-specific metrics tracking including poll latencies,
consumption rates, per-topic breakdowns, and reliability analysis.
"""
import statistics
import time
from collections import defaultdict
from typing import An... | 385 | 15,965 |
coremltools | coremltools/converters/mil/mil/ops/tests/iOS16/test_tensor_operation.py | .py | # Copyright (c) 2022, 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 numpy as np
import pytest
from coremltools.converters.mil import testing_re... | 86 | 2,795 |
wagtail | wagtail/users/forms.py | .py | from itertools import groupby
import swapper
from django import forms
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group, Permission
from django.contrib.auth.password_validation import (
password_validators_help_text_html,
validate_passw... | 416 | 14,547 |
sqlmap | extra/icmpsh/__init__.py | .py | #!/usr/bin/env python
#
# icmpsh - simple icmp command shell (port of icmpsh-m.pl written in
# Perl by Nico Leidecker <nico@leidecker.info>)
#
# Copyright (c) 2010, Bernardo Damele A. G. <bernardo.damele@gmail.com>
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of t... | 23 | 872 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_reduce_mean.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# reduce_mean paddle model generator
#
import numpy as np
import sys
from save_model import saveModel
def reduce_mean(name : str, x, axis=None, keepdim=False):
import paddle
paddle.enable_static()
with paddle.static.pro... | 47 | 1,490 |
httpie | tests/conftest.py | .py | import socket
import pytest
from pytest_httpbin import certs
from pytest_httpbin.serve import Server as PyTestHttpBinServer
from .utils import ( # noqa
HTTPBIN_WITH_CHUNKED_SUPPORT_DOMAIN,
HTTPBIN_WITH_CHUNKED_SUPPORT,
REMOTE_HTTPBIN_DOMAIN,
IS_PYOPENSSL,
mock_env
)
from .utils.plugins_cli import... | 97 | 2,558 |
mlflow | mlflow/pyfunc/loaders/chat_agent.py | .py | from typing import Any, Generator
import pydantic
from mlflow.exceptions import MlflowException
from mlflow.models.utils import _convert_llm_ndarray_to_list
from mlflow.protos.databricks_pb2 import INTERNAL_ERROR
from mlflow.pyfunc.model import (
_load_context_model_and_signature,
)
from mlflow.types.agent import... | 116 | 4,436 |
onnxruntime | onnxruntime/test/testdata/transform/transpose_graph_gen.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import onnx
from onnx import TensorProto, helper
def GenerateModel(mode... | 42 | 1,481 |
pyro | pyro/primitives.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import copy
import warnings
from collections import OrderedDict
from contextlib import ExitStack, contextmanager
from inspect import isclass
from operator import attrgetter
from typing import Callable, Iterator, Optional, Sequence,... | 601 | 24,384 |
pynacl | src/nacl/pwhash/_argon2.py | .py | # Copyright 2013 Donald Stufft and individual contributors
#
# 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... | 50 | 1,779 |
saleor | saleor/discount/tasks.py | .py | import datetime
from collections import Counter, defaultdict
from typing import TYPE_CHECKING
import graphene
from celery.utils.log import get_task_logger
from django.conf import settings
from django.db.models import Exists, F, OuterRef, Q, QuerySet
from ..celeryconf import app
from ..core.db.connection import allow_... | 394 | 14,653 |
wagtail | wagtail/test/i18n/models.py | .py | import swapper
from django.db import models
from modelcluster.fields import ParentalKey
from modelcluster.models import ClusterableModel
from wagtail.models import Orderable, TranslatableMixin
if swapper.is_swapped("wagtailcore", "Page"):
from wagtail.test.basepage.models import BasePage as Page
else:
from wa... | 63 | 1,612 |
pyomo | pyomo/dataportal/plugins/text.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... | 89 | 3,270 |
mkdocs | mkdocs/tests/structure/toc_tests.py | .py | #!/usr/bin/env python
import unittest
from mkdocs.structure.toc import get_toc
from mkdocs.tests.base import dedent, get_markdown_toc
class TableOfContentsTests(unittest.TestCase):
def test_indented_toc(self):
md = dedent(
"""
# Heading 1
## Heading 2
### ... | 199 | 5,255 |
django-cms | cms/management/commands/subcommands/list.py | .py | from cms.models import Page
from cms.models.pluginmodel import CMSPlugin
from cms.plugin_pool import plugin_pool
from .base import SubcommandsCommand
class ListApphooksCommand(SubcommandsCommand):
help_string = 'Lists all apphooks in pages'
command_name = 'apphooks'
def handle(self, *args, **options):
... | 136 | 4,733 |
textual | docs/examples/guide/workers/weather01.py | .py | import httpx
from rich.text import Text
from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widgets import Input, Static
class WeatherApp(App):
"""App to display the current weather."""
CSS_PATH = "weather.tcss"
def compose(self) -> ComposeResult:
... | 41 | 1,262 |
lemur | lemur/pending_certificates/cli.py | .py | """
.. module: lemur.pending_certificates.cli
.. moduleauthor:: James Chuong <jchuong@instartlogic.com>
.. moduleauthor:: Curtis Castrapel <ccastrapel@netflix.com>
"""
import copy
import sys
import click
from flask import current_app
from flask.cli import with_appcontext
from lemur.authorities.service import get as... | 151 | 5,344 |
astropy | astropy/wcs/tests/test_utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from contextlib import nullcontext
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_almost_equal, assert_equal
from packaging.version import Version
from astropy import units as u
from astropy.coordinates import ITRS, Ba... | 1,781 | 58,761 |
pyro | tests/distributions/test_spanning_tree.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import os
from collections import Counter
import pytest
import torch
import pyro
from pyro.distributions.spanning_tree import (
NUM_SPANNING_TREES,
SpanningTree,
find_best_tree,
make_complete_graph,... | 232 | 7,701 |
mlflow | mlflow/store/__init__.py | .py | from mlflow.store import _unity_catalog # noqa: F401
from mlflow.store.artifact import artifact_repo
from mlflow.store.tracking import abstract_store
__all__ = [
# tracking server meta-data stores
"abstract_store",
# artifact repository stores
"artifact_repo",
]
| 11 | 281 |
openvino | tests/stress_tests/scripts/memcheck_upload.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""
Upload metrics gathered by MemCheckTests into Mongo DB
Usage: ./scrips/memcheck_upload.py https://ci.intel.com/job/memchek/1234/ \
./gtest-parallel-logs/**/*.log \
--artifact_root ./gtest-parallel-logs --dryrun
"""
import a... | 366 | 13,627 |
saleor | saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_product_type_tax_class.py | .py | import pytest
from ... import DEFAULT_ADDRESS
from ...product.utils import (
create_category,
create_product,
create_product_channel_listing,
create_product_type,
create_product_variant,
create_product_variant_channel_listing,
update_product_type,
)
from ...shop.utils.preparing_shop import ... | 215 | 6,556 |
qutip | qutip/tests/solver/test_stochastic.py | .py | import pytest
import numpy as np
from qutip import (
mesolve, liouvillian, QobjEvo, spre, spost, CoreOptions,
destroy, coherent, qeye, fock_dm, num, basis
)
from qutip.solver.stochastic import smesolve, ssesolve, SMESolver, SSESolver
from qutip.core import data as _data
def f(t, w):
return w * t
def _mak... | 587 | 17,241 |
probability | tensorflow_probability/python/distributions/matrix_t_linear_operator.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... | 294 | 10,722 |
saleor | saleor/graphql/product/tests/mutations/test_collection_remove_products.py | .py | from unittest.mock import patch
import graphene
from .....discount.utils.promotion import get_active_catalogue_promotion_rules
from ....tests.utils import (
get_graphql_content,
)
COLLECTION_REMOVE_PRODUCTS_MUTATION = """
mutation collectionRemoveProducts(
$id: ID!, $products: [ID!]!) {
colle... | 76 | 2,516 |
coremltools | coremltools/test/optimize/torch/test_utils/test_validation_utils.py | .py | # Copyright (c) 2024, 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 pytest
import torch
from coremltools.optimize.torch._utils.validation_utils import (
Conf... | 137 | 5,089 |
hypercorn | src/hypercorn/middleware/__init__.py | .py | from __future__ import annotations
from .dispatcher import DispatcherMiddleware
from .http_to_https import HTTPToHTTPSRedirectMiddleware
from .proxy_fix import ProxyFixMiddleware
from .wsgi import AsyncioWSGIMiddleware, TrioWSGIMiddleware
__all__ = (
"AsyncioWSGIMiddleware",
"DispatcherMiddleware",
"HTTPT... | 15 | 401 |
saleor | saleor/tests/e2e/checkout/test_pay_for_part_of_checkout_with_gift_card.py | .py | import pytest
from ..gift_cards.utils import create_gift_card
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 (
checkout_add_promo_code,
checkout_complete,
checkout_create,
... | 120 | 3,974 |
pyro | pyro/distributions/von_mises_3d.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import torch
from . import constraints
from .torch_distribution import TorchDistribution
class VonMises3D(TorchDistribution):
"""
Spherical von Mises distribution.
This implementation combines the direc... | 67 | 2,694 |
onnx | onnx/fuzz/fuzz_checker.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import sys
import atheris
with atheris.instrument_imports():
from onnx import checker
def TestOneInput(data):
try:
checker.check_model(data, full_check=True)
except Exception:
... | 28 | 504 |
onnxruntime | onnxruntime/python/tools/qnn/add_trans_cast.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import json
from argparse import ArgumentParser
import onnx
from onnx i... | 293 | 13,456 |
mlflow | mlflow/metrics/genai/__init__.py | .py | from mlflow.metrics.genai.base import EvaluationExample
from mlflow.metrics.genai.genai_metric import (
make_genai_metric,
make_genai_metric_from_prompt,
retrieve_custom_metrics,
)
from mlflow.metrics.genai.metric_definitions import (
answer_correctness,
answer_relevance,
answer_similarity,
... | 26 | 596 |
probability | tensorflow_probability/python/experimental/sts_gibbs/gibbs_sampler.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... | 1,323 | 59,880 |
cvxpy | cvxpy/utilities/key_utils.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... | 248 | 7,429 |
wagtail | wagtail/tests/test_reference_index.py | .py | from io import StringIO
from unittest import mock
from django.contrib.contenttypes.models import ContentType
from django.core import management
from django.core.exceptions import FieldDoesNotExist
from django.db import models
from django.test import TestCase
from django.utils.functional import SimpleLazyObject, lazyst... | 970 | 37,165 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Add.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from common.tf_layer_test_class import CommonTFLayerTest
class TestAdd(CommonTFLayerTest):
def create_add_placeholder_const_net(self, x_shape, y_shape):
import tensorflow as tf
tf.c... | 257 | 12,250 |
openvino | tests/layer_tests/pytorch_tests/test_reshape.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import random
import numpy as np
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestReshape(PytorchLayerTest):
def _prepare_input(self, complex_type):
shape = (1, 12, 12, 24)
if complex_t... | 85 | 2,726 |
saleor | saleor/graphql/checkout/mutations/checkout_lines_update.py | .py | import graphene
from django.forms import ValidationError
from ....checkout.error_codes import CheckoutErrorCode
from ....checkout.fetch import CheckoutLineInfo
from ....core.exceptions import NonExistingCheckoutLines
from ....warehouse.reservations import is_reservation_enabled
from ....webhook.event_types import Webh... | 301 | 10,073 |
gunicorn | tests/requests/invalid/prefix_06.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 InvalidHTTPVersion
cfg = Config()
request = InvalidHTTPVersion
| 10 | 238 |
coveragepy | tests/plugin2.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""A file tracer plugin for test_plugins.py to import."""
from __future__ import annotations
import os.path
from types import FrameType
from typing import Any
... | 75 | 2,253 |
openvino | src/bindings/python/tests/test_graph/test_ops_multioutput.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import openvino.opset8 as ov
def test_split():
input_tensor = ov.constant(np.array([0, 1, 2, 3, 4, 5], dtype=np.int32))
axis = ov.constant(0, dtype=np.int64)
splits = 3
split... | 33 | 1,147 |
saleor | saleor/graphql/product/filters/product_helpers.py | .py | import datetime
from django.contrib.sites.models import Site
from django.db.models import Exists, OuterRef, Q, Subquery, Sum
from django.db.models.expressions import ExpressionWrapper
from django.db.models.fields import IntegerField
from django.db.models.functions import Coalesce
from django.utils import timezone
fro... | 654 | 22,657 |
kafka | tests/kafkatest/tests/streams/streams_broker_down_resilience_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 ... | 341 | 18,773 |
biopython | Tests/test_SwissProt.py | .py | # Copyright 2009 by Michiel de Hoon. All rights reserved.
# Revisions copyright 2010 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.
"""Test for the SwissProt pars... | 6,789 | 341,375 |
python-prompt-toolkit | tests/test_buffer.py | .py | from __future__ import annotations
import pytest
from prompt_toolkit.buffer import Buffer
@pytest.fixture
def _buffer():
buff = Buffer()
return buff
def test_initial(_buffer):
assert _buffer.text == ""
assert _buffer.cursor_position == 0
def test_insert_text(_buffer):
_buffer.insert_text("so... | 113 | 2,659 |
luigi | test/contrib/lsf_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... | 104 | 3,085 |
pyomo | pyomo/contrib/pyros/__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... | 25 | 950 |
sqlmap | plugins/dbms/frontbase/__init__.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.enums import DBMS
from lib.core.settings import FRONTBASE_SYSTEM_DBS
from lib.core.unescaper import unescaper
from plugins.dbms.frontbase.enumeration import Enumerat... | 30 | 938 |
onnx | onnx/backend/test/case/node/hammingwindow.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 HammingWindow(Base):
@staticmethod
def export() -> None:
... | 49 | 1,288 |
tqdm | tqdm/contrib/slack.py | .py | """
Sends updates to a Slack app.
Usage:
>>> from tqdm.contrib.slack import tqdm, trange
>>> for i in trange(10, token='{token}', channel='{channel}'):
... ...

"""
import logging
try:
from slack_sdk import WebClient
except ImportError:
raise ... | 120 | 4,049 |
pyomo | pyomo/version/tests/__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... | 10 | 548 |
saleor | saleor/product/product_images.py | .py | import logging
from typing import TYPE_CHECKING, Optional
from django.conf import settings
from django.templatetags.static import static
from ..thumbnail.models import Thumbnail
from ..thumbnail.utils import get_image_or_proxy_url, get_thumbnail_size
if TYPE_CHECKING:
from .models import ProductMedia
logger = ... | 34 | 1,085 |
onnxruntime | orttraining/orttraining/python/training/artifacts.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import contextlib
import logging
import os
import pathlib
from enum import Enum
import onnx
from onnxruntime.tools.convert_onnx_models_to_ort import OptimizationStyle, convert_onnx_models_to_ort
from onnxruntime.training im... | 273 | 12,339 |
mkdocs | docs/img/plugin-events.py | .py | # Run this to re-generate 'plugin-events.svg'.
# Requires `pip install graphviz`.
import contextlib
import pathlib
import re
from graphviz import Digraph
graph = Digraph("MkDocs", format="svg")
graph.attr(compound="true", bgcolor="transparent")
graph.graph_attr.update(fontname="inherit", tooltip=" ")
graph.node_attr... | 172 | 5,724 |
metrics | src/torchmetrics/functional/regression/concordance.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... | 84 | 3,340 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex_split.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");... | 60 | 1,757 |
pyro | pyro/contrib/funsor/handlers/plate_messenger.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
from collections import OrderedDict
from numbers import Number
import funsor
from pyro.contrib.funsor.handlers.named_messenger import (
DimRequest,
DimType,
GlobalNamedMessenger,
NamedMessenger,
)
from pyro.contrib.fu... | 384 | 15,224 |
mlflow | examples/llms/summarization/summarization.py | .py | import os
import pandas as pd
from langchain.chains import LLMChain
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
import mlflow
assert "OPENAI_API_KEY" in os.environ, (
"Please set the OPENAI_API_KEY environment variable to run this example."
)
def build_and_evaluate_model_with... | 81 | 3,635 |
saleor | saleor/graphql/discount/types/__init__.py | .py | from .discounts import OrderDiscount
from .promotions import Promotion, PromotionRule
from .sales import Sale, SaleChannelListing, SaleCountableConnection
from .vouchers import (
Voucher,
VoucherChannelListing,
VoucherCode,
VoucherCountableConnection,
)
__all__ = [
"OrderDiscount",
"Sale",
... | 23 | 510 |
metrics | src/torchmetrics/functional/text/mer.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... | 92 | 3,018 |
wandb | wandb/sdk/launch/agent/agent.py | .py | """Implementation of launch agent."""
from __future__ import annotations
import asyncio
import copy
import logging
import os
import pprint
import threading
import time
import traceback
from dataclasses import dataclass
from multiprocessing import Event
from typing import Any
import wandb
from wandb.analytics import ... | 970 | 38,105 |
probability | tensorflow_probability/python/distributions/normal_conjugate_posteriors.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... | 272 | 10,948 |
astropy | astropy/utils/tests/test_console.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import io
import sys
import pytest
from astropy import units as u
from astropy.utils import console
from . import test_progress_bar_func
class FakeTTY(io.StringIO):
"""IOStream that fakes a TTY; provide an encoding to emulate an output
strea... | 209 | 5,303 |
clearml | examples/hyperdatasets/legacy/data-registration/register_dataset_with_roi.py | .py | """
How to register data with ROIs and metadata from a json file.
Create a list of ROI's for each image in the metadata format required by a frame.
Notice: This is a custom parser for a specific dataset. Each dataset requires a different parser.
You can run this example from this dir with:
python register_dataset_wi... | 149 | 5,453 |
pyro | tests/infer/reparam/test_split.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer.autoguide.initialization import InitMessenger, init_to_median
from pyro.infer.reparam im... | 217 | 7,183 |
wagtail | wagtail/documents/rich_text/editor_html.py | .py | """
editor-html conversion for contenteditable editors
"""
from django.utils.html import escape
from wagtail.admin.rich_text.converters import editor_html
from wagtail.documents import get_document_model
class DocumentLinkHandler:
@staticmethod
def get_db_attributes(tag):
return {"id": tag["data-id"... | 36 | 1,061 |
jupytext | tests/conftest.py | .py | import contextlib
import itertools
import os.path
import re
import sys
import unittest.mock as mock
from pathlib import Path
import pytest
from jupyter_client.kernelspec import find_kernel_specs, get_kernel_spec
import nbformat
from nbformat import reads as nb_reads, validate
from nbformat.v4 import nbbase
from nbform... | 487 | 15,234 |
coremltools | coremltools/converters/mil/mil/ops/defs/iOS16/constexpr_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 numpy as np
from coremltools.converters.mil.mil import types
from coremltools.converters.mil.... | 373 | 13,765 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_InvertPermutation.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
class TestInvertPermutation(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
assert 'x:0' in inputs... | 43 | 1,538 |
scikit-bio | skbio/metadata/tests/test_enan.py | .py | # ----------------------------------------------------------------------------
# Copyright (c) 2016-2023, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ------------------------------------------------... | 43 | 1,372 |
hatch | tests/cli/self/test_report.py | .py | import os
import sys
from textwrap import indent
from urllib.parse import unquote_plus
import pytest
from hatch._version import __version__
from hatch.utils.structures import EnvVars
URL = "https://github.com/pypa/hatch/issues/new?body="
STATIC_BODY = """\
## Current behavior
<!-- A clear and concise description of ... | 288 | 6,108 |
pyro | tests/poutine/test_runtime.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import torch
import pyro
import pyro.poutine as poutine
from pyro.poutine.runtime import get_mask, get_plates
from tests.common import assert_equal
def test_get_mask():
assert get_mask() is None
with poutine.mask(mask=True)... | 40 | 1,113 |
biopython | BioSQL/BioSeq.py | .py | # Copyright 2002 by Andrew Dalke. All rights reserved.
# Revisions 2007-2016 copyright by Peter Cock. All rights reserved.
# Revisions 2008-2009 copyright by Cymon J. Cox. All rights reserved.
#
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or th... | 593 | 21,795 |
pyomo | pyomo/contrib/alternative_solutions/tests/test_balas.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... | 153 | 5,919 |
attrs | tests/test_cmp.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for methods from `attrib._cmp`.
"""
import pytest
from attr._cmp import cmp_using
from attr._compat import PY_3_13_PLUS
# Test parameters.
EqCSameType = cmp_using(eq=lambda a, b: a == b, class_name="EqCSameType")
PartialOrderCSameType = cmp_using(
eq=lambda a, b: a == b... | 506 | 15,151 |
scikit-optimize | skopt/sampler/__init__.py | .py | """
Utilities for generating initial sequences
"""
from .lhs import Lhs
from .sobol import Sobol
from .halton import Halton
from .hammersly import Hammersly
from .grid import Grid
from .base import InitialPointGenerator
__all__ = [
"Lhs", "Sobol",
"Halton", "Hammersly",
"Grid", "InitialPointGenerator"
]
| 17 | 319 |
astropy | astropy/visualization/wcsaxes/helpers.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Helpers functions for different kinds of WCSAxes instances.
"""
import numpy as np
from matplotlib.offsetbox import AnchoredOffsetbox, AuxTransformBox
from matplotlib.patches import Ellipse
from mpl_toolkits.axes_grid1.anchored_artists import Anchore... | 201 | 6,240 |
pyomo | doc/OnlineDocs/src/data/ABCD7.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... | 29 | 1,021 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.