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 |
|---|---|---|---|---|---|
readthedocs.org | readthedocs/rtd_tests/tests/test_build_notifications.py | .py | """Notifications sent after build is completed."""
import hashlib
import hmac
import json
from unittest import mock
import requests_mock
from django.core import mail
from django.test import TestCase, override_settings
from django.utils import timezone
from django_dynamic_fixture import get
from readthedocs.builds.con... | 364 | 13,887 |
conda | conda/plugins/virtual_packages/linux.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Detect whether this is Linux."""
from __future__ import annotations
import re
from typing import TYPE_CHECKING
from ...base.context import context
from ...common._os.linux import linux_get_libc_version
from .. import hookimpl
from ..types ... | 77 | 2,534 |
mlflow | tests/data/test_polars_dataset.py | .py | from __future__ import annotations
import json
import re
from datetime import date, datetime
from pathlib import Path
import pandas as pd
import polars as pl
import pytest
from mlflow.data.code_dataset_source import CodeDatasetSource
from mlflow.data.evaluation_dataset import EvaluationDataset
from mlflow.data.files... | 259 | 9,574 |
textual | tests/snapshot_tests/snapshot_apps/sort_children.py | .py | from operator import attrgetter
from textual.app import App, ComposeResult
from textual.containers import Horizontal, Vertical
from textual.widgets import Label
class Number(Label):
DEFAULT_CSS = """
Number {
width: 1fr;
}
"""
def __init__(self, number: int) -> None:
self.number ... | 80 | 1,672 |
beam | sdks/python/apache_beam/testing/benchmarks/nexmark/queries/query2.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... | 43 | 1,593 |
saleor | saleor/tests/e2e/account/utils/account_address_delete.py | .py | from ...utils import get_graphql_content
ACCOUNT_ADDRESS_DELETE_MUTATION = """
mutation deleteUserAddress($id: ID!) {
accountAddressDelete(id: $id) {
address {
city
}
user {
id
}
errors {
field
... | 40 | 815 |
conda | conda/testing/cases.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Extends unittest.TestCase to include select pytest fixtures."""
import unittest
import pytest
class BaseTestCase(unittest.TestCase):
fixture_names = ("tmpdir",)
@pytest.fixture(autouse=True)
def auto_injector_fixture(self, re... | 18 | 453 |
onnx | onnx/backend/test/case/node/roialign.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
def get_roi_align_input_values():
X = np.array(
[
[
... | 447 | 14,904 |
readthedocs.org | readthedocs/builds/tests/test_build_queryset.py | .py | from django.test import override_settings
import django_dynamic_fixture as fixture
import pytest
from readthedocs.builds.models import Build
from readthedocs.organizations.models import Organization
from readthedocs.projects.models import Project
from readthedocs.subscriptions.constants import TYPE_CONCURRENT_BUILDS
f... | 170 | 5,900 |
saleor | saleor/payment/gateways/stripe/consts.py | .py | PLUGIN_ID = "saleor.payments.stripe"
PLUGIN_NAME = "Stripe (deprecated)"
PLUGIN_DESCRIPTION = """
Stripe Plugin has been deprecated and will be removed in the future. Use the Stripe App instead.
https://docs.saleor.io/developer/app-store/apps/stripe/overview
"""
WEBHOOK_PATH = "webhooks/"
WEBHOOK_SUCCESS_EVENT = "pay... | 47 | 1,230 |
wandb | wandb/sdk/lib/wbauth/host_url.py | .py | from __future__ import annotations
import re
from typing_extensions import final, override
from wandb import env, util
from wandb.sdk.lib import urls
@final
class HostUrl:
"""A validated and normalized W&B server URL.
For convenient formatting, the __str__ representation is the URL itself.
"""
de... | 74 | 2,144 |
coremltools | coremltools/models/ml_program/experimental/compute_plan_utils.py | .py | # Copyright (c) 2025, 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 copy
from typing import Callable, List, Optional
from coremltools import ComputeUnit, _logger, p... | 554 | 19,394 |
python-prompt-toolkit | examples/prompts/finalterm-shell-integration.py | .py | #!/usr/bin/env python
"""
Mark the start and end of the prompt with Final term (iterm2) escape sequences.
See: https://iterm2.com/finalterm.html
"""
import sys
from prompt_toolkit import prompt
from prompt_toolkit.formatted_text import ANSI
BEFORE_PROMPT = "\033]133;A\a"
AFTER_PROMPT = "\033]133;B\a"
BEFORE_OUTPUT =... | 45 | 1,309 |
wagtail | wagtail/admin/tests/test_edit_handlers.py | .py | from collections.abc import Mapping
from datetime import date, datetime, timezone
from functools import wraps
from typing import Any
from unittest import mock
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 A... | 2,692 | 105,607 |
conda | conda/reporters.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Holds functions for output rendering in conda
"""
from __future__ import annotations
import logging
import sys
from functools import cache
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from contextlib import AbstractContextManage... | 104 | 2,787 |
coremltools | coremltools/converters/mil/frontend/torch/test/test_torch_stateful_model.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 itertools
from sys import version_info
import numpy as np
import pytest
import coremltools as ... | 1,194 | 42,528 |
metrics | src/torchmetrics/functional/regression/cosine_similarity.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... | 102 | 3,628 |
qutip | qutip/tests/core/data/conftest.py | .py | import numpy as np
import scipy.sparse
import qutip
def shuffle_indices_scipy_csr(matrix, gen=None):
"""
Given a scipy CSR matrix or array, shuffle the indices within each row and
return a new object of the same type. This should represent the same
matrix, but in the less efficient, "unsorted" manne... | 139 | 5,014 |
wandb | wandb/sdk/launch/wandb_reference.py | .py | """Support for parsing W&B URLs (which might be user provided) into constituent parts."""
from __future__ import annotations
from dataclasses import dataclass
from enum import IntEnum
from urllib.parse import urlparse
PREFIX_HTTP = "http://"
PREFIX_HTTPS = "https://"
class ReferenceType(IntEnum):
RUN = 1
J... | 132 | 3,971 |
biopython | Tests/test_UniProt_GOA.py | .py | # Copyright 2019-2020 by Sergio Valqui. 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.
"""Unit tests for the... | 183 | 7,614 |
clearml | clearml/task.py | .py | import numpy
import copy
import json
import os
import shutil
import sys
import threading
import time
import warnings
from argparse import ArgumentParser
from logging import getLogger
from tempfile import mkstemp, mkdtemp
from zipfile import ZipFile, ZIP_DEFLATED
try:
# noinspection PyCompatibility
from collect... | 5,690 | 258,389 |
pyro | pyro/infer/reparam/projected_normal.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import torch
import pyro
import pyro.distributions as dist
from pyro.ops.tensor_utils import safe_normalize
from .reparam import Reparam
class ProjectedNormalReparam(Reparam):
"""
Reparametrizer for :class:`~pyro.distributi... | 56 | 1,697 |
coveragepy | lab/warn_executed.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
"""
$ python warn_executed.py <coverage_data_file> <config_file>
Find lines that were excluded by "warn-executed" regex patterns
but were actually executed accor... | 214 | 6,345 |
probability | tensorflow_probability/python/distributions/lkj.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... | 624 | 27,157 |
cvxpy | cvxpy/constraints/__init__.py | .py | """
Copyright 2013 Steven Diamond, 2022 - 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 agre... | 27 | 1,154 |
clearml | examples/frameworks/xgboost/xgboost_sample.py | .py | import matplotlib.pyplot as plt
import xgboost as xgb
from sklearn import datasets
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
from xgboost import plot_tree
from clearml import Task
# Connecting ClearML with the current process,
# from here on everything is logged ... | 69 | 1,998 |
hydra | plugins/hydra_colorlog/example/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import hydra
from omegaconf import DictConfig
# A logger for this file
log = logging.getLogger(__name__)
@hydra.main(config_path=".", config_name="config")
def my_app(_cfg: DictConfig) -> None:
log.debug("Debug level message")... | 22 | 519 |
beam | sdks/python/apache_beam/runners/interactive/display/pipeline_graph_renderer.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... | 127 | 3,669 |
onnxruntime | orttraining/orttraining/test/python/orttraining_ortmodule_distributed_tests.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import logging
import sys
from _test_commons import run_subprocess
logging.basicConfig(format="%(asctime)s %(name)s [%(levelname)s] - %(message)s", level=logging.DEBUG)
log = logging.g... | 126 | 3,597 |
mlflow | dev/clint/src/clint/config.py | .py | import re
import typing
from dataclasses import dataclass, field
import tomli
from typing_extensions import Self
from clint.rules import ALL_RULES
from clint.utils import get_repo_root
def _validate_exclude_paths(exclude_paths: list[str]) -> None:
"""Validate that all paths in the exclude list exist.
Args:... | 111 | 3,827 |
django-cms | cms/test_utils/project/sampleapp/ns_urls.py | .py | from django.urls import re_path
from django.utils.translation import gettext_lazy as _
from . import views
urlpatterns = [
re_path(r'^current-app/$', views.current_app, name='current-app'),
re_path(_('page'), views.current_app, name='translated-url'),
]
| 10 | 264 |
scikit-bio | skbio/io/format/tests/test_gff3.py | .py | # ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# --------------------------------------------... | 349 | 13,406 |
astropy | astropy/modeling/tests/test_convolution.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# pylint: disable=invalid-name
import numpy as np
import pytest
from astropy.convolution import convolve_models_fft
from astropy.modeling.models import Const1D, Const2D
from astropy.utils.compat.optional_deps import HAS_SCIPY
@pytest.mark.skipif(not HAS... | 97 | 2,624 |
attrs | src/attr/_make.py | .py | # SPDX-License-Identifier: MIT
from __future__ import annotations
import abc
import contextlib
import enum
import itertools
import linecache
import sys
import types
import unicodedata
import weakref
from collections.abc import Callable, Mapping
from functools import cached_property
from typing import Any, NamedTuple... | 3,463 | 108,046 |
probability | tensorflow_probability/python/math/psd_kernels/spectral_mixture.py | .py | # Copyright 2021 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... | 194 | 8,071 |
black | tests/data/cases/comments5.py | .py | while True:
if something.changed:
do.stuff() # trailing comment
# Comment belongs to the `if` block.
# This one belongs to the `while` block.
# Should this one, too? I guess so.
# This one is properly standalone now.
for i in range(100):
# first we do this
if i % 33 == 0:
... | 68 | 1,011 |
saleor | saleor/warehouse/tests/test_stock_availability.py | .py | import pytest
from ...checkout.fetch import fetch_checkout_lines
from ...core.exceptions import InsufficientStock
from ..availability import (
_get_available_quantity,
check_stock_and_preorder_quantity,
check_stock_quantity,
check_stock_quantity_bulk,
get_available_quantity,
is_product_in_stock... | 599 | 17,142 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_avg_pool_2D.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasAvgPool2D(CommonTF2LayerTest):
def create_keras_avg_pool_2D_net(self, pool_size, strides, padding, data_format, input_... | 58 | 2,707 |
wagtail | wagtail/admin/views/pages/convert_alias.py | .py | import swapper
from django.core.exceptions import PermissionDenied
from django.db import transaction
from django.shortcuts import get_object_or_404, redirect
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
from django.views.generic import TemplateView
from wagtail... | 60 | 2,192 |
astropy | astropy/nddata/nduncertainty.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import weakref
from abc import ABCMeta, abstractmethod
from copy import deepcopy
import numpy as np
# from astropy.utils.compat import ignored
from astropy import log
from astropy.units import Quantity, Unit, UnitConversionError
__all__ = [
"Incomp... | 1,222 | 44,787 |
mlflow | dev/flavors/src/flavors/_schema.py | .py | from __future__ import annotations
from datetime import datetime, timezone
from pathlib import Path
from packaging.specifiers import SpecifierSet
from packaging.version import Version as OriginalVersion
from pydantic import BaseModel, ConfigDict, field_validator
DEV_VERSION = "dev"
# Treat "dev" as "newer than any e... | 113 | 3,614 |
pyomo | pyomo/core/pyomoobject.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... | 55 | 2,059 |
confluent-kafka-python | src/confluent_kafka/schema_registry/rule_registry.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... | 104 | 3,182 |
mkdocs | mkdocs/tests/structure/page_tests.py | .py | from __future__ import annotations
import os
import sys
import textwrap
import unittest
from unittest import mock
import markdown
from mkdocs.config.defaults import MkDocsConfig
from mkdocs.structure.files import File, Files
from mkdocs.structure.pages import Page, _ExtractTitleTreeprocessor, _RelativePathTreeproces... | 1,383 | 58,588 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Conj.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
# Testing operation Conj
# Documentation: https://www.tensorflow.org/api_docs/python/tf/raw_ops/Conj
class TestComplexCo... | 60 | 2,141 |
textual | tests/snapshot_tests/snapshot_apps/data_table_cell_padding.py | .py | from textual.app import App, ComposeResult
from textual.widgets import DataTable
class TableApp(App):
CSS = """
DataTable {
margin: 1;
}
"""
def compose(self) -> ComposeResult:
for cell_padding in range(5):
dt = DataTable(cell_padding=cell_padding)
dt.add_c... | 29 | 633 |
textual | tests/text_area/test_history.py | .py | from __future__ import annotations
import dataclasses
import pytest
from textual.app import App, ComposeResult
from textual.events import Paste
from textual.widgets import TextArea
from textual.widgets.text_area import EditHistory, Selection
MAX_CHECKPOINTS = 5
SIMPLE_TEXT = """\
ABCDE
FGHIJ
KLMNO
PQRST
UVWXY
Z
"""... | 402 | 12,929 |
wagtail | wagtail/tests/test_tests.py | .py | import json
import unittest
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.files.uploadedfile import SimpleUploadedFile
from django.template import Context, Origin, Template
from django.test import SimpleTestCase, TestCase
from wagtail.admin.tests.test_conten... | 545 | 20,396 |
wandb | tests/system_tests/test_launch/test_launch_run.py | .py | import json
from unittest import mock
import wandb
from wandb.apis import internal, public
from wandb.sdk.artifacts._internal_artifact import InternalArtifact
from wandb.sdk.internal import job_builder
from wandb.sdk.launch._project_spec import _inject_wandb_config_env_vars
from wandb.util import make_artifact_name_sa... | 131 | 4,746 |
saleor | saleor/asgi/health_check.py | .py | from asgiref.typing import (
ASGI3Application,
ASGIReceiveCallable,
ASGISendCallable,
HTTPResponseBodyEvent,
HTTPResponseStartEvent,
Scope,
)
def health_check(application: ASGI3Application, health_url: str) -> ASGI3Application:
async def health_check_wrapper(
scope: Scope, receive:... | 31 | 929 |
pyomo | pyomo/contrib/parmest/examples/rooney_biegler/rooney_biegler.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... | 138 | 5,237 |
saleor | saleor/graphql/page/tests/queries/pages_with_where/test_with_where_ids.py | .py | import graphene
from .....tests.utils import get_graphql_content
from .shared import QUERY_PAGES_WITH_WHERE
def test_pages_query_with_where_by_ids(
staff_api_client, permission_manage_pages, page_list, page_list_unpublished
):
# given
query = QUERY_PAGES_WITH_WHERE
page_ids = [
graphene.Node... | 26 | 734 |
metrics | src/torchmetrics/classification/base.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... | 33 | 1,234 |
onnx | onnx/reference/ops/op_softsign.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 OpRunUnaryNum
class Softsign(OpRunUnaryNum):
def _run(self, X):
tmp = np.abs(X)
tmp += 1
np.divide(X, tmp, out=tmp)
... | 17 | 340 |
django-cms | cms/extensions/models.py | .py | from django.db import models
from django.db.models import ManyToManyField
from cms.models import Page, PageContent
class BaseExtension(models.Model):
extended_object = None
class Meta:
abstract = True
def get_page(self): # pragma: no cover
raise NotImplementedError('Function must be ov... | 70 | 2,070 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Conv3DBackprop.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from common.tf_layer_test_class import CommonTFLayerTest
# Testing operation Conv3DBackpropInputV2
# Documentation: https://www.tensorflow.org/api_docs/python/tf/raw_ops/Conv3DBackpropInputV2
class TestConv3DBackprop(Co... | 88 | 4,847 |
metrics | tests/unittests/audio/test_dnsmos.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... | 272 | 10,206 |
coveragepy | ci/trigger_action.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
"""Trigger a repository_dispatch GitHub action."""
import sys
import time
from session import get_session
# The GitHub URL makes no mention of which workflow t... | 56 | 1,552 |
coremltools | coremltools/optimize/torch/palettization/fake_palettize.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 contextlib
import logging as _logging
from typing import Optional as _Optional
from typing imp... | 805 | 32,363 |
wandb | wandb/sdk/internal/internal_api.py | .py | from __future__ import annotations
import base64
import datetime
import functools
import http.client
import json
import logging
import os
import re
import socket
import sys
import tempfile
from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence
from copy import deepcopy
from pathlib import Pa... | 3,819 | 133,198 |
scikit-bio | skbio/io/format/embed.py | .py | r"""Embedding format (:mod:`skbio.io.format.embed`).
====================================================
.. currentmodule:: skbio.io.format.embed
This module provides support for reading and writing embedding files that
are outputted by sequential language models such as protein language models
(pLMs).
Format Suppo... | 348 | 12,611 |
mlflow | dev/clint/src/clint/rules/unused_disable_comment.py | .py | from clint.rules.base import Rule
class UnusedDisableComment(Rule):
def __init__(self, rule_name: str) -> None:
self.rule_name = rule_name
def _message(self) -> str:
return f"Unused disable comment for rule `{self.rule_name}`"
| 10 | 254 |
saleor | saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_draft_order_updated.py | .py | import json
from unittest.mock import patch
import graphene
from django.test import override_settings
from ......core.models import EventDelivery
from ......graphql.webhook.subscription_query import SubscriptionQuery
from ......webhook.event_types import WebhookEventAsyncType
from .....manager import get_plugins_mana... | 234 | 7,076 |
saleor | saleor/graphql/meta/tests/conftest.py | .py | import pytest
PRIVATE_KEY = "private_key"
PRIVATE_VALUE = "private_vale"
PUBLIC_KEY = "key"
PUBLIC_VALUE = "value"
@pytest.fixture
def payment_with_public_metadata(payment):
payment.store_value_in_metadata({PUBLIC_KEY: PUBLIC_VALUE})
payment.save(update_fields=["metadata"])
return payment
@pytest.fixt... | 22 | 514 |
saleor | saleor/graphql/account/tests/mutations/customer_type/test_customer_type_reorder_attributes.py | .py | from unittest.mock import patch
import graphene
from ......account.error_codes import CustomerTypeReorderAttributesErrorCode
from ......attribute.models import AttributeCustomerType
from .....tests.utils import assert_no_permission, get_graphql_content
CUSTOMER_TYPE_REORDER_ATTRIBUTES_MUTATION = """
mutation Cus... | 230 | 7,051 |
astropy | astropy/coordinates/tests/accuracy/generate_spectralcoord_ref.py | .py | # Script to generate random targets, observatory locations, and times, and
# run these using the Starlink rv command to generate reference values for the
# velocity frame corrections. This requires that Starlink is installed and that
# the rv command is in your PATH. More information about Starlink can be found
# at ht... | 101 | 3,637 |
astropy | astropy/cosmology/_src/parameter/__init__.py | .py | """Cosmological Parameters. Private API."""
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from .converter import *
from .core import *
from .descriptors import *
from .utils import *
| 8 | 202 |
coremltools | coremltools/converters/mil/mil/ops/tests/coreml_dialect/__init__.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
| 5 | 216 |
coremltools | coremltools/test/sklearn_tests/test_random_forest_classifier.py | .py | # Copyright (c) 2017, 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 unittest
import numpy as np
from ..utils import load_boston
from coremltools._deps import _HAS_... | 165 | 6,285 |
saleor | saleor/graphql/account/tests/mutations/account/test_account_register.py | .py | from unittest.mock import ANY, patch
from urllib.parse import urlencode
import pytest
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from ......account import events as account_events
from ......account.models import User
from ......account.notifications ... | 612 | 18,977 |
probability | tensorflow_probability/python/distributions/probit_bernoulli.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... | 249 | 9,823 |
readthedocs.org | readthedocs/oauth/querysets.py | .py | """Managers for OAuth models."""
from django.db import models
from readthedocs.allauth.providers.githubapp.provider import GitHubAppProvider
from readthedocs.core.querysets import NoReprQuerySet
from readthedocs.oauth.constants import GITHUB
from readthedocs.oauth.constants import GITHUB_APP
def _has_account_connec... | 78 | 3,213 |
saleor | saleor/giftcard/tests/test_utils.py | .py | import datetime
import json
from unittest.mock import patch
import graphene
import pytest
from dateutil.relativedelta import relativedelta
from django.core.exceptions import ValidationError
from django.db.models import QuerySet
from django.utils import timezone
from freezegun import freeze_time
from ...checkout.error... | 1,165 | 36,620 |
hydra | tests/defaults_list/__init__.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any, List, Optional
from hydra._internal.config_repository import ConfigRepository, IConfigRepository
from hydra._internal.config_search_path_impl import ConfigSearchPathImpl
from hydra._internal.defaults_list import (
Defaul... | 64 | 2,208 |
pyro | tests/infer/reparam/test_stable.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from scipy.stats import ks_2samp
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.distributions.torch_distribution import MaskedDistributio... | 168 | 6,419 |
pynacl | tests/test_aead.py | .py | # Copyright 2016 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... | 250 | 8,275 |
mlflow | tests/entities/test_evaluation_dataset.py | .py | import json
from unittest.mock import Mock, patch
import pandas as pd
import pytest
from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan
from mlflow.entities.dataset_record import DatasetRecord
from mlflow.entities.dataset_record_source import DatasetRecordSourceType
from mlflow.entities.evaluation_da... | 747 | 23,993 |
openvino | samples/python/hello_reshape_ssd/hello_reshape_ssd.py | .py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
import os
import sys
import cv2
import numpy as np
import openvino as ov
def main():
log.basicConfig(format='[ %(levelname)s ] %(message)s', level=log.INFO, stre... | 120 | 4,468 |
wandb | wandb/sdk/launch/git_reference.py | .py | """Support for parsing GitHub URLs (which might be user provided) into constituent parts."""
from __future__ import annotations
import os
import re
from enum import IntEnum
from wandb.sdk.launch.errors import LaunchError
from wandb.sdk.lib.gitlib import GitCommandError, run_git
PREFIX_HTTPS = "https://"
GIT_COMMI... | 148 | 5,238 |
wandb | wandb/sdk/artifacts/_generated/artifact_type_artifact_collections.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 ArtifactCollectionFragment, PageInfoFragment
class ArtifactTypeArtifactCollections(GQLResult):
project: ArtifactT... | 48 | 1,561 |
pyomo | pyomo/core/tests/unit/test_list_objects.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... | 411 | 14,853 |
gunicorn | tests/test_asgi_keepalive_smuggling.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""End-to-end regression test for the keepalive smuggling guard.
Drives an ``ASGIProtocol`` against a fake transport with two pipelined
requests: the first POST advertises a Content-Length the client never
finishe... | 190 | 5,551 |
black | tests/data/cases/async_stmts.py | .py | async def func() -> (int):
return 0
@decorated
async def func() -> (int):
return 0
async for (item) in async_iter:
pass
# output
async def func() -> int:
return 0
@decorated
async def func() -> int:
return 0
async for item in async_iter:
pass
| 28 | 279 |
saleor | saleor/checkout/payment_utils.py | .py | """Checkout-related utility functions."""
from collections.abc import Iterable
from django.conf import settings
from django.db.models import Exists, Q
from prices import Money
from ..core.db.connection import allow_writer
from ..core.taxes import zero_money
from ..payment.models import TransactionItem
from . import ... | 136 | 5,113 |
kafka | tests/kafkatest/services/trogdor/degraded_network_fault_spec.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 ... | 49 | 2,160 |
pyomo | pyomo/core/tests/unit/test_reference.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... | 1,390 | 46,004 |
pyomo | pyomo/common/log.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... | 513 | 18,407 |
probability | tensorflow_probability/python/distributions/autoregressive.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... | 340 | 13,299 |
saleor | saleor/plugins/apps.py | .py | from typing import TYPE_CHECKING
from django.apps import AppConfig
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.module_loading import import_string
if TYPE_CHECKING:
from .base_plugin import BasePlugin
class PluginConfig(AppConfig):
name = "saleo... | 36 | 1,113 |
owasp-mstg | src/scripts/yaml_to_excel.py | .py | import yaml
from openpyxl import Workbook
from openpyxl.styles import Font
from openpyxl.drawing.image import Image
from openpyxl.styles import PatternFill
from enum import IntEnum
import combine_data_for_checklist
import excel_styles_and_validation as mas_styles
""" Tool for exporting the MASVS requirements as a c... | 347 | 13,561 |
astropy | astropy/timeseries/periodograms/lombscargle/tests/test_utils.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.timeseries.periodograms.lombscargle.core import LombScargle
from astropy.timeseries.periodograms.lombscargle.utils import (
compute_chi2_ref,
convert_normalization,
)
NORMALIZATIONS = ["standard", "model", "log", "psd"]
... | 46 | 1,372 |
hatch | tests/helpers/templates/wheel/standard_editable_exact.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 58 | 1,732 |
saleor | saleor/graphql/order/tests/mutations/test_order_grant_refund_create_line_reason.py | .py | from decimal import Decimal
import graphene
from .....page.models import Page, PageType
from ....core.utils import to_global_id_or_none
from ....tests.utils import get_graphql_content
from ...enums import (
OrderGrantRefundCreateErrorCode,
OrderGrantRefundCreateLineErrorCode,
)
ORDER_GRANT_REFUND_CREATE = ""... | 408 | 12,021 |
probability | tensorflow_probability/python/distributions/poisson_lognormal.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... | 448 | 17,920 |
hydra | plugins/hydra_joblib_launcher/hydra_plugins/hydra_joblib_launcher/config.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from typing import Optional
from hydra.core.config_store import ConfigStore
@dataclass
class JobLibLauncherConf:
_target_: str = "hydra_plugins.hydra_joblib_launcher.joblib_launcher.JoblibLauncher"
# max... | 55 | 1,659 |
mlflow | dev/flavors/src/flavors/_releases.py | .py | from __future__ import annotations
from datetime import datetime, timedelta, timezone
from pypi import Package
from flavors._schema import Version
RELEASE_CUTOFF_DAYS = 7
def get_released_versions(package: Package) -> list[Version]:
cutoff = datetime.now(tz=timezone.utc) - timedelta(days=RELEASE_CUTOFF_DAYS)
... | 22 | 663 |
wandb | tests/system_tests/test_functional/dspy/test_dspy.py | .py | from __future__ import annotations
import importlib
from collections.abc import Callable
from typing import Any
import pytest
@pytest.fixture
def run_and_snapshot(wandb_backend_spy):
"""Factory fixture to run a dspy example module and collect W&B snapshot.
Args:
wandb_backend_spy: Spy fixture for W... | 276 | 9,406 |
probability | tensorflow_probability/python/sts/components/autoregressive.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... | 419 | 17,654 |
saleor | saleor/graphql/tests/test_decorators.py | .py | import pytest
from ...permission.enums import (
AppPermission,
CheckoutPermissions,
OrderPermissions,
get_permissions_from_names,
)
from ...permission.models import Permission
from ...permission.utils import permission_required as core_permission_required
from ..utils import get_user_or_app_from_contex... | 94 | 2,924 |
onnxruntime | onnxruntime/python/tools/transformers/bert_perf_test.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# This tool measures the inference performance of onnxruntime on BERT-l... | 630 | 20,163 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.