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/proxito/tests/test_custom_path_prefixes.py | .py | from django.test.utils import override_settings
from readthedocs.projects.constants import (
MULTIPLE_VERSIONS_WITHOUT_TRANSLATIONS,
SINGLE_VERSION_WITHOUT_TRANSLATIONS,
)
from readthedocs.proxito.tests.base import BaseDocServing
@override_settings(
PYTHON_MEDIA=False,
PUBLIC_DOMAIN="readthedocs.io",... | 624 | 23,842 |
saleor | saleor/graphql/product/bulk_mutations/collection_bulk_delete.py | .py | import graphene
from django.conf import settings
from django.db.models import Exists, OuterRef
from ....discount.utils.promotion import mark_active_catalogue_promotion_rules_as_dirty
from ....permission.enums import ProductPermissions
from ....product import models
from ....product.models import ProductChannelListing
... | 64 | 2,613 |
clearml | examples/pipeline/step2_data_processing.py | .py | import pickle
from clearml import Task, StorageManager
from sklearn.model_selection import train_test_split
# Connecting ClearML with the current process,
# from here on everything is logged automatically
task = Task.init(project_name="examples", task_name="Pipeline step 2 process dataset")
# program arguments
# Use... | 57 | 1,806 |
saleor | saleor/attribute/models/customer.py | .py | from django.contrib.postgres.indexes import BTreeIndex
from django.db import models
from ...account.models import CustomerType, User
from ...core.models import SortableModel
from .base import AssociatedAttributeManager
class AssignedUserAttributeValue(SortableModel):
value = models.ForeignKey(
"Attribute... | 49 | 1,439 |
biopython | Tests/test_SearchIO_infernal_text_index.py | .py | # Copyright 2024 by Samuel Prince. 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 SearchIO In... | 529 | 37,778 |
coremltools | deps/pybind11/pybind11/__init__.py | .py | from __future__ import annotations
import sys
if sys.version_info < (3, 7): # noqa: UP036
msg = "pybind11 does not support Python < 3.7. v2.12 was the last release supporting Python 3.6."
raise ImportError(msg)
from ._version import __version__, version_info
from .commands import get_cmake_dir, get_include... | 20 | 459 |
probability | tensorflow_probability/python/internal/variadic_reduce.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... | 220 | 9,088 |
pyomo | pyomo/repn/tests/test_linear.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,802 | 67,584 |
textual | docs/examples/widgets/data_table_sort.py | .py | from rich.text import Text
from textual.app import App, ComposeResult
from textual.widgets import DataTable, Footer
ROWS = [
("lane", "swimmer", "country", "time 1", "time 2"),
(4, "Joseph Schooling", Text("Singapore", style="italic"), 50.39, 51.84),
(2, "Michael Phelps", Text("United States", style="ital... | 93 | 3,236 |
pyomo | scripts/get_pyomo_extras.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... | 37 | 1,187 |
mlflow | tests/gateway/providers/test_openai_uc_functions.py | .py | # TODO: ADD MORE TESTS
import json
from unittest import mock
import pytest
from fastapi.encoders import jsonable_encoder
from mlflow.gateway.config import EndpointConfig
from mlflow.gateway.providers.openai import OpenAIProvider
from mlflow.gateway.schemas import chat
from mlflow.gateway.uc_function_utils import (
... | 451 | 14,855 |
mlflow | mlflow/gateway/provider_registry.py | .py | import logging
from mlflow import MlflowException
from mlflow.gateway.config import Provider
from mlflow.gateway.providers import BaseProvider
from mlflow.utils.plugins import get_entry_points
from mlflow.utils.provider_filter import is_provider_allowed
_logger = logging.getLogger(__name__)
class ProviderRegistry:
... | 108 | 4,890 |
pyro | tests/contrib/epidemiology/test_distributions.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import math
import pytest
import torch
from torch.distributions.transforms import SigmoidTransform
import pyro.distributions as dist
from pyro.contrib.epidemiology import beta_binomial_dist, binomial_dist, infection_dist
from pyro.co... | 280 | 9,012 |
beam | sdks/python/apache_beam/io/requestresponse_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... | 313 | 10,630 |
beam | sdks/python/apache_beam/examples/inference/tensorflow_mnist_with_weights.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... | 94 | 3,646 |
openvino | tests/layer_tests/pytorch_tests/test_len.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
@pytest.mark.parametrize('input_tensor',
[
[2, 1, 3], [3, 7], [1, 1, 4, 4]
])
class TestLen(PytorchLayerTest):
def _prepare_i... | 75 | 2,136 |
mlflow | mlflow/models/evaluation/evaluators/default.py | .py | import logging
import os
import time
from typing import Optional
import numpy as np
import pandas as pd
import mlflow
from mlflow.entities.metric import Metric
from mlflow.exceptions import MlflowException
from mlflow.metrics import (
MetricValue,
ari_grade_level,
exact_match,
flesch_kincaid_grade_lev... | 237 | 8,493 |
kafka | tests/kafkatest/services/trogdor/no_op_task_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 ... | 36 | 1,435 |
astropy | astropy/samp/utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Utility functions and classes.
"""
import inspect
import queue
import traceback
import xmlrpc.client as xmlrpc
from io import StringIO
from urllib.request import urlopen
from .constants import SAMP_STATUS_ERROR
from .errors import SAMPProxyError
de... | 218 | 6,660 |
saleor | saleor/warehouse/webhooks/payloads.py | .py | from collections.abc import Iterable
from typing import TYPE_CHECKING, Optional
import graphene
from ...core.db.connection import allow_writer
from ...webhook import traced_payload_generator
from ...webhook.payload_helpers import generate_meta, generate_requestor
from ...webhook.payload_serializers import PayloadSeri... | 36 | 1,277 |
saleor | saleor/graphql/payment/tests/mutations/test_transaction_create.py | .py | from decimal import Decimal
from unittest.mock import patch
import graphene
import pytest
from freezegun import freeze_time
from .....checkout import CheckoutAuthorizeStatus, CheckoutChargeStatus
from .....checkout.calculations import fetch_checkout_data
from .....checkout.complete_checkout import create_order_from_c... | 2,894 | 94,834 |
beam | sdks/python/apache_beam/internal/test_data/module_3_modified.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 | 999 |
luigi | luigi/interface.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... | 211 | 8,864 |
voila | voila/tornado/kernel_websocket_handler.py | .py | import json
from typing import Any, Dict, Optional, Union
try:
from jupyter_server.services.kernels.websocket import (
KernelWebsocketHandler as WebsocketHandler,
)
except ImportError:
from jupyter_server.services.kernels.handlers import (
ZMQChannelsHandler as WebsocketHandler,
)
def... | 44 | 1,338 |
hatch | backend/src/hatchling/version/scheme/standard.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal, cast
from hatchling.version.scheme.plugin.interface import VersionSchemeInterface
if TYPE_CHECKING:
from packaging.version import Version
class StandardScheme(VersionSchemeInterface):
"""
See https://peps.python.org/pep-... | 112 | 4,420 |
onnx | onnx/reference/ops/op_asin.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 Asin(OpRunUnaryNum):
def _run(self, x):
return (np.arcsin(x),)
| 14 | 269 |
onnx | onnx/backend/test/case/node/dynamicquantizelinear.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 DynamicQuantizeLinear(Base):
@staticmethod
def export() -> Non... | 71 | 2,477 |
pyomo | pyomo/core/base/component_order.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... | 30 | 1,256 |
beam | sdks/python/apache_beam/metrics/metric_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... | 326 | 11,857 |
beam | sdks/python/apache_beam/ml/inference/anthropic_inference_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... | 352 | 12,060 |
bazel | src/test/py/bazel/action_temp_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... | 267 | 9,622 |
python-prompt-toolkit | src/prompt_toolkit/clipboard/__init__.py | .py | from __future__ import annotations
from .base import Clipboard, ClipboardData, DummyClipboard, DynamicClipboard
from .in_memory import InMemoryClipboard
# We are not importing `PyperclipClipboard` here, because it would require the
# `pyperclip` module to be present.
# from .pyperclip import PyperclipClipboard
__al... | 18 | 439 |
hypercorn | src/hypercorn/middleware/http_to_https.py | .py | from __future__ import annotations
from collections.abc import Callable
from urllib.parse import urlunsplit
from ..typing import ASGIFramework, HTTPScope, Scope, WebsocketScope, WWWScope
class HTTPToHTTPSRedirectMiddleware:
def __init__(self, app: ASGIFramework, host: str | None) -> None:
self.app = app... | 68 | 2,615 |
toolz | toolz/tests/test_tlz.py | .py | import toolz
def test_tlz():
import tlz
tlz.curry
tlz.functoolz.curry
assert tlz.__package__ == 'tlz'
assert tlz.__name__ == 'tlz'
import tlz.curried
assert tlz.curried.__package__ == 'tlz.curried'
assert tlz.curried.__name__ == 'tlz.curried'
tlz.curried.curry
import tlz.currie... | 58 | 1,593 |
lemur | lemur/users/service.py | .py | """
.. module: lemur.users.service
:platform: Unix
:synopsis: This module contains all of the services level functions used to
administer users in Lemur
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisso... | 174 | 4,805 |
scikit-bio | skbio/_config.py | .py | r"""Configuration Options
=====================
.. currentmodule:: skbio
This module provides a configuration system that controls the global behavior of all
scikit-bio functionalities.
Functions
---------
.. autosummary::
:toctree: generated/
get_config
set_config
Configuration options
----------------... | 148 | 3,931 |
wandb | wandb/sdk/artifacts/_generated/project_artifact_types.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 ArtifactTypeFragment, PageInfoFragment
class ProjectArtifactTypes(GQLResult):
project: ProjectArtifactTypesProjec... | 36 | 971 |
saleor | saleor/discount/tests/fixtures/promotion.py | .py | import datetime
from decimal import Decimal
import graphene
import pytest
from django.utils import timezone
from ....product.utils.variants import fetch_variants_for_promotion_rules
from ....tests.utils import dummy_editorjs
from ... import PromotionType, RewardType, RewardValueType
from ...models import Promotion, P... | 336 | 11,641 |
saleor | saleor/tests/e2e/orders/test_order_keep_address_information.py | .py | import pytest
from .. import ADDRESS_DE, DEFAULT_ADDRESS
from ..account.utils import account_address_delete, 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
f... | 132 | 4,148 |
ipython | tests/test_qt_loaders.py | .py | import importlib
import pytest
from IPython.external.qt_loaders import ID
def test_import_denier():
ID.forbid("ipython_denied_module")
with pytest.raises(ImportError, match="disabled by IPython"):
import ipython_denied_module
with pytest.raises(ImportError, match="disabled by IPython"):
im... | 12 | 367 |
beam | sdks/python/apache_beam/io/gcp/bigquery_file_loads.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... | 1,409 | 55,078 |
beam | sdks/python/apache_beam/ml/transforms/embeddings/huggingface_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... | 384 | 13,773 |
astropy | astropy/utils/tests/test_diff.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Some might be indirectly tested already in ``astropy.io.fits.tests``.
"""
import io
import numpy as np
import pytest
from astropy.table import Table
from astropy.utils.diff import diff_values, report_diff_values, where_not_allclose
@pytest.mark.pa... | 188 | 5,154 |
clearml | examples/reporting/using_artifacts_example.py | .py | # Using artifacts example
"""
Upload artifacts from a Task, and then a different Task can access and utilize the data from that artifact.
"""
from clearml import Task
from time import sleep
task1 = Task.init(project_name='examples', task_name='Create artifact')
# upload data file to the initialized task, inputting a n... | 31 | 1,368 |
loguru | tests/exceptions/source/others/catch_as_function.py | .py | import sys
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="", diagnose=False, backtrace=False, colorize=False)
def a():
1 / 0
a = logger.catch()(a)
a()
| 15 | 187 |
biopython | Bio/PDB/Superimposer.py | .py | # Copyright (C) 2002, Thomas Hamelryck (thamelry@binf.ku.dk)
#
# 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.
"""Superimpose two s... | 57 | 1,943 |
jupyterlab | jupyterlab/tests/echo_kernel.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import logging
from ipykernel.kernelapp import IPKernelApp
from ipykernel.kernelbase import Kernel
class EchoKernel(Kernel):
implementation = "Echo"
implementation_version = "1.0"
language = "echo"
l... | 54 | 1,555 |
onnxruntime | tools/python/run_packaging_pipelines.py | .py | # See PythonTools.md in this folder
import argparse
import json
import subprocess
import sys
from concurrent.futures import ThreadPoolExecutor, as_completed
from datetime import datetime, timedelta
from typing import Literal, TypedDict
from urllib.parse import urlparse
import requests
import yaml
# --- Data Structur... | 506 | 21,687 |
pyro | tests/distributions/conftest.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
from math import pi
import numpy as np
import pytest
import scipy.stats as sp
import pyro.distributions as dist
from pyro.distributions.testing.naive_dirichlet import NaiveBeta, NaiveDirichlet
from pyro.distributions.... | 1,082 | 35,808 |
saleor | saleor/graphql/page/tests/queries/test_pages.py | .py | import graphene
import pytest
from django.utils import timezone
from freezegun import freeze_time
from .....page.models import Page
from .....tests.utils import dummy_editorjs
from ....tests.utils import get_graphql_content
QUERY_PAGES_WITH_FILTER = """
query ($filter: PageFilterInput) {
pages(first: 5, f... | 454 | 12,589 |
sphinx | sphinx/builders/html/_assets.py | .py | from __future__ import annotations
import os
import zlib
from functools import cache
from typing import TYPE_CHECKING
from sphinx.errors import ThemeError
if TYPE_CHECKING:
from pathlib import Path
from typing import Any, NoReturn
class _CascadingStyleSheet:
filename: str | os.PathLike[str]
priorit... | 136 | 4,141 |
returns | returns/interfaces/specific/reader.py | .py | """
This module is special.
``Reader`` does not produce ``ReaderLikeN`` interface as other containers.
Because ``Reader`` can be used with two or three type arguments:
- ``RequiresContext[value, env]``
- ``RequiresContextResult[value, error, env]``
Because the second type argument changes its meaning
based on the us... | 263 | 7,669 |
django-cms | cms/templatetags/cms_admin.py | .py | import django
from classytags.arguments import Argument
from classytags.core import Options, Tag
from classytags.helpers import AsTag, InclusionTag
from django import template
from django.conf import settings
from django.contrib import admin
from django.contrib.admin.helpers import Fieldset
from django.contrib.admin.op... | 351 | 12,721 |
beam | sdks/python/apache_beam/runners/direct/clock.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... | 54 | 1,619 |
metrics | src/torchmetrics/functional/clustering/davies_bouldin_score.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... | 67 | 2,595 |
hypercorn | tests/middleware/test_http_to_https.py | .py | from __future__ import annotations
import pytest
from hypercorn.middleware import HTTPToHTTPSRedirectMiddleware
from hypercorn.typing import ConnectionState, HTTPScope, WebsocketScope
from ..helpers import empty_framework
@pytest.mark.asyncio
@pytest.mark.parametrize("raw_path", [b"/abc", b"/abc%3C"])
async def tes... | 172 | 4,811 |
openvino | src/bindings/python/tests/test_graph/test_loop.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import numpy as np
import openvino.opset8 as ov
from openvino import Model, Shape
from openvino.op.util import (
InvariantInputDescription,
BodyOutputDescription,
SliceInputDescription,
... | 278 | 10,056 |
probability | tensorflow_probability/python/optimizer/convergence_criteria/successive_gradients_are_uncorrelated.py | .py | # Copyright 2019 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 111 | 4,849 |
saleor | saleor/graphql/account/tests/queries/test_user_customer_type.py | .py | import graphene
from ....tests.utils import assert_no_permission, get_graphql_content
USER_CUSTOMER_TYPE_QUERY = """
query User($id: ID!) {
user(id: $id) {
id
customerType {
id
name
slug
isDefault
}
... | 98 | 3,023 |
probability | tensorflow_probability/python/math/psd_kernels/positive_semidefinite_kernel.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... | 1,481 | 57,724 |
coremltools | coremltools/converters/mil/mil/ops/defs/iOS18/transformers.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 numpy as np
from coremltools.converters.mil.mil import types
from coremltools.converters.mil.... | 167 | 6,653 |
wandb | wandb/sdk/artifacts/storage_handler.py | .py | """Storage handler."""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Final
from wandb.sdk.lib.paths import FilePathStr, URIStr
if TYPE_CHECKING:
from urllib.parse import ParseResult
from wandb.sdk.artifacts.artifact import Artifact
from wandb.s... | 69 | 2,045 |
kafka | committer-tools/kafka-merge-pr.py | .py | #!/usr/bin/env python
#
# 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 "Li... | 484 | 19,696 |
coremltools | coremltools/optimize/torch/optimization_config.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 re as _re
from collections import OrderedDict as _OrderedDict
from enum import Enum as _Enum
f... | 198 | 7,446 |
saleor | saleor/tests/test_cache_key_warning.py | .py | import warnings
from django.core.cache import CacheKeyWarning, cache
def test_ignore_cache_key_warning():
key_over_250_characters = 300 * "x"
# Ensure all warnings are errors
warnings.simplefilter("error")
# Ignore CacheKeyWarning
warnings.filterwarnings("ignore", category=CacheKeyWarning)
... | 17 | 405 |
probability | tensorflow_probability/python/distributions/hidden_markov_model_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... | 2,117 | 92,826 |
pyomo | pyomo/contrib/mpc/data/tests/test_interval_data.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... | 353 | 14,401 |
beam | sdks/python/apache_beam/ml/rag/embeddings/vertex_ai.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... | 197 | 7,094 |
scikit-optimize | examples/bayesian-optimization.py | .py | """
==================================
Bayesian optimization with `skopt`
==================================
Gilles Louppe, Manoj Kumar July 2016.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
Problem statement
-----------------
We are interested in solving
.. math::
x^* = arg \min_x f(x)
und... | 214 | 7,424 |
wagtail | wagtail/tests/test_locale_model.py | .py | from django.conf import settings
from django.test import TestCase, override_settings
from django.utils import translation
from django.utils.translation import gettext_lazy as _
from wagtail.models import Locale
from wagtail.test.i18n.models import TestPage
from wagtail.test.utils import Page
def make_test_page(**kwa... | 170 | 6,880 |
ipython | tests/test_display_trap.py | .py | """Tests for IPython.core.display_trap."""
import sys
import pytest
from IPython.core.display_trap import DisplayTrap
def _custom_hook(value):
pass
def test_display_trap_sets_displayhook():
original_hook = sys.displayhook
trap = DisplayTrap(hook=_custom_hook)
with trap:
assert sys.display... | 73 | 1,897 |
metrics | tests/unittests/pairwise/test_pairwise_distance.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 | 5,523 |
openvino | tests/fuzz/scripts/init_corpus.py | .py | #!/usr/bin/env python3
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# Sample usage:
# ./scripts/init_corpus.py ./paddle_layer_models/**/*.pdmodel --join pdiparams
# mkdir -p corpus && find ./paddle_layer_models/ -name "*.fuzz" -exec cp \{\} .//import_paddle-corpus \;
import ar... | 57 | 1,918 |
saleor | saleor/graphql/payment/mutations/transaction/shared.py | .py | from typing import Annotated
import graphene
from django.core.exceptions import ValidationError
from pydantic import BaseModel, ConfigDict, StringConstraints
from pydantic import ValidationError as PydanticValidationError
from .....payment import PaymentMethodType
from .....payment.error_codes import (
Transactio... | 316 | 10,882 |
wagtail | wagtail/embeds/forms.py | .py | from django import forms
from django.core.validators import URLValidator
from django.utils.translation import gettext_lazy as _
class EmbedForm(forms.Form):
url = forms.CharField(
label=_("URL"), validators=[URLValidator(message=_("Please enter a valid URL"))]
)
| 10 | 281 |
wagtail | wagtail/admin/forms/collections.py | .py | from itertools import groupby
from django import forms
from django.conf import settings
from django.contrib.auth.models import Group, Permission
from django.core.exceptions import ValidationError
from django.db import transaction
from django.db.models import Min
from django.template.loader import render_to_string
from... | 378 | 13,689 |
readthedocs.org | readthedocs/core/unresolver.py | .py | import re
from dataclasses import dataclass
from enum import Enum
from enum import auto
from urllib.parse import ParseResult
from urllib.parse import urlparse
import structlog
from django.conf import settings
from django.db.models.functions import Length
from readthedocs.builds.constants import EXTERNAL
from readthed... | 667 | 24,432 |
astropy | astropy/utils/parsing.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Wrappers for PLY to provide thread safety.
"""
import contextlib
import functools
import re
import threading
from collections.abc import Generator
from pathlib import Path
from types import ModuleType
from astropy.extern.ply.lex import Lexer
from ast... | 146 | 4,843 |
saleor | saleor/graphql/account/tests/mutations/authentication/test_token_create.py | .py | import datetime
from unittest.mock import patch
import graphene
from django.urls import reverse
from freezegun import freeze_time
from ......account.error_codes import AccountErrorCode
from ......account.throttling import (
get_cache_key_blocked_ip,
get_cache_key_failed_ip,
get_cache_key_failed_ip_with_us... | 621 | 21,453 |
python-prompt-toolkit | examples/prompts/history/slow-history.py | .py | #!/usr/bin/env python
"""
Simple example of a custom, very slow history, that is loaded asynchronously.
By wrapping it in `ThreadedHistory`, the history will load in the background
without blocking any user interaction.
"""
import time
from prompt_toolkit import PromptSession
from prompt_toolkit.history import Histo... | 50 | 1,367 |
onnxruntime | onnxruntime/test/python/quantization/test_qdq_block_size.py | .py | #!/usr/bin/env python
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# ---------------------------------------------------------------... | 269 | 11,602 |
tqdm | benchmarks/benchmarks.py | .py | # Write the benchmarking functions here.
# See "Writing benchmarks" in the asv docs for more information.
from functools import partial
class Comparison:
"""Running time of wrapped empty loops"""
def __init__(self, length):
try:
from time import process_time
self.time = process... | 90 | 2,380 |
sphinx | tests/test_config/test_config.py | .py | """Test the sphinx.config.Config class."""
from __future__ import annotations
import pickle
from collections import Counter
from typing import TYPE_CHECKING, Any
from unittest import mock
import pytest
import sphinx
from sphinx.config import (
ENUM,
Config,
check_confval_types,
is_serializable,
)
fr... | 811 | 25,757 |
pyomo | examples/pyomobook/abstract-ch/postprocess_fn.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... | 47 | 1,625 |
saleor | saleor/graphql/product/mutations/product_variant/product_variant_create.py | .py | import graphene
from django.core.exceptions import ValidationError
from .....attribute import models as attribute_models
from .....core.tracing import traced_atomic_transaction
from .....discount.utils.promotion import mark_active_catalogue_promotion_rules_as_dirty
from .....permission.enums import ProductPermissions
... | 276 | 10,638 |
beam | learning/katas/python/Core Transforms/Combine/Combine PerKey/task.py | .py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); y... | 43 | 1,408 |
pyro | tests/infer/test_resampler.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import functools
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro.infer.resampler import Resampler
from tests.common import assert_close
@pytest.mark.parametrize("stable", [False, True])
def test_r... | 44 | 1,321 |
pyomo | pyomo/solvers/tests/models/MILP_unbounded.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... | 73 | 2,437 |
sqlmap | plugins/dbms/cubrid/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):... | 33 | 917 |
pyomo | pyomo/contrib/solver/solvers/knitro/typing.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... | 70 | 1,780 |
sqlmap | tamper/overlongutf8more.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import string
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.LOWEST
def dependencies():
pass
def tamper(payload, **kwargs):
"""
Converts all character... | 49 | 1,745 |
cvxpy | cvxpy/atoms/length.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
... | 85 | 2,358 |
textual | tests/snapshot_tests/snapshot_apps/auto-table.py | .py | from textual.app import App
from textual.containers import Container, Horizontal, ScrollableContainer, Vertical
from textual.screen import Screen
from textual.widgets import DataTable, Header, Label
class LabeledBox(Container):
DEFAULT_CSS = """
LabeledBox {
layers: base_ top_;
width: 100%;
... | 188 | 3,818 |
onnxruntime | onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/ModuleState.py | .py | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: fbs
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class ModuleState(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flat... | 142 | 4,853 |
pyro | pyro/contrib/cevae/__init__.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
This module implements the Causal Effect Variational Autoencoder [1], which
demonstrates a number of innovations including:
- a generative model for causal effect inference with hidden confounders;
- a model and guide with twi... | 663 | 23,080 |
mlflow | tests/genai/utils/test_trace_utils.py | .py | import asyncio
import json
from collections import OrderedDict
from typing import Any
from unittest import mock
import httpx
import numpy as np
import openai
import pandas as pd
import pytest
from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan
import mlflow
from mlflow.entities.assessment import Expe... | 1,754 | 58,625 |
mlflow | examples/mlflow-3/load_model_from_runs_uri.py | .py | from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
import mlflow
from mlflow.models import infer_signature
X, y = load_iris(return_X_y=True, as_frame=True)
model = LogisticRegression().fit(X, y)
signature = infer_signature(X, model.predict(X))
with mlflow.start_run() as run:
... | 16 | 519 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Expm1.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
rng = np.random.default_rng(345345)
class TestExpm1(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
... | 39 | 1,409 |
probability | tensorflow_probability/python/bijectors/absolute_value.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... | 117 | 3,664 |
astropy | astropy/modeling/tests/test_constraints.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# pylint: disable=invalid-name
import platform
import types
import warnings
from contextlib import nullcontext
import numpy as np
import pytest
from numpy.random import default_rng
from numpy.testing import assert_allclose
from astropy.modeling import f... | 675 | 24,145 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.