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 |
|---|---|---|---|---|---|
openvino | tests/layer_tests/tensorflow_tests/test_tf_StaticRegexReplace.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 TestStaticRegexReplace(CommonTFLaye... | 49 | 2,171 |
readthedocs.org | readthedocs/rtd_tests/tests/test_api_permissions.py | .py | from functools import partial
from unittest import TestCase
from unittest.mock import Mock
from readthedocs.api.v2.permissions import ReadOnlyPermission
class APIRestrictedPermissionTests(TestCase):
def get_request(self, method, is_admin):
request = Mock()
request.method = method
request... | 71 | 2,337 |
wandb | wandb/sync/sync.py | .py | """sync."""
from __future__ import annotations
import atexit
import datetime
import fnmatch
import os
import queue
import sys
import tempfile
import threading
import time
from urllib.parse import quote as url_quote
import wandb
from wandb.proto import wandb_internal_pb2 # type: ignore
from wandb.sdk.interface.inter... | 454 | 15,979 |
mlflow | tests/pyfunc/test_pyfunc_schema_enforcement.py | .py | import base64
import datetime
import decimal
import json
import os
import re
from unittest import mock
import cloudpickle
import numpy as np
import pandas as pd
import pytest
import sklearn.linear_model
from packaging.version import Version
import mlflow
import mlflow.pyfunc.scoring_server as pyfunc_scoring_server
fr... | 3,084 | 119,325 |
onnxruntime | onnxruntime/test/python/quantization/test_op_pad.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.
# ---------------------------------------------------------------... | 688 | 28,908 |
textual | tests/snapshot_tests/snapshot_apps/missing_vertical_scroll.py | .py | from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import OptionList
class MissingScrollbarApp(App[None]):
CSS = """
OptionList {
height: 1fr;
}
#left {
min-width: 25;
}
#middle {
width: 5fr;
}
#right {
... | 35 | 685 |
mkdocs-material | material/plugins/social/plugin.py | .py | # Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, c... | 1,128 | 46,725 |
sqlmap | lib/utils/bcrypt.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import struct
from lib.core.compat import xrange
from lib.core.convert import getBytes
# bcrypt (Provos-Mazieres EksBlowfish); the Blowfish P/S init constants are the fractional... | 147 | 4,575 |
wagtail | wagtail/management/commands/fixtree.py | .py | import functools
import operator
import swapper
from django.core.management.base import BaseCommand
from django.db import models
from django.db.models import Q
from wagtail.models import Collection
Page = swapper.load_model("wagtailcore", "Page")
class Command(BaseCommand):
help = "Checks for data integrity er... | 169 | 6,826 |
wagtail | wagtail/contrib/typed_table_block/blocks.py | .py | from django import forms
from django.core.exceptions import ValidationError
from django.forms.utils import ErrorList
from django.template.loader import render_to_string
from django.utils.functional import cached_property
from django.utils.translation import gettext as _
from wagtail.admin.staticfiles import versioned_... | 442 | 15,278 |
saleor | saleor/graphql/order/tests/mutations/test_fulfillment_return_products.py | .py | from decimal import Decimal
from unittest import mock
from unittest.mock import ANY, patch
import graphene
from prices import Money, TaxedMoney
from .....core.prices import quantize_price
from .....order import FulfillmentLineData, OrderOrigin, OrderStatus
from .....order.error_codes import OrderErrorCode
from .....o... | 1,245 | 44,834 |
wandb | tests/fixtures/wandb_backend_spy/__init__.py | .py | """Defines a proxy server that spies on requests to the W&B backend."""
__all__ = (
"spy_proxy",
"WandbBackendProxy",
"WandbBackendSpy",
)
from .proxy import WandbBackendProxy, spy_proxy
from .spy import WandbBackendSpy
| 11 | 234 |
onnx | tests/python/compose_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING
import numpy as np
import pytest
from onnx import (
FunctionProto,
GraphProto,
ModelProto,
NodeProto,
SparseTensorProto,
TensorProto,
ValueI... | 1,123 | 40,331 |
sphinx | tests/roots/test-ext-apidoc-toc/mypackage/main.py | .py | from pathlib import Path
import mod_resource
import mod_something
if __name__ == '__main__':
print(f'Hello, world! -> something returns: {mod_something.something()}')
res_path = Path(mod_resource.__file__).parent / 'resource.txt'
text = res_path.read_text(encoding='utf-8')
print(f'From mod_resource:r... | 12 | 344 |
mlflow | mlflow/demo/generators/issues.py | .py | from __future__ import annotations
import logging
from typing import Any
import mlflow
from mlflow import MlflowClient
from mlflow.demo.base import (
DEMO_EXPERIMENT_NAME,
BaseDemoGenerator,
DemoFeature,
DemoResult,
)
from mlflow.demo.data import ASSESSMENT_TO_ISSUE, ROOT_CAUSE_EXPLANATIONS
from mlflo... | 233 | 9,592 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/django_app/asgi.py | .py | """
ASGI config for Django compatibility testing.
"""
import os
import time
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
import django
django.setup()
from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application
from routing import websocket_urlpatterns
... | 61 | 1,754 |
python-prompt-toolkit | src/prompt_toolkit/layout/margins.py | .py | """
Margin implementations for a :class:`~prompt_toolkit.layout.containers.Window`.
"""
from __future__ import annotations
from abc import ABCMeta, abstractmethod
from collections.abc import Callable
from typing import TYPE_CHECKING
from prompt_toolkit.filters import FilterOrBool, to_filter
from prompt_toolkit.forma... | 306 | 10,402 |
eve | eve/methods/common.py | .py | # -*- coding: utf-8 -*-
"""
eve.methods.common
~~~~~~~~~~~~~~~~~~
Utility functions for API methods implementations.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
import base64
import re
import time
from collections import Counter
from copy import copy
f... | 1,535 | 57,271 |
mkdocs-material | material/plugins/offline/config.py | .py | # Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, c... | 31 | 1,483 |
pyro | tests/test_util.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import warnings
import pytest
import torch
from pyro import util
pytestmark = pytest.mark.stage("unit")
def test_warn_if_nan():
# scalar case
with warnings.catch_warnings(record=True) as w:
warnings.simplefilte... | 106 | 3,150 |
sphinx | sphinx/ext/apidoc/_extension.py | .py | """Sphinx extension for auto-generating API documentation."""
from __future__ import annotations
import fnmatch
import re
from pathlib import Path
from typing import TYPE_CHECKING
from sphinx._cli.util.colour import bold
from sphinx.ext.apidoc._generate import create_modules_toc_file, recurse_tree
from sphinx.ext.ap... | 264 | 7,537 |
saleor | saleor/graphql/page/tests/queries/pages_with_where/test_with_where_attributes_datetime.py | .py | import datetime
import pytest
from ......attribute import AttributeInputType, AttributeType
from ......attribute.models import Attribute
from ......attribute.utils import associate_attribute_values_to_instance
from .....tests.utils import get_graphql_content
from .shared import QUERY_PAGES_WITH_WHERE
@pytest.mark.p... | 127 | 3,957 |
astropy | astropy/coordinates/matching.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains functions for matching coordinate catalogs.
"""
from typing import NamedTuple
import numpy as np
from numpy.typing import NDArray
from astropy.units import Quantity
from . import Angle
from .representation import UnitSpherical... | 493 | 19,913 |
biopython | Scripts/GenBank/check_output_simple.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.
"""Display the SeqFeatures produced by the parser.
This produces a ton of... | 57 | 1,669 |
python-prompt-toolkit | src/prompt_toolkit/mouse_events.py | .py | """
Mouse events.
How it works
------------
The renderer has a 2 dimensional grid of mouse event handlers.
(`prompt_toolkit.layout.MouseHandlers`.) When the layout is rendered, the
`Window` class will make sure that this grid will also be filled with
callbacks. For vt100 terminals, mouse events are received through ... | 86 | 2,473 |
astropy | astropy/timeseries/periodograms/lombscargle/tests/test_statistics.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
import astropy.units as u
from astropy.timeseries.periodograms.lombscargle import LombScargle
from astropy.timeseries.periodograms.lombscargle._statistics import (
METHODS,
fap_single,
inv_fap_single,
)
from astropy.timeseries.perio... | 208 | 7,135 |
saleor | saleor/graphql/page/filters.py | .py | import django_filters
import graphene
from django.db.models import Exists, OuterRef, Q, QuerySet
from ...attribute.models import (
AssignedPageAttributeValue,
AttributePage,
AttributeValue,
)
from ...page import models
from ..attribute.shared_filters import (
AssignedAttributeWhereInput,
filter_obj... | 169 | 5,022 |
wagtail | wagtail/documents/tests/test_models.py | .py | from django.conf import settings
from django.contrib.auth.models import Group, Permission
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.core.files.base import ContentFile
from django.db import transaction
from django.test import TestCase, TransactionTestCase, tag
from django.test.... | 322 | 13,075 |
biopython | Bio/SearchIO/BlastIO/__init__.py | .py | # Copyright 2012 by Wibowo Arindrarto. 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.
"""Bio.SearchIO supp... | 339 | 17,923 |
probability | tensorflow_probability/python/experimental/util/trainable_test.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... | 366 | 15,651 |
eve | tests/test_settings.py | .py | # -*- coding: utf-8 -*-
import copy
MONGO_HOST = "localhost"
MONGO_PORT = 27017
MONGO_USERNAME = MONGO1_USERNAME = "test_user"
MONGO_PASSWORD = MONGO1_PASSWORD = "test_pw"
MONGO_DBNAME, MONGO1_DBNAME = "eve_test", "eve_test1"
ID_FIELD = "_id"
RESOURCE_METHODS = ["GET", "POST", "DELETE"]
ITEM_METHODS = ["GET", "PATCH"... | 443 | 14,190 |
wagtail | wagtail/contrib/frontend_cache/backends/cloudflare.py | .py | import logging
import requests
from django.core.exceptions import ImproperlyConfigured
from .base import BaseBackend
logger = logging.getLogger("wagtail.frontendcache")
__all__ = ["CloudflareBackend"]
class CloudflareBackend(BaseBackend):
CHUNK_SIZE = 30
def __init__(self, params):
super().__ini... | 111 | 3,661 |
mlflow | mlflow/pyfunc/__init__.py | .py | """
The ``python_function`` model flavor serves as a default model interface for MLflow Python models.
Any MLflow Python model is expected to be loadable as a ``python_function`` model.
In addition, the ``mlflow.pyfunc`` module defines a generic :ref:`filesystem format
<pyfunc-filesystem-format>` for Python models and... | 3,997 | 170,947 |
astropy | astropy/modeling/tests/test_bounding_box.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import unittest.mock as mk
import numpy as np
import pytest
import astropy.units as u
from astropy.coordinates import SpectralCoord
from astropy.modeling.bounding_box import (
CompoundBoundingBox,
ModelBoundingBox,
_BaseInterval,
_BaseSel... | 2,939 | 114,325 |
mlflow | tests/llama_index/test_llama_index_autolog.py | .py | from importlib import metadata
from unittest import mock
import pytest
from llama_index.core.chat_engine.types import ChatMode
from llama_index.core.instrumentation import get_dispatcher
from llama_index.core.instrumentation.event_handlers.base import BaseEventHandler
from llama_index.core.instrumentation.span_handler... | 388 | 12,937 |
jupytext | demo/vscode/notebook.py | .py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.18.0-dev
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %% [markdown]
... | 41 | 904 |
mlflow | tests/tracing/utils/test_config.py | .py | import pytest
import mlflow
from mlflow.tracing.config import TracingConfig, get_config
@pytest.fixture(autouse=True)
def reset_tracing_config():
mlflow.tracing.reset()
def test_tracing_config_default_values():
config = TracingConfig()
assert config.span_processors == []
def test_configure():
# D... | 115 | 3,089 |
textual | src/textual/drivers/_input_reader.py | .py | import sys
__all__ = ["InputReader"]
WINDOWS = sys.platform == "win32"
if WINDOWS:
from textual.drivers._input_reader_windows import InputReader
else:
from textual.drivers._input_reader_linux import InputReader
| 11 | 222 |
clearml | examples/frameworks/fire/fire_typing.py | .py | from typing import Tuple, List
from clearml import Task
import fire
def with_ret() -> Tuple:
print("With ret called")
return 1, 2
def with_args(arg1: int, arg2: List):
print("With args called", arg1, arg2)
def with_args_and_ret(arg1: int, arg2: List) -> Tuple:
print("With args and ret called", arg... | 23 | 462 |
scikit-bio | skbio/io/format/stockholm.py | .py | """Stockholm format (:mod:`skbio.io.format.stockholm`)
===================================================
.. currentmodule:: skbio.io.format.stockholm
The Stockholm format is a multiple sequence alignment format (MSA) that
optionally supports storing arbitrary alignment features (metadata). Features
can be placed in... | 818 | 29,028 |
beam | learning/tour-of-beam/learning-content/final-challenge/final-challenge-1/python-solution/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... | 100 | 4,185 |
textual | src/textual/css/parse.py | .py | from __future__ import annotations
import dataclasses
import re
from functools import lru_cache
from typing import Iterable, Iterator, NoReturn
from textual.css._help_renderables import HelpText
from textual.css._styles_builder import DeclarationError, StylesBuilder
from textual.css.errors import UnresolvedVariableEr... | 489 | 17,000 |
hatch | src/hatch/cli/python/__init__.py | .py | import click
from hatch.cli.python.find import find
from hatch.cli.python.install import install
from hatch.cli.python.remove import remove
from hatch.cli.python.show import show
from hatch.cli.python.update import update
@click.group(short_help="Manage Python installations")
def python():
pass
python.add_comm... | 20 | 437 |
hatch | backend/src/hatchling/version/scheme/plugin/hooks.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from hatchling.plugin import hookimpl
from hatchling.version.scheme.standard import StandardScheme
if TYPE_CHECKING:
from hatchling.version.scheme.plugin.interface import VersionSchemeInterface
@hookimpl
def hatch_register_version_scheme() -> ... | 15 | 376 |
qutip | qutip/tests/core/test_brtools.py | .py | import pytest
import qutip
import numpy as np
from qutip.core._brtools import matmul_var_data, _EigenBasisTransform
from qutip.core.blochredfield import brterm, bloch_redfield_tensor, brcrossterm
from qutip.core._brtensor import (
_br_term_dense, _br_term_sparse, _br_term_data,
_br_cterm_dense, _br_cterm_sparse... | 414 | 14,166 |
astropy | astropy/cosmology/_src/tests/test_scipy_compat.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
from astropy.cosmology._src.flrw.base import quad
from astropy.utils.compat.optional_deps import HAS_SCIPY
@pytest.mark.skipif(HAS_SCIPY, reason="scipy is installed")
def test_optional_deps_functions():
"""Test stand-in functions when... | 14 | 464 |
mlflow | dev/clint/src/clint/index.py | .py | """Symbol indexing for MLflow codebase.
This module provides efficient indexing and lookup of Python symbols (functions, classes)
across the MLflow codebase using AST parsing and parallel processing.
Key components:
- FunctionInfo: Lightweight function signature information
- ModuleSymbolExtractor: AST visitor for ex... | 222 | 7,936 |
onnx | onnx/model_container.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
"""Implements function make_large_model to easily create and save models
bigger than 2 Gb.
"""
from __future__ import annotations
import os
import sys
from typing import TYPE_CHECKING, Any
import numpy as np
import onnx
import onnx.ex... | 347 | 12,489 |
textual | tests/deadlock.py | .py | """
Called by test_pipe.py
"""
from textual.app import App
from textual.binding import Binding
from textual.widgets import Footer
class MyApp(App[None]):
BINDINGS = [
Binding(key="q", action="quit", description="Quit the app"),
]
def compose(self):
yield Footer()
app = MyApp()
app.run... | 22 | 323 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_ParallelDynamicStitch.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
class TestParallelDynamicStitch(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
inputs_data = {}
... | 92 | 4,269 |
openvino | tools/commit_slider/utils/break_validator.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from utils.helpers import CfgError
import csv
from statistics import mean
from enum import Enum
def getJSONFromCSV(csvFilePath):
data = []
with open(csvFilePath, encoding='utf-8') as csvf:
csvReader = csv.DictReader(csvf... | 130 | 4,592 |
metrics | src/torchmetrics/functional/clustering/dunn_index.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... | 83 | 2,764 |
hydra | examples/plugins/example_searchpath_plugin/tests/test_example_search_path_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from hydra.core.global_hydra import GlobalHydra
from hydra.core.plugins import Plugins
from hydra import initialize
from hydra.plugins.search_path_plugin import SearchPathPlugin
from hydra_plugins.example_searchpath_plugin.example_searchpath_plugin... | 25 | 860 |
coremltools | deps/protobuf/python/google/protobuf/internal/well_known_types_test.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 1,006 | 38,635 |
wandb | wandb/sdk/artifacts/storage_policies/__init__.py | .py | from wandb.sdk.artifacts.storage_policies.register import WANDB_STORAGE_POLICY
from wandb.sdk.artifacts.storage_policies.wandb_storage_policy import WandbStoragePolicy
__all__ = ["WANDB_STORAGE_POLICY", "WandbStoragePolicy"]
| 5 | 226 |
saleor | saleor/discount/tests/fixtures/voucher.py | .py | import pytest
from django_countries import countries
from prices import Money
from ... import DiscountValueType, VoucherType
from ...models import Voucher, VoucherChannelListing, VoucherCode, VoucherCustomer
@pytest.fixture
def voucher_without_channel(db):
voucher = Voucher.objects.create()
VoucherCode.objec... | 222 | 6,502 |
saleor | saleor/checkout/tests/test_delivery_context.py | .py | import datetime
from decimal import Decimal
from unittest import mock
import graphene
from django.utils import timezone
from freezegun import freeze_time
from prices import Money
from promise import Promise
from ...shipping.interface import ExcludedShippingMethod, ShippingMethodData
from ...shipping.models import Shi... | 1,732 | 57,668 |
onnxruntime | onnxruntime/test/testdata/transform/fusion/qdq_fusion_gen.py | .py | import onnx
from onnx import OperatorSetIdProto, TensorProto, helper
# inputs/outputs
A = helper.make_tensor_value_info("A", TensorProto.FLOAT, ["unk_1", "unk_2", 1024, 4096])
B = helper.make_tensor_value_info("B", TensorProto.FLOAT, ["unk_1", "unk_2", 1024, 4096])
# initializers
quant_scale = helper.make_tensor("qua... | 74 | 2,299 |
mlflow | tests/demo/test_cli.py | .py | import socket
import sys
from unittest import mock
import click
import pytest
from click.testing import CliRunner
import mlflow
from mlflow.cli import cli
from mlflow.cli.demo import _check_server_connection, demo
from mlflow.demo.base import DEMO_EXPERIMENT_NAME, DEMO_PROMPT_PREFIX
from mlflow.demo.generators.traces... | 185 | 5,393 |
beam | learning/tour-of-beam/learning-content/windowing/global-window/python-example/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... | 51 | 1,717 |
ipython | tests/test_generics.py | .py | """Tests for IPython.utils.generics (singledispatch hooks)"""
import warnings
import pytest
from IPython.core.error import TryNext
from IPython.utils import generics
from IPython.utils.generics import complete_object
def test_inspect_object_deprecated():
with pytest.warns(DeprecationWarning, match="inspect_obj... | 64 | 1,703 |
coremltools | deps/pybind11/tools/libsize.py | .py | from __future__ import annotations
import os
import sys
# Internal build script for generating debugging test .so size.
# Usage:
# python libsize.py file.so save.txt -- displays the size of file.so and, if save.txt exists, compares it to the
# size in it, then overwrites ... | 39 | 1,067 |
luigi | test/db_task_history_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... | 179 | 7,367 |
astropy | astropy/samp/integrated_client.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from .client import SAMPClient
from .hub_proxy import SAMPHubProxy
__all__ = ["SAMPIntegratedClient"]
__doctest_skip__ = ["SAMPIntegratedClient.*"]
class SAMPIntegratedClient:
"""
A Simple SAMP client.
This class is meant to simplify the... | 505 | 17,253 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/chi2_impl.py | .py | import numpy as np
from .mle import design_matrix
def lombscargle_chi2(
t,
y,
dy,
frequency,
normalization="standard",
fit_mean=True,
center_data=True,
nterms=1,
):
"""Lomb-Scargle Periodogram.
This implements a chi-squared-based periodogram, which is relatively slow
but ... | 94 | 2,891 |
kafka | tests/kafkatest/tests/streams/utils/__init__.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 ... | 17 | 900 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_AddN.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
from common.utils.tflite_utils import parametrize_tests
num_inputs = [
{'num_inputs': 2},
{'num_inputs': 4},
{'num_inputs': 5},
]
test_params = [
{'shape': [2, 10, 10, 3]},
{'shape': [2, 10]}
]
test_... | 47 | 1,467 |
pyomo | examples/dae/Path_Constraint.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... | 83 | 2,036 |
openvino | docs/openvino_sphinx_theme/openvino_sphinx_theme/__init__.py | .py | import os
import json
import sys
from json import JSONDecodeError
from sphinx.errors import ExtensionError
import jinja2
from docutils.parsers import rst
from pathlib import Path
from sphinx.util import logging
from .directives.code import DoxygenSnippet, Scrollbox, Nodescrollbox, visit_scrollbox, depart_scrollbox, Dat... | 109 | 4,583 |
beam | learning/katas/python/Core Transforms/Map/FlatMap/tests/test_task.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not... | 36 | 1,276 |
mlflow | tests/test_import.py | .py | import subprocess
import sys
from pathlib import Path
import pytest
from mlflow.utils.os import is_windows
@pytest.mark.skipif(is_windows(), reason="This test fails on Windows")
def test_import_mlflow(tmp_path: Path):
tmp_script = tmp_path.joinpath("test.py")
tmp_script.write_text(
"""
from pathlib ... | 36 | 822 |
mlflow | tests/entities/test_trace_info_v2.py | .py | import pytest
from google.protobuf.duration_pb2 import Duration
from google.protobuf.timestamp_pb2 import Timestamp
from mlflow.entities.trace_info_v2 import TraceInfoV2
from mlflow.entities.trace_status import TraceStatus
from mlflow.protos.service_pb2 import TraceInfo as ProtoTraceInfo
from mlflow.protos.service_pb2... | 171 | 5,769 |
saleor | saleor/core/utils/__init__.py | .py | import socket
from collections.abc import Iterable
from io import BytesIO
from typing import TYPE_CHECKING
from urllib.parse import urljoin, urlparse
from django.conf import settings
from django.contrib.sites.models import Site
from django.core.files import File
from django.db.models import Model
from django.utils.enc... | 172 | 5,373 |
readthedocs.org | readthedocs/projects/tasks/mixins.py | .py | from collections import Counter
import structlog
from readthedocs.builds import tasks as build_tasks
from readthedocs.builds.constants import LATEST_VERBOSE_NAME
from readthedocs.builds.constants import STABLE_VERBOSE_NAME
from readthedocs.builds.models import APIVersion
from ..exceptions import RepositoryError
from... | 105 | 3,423 |
django-cms | cms/test_utils/fixtures/navextenders.py | .py | from cms.api import create_page
from cms.models.pagemodel import Page
class NavextendersFixture:
def create_fixtures(self):
"""
Tree from fixture:
page1
page2
page3
page4
page5
"""
defaults = {
... | 29 | 940 |
wagtail | wagtail/documents/views/serve.py | .py | from django.conf import settings
from django.http import FileResponse, Http404, HttpResponse
from django.shortcuts import get_object_or_404, redirect
from django.template.response import TemplateResponse
from django.urls import reverse
from django.utils.http import url_has_allowed_host_and_scheme
from django.views.deco... | 151 | 6,008 |
pdm | src/pdm/formats/flit.py | .py | from __future__ import annotations
import ast
import os
from collections.abc import Mapping
from pathlib import Path
from typing import TYPE_CHECKING, Any, cast
from pdm.compat import tomllib
from pdm.formats.base import (
MetaConverter,
Unset,
array_of_inline_tables,
convert_from,
make_array,
... | 158 | 5,966 |
biopython | Tests/test_Align_stockholm.py | .py | # Copyright 2008 by Peter Cock. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Tests for Align.stockholm module."""
import unittest
from io import StringIO
from Bio import A... | 7,693 | 506,847 |
mlflow | dev/clint/src/clint/rules/lazy_import.py | .py | from clint.builtin import BUILTIN_MODULES
from clint.rules.base import Rule
# Third-party packages that are always available as core dependencies of mlflow-tracing
# (the smallest installable unit of MLflow). Lazy imports of these packages are flagged
# the same way as stdlib lazy imports.
_ALWAYS_AVAILABLE_MODULES = ... | 27 | 851 |
saleor | saleor/tests/e2e/checkout/discounts/promotions/test_promotion_applied_on_checkout_with_subtotal_within_specified_range.py | .py | from decimal import Decimal
import pytest
from ......checkout.models import Checkout
from ......discount import DiscountType, RewardValueType
from ....product.utils.preparing_product import prepare_product
from ....promotions.utils import (
create_promotion,
create_promotion_rule,
)
from ....shop.utils.prepar... | 302 | 10,867 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/pardo_dofn.py | .py | # coding=utf-8
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License");... | 64 | 1,812 |
pyomo | examples/gdp/small_lit/contracts_problem.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... | 256 | 9,148 |
wagtail | wagtail/embeds/finders/instagram.py | .py | import json
from urllib import request as urllib_request
from urllib.error import HTTPError, URLError
from urllib.parse import urlencode
from urllib.request import Request
from django.utils.html import format_html
from wagtail.embeds.exceptions import EmbedException, EmbedNotFoundException
from .oembed import OEmbed... | 94 | 3,262 |
saleor | saleor/asgi/asgi_handler.py | .py | """Code copied from Django Software Foundation (https://djangoproject.com/) which is licensed under the BSD 3-Clause.
Original code: https://github.com/django/django/blob/001c2f546b4053acb04f16d6b704f7b4fbca1c45/django/core/handlers/asgi.py
Modifications: we added a fix for a memory leak
(https://code.djangoproject.c... | 127 | 5,563 |
cvxpy | cvxpy/expressions/constants/parameter.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... | 121 | 3,918 |
biopython | Bio/Align/interfaces.py | .py | # Copyright 2006-2021 by Peter Cock.
# Copyright 2022 by Michiel de Hoon.
# 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 t... | 350 | 12,461 |
readthedocs.org | readthedocs/gold/apps.py | .py | """Django app configuration for the Gold membership app."""
from django.apps import AppConfig
class GoldAppConfig(AppConfig):
name = "readthedocs.gold"
verbose_name = "Gold"
def ready(self):
import readthedocs.gold.signals # noqa
| 12 | 255 |
probability | tensorflow_probability/python/internal/backend/numpy/gen/linear_operator_kronecker.py | .py | # Copyright 2020 The TensorFlow Probability Authors. All Rights Reserved.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# THIS FILE IS AUTO-GENERATED BY `gen_linear_operators.py`.
# DO NOT MODIFY DIRECTLY.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@... | 575 | 22,903 |
coremltools | coremltools/optimize/torch/_utils/version_utils.py | .py | # Copyright (c) 2024, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import torch as _torch
from packaging import version
def version_ge(module, target_version):
re... | 20 | 508 |
conda | conda/models/package_info.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""(Legacy) Low-level implementation of a PackageRecord."""
from logging import getLogger
from ..auxlib.entity import (
ComposableField,
Entity,
EnumField,
ImmutableEntity,
IntegerField,
ListField,
StringField,
)
fr... | 81 | 2,257 |
conda | conda/core/solve.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""The classic solver implementation."""
from __future__ import annotations
import copy
import sys
from itertools import chain
from logging import DEBUG, getLogger
from textwrap import dedent
from typing import TYPE_CHECKING
from .. import Co... | 1,489 | 64,000 |
saleor | saleor/graphql/order/mutations/order_update_shipping.py | .py | from typing import cast
import graphene
from django.core.exceptions import ValidationError
from ....order import models
from ....order.actions import call_order_event
from ....order.error_codes import OrderErrorCode
from ....permission.enums import OrderPermissions
from ....shipping import models as shipping_models
f... | 155 | 5,501 |
saleor | saleor/graphql/attribute/mutations/attribute_bulk_create.py | .py | from collections import defaultdict
from typing import cast
import graphene
from django.core.exceptions import ValidationError
from django.utils.text import slugify
from graphene.utils.str_converters import to_camel_case
from text_unidecode import unidecode
from ....attribute import (
ATTRIBUTE_PROPERTIES_CONFIGU... | 681 | 25,194 |
mlflow | tests/demo/test_traces_generator.py | .py | import pytest
import mlflow
from mlflow import get_experiment_by_name, set_experiment
from mlflow.demo.base import DEMO_EXPERIMENT_NAME, DemoFeature, DemoResult
from mlflow.demo.generators.traces import (
_PROVIDER_TO_LLM_SPAN_NAME,
DEMO_SESSION_TURN_TAG,
DEMO_TRACE_TYPE_TAG,
DEMO_VERSION_TAG,
Trac... | 293 | 11,051 |
hydra | tests/test_apps/app_with_cfg_decorated/decorators/outer_decorator.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from functools import wraps
from typing import Callable, List, ParamSpec, TypeVar
P = ParamSpec("P")
R = TypeVar("R")
data: List[str] = []
def outer_decorator(arg1: str) -> Callable[[Callable[P, R]], Callable[P, R]]:
def wrapper(func: Calla... | 22 | 559 |
pyro | scripts/update_version.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import glob
import os
import re
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Get new version.
with open(os.path.join(root, "pyro", "__init__.py")) as f:
for line in f:
if line.startswith("version_p... | 37 | 1,188 |
beam | sdks/python/apache_beam/typehints/arrow_batching_microbenchmark.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... | 79 | 2,781 |
astropy | astropy/io/fits/scripts/fitsheader.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
``fitsheader`` is a command line script based on astropy.io.fits for printing
the header(s) of one or more FITS file(s) to the standard output in a human-
readable format.
Example uses of fitsheader:
1. Print the header of all the HDUs of a .fits fil... | 515 | 17,178 |
openvino | src/bindings/python/src/openvino/properties/log/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# Enums
from openvino._pyopenvino.properties.log import Level
# Properties
import openvino._pyopenvino.properties.log as __log
from openvino.properties._properties import __make_properties
__make_properties(__log... | 12 | 332 |
sqlmap | lib/request/rangehandler.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.exception import SqlmapConnectionException
from thirdparty.six.moves import urllib as _urllib
class HTTPRangeHandler(_urllib.request.BaseHandler):
"""
Handl... | 30 | 941 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.