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/page/utils.py | .py | from .tasks import mark_pages_search_vector_as_dirty
# Results in update time ~0.2s, consumes ~30 MB
MARK_SEARCH_VECTOR_DIRTY_BATCH_SIZE = 1000
def mark_pages_search_vector_as_dirty_in_batches(page_ids: list[int]):
"""Mark pages as needing search index updates."""
for i in range(0, len(page_ids), MARK_SEARCH... | 12 | 480 |
beam | sdks/java/extensions/python/src/main/resources/org/apache/beam/sdk/extensions/python/bootstrap_beam_venv.py | .py | # The ASF licenses this file to You 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, softwa... | 119 | 4,368 |
deap | examples/ga/onemax_short.py | .py | # This file is part of DEAP.
#
# DEAP 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.
#
# DEAP is distributed ... | 64 | 2,067 |
wagtail | wagtail/api/v3/schemas/generators/__init__.py | .py | from .read import read_generator
from .write import create_generator, patch_generator
__all__ = [
"read_generator",
"create_generator",
"patch_generator",
]
| 9 | 170 |
django-cms | cms/tests/test_grouper_admin.py | .py | import copy
from unittest.mock import MagicMock, patch
from django.conf import settings
from django.contrib.admin import site
from django.contrib.auth import get_permission_codename
from django.contrib.sites.models import Site
from django.db import connection
from django.templatetags.static import static
from django.t... | 1,289 | 61,494 |
sqlmap | plugins/dbms/mysql/fingerprint.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.common import Backend
from lib.core.common import Format
from lib.core.common import hashDBRetrieve
from lib.core.common import hashDBWrite
from lib.core.... | 356 | 14,184 |
saleor | saleor/tests/e2e/vouchers/utils/voucher_update.py | .py | from ...utils import get_graphql_content
VOUCHER_UPDATE_MUTATION = """
mutation VoucherUpdate($id:ID! $input: VoucherInput!) {
voucherUpdate(id: $id, input: $input) {
errors {
message
code
field
}
voucher {
id
applyOncePerCustomer
applyOncePerOrder
endDate
... | 60 | 1,183 |
saleor | saleor/graphql/payment/tests/mutations/test_payment_method_initialize_tokenization.py | .py | from unittest.mock import patch
import pytest
from .....payment import TokenizedPaymentFlow
from .....payment.interface import (
PaymentMethodInitializeTokenizationRequestData,
PaymentMethodTokenizationResponseData,
PaymentMethodTokenizationResult,
)
from .....plugins.manager import PluginsManager
from ..... | 289 | 9,833 |
coremltools | coremltools/converters/mil/mil/ops/defs/_op_reqs.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
from coremltools.converters.mil.mil.ops.registry import \
SSAOpRegistry as _SSAOpRegistry
registe... | 9 | 354 |
attrs | tests/attr_import_star.py | .py | # SPDX-License-Identifier: MIT
from attr import * # noqa: F403
# This is imported by test_import::test_from_attr_import_star; this must
# be done indirectly because importing * is only allowed on module level,
# so can't be done inside a test.
| 10 | 249 |
cvxpy | cvxpy/utilities/debug_tools.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
dis... | 80 | 3,264 |
wandb | wandb/sdk/mailbox/wait_with_progress.py | .py | from __future__ import annotations
import time
from collections.abc import Callable, Coroutine
from typing import Any, TypeVar, cast
from wandb.sdk.lib import asyncio_compat
from .mailbox_handle import MailboxHandle
_T = TypeVar("_T")
def wait_with_progress(
handle: MailboxHandle[_T],
*,
timeout: floa... | 102 | 3,117 |
bazel | src/test/py/bazel/bazel_clean_test.py | .py | # Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 112 | 3,865 |
cvxpy | cvxpy/atoms/norm1.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... | 135 | 4,091 |
onnxruntime | onnxruntime/core/providers/coreml/mlprogram_test_scripts/convtranspose_test.py | .py | import coremltools as ct
import numpy as np
from coremltools.converters.mil import Builder as mb
target = ct.target.iOS15
x_shape = (1, 3, 4, 4)
w_shape = (3, 3, 3, 3)
@mb.program(input_specs=[mb.TensorSpec(shape=x_shape)], opset_version=target)
def prog(x):
weight = mb.const(name="weight", val=np.ones(w_shape,... | 43 | 1,364 |
onnx | onnx/reference/ops/op_expand.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
def common_reference_implementation(data: np.ndarray, shape: np.ndarray) -> np.ndarray:
ones = np.ones(shape, dtype=data.dtype)
retur... | 19 | 453 |
beam | sdks/python/apache_beam/io/gcp/datastore/v1new/util_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... | 102 | 3,590 |
biopython | Doc/examples/clustal_run.py | .py | #!/usr/bin/env python
# Copyright 2000 Brad Chapman. 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.
"""Run clustalw and parse the output.
Example code to show how to create ... | 52 | 1,617 |
sqlmap | lib/request/pkihandler.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
ssl = None
try:
import ssl as _ssl
ssl = _ssl
except ImportError:
pass
from lib.core.data import conf
from lib.core.common import getSafeExString
from lib.core.except... | 52 | 1,774 |
astropy | astropy/utils/xml/unescaper.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""URL unescaper functions."""
# STDLIB
from xml.sax import saxutils
__all__ = ["unescape_all"]
# This is DIY
_bytes_entities = {
b"&": b"&",
b"<": b"<",
b">": b">",
b"&&": b"&",
b"&&": b"&",
b"%2F": b"/",
}
_by... | 64 | 1,420 |
jupytext | tests/functional/round_trip/test_read_all_py.py | .py | import jupytext
from jupytext.compare import compare
def test_identity_source_write_read(py_file):
with open(py_file) as fp:
py = fp.read()
nb = jupytext.reads(py, "py")
py2 = jupytext.writes(nb, "py")
compare(py2, py)
| 13 | 247 |
textual | tests/test_binding_inheritance.py | .py | """Tests relating to key binding inheritance.
In here you'll find some tests for general key binding inheritance, but
there is an emphasis on the inheriting of movement key bindings as they (as
of the time of writing) hold a special place in the Widget hierarchy of
Textual.
<URL:https://github.com/Textualize/textual/... | 643 | 24,202 |
wandb | wandb/sdk/launch/errors.py | .py | from wandb.errors import Error
class LaunchError(Error):
"""Raised when a known error occurs in wandb launch."""
class LaunchDockerError(Error):
"""Raised when Docker daemon is not running."""
class ExecutionError(Error):
"""Generic execution exception."""
| 14 | 275 |
wandb | tests/unit_tests/test_lib/test_settings_file.py | .py | import pathlib
import re
import textwrap
import pytest
from wandb.sdk.lib import settings_file
from tests.fixtures.mock_wandb_log import MockWandbLog
def test_error_writing(tmp_path: pathlib.Path):
local_settings = tmp_path / "local_settings"
local_settings.mkdir() # Cannot read or write a directory.
... | 198 | 5,213 |
astropy | astropy/io/fits/convenience.py | .py | # Licensed under a 3-clause BSD style license - see PYFITS.rst
"""Convenience functions for working with FITS files.
Convenience functions
=====================
The functions in this module provide shortcuts for some of the most basic
operations on FITS files, such as reading and updating the header. They are
inclu... | 1,188 | 42,687 |
conda | tests/cli/test_main_export.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Test conda export."""
from __future__ import annotations
import json
import uuid
import warnings
from typing import TYPE_CHECKING
import pytest
from conda.base.context import context
from conda.cli.main_export import CondaExportWarning
fr... | 1,090 | 38,392 |
pyro | pyro/poutine/escape_messenger.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from typing import Callable
from pyro.poutine.messenger import Messenger
from pyro.poutine.runtime import Message, NonlocalExit
class EscapeMessenger(Messenger):
"""
Messenger that does a nonlocal exit by raising a util.... | 43 | 1,339 |
saleor | saleor/order/tests/fixtures/draft_order.py | .py | from decimal import Decimal
from functools import partial
import graphene
import pytest
from django.conf import settings
from prices import Money, TaxedMoney, fixed_discount
from ....core.prices import quantize_price
from ....core.taxes import zero_money
from ....discount import DiscountType, DiscountValueType, Rewar... | 268 | 9,408 |
python-prompt-toolkit | examples/prompts/auto-completion/multi-column-autocompletion-with-meta.py | .py | #!/usr/bin/env python
"""
Autocompletion example that shows meta-information alongside the completions.
"""
from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.shortcuts import CompleteStyle, prompt
animal_completer = WordCompleter(
[
"alligator",
"ant",
"ape",
... | 52 | 1,211 |
mlflow | mlflow/protos/unity_catalog_prompt_messages_pb2_grpc.py | .py | # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings
GRPC_GENERATED_VERSION = '1.71.0'
GRPC_VERSION = grpc.__version__
_version_not_supported = False
try:
from grpc._utilities import first_ver... | 25 | 910 |
qutip | qutip/solver/steadystate.py | .py | from qutip import liouvillian, lindblad_dissipator, Qobj, qzero_like, qeye_like
from qutip import vector_to_operator, operator_to_vector, hilbert_dist
from qutip import settings, CoreOptions
import qutip.core.data as _data
import numpy as np
import scipy.sparse.csgraph
import scipy.sparse.linalg
from warnings import wa... | 613 | 21,055 |
mlflow | tests/tracking/fluent/test_metric_value_conversion_utils.py | .py | import numpy as np
import pytest
import mlflow
from mlflow import tracking
from mlflow.exceptions import INVALID_PARAMETER_VALUE, ErrorCode, MlflowException
from mlflow.tracking.fluent import start_run
from mlflow.tracking.metric_value_conversion_utils import convert_metric_value_to_float_if_possible
from tests.helpe... | 40 | 1,327 |
scikit-optimize | examples/hyperparameter-optimization.py | .py | """
============================================
Tuning a scikit-learn estimator with `skopt`
============================================
Gilles Louppe, July 2016
Katie Malone, August 2016
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
If you are looking for a :obj:`sklearn.model_selection.GridSearc... | 115 | 4,312 |
probability | spinoffs/inference_gym/inference_gym/targets/logistic_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... | 174 | 6,048 |
openvino | src/bindings/python/tests/test_graph/test_segment_max.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino import Type, PartialShape, Dimension
from openvino.opset15 import parameter
import openvino.opset16 as ov
import pytest
@pytest.mark.parametrize("dtype_segment_ids", [
Type.i32,
Type.i64
])... | 54 | 1,965 |
sphinx | tests/test_builders/test_build_html_numfig.py | .py | """Test the HTML builder and check output against XPath."""
from __future__ import annotations
import re
from typing import TYPE_CHECKING
import pytest
from tests.test_builders.xpath_data import FIGURE_CAPTION
from tests.test_builders.xpath_util import check_xpath
if TYPE_CHECKING:
from collections.abc import ... | 1,146 | 35,121 |
luigi | test/fib_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... | 77 | 2,260 |
wagtail | wagtail/admin/views/pages/bulk_actions/move.py | .py | import swapper
from django import forms
from django.template.response import TemplateResponse
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ngettext
from wagtail.admin import widgets
from wagtail.admin.views.pages.bulk_actions.page_bulk_action import PageBulkAction
Page =... | 161 | 5,811 |
pyfilesystem2 | fs/glob.py | .py | """Useful functions for working with glob patterns.
"""
from __future__ import unicode_literals
import typing
from functools import partial
import re
from collections import namedtuple
from ._repr import make_repr
from .lrucache import LRUCache
from .path import iteratepath
GlobMatch = namedtuple("GlobMatch", ["p... | 462 | 13,740 |
django-cms | cms/test_utils/project/sampleapp/cms_wizards.py | .py | from cms.test_utils.project.sampleapp.forms import SampleWizardForm
from cms.wizards.wizard_base import Wizard
class SampleWizard(Wizard):
pass
sample_wizard = SampleWizard(
title="Sample",
weight=105,
form=SampleWizardForm,
description="Create a new Sample",
)
| 15 | 286 |
beam | sdks/python/apache_beam/runners/interactive/pipeline_fragment.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... | 270 | 11,876 |
sphinx | sphinx/testing/fixtures.py | .py | """Sphinx test fixtures for pytest"""
from __future__ import annotations
import shutil
import subprocess
import sys
from collections import namedtuple
from io import StringIO
from typing import TYPE_CHECKING
import pytest
from sphinx.testing.util import SphinxTestApp, SphinxTestAppWrapperForSkipBuilding
if TYPE_CH... | 261 | 7,941 |
confluent-kafka-python | tests/test_DeserializingShareConsumer.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2026 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... | 346 | 13,304 |
saleor | saleor/graphql/meta/tests/mutations/test_product.py | .py | from unittest.mock import patch
import graphene
from . import PRIVATE_KEY, PRIVATE_VALUE, PUBLIC_KEY, PUBLIC_VALUE
from .test_delete_metadata import (
execute_clear_public_metadata_for_item,
item_without_public_metadata,
)
from .test_delete_private_metadata import (
execute_clear_private_metadata_for_item... | 953 | 31,062 |
wagtail | wagtail/admin/views/home.py | .py | from collections.abc import Mapping
from typing import Any
import swapper
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import permission_required
from django.db.models import Exists, IntegerField, Max, OuterRef, Q
from django.db.models.functions im... | 376 | 13,968 |
textual | tests/test_suggestions.py | .py | import pytest
from textual.suggestions import get_suggestion, get_suggestions
@pytest.mark.parametrize(
"word, possible_words, expected_result",
(
["background", ("background",), "background"],
["backgroundu", ("background",), "background"],
["bkgrund", ("background",), "background"],... | 36 | 1,355 |
openvino | tests/layer_tests/pytorch_tests/test_shape_as_tensor.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class aten_shape_as_tensor(torch.nn.Module):
def __init__(self) -> None:
torch.nn.Module.__init__(self)
def forward(se... | 33 | 912 |
openvino | docs/articles_en/assets/snippets/ov_python_exclusives.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import openvino as ov
from utils import get_path_to_model, get_image
#! [properties_example]
import openvino.opset12 as ops
core = ov.Core()
input_a = ops.parameter([8], name="input_a")
res = ops.absolute(input_a)
... | 196 | 5,176 |
probability | tensorflow_probability/python/distributions/cauchy.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... | 270 | 9,637 |
astropy | astropy/cosmology/_src/tests/traits/test_trait_curvature.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.cosmology._src.traits.curvature import CurvatureComponent
from .helper import is_positional_only
class DummyCurvature(CurvatureComponent):
def __init__(self, ok0):
self._ok0 = ok0
@property
def Ok0(self):
... | 43 | 969 |
jupytext | tests/unit/data/landing_page/notebook_light.py | .py | # # Quarterly Sales
# A look at Q4 revenue by region.
import pandas as pd
df = pd.read_csv("sales.csv")
df.groupby("region")["revenue"].sum().plot.bar()
| 8 | 155 |
textual | src/textual/widgets/_radio_set.py | .py | """Provides a RadioSet widget, which groups radio buttons."""
from __future__ import annotations
from typing import ClassVar, Optional
import rich.repr
from rich.console import RenderableType
from textual import _widget_navigation
from textual.binding import Binding, BindingType
from textual.containers import Verti... | 316 | 11,492 |
sphinx | tests/test_util/test_util_inspect.py | .py | """Tests util.inspect functions."""
from __future__ import annotations
import ast
import datetime
import enum
import functools
import types
from inspect import Parameter
from typing import Callable, List, Optional, Union # NoQA: UP035
import pytest
from sphinx.util import inspect
from sphinx.util.inspect import (
... | 1,018 | 33,651 |
clearml | clearml/utilities/plotlympl/mplexporter/renderers/vincent_renderer.py | .py | import warnings
from typing import Dict, Union, Optional, TYPE_CHECKING, Any
import numpy
from .base import Renderer
from ..exporter import Exporter
if TYPE_CHECKING:
import vincent
class VincentRenderer(Renderer):
def open_figure(self, fig: Any, props: Dict[str, Union[int, float]]) -> None:
self.c... | 72 | 2,227 |
saleor | saleor/graphql/checkout/tests/mutations/test_checkout_lines_update.py | .py | import datetime
from decimal import Decimal
from unittest import mock
from unittest.mock import ANY, patch
import graphene
import pytest
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from .....checkout.actions import call_checkout_info_event
from .....ch... | 2,108 | 68,799 |
beam | sdks/python/apache_beam/internal/test_data/module_3.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... | 27 | 993 |
biopython | Tests/test_PDB_vectors.py | .py | # Copyright 2017 by Peter Cock. 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.
"""Tests for the vector code ... | 308 | 12,294 |
textual | tests/command_palette/test_no_results.py | .py | from textual.app import App
from textual.command import CommandPalette
from textual.widgets import OptionList
class CommandPaletteApp(App[None]):
COMMANDS = set()
def on_mount(self) -> None:
self.action_command_palette()
async def test_no_results() -> None:
"""Receiving no results from a search... | 28 | 1,066 |
probability | tensorflow_probability/python/internal/backend/numpy/sparse_lib.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... | 42 | 1,424 |
wagtail | wagtail/contrib/settings/tests/site_specific/test_model.py | .py | import pickle
from django.test import RequestFactory, TestCase, override_settings
from wagtail.models import Site
from wagtail.permission_policies.sites import SitePermissionPolicy
from wagtail.permissions import policy_registry
from wagtail.test.testapp.models import ImportantPagesSiteSetting, TestSiteSetting
from ... | 239 | 10,298 |
openvino | tests/e2e_tests/common/ir_provider/provider.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import inspect
from e2e_tests.common.common.base_provider import BaseProvider, BaseStepProvider
class ClassProvider(BaseProvider):
registry = {}
@classmethod
def validate(cls):
methods = [
f[0] for f in... | 38 | 1,362 |
hatch | tests/helpers/templates/wheel/utils.py | .py | import hashlib
import os
import tempfile
from hatchling.builders.utils import format_file_hash, normalize_artifact_permissions
def update_record_file_contents(record_file, files, generated_files=()):
for template_file in sorted(
files,
key=lambda f: (
f.path.parts[0].endswith(".dist-i... | 61 | 1,933 |
sqlmap | lib/techniques/jwt/inject.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import time
from lib.core.common import beep
from lib.core.common import randomStr
from lib.core.convert import getUnicode
from lib.core.data import conf
from lib.core.data impor... | 362 | 17,001 |
saleor | saleor/tests/models.py | .py | from django.db import models
class Book(models.Model):
name = models.CharField(max_length=30)
| 6 | 100 |
coremltools | coremltools/test/neural_network/test_numpy_nn_layers.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
import itertools
import math
import os
import platform
import random
import tempfile
import unittest
im... | 7,112 | 282,016 |
astropy | astropy/constants/astropyconst13.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Astronomical and physics constants for Astropy v1.3 and earlier.
See :mod:`astropy.constants` for a complete listing of constants
defined in Astropy.
"""
from astropy.utils import find_current_module
from . import codata2010, iau2012
from . import ut... | 21 | 485 |
kafka | tests/kafkatest/tests/connect/connect_rest_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 ... | 239 | 12,863 |
probability | spinoffs/inference_gym/inference_gym/tools/stan/item_response_theory.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 175 | 5,977 |
textual | tests/test_styles_cache.py | .py | from __future__ import annotations
from rich.segment import Segment
from textual._styles_cache import StylesCache
from textual.color import Color
from textual.css.styles import Styles
from textual.geometry import Region, Size
from textual.strip import Strip
def _extract_content(lines: list[Strip]) -> list[str]:
... | 272 | 6,016 |
beam | sdks/python/apache_beam/io/tfrecordio_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... | 828 | 31,248 |
mlflow | mlflow/pytest/session.py | .py | """Session state for the ``@mlflow.test`` pytest plugin.
Tracks the single test run per pytest session and which test is currently
executing (for trace tagging).
"""
from __future__ import annotations
import datetime
import logging
import threading
import uuid
import mlflow
_logger = logging.getLogger(__name__)
T... | 146 | 4,730 |
readthedocs.org | readthedocs/analytics/tests.py | .py | from unittest import mock
import pytest
from django.test import RequestFactory, TestCase, override_settings
from django.urls import reverse
from django.utils import timezone
from django_dynamic_fixture import get
from readthedocs.builds.constants import EXTERNAL
from readthedocs.builds.models import Version
from read... | 276 | 10,856 |
saleor | saleor/tests/e2e/orders/test_able_to_decide_if_address_is_saved_in_user_address_book.py | .py | import pytest
from .. import ADDRESS_DE, DEFAULT_ADDRESS
from ..account.utils import create_customer, get_user
from ..product.utils.preparing_product import prepare_product
from ..shop.utils.preparing_shop import prepare_default_shop
from ..utils import assert_address_data, assign_permissions
from .utils import (
... | 236 | 7,444 |
mlflow | mlflow/transformers/llm_inference_utils.py | .py | from __future__ import annotations
import time
import uuid
from typing import TYPE_CHECKING, Any
import numpy as np
import pandas as pd
from mlflow.exceptions import MlflowException
from mlflow.models import ModelSignature
from mlflow.protos.databricks_pb2 import BAD_REQUEST, INVALID_PARAMETER_VALUE
from mlflow.tran... | 469 | 17,406 |
beam | sdks/python/apache_beam/examples/cookbook/coders_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... | 57 | 1,819 |
mlflow | tests/entities/test_trace_data.py | .py | import json
from unittest import mock
import pytest
import mlflow
from mlflow.entities import SpanType, TraceData
from mlflow.entities.span_event import SpanEvent
def test_json_deserialization():
class TestModel:
@mlflow.trace()
def predict(self, x, y):
z = x + y
with ml... | 241 | 8,531 |
beam | sdks/python/apache_beam/internal/test_data/module_1_nested_function_2_added.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... | 33 | 1,125 |
black | tests/data/cases/python38.py | .py | def starred_return():
my_list = ["value2", "value3"]
return "value1", *my_list
def starred_yield():
my_list = ["value2", "value3"]
yield "value1", *my_list
# all right hand side expressions allowed in regular assignments are now also allowed in
# annotated assignments
a : Tuple[ str, int] = "1", 2
a... | 40 | 780 |
astropy | astropy/convolution/utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
from astropy.modeling.core import Model, custom_model
__all__ = [
"KernelArithmeticError",
"KernelError",
"KernelSizeError",
"discretize_model",
]
class KernelError(Exception):
"""
Base error class for kernel ... | 356 | 12,151 |
onnx | onnx/reference/ops/op_selu.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
class Selu(OpRun):
def _run(self, x, alpha=None, gamma=None):
return (
(np.where(x > 0, x, np.exp(x) * alpha - alpha)... | 16 | 357 |
sqlmap | lib/core/session.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.common import Backend
from lib.core.common import Format
from lib.core.common import hashDBWrite
from lib.core.data import kb
from lib.core.data import lo... | 80 | 1,979 |
beam | sdks/python/apache_beam/io/gcp/bigquery_json_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... | 485 | 16,187 |
colorama | demos/demo06.py | .py | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
import fixpath
import colorama
from colorama import Fore, Back, Style, Cursor
from random import randint, choice
from string import printable
# Demonstrate printing colored, random characters at random positions on the screen
# Fore, Back and ... | 42 | 1,749 |
saleor | saleor/plugins/admin_email/tests/test_plugin.py | .py | from dataclasses import asdict
from smtplib import SMTPNotSupportedError
from unittest.mock import MagicMock, Mock, patch
import pytest
from django.core.exceptions import ValidationError
from django.core.mail.backends.smtp import EmailBackend
from ....core.notify import NotifyEventType
from ....graphql.tests.utils im... | 447 | 14,457 |
readthedocs.org | readthedocs/rtd_tests/tests/test_unresolver.py | .py | import django_dynamic_fixture as fixture
import pytest
from django.test import override_settings
from django_dynamic_fixture import get
from readthedocs.builds.constants import EXTERNAL
from readthedocs.builds.models import Version
from readthedocs.core.unresolver import (
InvalidCustomDomainError,
InvalidExte... | 470 | 20,015 |
wagtail | wagtail/documents/tests/test_admin_views.py | .py | import json
from unittest import mock
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType
from django.core.files.uploadedfile import SimpleUploadedFile
from django.template.defaultfilters import filesizeformat
from django.template.loader import render_to_... | 2,643 | 102,339 |
onnxruntime | onnxruntime/python/tools/transformers/models/t5/t5_encoder_decoder_init.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# -------------------------------------------------------------------------
import logging
import os
import tempfile
from pathlib import Path
import... | 362 | 15,060 |
ipython | IPython/lib/editorhooks.py | .py | """ 'editor' hooks for common editors that work well with ipython
They should honor the line number argument, at least.
Contributions are *very* welcome.
"""
import os
import shlex
import subprocess
import sys
from IPython.core.getipython import get_ipython
from IPython.core.error import TryNext
def install_edito... | 127 | 3,925 |
bazel | third_party/py/abseil/absl/testing/absltest.py | .py | # Copyright 2017 The Abseil 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 ... | 2,578 | 95,906 |
pyro | tests/contrib/mue/test_statearrangers.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pyro.contrib.mue.statearrangers import Profile, mg2k
def simpleprod(lst):
# Product of list of scalar tensors, as numpy would do it.
if len(lst) == 0:
return torch.tensor(1.0)
else... | 272 | 10,625 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_StringSplitV2.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
from common.utils.tf_utils import run_in_jenkins
rng = np.random.default_rng()
class TestStringSplitV2(CommonTFLayerTest... | 49 | 2,089 |
onnxruntime | onnxruntime/test/testdata/transform/dropout_zeroratio_elimination.py | .py | import onnx
from onnx import OperatorSetIdProto, TensorProto, helper
# inputs/outputs
X = helper.make_tensor_value_info("X", TensorProto.FLOAT, [2, 1])
O1 = helper.make_tensor_value_info("O1", TensorProto.FLOAT, [2, 1])
O2 = helper.make_tensor_value_info("O2", TensorProto.FLOAT, [2, 1])
O3 = helper.make_tensor_value_i... | 61 | 2,837 |
clearml | clearml/backend_api/services/v2_13/auth.py | .py | """
auth service
This service provides authentication management and authorization
validation for the entire system.
"""
from typing import List, Optional, Any
from datetime import datetime
import six
from clearml.backend_api.session import (
Request,
Response,
NonStrictDataModel,
schema_property,
)
fr... | 601 | 18,714 |
saleor | saleor/core/tests/test_metadata_manager.py | .py | import pytest
from ...account.models import Address
from ...graphql.meta.inputs import MetadataInput
from ..models import ModelWithMetadata
from ..utils.metadata_manager import (
MetadataEmptyKeyError,
MetadataItem,
MetadataItemCollection,
MetadataType,
create_from_graphql_input,
store_on_insta... | 162 | 4,604 |
sqlmap | lib/techniques/xpath/inject.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 time
from collections import namedtuple
from lib.core.common import beep
from lib.core.common import dataToOutFile
from lib.core.common import randomStr
from li... | 949 | 44,089 |
scikit-optimize | skopt/tests/test_space.py | .py | import pytest
import numbers
import numpy as np
import os
import yaml
from tempfile import NamedTemporaryFile
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_array_equal
from numpy.testing import assert_equal
from numpy.testing import assert_raises_regex
from skopt import Optimize... | 797 | 27,757 |
beam | sdks/python/apache_beam/runners/pipeline_utils_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... | 199 | 8,155 |
astropy | astropy/nddata/tests/test_bitmask.py | .py | """
A module containing unit tests for the `bitmask` module.
Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
import warnings
import numpy as np
import pytest
from astropy.nddata import bitmask
MAX_INT_TYPE = np.int64
MAX_UINT_TYPE = np.uint64
MAX_UINT_FLAG = np.left_shift(
MAX_UINT_TYPE(1), ... | 443 | 11,495 |
mlflow | tests/server/auth/test_authorization_coverage.py | .py | # CI guard for the basic-auth dispatcher: every Flask route must resolve to an
# authorization decision, or be listed in the debt list _KNOWN_UNGATED_ROUTE_MARKERS.
from mlflow.server import auth as a
from mlflow.server.handlers import get_endpoints
class _Req:
def __init__(self, path, method):
self.path... | 139 | 5,461 |
pyomo | pyomo/gdp/tests/test_gdp.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... | 240 | 9,039 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.