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 |
|---|---|---|---|---|---|
astropy | astropy/convolution/tests/test_convolve_kernels.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_almost_equal
from astropy import units as u
from astropy.convolution.convolve import convolve, convolve_fft
from astropy.convolution.kernels import (
Box2DKernel,
... | 156 | 4,403 |
onnxruntime | onnxruntime/test/providers/cpu/nn/lp_pool_test_generator.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import numpy as np
import torch
from torch import nn
# use this code to generate test data for PoolTest.LpPool1d and PoolTest.LpPool2d
def generate_lppool_1d_test_cases() -> None:
p = 2
x = np.array(
[
... | 63 | 1,577 |
conda | tests/test_deprecations.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import sys
import warnings
from argparse import ArgumentParser, _StoreAction, _StoreTrueAction
from contextlib import nullcontext
from types import ModuleType
from typing import TYPE_CHECKING
import pytest
f... | 343 | 10,317 |
biopython | Bio/PDB/PDBParser.py | .py | # Copyright (C) 2002, Thomas Hamelryck (thamelry@binf.ku.dk)
# 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.
"""Parser for PDB files."""
import warnings
import numpy as np
from Bio.File import as_... | 413 | 17,185 |
astropy | astropy/timeseries/periodograms/lombscargle_multiband/implementations/__init__.py | .py | """Various implementations of the Multiband Lomb-Scargle Periodogram"""
from .main import available_methods, lombscargle_multiband
from .mbfast_impl import lombscargle_mbfast
from .mbflex_impl import lombscargle_mbflex
| 6 | 220 |
onnx | onnx/backend/test/case/node/sign.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 Sign(Base):
@staticmethod
def export() -> None:
node =... | 25 | 569 |
black | tests/data/cases/python315.py | .py | # flags: --fast
lazy import json
lazy from package.subpackage import (
alpha,
beta,
gamma,
)
from .lazy import thing
lazy = "still an identifier"
def eager():
lazy = "still an identifier"
return lazy
flattened = [*item for item in items]
generator = (*item for item in items)
combined = {*member... | 53 | 919 |
astropy | astropy/nddata/blocks.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module includes helper functions for array operations.
"""
import numpy as np
from .decorators import support_nddata
__all__ = ["block_reduce", "block_replicate", "reshape_as_blocks"]
def _process_block_inputs(data, block_size):
data = np... | 214 | 6,794 |
pyro | pyro/distributions/transforms/simplex_to_ordered.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.distributions.transforms import Transform
from torch.special import expit, logit
from .. import constraints
# This class is a port of https://num.pyro.ai/en/stable/_modules/numpyro/distributions/transforms.ht... | 71 | 2,527 |
onnxruntime | orttraining/tools/ci_test/compare_huggingface.py | .py | import collections
import json
import sys
actual = sys.argv[1]
expect = sys.argv[2]
with open(actual) as file_actual:
json_actual = json.loads(file_actual.read())
with open(expect) as file_expect:
json_expect = json.loads(file_expect.read())
def almost_equal(x, y, threshold=0.05):
return abs(x - y) < t... | 53 | 1,470 |
openvino | tests/layer_tests/pytorch_tests/test_dict.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestDict(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(2, 5, 3, 4),)
def create_model(se... | 89 | 3,252 |
ipython | IPython/core/shellapp.py | .py | """
A mixin for :class:`~IPython.core.application.Application` classes that
launch InteractiveShell instances, load extensions, etc.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
from __future__ import annotations
import glob
from itertools import chain
impo... | 502 | 19,596 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_BiasAdd.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 TestBiasAdd(CommonTFLayerTest):
def create_bias_add_placeholder_const_net(self, shape, ir_version, output_type=... | 189 | 8,106 |
textual | examples/json_tree.py | .py | import json
from pathlib import Path
from rich.text import Text
from textual.app import App, ComposeResult
from textual.widgets import Header, Footer, Tree
from textual.widgets.tree import TreeNode
class TreeApp(App):
BINDINGS = [
("a", "add", "Add node"),
("c", "clear", "Clear"),
("t",... | 94 | 2,808 |
sqlmap | thirdparty/clientform/clientform.py | .py | """HTML form handling for web clients.
ClientForm is a Python module for handling HTML forms on the client
side, useful for parsing HTML forms, filling them in and returning the
completed forms to the server. It has developed from a port of Gisle
Aas' Perl module HTML::Form, from the libwww-perl library, but the
inte... | 3,417 | 126,727 |
saleor | saleor/checkout/tests/test_payment_utils.py | .py | from decimal import Decimal
import pytest
from .. import CheckoutChargeStatus
from ..payment_utils import update_checkout_payment_statuses
@pytest.mark.parametrize(
("checkout_total", "charged_value", "has_lines", "expected_charge_status"),
[
(Decimal(-1), Decimal(-1), False, CheckoutChargeStatus.NO... | 55 | 2,026 |
jupytext | src/jupytext/magics.py | .py | """Escape Jupyter magics when converting to other formats"""
import re
from .languages import _COMMENT, _SCRIPT_EXTENSIONS, usual_language_name
from .stringparser import StringParser
def get_comment(ext):
return re.escape(_SCRIPT_EXTENSIONS[ext]["comment"])
# A magic expression is a line or cell or metakernel... | 188 | 7,346 |
openvino | src/bindings/python/src/openvino/frontend/pytorch/module_extension.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from typing import Optional, Union
from collections.abc import Callable
import torch
class ModuleExtension:
"""An extension that replaces a PyTorch module with a single operation.
A module can be identi... | 69 | 3,104 |
scikit-bio | skbio/metadata/base.py | .py | """Base for the metadata module."""
# ----------------------------------------------------------------------------
# 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.
# ------------... | 66 | 2,125 |
wandb | wandb/apis/public/jobs.py | .py | """W&B Public API for management Launch Jobs and Launch Queues.
This module provides classes for managing W&B jobs, queued runs, and run
queues.
"""
from __future__ import annotations
import json
import os
import shutil
import time
from collections.abc import Callable, Mapping
from typing import TYPE_CHECKING, Any, ... | 779 | 28,276 |
mlflow | mlflow/pyfunc/utils/__init__.py | .py | from mlflow.pyfunc.utils.data_validation import pyfunc
__all__ = ["pyfunc"]
| 4 | 77 |
saleor | saleor/graphql/discount/tests/mutations/test_promotion_update.py | .py | import datetime
from unittest.mock import patch
import graphene
from django.utils import timezone
from freezegun import freeze_time
from .....discount import PromotionEvents
from .....discount.error_codes import PromotionCreateErrorCode
from .....discount.models import PromotionEvent
from ....tests.utils import asser... | 366 | 12,758 |
sphinx | tests/test_ext_napoleon/pep526_data_numpy.py | .py | """Test module for napoleon PEP 526 compatibility with numpy style"""
from __future__ import annotations
module_level_var: int = 99
"""This is an example module level variable"""
class PEP526NumpyClass:
"""Sample class with PEP 526 annotations and numpy docstring
Attributes
----------
attr1:
... | 23 | 417 |
textual | tests/css/test_help_text.py | .py | import pytest
from tests.utilities.render import render
from textual.css._help_text import (
align_help_text,
border_property_help_text,
color_property_help_text,
fractional_property_help_text,
layout_property_help_text,
offset_property_help_text,
offset_single_axis_help_text,
scalar_he... | 128 | 4,015 |
textual | docs/examples/styles/layout.py | .py | from textual.app import App
from textual.containers import Container
from textual.widgets import Label
class LayoutApp(App):
CSS_PATH = "layout.tcss"
def compose(self):
yield Container(
Label("Layout"),
Label("Is"),
Label("Vertical"),
id="vertical-layou... | 27 | 557 |
probability | tensorflow_probability/python/distributions/finite_discrete_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... | 465 | 19,107 |
onnxruntime | onnxruntime/test/providers/cpu/tensor/affine_grid_test_gen.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# This code is used to generate the test cases for the AffineGrid operator
# in onnxruntime/test/providers/cpu/tensor/affine_grid_test.cc
import argparse
import numpy as np
import torch
from torch.nn.functional import affin... | 118 | 5,620 |
saleor | saleor/core/tests/test_text.py | .py | from ..utils.text import strip_accents
def test_strip_accents_removes_diacritics():
assert strip_accents("Magnésium") == "Magnesium"
def test_strip_accents_removes_multiple_diacritics():
assert strip_accents("café") == "cafe"
def test_strip_accents_removes_diaeresis():
assert strip_accents("naïve") ==... | 22 | 509 |
sqlmap | plugins/dbms/cratedb/takeover.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.takeover import Takeover as GenericTakeover
class Takeover(GenericTakeover):
def osCmd(s... | 29 | 974 |
saleor | saleor/graphql/discount/tests/queries/test_promotions_sorting.py | .py | import datetime
import pytest
from django.utils import timezone
from ....tests.utils import get_graphql_content
QUERY_PROMOTIONS = """
query Promotions($sortBy: PromotionSortingInput){
promotions(first: 10, sortBy: $sortBy) {
edges {
node {
id
... | 160 | 4,158 |
saleor | saleor/payment/tests/test_utils/test_parse_transaction_action_data_for_session_webhook.py | .py | import datetime
from decimal import Decimal
import pytest
from freezegun import freeze_time
from ... import TransactionEventType
from ...interface import TransactionRequestEventResponse, TransactionSessionResponse
from ...utils import (
parse_transaction_action_data_for_session_webhook,
)
@pytest.mark.parametri... | 262 | 8,146 |
beam | sdks/python/apache_beam/transforms/enrichment_handlers/bigtable.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... | 169 | 6,765 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/sum_globally.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");... | 53 | 1,535 |
saleor | saleor/order/tests/webhooks/test_exclude_shipping.py | .py | import json
import uuid
from decimal import Decimal
from unittest import mock
from unittest.mock import call
import graphene
import pytest
from measurement.measures import Weight
from prices import Money
from promise import Promise
from ....core.prices import quantize_price
from ....shipping.interface import Shipping... | 537 | 16,995 |
wagtail | wagtail/admin/tests/api/test_images.py | .py | import json
from django.urls import reverse
from wagtail.api.v2.tests.test_images import (
TestImageDetail,
TestImageListing,
TestImageListingSearch,
)
from wagtail.images import get_image_model
from wagtail.images.tests.utils import get_test_image_file
from .utils import AdminAPITestCase
class TestAdm... | 270 | 9,304 |
saleor | saleor/graphql/discount/mutations/voucher/voucher_create.py | .py | import graphene
from django.core.exceptions import ValidationError
from django.db import transaction
from .....core.utils.promo_code import generate_promo_code, is_available_promo_code
from .....discount import models
from .....discount.error_codes import DiscountErrorCode
from .....permission.enums import DiscountPer... | 317 | 10,955 |
saleor | saleor/graphql/product/tests/mutations/test_product_variant_create.py | .py | import datetime
import json
from unittest.mock import ANY, patch
from uuid import uuid4
import graphene
from django.conf import settings
from django.utils.text import slugify
from freezegun import freeze_time
from .....discount.utils.promotion import get_active_catalogue_promotion_rules
from .....product.error_codes ... | 2,967 | 94,497 |
astropy | astropy/cosmology/_src/tests/io/test_cosmology.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
from astropy.cosmology._src.io.builtin.cosmology import from_cosmology, to_cosmology
from .base import IODirectTestBase, ToFromTestMixinBase
###############################################################################
class ToFromCos... | 58 | 2,308 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_rsqrt.py | .py | import sys
import paddle
import numpy as np
from save_model import saveModel
def rsqrt(name: str, x):
paddle.enable_static()
with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()):
node_x = paddle.static.data(name="x", shape=x.shape, dtype=x.dtype)
out = paddle.rsq... | 46 | 1,212 |
beam | sdks/python/apache_beam/runners/portability/beam_plugins_it_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... | 71 | 2,293 |
black | tests/data/cases/composition.py | .py | class C:
def test(self) -> None:
with patch("black.out", print):
self.assertEqual(
unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
)
self.assertEqual(
unstyle(str(report)),
"1 file reformatted, 1 file ... | 180 | 5,574 |
saleor | saleor/payment/tests/test_payment.py | .py | import uuid
from decimal import Decimal
from unittest.mock import Mock, patch
import pytest
from ...checkout.calculations import calculate_checkout_total
from ...checkout.fetch import fetch_checkout_info, fetch_checkout_lines
from ...core.prices import quantize_price
from ...plugins.manager import PluginsManager, get... | 781 | 24,763 |
wandb | wandb/sdk/artifacts/_generated/fetch_artifact_manifest.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/artifacts/
from __future__ import annotations
from pydantic import Field
from wandb._pydantic import GQLResult
from .fragments import DeferredManifestFragment
class FetchArtifactManifest(GQLResult):
artifact: FetchArtifactManifestArtifact | None
... | 23 | 542 |
saleor | saleor/graphql/product/tests/test_product_sorting_attributes.py | .py | import os.path
from decimal import Decimal
import graphene
import pytest
from ....attribute import AttributeInputType, AttributeType
from ....attribute import models as attribute_models
from ....attribute.utils import associate_attribute_values_to_instance
from ....product import ProductTypeKind
from ....product impo... | 695 | 22,750 |
openvino | scripts/utils/utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import subprocess # nosec B404
import tarfile
from datetime import datetime
from shutil import copyfile, copytree, rmtree
major_version = 0
minor_version = 3
class Automation:
@staticmethod
def parse_bom(bom_path):
... | 60 | 2,151 |
saleor | saleor/graphql/discount/mutations/promotion/promotion_rule_delete.py | .py | import graphene
from .....discount import PromotionType, events, models
from .....graphql.core.mutations import ModelDeleteMutation
from .....permission.enums import DiscountPermissions
from .....product.utils.product import (
get_channel_to_products_map_from_rules,
mark_products_in_channels_as_dirty,
)
from .... | 78 | 2,980 |
beam | sdks/python/apache_beam/examples/cookbook/combiners_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... | 78 | 2,656 |
luigi | luigi/contrib/hdfs/__init__.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... | 75 | 2,900 |
kafka | tests/kafkatest/tests/core/reassign_partitions_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 ... | 181 | 9,391 |
lemur | lemur/notifications/cli.py | .py | """
.. module: lemur.notifications.cli
:platform: Unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
import click
from flask import current_app
from flask.cli import with_appcontext
from s... | 147 | 5,223 |
structlog | src/structlog/_config.py | .py | # SPDX-License-Identifier: MIT OR Apache-2.0
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the MIT License. See the LICENSE file in the root of this
# repository for complete details.
"""
Global state department. Don't reload this module or everything breaks.
"""
from __futu... | 440 | 14,011 |
openvino | tests/e2e_tests/common/postprocessors/mask_rcnn.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Mask RCNN postprocessor"""
import logging as log
import sys
import cv2
import numpy as np
from .provider import ClassProvider
class ParseMaskRCNN(ClassProvider):
"""Semantic segmentation parser
returns new "score" layer, c... | 70 | 3,160 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Pooling.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import pytest
from common.tf_layer_test_class import CommonTFLayerTest
class TestPooling(CommonTFLayerTest):
def create_pooling_net(self, kernel_size, strides, pads, in_shape, out_shape, method,
... | 235 | 15,226 |
gunicorn | tests/ctl/test_client.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for control socket client."""
import os
import socket
import tempfile
import threading
import pytest
from gunicorn.ctl.client import (
ControlClient,
ControlClientError,
parse_command,
)
fro... | 276 | 9,177 |
lemur | lemur/plugins/lemur_acme/dyn.py | .py | import time
import dns
import dns.exception
import dns.name
import dns.query
import dns.resolver
from dyn.tm.errors import (
DynectCreateError,
DynectDeleteError,
DynectGetError,
DynectUpdateError,
)
from dyn.tm.session import DynectSession
from dyn.tm.zones import Node, Zone, get_all_zones
from flask ... | 287 | 9,285 |
saleor | saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_refund_requested.py | .py | import json
from decimal import Decimal
import graphene
from django.utils import timezone
from freezegun import freeze_time
from ....core.prices import quantize_price
from ....graphql.tests.queries import fragments
from ....payment import TransactionAction, TransactionEventType
from ....payment.interface import Trans... | 335 | 10,462 |
confluent-kafka-python | tests/integration/producer/test_producer_wakeable_poll_flush.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2024 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 202 | 7,622 |
onnxruntime | onnxruntime/python/tools/transformers/models/stable_diffusion/benchmark.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
import csv
import logging
import os
import statistics
i... | 1,512 | 49,574 |
biopython | Tests/test_motifs.py | .py | # Copyright 2008 by Bartek Wilczynski. All rights reserved.
# Revisions copyright 2019 by Victor Lin.
# Adapted from test_Mymodule.py by Jeff Chang.
# 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 LICEN... | 5,163 | 260,094 |
pyro | tests/infer/reparam/util.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import warnings
import pytest
from pyro import poutine
from pyro.infer.autoguide.initialization import InitMessenger, init_to_value
from pyro.infer.reparam.reparam import Reparam
from tests.common import assert_close
def check_init... | 35 | 1,193 |
ipython | IPython/terminal/shortcuts/auto_match.py | .py | """
Utilities function for keybinding with prompt toolkit.
This will be bound to specific key press and filter modes,
like whether we are in edit mode, and whether the completer is open.
"""
import re
from prompt_toolkit.key_binding import KeyPressEvent
def parenthesis(event: KeyPressEvent):
"""Auto-close paren... | 106 | 3,066 |
luigi | examples/terasort.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... | 109 | 3,267 |
jupytext | tests/functional/config/test_config.py | .py | import os
from pathlib import Path
from contextlib import contextmanager
import pytest
from jupytext.config import (
find_jupytext_configuration_file,
load_jupytext_configuration_file,
notebook_formats,
)
from jupytext.jupytext import load_jupytext_config, read
@contextmanager
def change_dir(path):
... | 419 | 13,546 |
probability | tensorflow_probability/python/internal/auto_composite_tensor.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... | 814 | 30,700 |
flit | tests/test_find_python_executable.py | .py | from os.path import isabs, basename, dirname
import os
import re
import sys
import venv
import pytest
from flit import PythonNotFoundError, find_python_executable
def test_default():
assert find_python_executable(None) == sys.executable
def test_self():
assert find_python_executable(sys.executable) == sys... | 50 | 1,255 |
wandb | wandb/sdk/data_types/histogram.py | .py | from __future__ import annotations
import sys
from collections.abc import Sequence
from typing import TYPE_CHECKING
from wandb import util
from .base_types.wb_value import WBValue
if TYPE_CHECKING: # pragma: no cover
import numpy as np
from wandb.sdk.artifacts.artifact import Artifact
from ..wandb_ru... | 111 | 3,377 |
beam | learning/katas/python/IO/TextIO/ReadFromText/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"); you may... | 41 | 1,275 |
probability | tensorflow_probability/python/experimental/mcmc/sample_sequential_monte_carlo.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... | 595 | 24,492 |
mlflow | dev/check_whitespace_only.py | .py | """
Detect files where all changes are whitespace-only.
This helps avoid unnecessary commit history noise from whitespace-only changes.
"""
import argparse
import json
import os
import sys
import time
import urllib.error
import urllib.request
from typing import cast
BYPASS_LABEL = "allow-whitespace-only"
_MAX_ATTEM... | 149 | 4,404 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/min_test.py | .py | # coding=utf-8
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License");... | 63 | 1,975 |
pyro | tests/ops/test_stats.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import warnings
import pytest
import torch
from pyro.ops.stats import (
_cummin,
autocorrelation,
autocovariance,
crps_empirical,
effective_sample_size,
energy_score_empirical,
fit_generalized_pareto,
... | 376 | 11,712 |
mlflow | tests/cli/test_eval.py | .py | import re
from unittest import mock
import click
import pandas as pd
import pytest
import mlflow
from mlflow.cli.eval import evaluate_traces
from mlflow.entities import Trace, TraceInfo
from mlflow.genai.scorers.base import scorer
def test_evaluate_traces_with_single_trace_table_output():
experiment_id = mlflow... | 218 | 7,730 |
saleor | saleor/graphql/discount/tests/benchmark/test_promotion_rule_delete.py | .py | import graphene
import pytest
from ....tests.utils import get_graphql_content
from ..mutations.test_promotion_rule_delete import PROMOTION_RULE_DELETE_MUTATION
@pytest.mark.django_db
@pytest.mark.count_queries(autouse=False)
def test_promotion_rule_delete(
staff_api_client,
permission_group_manage_discounts,... | 32 | 838 |
sqlmap | plugins/dbms/db2/enumeration.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.data import logger
from plugins.generic.enumeration import Enumeration as GenericEnumeration
class Enumeration(GenericEnumeration):
def getPasswordHashes(self):... | 23 | 614 |
astropy | astropy/modeling/tests/test_separable.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Test separability of models.
"""
import numpy as np
# pylint: disable=invalid-name
import pytest
from numpy.testing import assert_allclose
from astropy.modeling import custom_model, models
from astropy.modeling.core import ModelDefinitionError
from... | 194 | 5,510 |
mlflow | mlflow/xgboost/__init__.py | .py | """
The ``mlflow.xgboost`` module provides an API for logging and loading XGBoost models.
This module exports XGBoost models with the following flavors:
XGBoost (native) format
This is the main flavor that can be loaded back into XGBoost.
:py:mod:`mlflow.pyfunc`
Produced for use by generic pyfunc-based deploym... | 924 | 38,561 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineglobally_multiple_arguments.py | .py | # coding=utf-8
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License");... | 63 | 2,090 |
openvino | src/bindings/python/tests/test_graph/test_sequence_processing.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 as ov
import openvino.opset16 as ov16
@pytest.mark.parametrize(("depth", "on_value", "off_value", "axis", "expected_shape"), [
(2, 5, 10, -1, [3, 2]),
(3... | 77 | 2,473 |
mlflow | tests/data/test_dataset.py | .py | import json
from mlflow.types.schema import Schema
from tests.resources.data.dataset import SampleDataset
from tests.resources.data.dataset_source import SampleDatasetSource
def test_conversion_to_json():
source_uri = "test:/my/test/uri"
source = SampleDatasetSource._resolve(source_uri)
dataset = Sample... | 43 | 1,672 |
textual | tests/test_auto_refresh.py | .py | import asyncio
from time import time
from textual.app import App
from textual.pilot import Pilot
class RefreshApp(App[float]):
def __init__(self):
self.count = 0
super().__init__()
def on_mount(self):
self.start = time()
self.auto_refresh = 0.1
def automatic_refresh(self... | 34 | 773 |
metrics | src/torchmetrics/retrieval/ndcg.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... | 163 | 6,664 |
probability | tensorflow_probability/python/distributions/quantized_distribution.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... | 617 | 22,579 |
pyomo | examples/pyomobook/scripts-ch/prob_mod_ex.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... | 61 | 1,755 |
sqlmap | tests/test_payloads_structure.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Structural invariants of the injection payload/boundary definitions
(data/xml/payloads/*.xml -> conf.tests, data/xml/boundaries.xml -> conf.boundaries).
These XML files ARE the detec... | 131 | 5,751 |
pyomo | pyomo/core/base/config.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... | 149 | 4,690 |
wandb | wandb/agents/pyagent.py | .py | """Agent - Agent object.
Manage wandb agent.
"""
import ctypes
import logging
import os
import queue
import socket
import sys
import threading
import time
import traceback
from typing import Any
import wandb
from wandb.apis import InternalApi
from wandb.sdk.launch.sweeps import SweepNotFoundError
from wandb.sdk.lau... | 431 | 16,259 |
saleor | saleor/warehouse/tasks.py | .py | from celery.utils.log import get_task_logger
from django.db.models import F, Sum
from django.db.models.functions import Coalesce
from django.utils import timezone
from ..celeryconf import app
from ..core.db.connection import allow_writer
from .management import delete_allocations, stock_bulk_update
from .models import... | 69 | 2,257 |
hydra | tests/test_examples/test_experimental.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from pathlib import Path
from hydra.test_utils.test_utils import run_python_script
def test_rerun(tmpdir: Path) -> None:
cmd = [
"examples/experimental/rerun/my_app.py",
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.ch... | 19 | 573 |
saleor | saleor/tests/e2e/vouchers/utils/voucher_create.py | .py | from ...utils import get_graphql_content
VOUCHER_CREATE_MUTATION = """
mutation VoucherCreate($input: VoucherInput!) {
voucherCreate(input: $input) {
errors {
field
message
code
}
voucher {
id
startDate
discountValueType
type
codes(first: 10) {
edge... | 51 | 924 |
hatch | tests/cli/self/test_self.py | .py | import os
def test(hatch):
result = hatch(os.environ["PYAPP_COMMAND_NAME"], "-h")
assert result.exit_code == 0, result.output
| 8 | 137 |
pyomo | pyomo/repn/plugins/cpxlp.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... | 981 | 39,688 |
saleor | saleor/giftcard/tests/fixtures/giftcard_tag.py | .py | import pytest
from ...models import GiftCardTag
@pytest.fixture
def gift_card_tag_list(db):
tags = [GiftCardTag(name=f"test-tag-{i}") for i in range(5)]
return GiftCardTag.objects.bulk_create(tags)
| 10 | 209 |
sphinx | sphinx/directives/other.py | .py | from __future__ import annotations
import re
from os.path import relpath
from pathlib import Path
from typing import TYPE_CHECKING, cast
from docutils import nodes
from docutils.parsers.rst import directives
from docutils.parsers.rst.directives.misc import Class
from docutils.parsers.rst.directives.misc import Includ... | 442 | 16,455 |
readthedocs.org | readthedocs/search/api/pagination.py | .py | from collections import namedtuple
from math import ceil
from django.utils.translation import gettext as _
from rest_framework.exceptions import ValidationError
from rest_framework.pagination import PageNumberPagination
class PaginatorPage:
"""
Mimics the result from a paginator.
By using this class, we... | 107 | 3,577 |
mlflow | mlflow/genai/scorers/deepeval/scorers/conversational_metrics.py | .py | """Conversational metrics for evaluating multi-turn dialogue performance."""
from __future__ import annotations
from typing import ClassVar
from mlflow.genai.judges.builtin import _MODEL_API_DOC
from mlflow.genai.scorers.deepeval import DeepEvalScorer
from mlflow.utils.docstring_utils import format_docstring
@form... | 218 | 6,896 |
openvino | tests/samples_tests/smoke_tests/test_hello_reshape_ssd.py | .py | """
Copyright (C) 2018-2026 Intel Corporation
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 w... | 32 | 1,408 |
saleor | saleor/graphql/checkout/tests/deprecated/test_checkout_create.py | .py | import graphene
from .....checkout.models import Checkout
from ....tests.utils import get_graphql_content
def test_checkout_create(api_client, stock, graphql_address_data, channel_USD):
"""Create checkout object using GraphQL API."""
query = """
mutation createCheckout($checkoutInput: CheckoutCreateI... | 81 | 2,265 |
pyomo | pyomo/core/tests/examples/pmedian_concrete.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... | 69 | 2,216 |
black | tests/data/cases/comments.py | .py | #!/usr/bin/env python3
# fmt: on
# Some license here.
#
# Has many lines. Many, many lines.
# Many, many, many lines.
"""Module docstring.
Possibly also many, many lines.
"""
import os.path
import sys
import a
from b.c import X # some noqa comment
try:
import fast
except ImportError:
import slow as fast
... | 97 | 1,909 |
pyro | tests/ops/test_provenance.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pyro.ops.provenance import ProvenanceTensor, get_provenance, track_provenance
from tests.common import assert_equal, requires_cuda
@requires_cuda
@pytest.mark.parametrize(
"dtype1",
[
... | 69 | 1,855 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.