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 |
|---|---|---|---|---|---|
wagtail | wagtail/utils/templates.py | .py | from functools import lru_cache
from pathlib import Path
from django.template import TemplateDoesNotExist
from django.template.loader import select_template
import wagtail
@lru_cache(maxsize=None)
def template_is_overridden(template_name: str, expected_location: str) -> bool:
"""
Check if a template has bee... | 27 | 751 |
beam | sdks/python/apache_beam/transforms/resources.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 ... | 264 | 8,422 |
sphinx | tests/js/roots/titles/relevance.py | .py | class Example:
"""Example class"""
num_attribute = 5
text_attribute = 'string'
relevance = 'testing'
"""attribute docstring"""
| 9 | 149 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_spatialdropout1d.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 TestKerasSpatialDropout1D(CommonTF2LayerTest):
def create_keras_spatialdropout1d_net(self, input_names, input_shapes, input_typ... | 38 | 1,670 |
gunicorn | tests/requests/valid/rfc9112_smuggle_te_identity_chunked_01.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# RFC 9112 section 6.1: identity is a no-op coding and may precede chunked.
# Worth codifying because proxies have historically disagreed on this form.
request = {
"method": "POST",
"uri": uri("/upload"),
... | 17 | 475 |
mlflow | tests/utils/test_rest_utils.py | .py | import re
import time
import warnings
from unittest import mock
import numpy
import pytest
import requests
from mlflow.deployments.databricks import DatabricksDeploymentClient
from mlflow.environment_variables import (
_MLFLOW_DATABRICKS_TRAFFIC_ID,
MLFLOW_HTTP_REQUEST_TIMEOUT,
)
from mlflow.exceptions import... | 1,043 | 40,718 |
beam | learning/katas/python/Common Transforms/Aggregation/Sum/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... | 36 | 1,212 |
biopython | Bio/Graphics/GenomeDiagram/_GraphSet.py | .py | # Copyright 2003-2008 by Leighton Pritchard. All rights reserved.
# Revisions copyright 2008-2010 by Peter Cock.
#
# 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 incl... | 172 | 5,634 |
scikit-bio | skbio/stats/evolve/__init__.py | .py | """Evolutionary statistics (:mod:`skbio.stats.evolve`)
===================================================
.. currentmodule:: skbio.stats.evolve
This package contains statistics pertaining to phylogenies and evolution.
Cophylogenetic methods
----------------------
These functions test for correlation between phylog... | 35 | 948 |
saleor | saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_payment_gateway_initialize_tokenization_session.py | .py | import json
import graphene
from ....payment.interface import PaymentGatewayInitializeTokenizationRequestData
from ...event_types import WebhookEventSyncType
from ...transport.asynchronous import create_deliveries_for_subscriptions
PAYMENT_GATEWAY_INITIALIZE_TOKENIZATION = """
subscription {
event {
... on Pay... | 90 | 2,715 |
sphinx | tests/roots/test-image-in-parsed-literal/conf.py | .py | exclude_patterns = ['_build']
rst_epilog = """
.. |picture| image:: pic.png
:height: 1cm
:scale: 200%
:align: middle
:alt: alternative_text
"""
| 10 | 161 |
astropy | astropy/modeling/tests/test_polynomial.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Tests for polynomial models."""
# pylint: disable=invalid-name
import os
import unittest.mock as mk
import warnings
import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy import conf, wcs
from astropy.io import fits
... | 688 | 23,784 |
biopython | Tests/test_PDB_FragmentMapper.py | .py | # Copyright 2017 by Sourav Singh. All rights reserved.
# Revisions copyright 2017 by Peter Cock. All rights reserved.
#
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been... | 45 | 1,328 |
luigi | luigi/contrib/kubernetes.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2015 Outlier Bio, LLC
#
# 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... | 367 | 13,674 |
onnxruntime | onnxruntime/test/testdata/squeeze_mul_relu.py | .py | from onnx import TensorProto, checker, helper, save, shape_inference
# A --> Squeeze --> Mul --> Relu --> Mul(2x) --> C
# ^
# |
# B ----------------+
graph_proto = helper.make_graph(
nodes=[
helper.make_node(
"Squeeze",
inputs=["A"],
o... | 51 | 1,411 |
astropy | astropy/io/fits/__init__.py | .py | # Licensed under a 3-clause BSD style license - see PYFITS.rst
"""
A package for reading and writing FITS files and manipulating their
contents.
A module for reading and writing Flexible Image Transport System
(FITS) files. This file format was endorsed by the International
Astronomical Union in 1999 and mandated by... | 105 | 3,397 |
pyomo | pyomo/contrib/interior_point/linalg/mumps_interface.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... | 142 | 5,313 |
onnx | onnx/backend/test/case/node/center_crop_pad.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 CenterCropPad(Base):
@staticmethod
def export_center_crop_pad_... | 131 | 3,939 |
probability | tensorflow_probability/python/experimental/psd_kernels/feature_scaled_with_embedded_categorical_test.py | .py | # Copyright 2023 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... | 400 | 17,176 |
beam | sdks/python/apache_beam/io/components/util.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... | 97 | 3,684 |
coremltools | deps/protobuf/python/google/protobuf/descriptor_database.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... | 178 | 6,819 |
saleor | saleor/webhook/tests/test_webhook_sample_payloads.py | .py | import copy
import json
from unittest import mock
import graphene
import pytest
from ...order import OrderStatus
from ..event_types import WebhookEventAsyncType
from ..payloads import (
generate_checkout_payload,
generate_fulfillment_payload,
generate_order_payload,
generate_product_payload,
gener... | 214 | 7,856 |
probability | tensorflow_probability/python/stats/calibration_test.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... | 346 | 14,368 |
mlflow | mlflow/genai/mcp_servers.py | .py | from __future__ import annotations
import json
import urllib.error
import urllib.parse
import urllib.request
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal, Mapping
from mlflow.entities.mcp_server import (
MCPRemoteTransportType,
MCPStatus,
MCPTool,
validate_mcp_server_name,
)... | 788 | 28,562 |
astropy | astropy/utils/xml/tests/test_c_iterparse.py | .py | import io
from dataclasses import dataclass
from typing import Any
import pytest
from astropy.utils.xml import _iterparser
@dataclass(kw_only=True, slots=True, frozen=True)
class XMLTestData:
"""Strictly typed container for XML parsing validation."""
xml_bytes: bytes
expected_events: tuple[tuple[bool, ... | 81 | 2,677 |
openvino | tools/ovc/openvino/tools/ovc/ovc.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# !/usr/bin/env python3
import sys
if __name__ == "__main__":
from openvino.tools.ovc.telemetry_utils import init_ovc_telemetry
from openvino.tools.ovc.main import main
init_ovc_telemetry()
sys.exit(main())
| 14 | 309 |
wagtail | wagtail/api/v3/tests/base.py | .py | from typing import Any
from django.contrib.auth import get_user_model
from django.test import SimpleTestCase
from wagtail.api.v3.errors import PROBLEM_JSON
from wagtail.log_actions import registry as log_registry
from wagtail.models import APIToken
class TestV3Base(SimpleTestCase):
def authorize(self, user, *, ... | 87 | 3,261 |
probability | tensorflow_probability/python/experimental/mcmc/sample.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... | 265 | 11,649 |
saleor | saleor/menu/tests/fixtures/menu.py | .py | import pytest
from ...models import Menu
@pytest.fixture
def menu(db):
return Menu.objects.get_or_create(name="test-navbar", slug="test-navbar")[0]
@pytest.fixture
def menu_with_items(menu, category, published_collection):
menu.items.create(name="Link 1", url="http://example.com/")
menu_item = menu.ite... | 22 | 603 |
sphinx | sphinx/environment/collectors/__init__.py | .py | """The data collector components for sphinx.environment."""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Set
from docutils import nodes
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
class ... | 103 | 3,219 |
attrs | src/attr/setters.py | .py | # SPDX-License-Identifier: MIT
"""
Commonly used hooks for on_setattr.
"""
from . import _config
from .exceptions import FrozenAttributeError
def pipe(*setters):
"""
Run all *setters* and return the return value of the last one.
.. warning::
Generators are not allowed in ``pipe()``.
.. vers... | 83 | 1,684 |
mlflow | mlflow/utils/async_logging/async_logging_queue.py | .py | """
Defines an AsyncLoggingQueue that provides async fashion logging of metrics/tags/params using
queue based approach.
"""
import atexit
import enum
import logging
import threading
from concurrent.futures import ThreadPoolExecutor
from queue import Empty, Queue
from typing import Callable
from mlflow.entities.metric... | 367 | 14,279 |
saleor | saleor/core/jwt_manager.py | .py | import json
import logging
from functools import cache
from os.path import exists, join
from typing import cast
import jwt
from authlib.jose import JsonWebKey
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from django.conf import settings
from django.... | 232 | 7,138 |
loguru | tests/exceptions/source/others/catch_message.py | .py | import sys
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="{message}", diagnose=False, backtrace=False, colorize=False)
def a():
1 / 0
with logger.catch(message="An error occurred (1):"):
a()
a = logger.catch(message="An error occurred (2):")(a)
a()
| 18 | 290 |
pyro | tests/distributions/test_one_one_matching.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import logging
import math
import pytest
import torch
import pyro.distributions as dist
from tests.common import assert_close, assert_equal, xfail_if_not_implemented
BP_ITERS = 50
def _hash(value):
return tuple(value.tolist())... | 157 | 5,643 |
pymc | pymc/_version.py | .py | # Copyright 2024 - present The PyMC Developers
#
# 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... | 697 | 25,108 |
openvino | tools/ovc/unit_tests/ovc/utils/error_test.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import unittest
from openvino.tools.ovc.error import classify_error_type
class TestingErrorClassifier(unittest.TestCase):
def test_no_module(self):
message = "No module named 'openvino._offline_transformations.offline_tran... | 25 | 977 |
mlflow | dev/clint/src/clint/rules/test_name_typo.py | .py | from clint.rules.base import Rule
class TestNameTypo(Rule):
def _message(self) -> str:
return "This function looks like a test, but its name does not start with 'test_'."
| 7 | 185 |
slimit | src/slimit/tests/test_ecmavisitor.py | .py | ###############################################################################
#
# Copyright (c) 2011 Ruslan Spivak
#
# 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, inc... | 506 | 10,717 |
biopython | Bio/SearchIO/ExonerateIO/exonerate_cigar.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 parser ... | 110 | 4,106 |
wandb | wandb/sdk/data_types/molecule.py | .py | from __future__ import annotations
import io
import os
import pathlib
from collections.abc import Sequence
from typing import TYPE_CHECKING, TypeAlias
from wandb import util
from wandb.sdk.lib import runid
from wandb.sdk.lib.paths import LogicalPath
from ._private import MEDIA_TMP
from .base_types.media import Batch... | 254 | 8,882 |
pyomo | pyomo/unsupported/__init__.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... | 9 | 546 |
beam | sdks/python/apache_beam/ml/transforms/embeddings/huggingface.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... | 263 | 9,351 |
onnxruntime | orttraining/orttraining/python/training/ortmodule/_graph_transition_manager.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from __future__ import annotations
import copy
import inspect
import io... | 1,059 | 54,225 |
mkdocs | mkdocs/commands/new.py | .py | from __future__ import annotations
import logging
import os
config_text = 'site_name: My Docs\n'
index_text = """# Welcome to MkDocs
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
## Commands
* `mkdocs new [dir-name]` - Create a new project.
* `mkdocs serve` - Start the live-reloading docs serv... | 54 | 1,454 |
cvxpy | cvxpy/constraints/psd.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... | 235 | 7,949 |
coremltools | coremltools/converters/mil/mil/passes/defs/cleanup/const_deduplication.py | .py | # Copyright (c) 2023, 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 hashlib
from typing import Dict, List, Tuple, Union
import numpy as np
from coremltools.conv... | 256 | 10,597 |
coremltools | coremltools/test/sklearn_tests/test_nearest_neighbors_builder.py | .py | # Copyright (c) 2019, 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 os
import shutil
import unittest
from coremltools._deps import _HAS_SKLEARN
from coremltools.mod... | 419 | 16,089 |
saleor | saleor/tests/e2e/gift_cards/utils/__init__.py | .py | from .gift_card_bulk_create import bulk_create_gift_card
from .gift_card_create import create_gift_card
from .gift_cards_query import get_gift_cards
__all__ = [
"create_gift_card",
"get_gift_cards",
"bulk_create_gift_card",
]
| 10 | 239 |
onnx | onnx/reference/ops/op_tile.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
class Tile(OpRun):
def _run(self, x, repeats):
return (np.tile(x, repeats),)
| 14 | 268 |
wandb | tests/unit_tests/test_launch/test_job.py | .py | import json
import os
from unittest.mock import MagicMock
from wandb.apis.public import Job
from wandb.sdk.internal.job_builder import JobBuilder
def test_configure_notebook_repo_job(mocker, tmp_path):
new_fname = "test.py"
mocker.patch(
"wandb.apis.public.jobs.convert_jupyter_notebook_to_script",
... | 124 | 3,979 |
coremltools | coremltools/test/ml_program/experimental/test_compute_plan_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
from typing import Optional
import platform
import pytest
import coremltools as ct
from coremltools... | 204 | 7,847 |
pyro | pyro/contrib/gp/util.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from pyro.infer import TraceMeanField_ELBO
from pyro.infer.util import torch_backward, torch_item
def conditional(
Xnew,
X,
kernel,
f_loc,
f_scale_tril=None,
Lff=None,
full_cov=False,
... | 195 | 7,152 |
beam | sdks/python/apache_beam/transforms/fully_qualified_named_transform.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... | 146 | 5,016 |
wandb | wandb/jupyter.py | .py | from __future__ import annotations
import json
import logging
import os
import re
import shutil
import sys
import traceback
import urllib.parse
import urllib.request
from base64 import b64encode
from typing import Any
import IPython
import IPython.display
from IPython.core.magic import Magics, line_cell_magic, magics... | 512 | 16,417 |
lemur | lemur/auth/permissions.py | .py | """
.. module: lemur.auth.permissions
:platform: Unix
:synopsis: This module defines all the permission used within Lemur
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
from functools i... | 102 | 3,358 |
sqlmap | lib/request/direct.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import binascii
import re
import time
from lib.core.agent import agent
from lib.core.common import Backend
from lib.core.common import calculateDeltaSeconds
from lib.core.common ... | 112 | 4,913 |
mlflow | mlflow/genai/judges/optimizers/memalign/utils.py | .py | import copy
import json
import logging
import re
from concurrent.futures import ThreadPoolExecutor, as_completed
from functools import lru_cache
from typing import TYPE_CHECKING, Any
from pydantic import BaseModel
# Try to import jinja2 at module level
try:
from jinja2 import Template
_JINJA2_AVAILABLE = Tru... | 576 | 20,745 |
luigi | luigi/contrib/bigquery.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2015 Twitter 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 required by applicable law or ... | 832 | 29,480 |
mlflow | mlflow/entities/_mlflow_object.py | .py | import pprint
from abc import abstractmethod
from functools import cached_property
class _MlflowObject:
def __iter__(self):
# Iterate through list of properties and yield as key -> value
for prop in self._properties():
yield prop, self.__getattribute__(prop)
@classmethod
def _... | 56 | 1,473 |
httpie | httpie/downloads.py | .py | """
Download mode implementation.
"""
import mimetypes
import os
import re
from mailbox import Message
from time import monotonic
from typing import IO, Optional, Tuple
from urllib.parse import urlsplit
import requests
from .models import HTTPResponse, OutputOptions
from .output.streams import RawStream
from .contex... | 378 | 11,802 |
pyomo | doc/OnlineDocs/src/kernel/examples/conic.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... | 32 | 976 |
saleor | saleor/graphql/order/bulk_mutations/utils.py | .py | from typing import Any
from django.core.exceptions import ValidationError
from graphql.error import GraphQLError
from ....order.error_codes import OrderBulkCreateErrorCode
from ...core.utils import from_global_id_or_error
def get_instance(
input: dict[str, Any],
model,
key_map: dict[str, str],
insta... | 92 | 3,468 |
onnx | onnx/backend/test/case/node/qlinearconv.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 QLinearConv(Base):
@staticmethod
def export() -> None:
... | 83 | 2,295 |
tqdm | tests/conftest.py | .py | """Shared pytest config."""
import sys
from pytest import fixture
from tqdm import tqdm
@fixture(autouse=True)
def pretest_posttest():
"""Fixture for all tests ensuring environment cleanup"""
try:
sys.setswitchinterval(1)
except AttributeError:
sys.setcheckinterval(100) # deprecated
... | 28 | 739 |
lemur | lemur/dns_providers/cli.py | .py | import sys
import click
from flask.cli import with_appcontext
from sentry_sdk import capture_exception
from lemur.constants import SUCCESS_METRIC_STATUS
from lemur.dns_providers.service import get_all_dns_providers, set_domains
from lemur.extensions import metrics
from lemur.plugins.lemur_acme.acme_handlers import Ac... | 51 | 1,604 |
black | tests/data/cases/fmtskip.py | .py | a, b = 1, 2
c = 6 # fmt: skip
d = 5
| 4 | 40 |
beam | sdks/python/apache_beam/dataframe/__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 us... | 33 | 1,470 |
sqlmap | tamper/bluecoat.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.data import kb
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.NORMAL
def dependencies():
pass
def tamper(payload, **kwargs):
"""
... | 51 | 1,333 |
beam | sdks/python/apache_beam/examples/inference/online_clustering/write_data_to_pubsub_pipeline/main.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... | 90 | 2,747 |
openvino | docs/articles_en/assets/snippets/gpu/preprocessing_nv12_two_planes.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from snippets import get_model
import openvino as ov
def init_preproc():
model = get_model()
#! [init_preproc]
import openvino as ov
from openvino.preprocess import PrePostProcessor, ColorFormat
core = ov.Core()
... | 32 | 790 |
astropy | astropy/coordinates/representation/cylindrical.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Cylindrical representations and differentials."""
import operator
import numpy as np
import astropy.units as u
from astropy.coordinates.angles import Angle
from .base import BaseDifferential, BaseRepresentation
from .cartesian import CartesianRepres... | 176 | 6,118 |
readthedocs.org | readthedocs/rtd_tests/tests/test_middleware.py | .py | from corsheaders.middleware import (
ACCESS_CONTROL_ALLOW_CREDENTIALS,
ACCESS_CONTROL_ALLOW_ORIGIN,
)
from django.test import TestCase, override_settings
from django.test.client import RequestFactory
from django_dynamic_fixture import get
from readthedocs.builds.constants import LATEST
from readthedocs.core.mi... | 254 | 9,655 |
astropy | astropy/timeseries/periodograms/lombscargle/_statistics.py | .py | """
Utilities for computing periodogram statistics.
This is an internal module; users should access this functionality via the
``false_alarm_probability`` and ``false_alarm_level`` methods of the
``astropy.timeseries.LombScargle`` API.
"""
from functools import wraps
import numpy as np
from astropy import units as ... | 506 | 16,195 |
hydra | plugins/hydra_ax_sweeper/tests/apps/polynomial_with_list_coefficients.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any
import hydra
from omegaconf import DictConfig
@hydra.main(config_path=".", config_name="polynomial_with_coefficients")
def polynomial_with_list_coefficients(cfg: DictConfig) -> Any:
x, y, z = cfg.polynomial.coefficients... | 19 | 461 |
coremltools | coremltools/optimize/torch/quantization/_annotation_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
from typing import Optional as _Optional
import torch as _torch
import torch.ao.quantization as _aoq... | 110 | 4,080 |
cvxpy | cvxpy/reductions/solvers/qp_solvers/piqp_qpif.py | .py | """
Copyright 2023, 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, sof... | 206 | 7,790 |
pyro | pyro/contrib/bnn/hidden_layer.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
import torch.nn.functional as F
from torch.distributions.utils import lazy_property
from pyro.contrib.bnn.utils import adjoin_ones_vector
from pyro.distributions.torch_distribution import TorchDistribution
class Hid... | 127 | 5,384 |
textual | tests/snapshot_tests/snapshot_apps/text_area.py | .py | """Tests the rendering of the TextArea for all supported languages."""
from textual.app import App, ComposeResult
from textual.widgets import TextArea
class TextAreaSnapshot(App):
def compose(self) -> ComposeResult:
text_area = TextArea.code_editor()
text_area.cursor_blink = False
yield te... | 16 | 396 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_gather_nd.py | .py | #
# gather_nd paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle
import sys
def gather_nd(name: str, x, y):
paddle.enable_static()
with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()):
data = paddle.static.data(name="x", shape=x.sh... | 76 | 2,048 |
pyomo | pyomo/_archive/plugin.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... | 53 | 1,585 |
gunicorn | tests/docker/http2/test_http2_docker.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""HTTP/2 Docker integration tests.
These tests verify HTTP/2 functionality with real connections to gunicorn
running in Docker containers, both directly and through an nginx proxy.
"""
import asyncio
import ssl
... | 393 | 15,679 |
omegaconf | omegaconf/resolvers/oc/dict.py | .py | from typing import Any, List
from omegaconf import AnyNode, Container, DictConfig, ListConfig
from omegaconf._utils import Marker
from omegaconf.basecontainer import BaseContainer
from omegaconf.errors import ConfigKeyError
_DEFAULT_SELECT_MARKER_: Any = Marker("_DEFAULT_SELECT_MARKER_")
def keys(
key: str,
... | 84 | 2,324 |
confluent-kafka-python | tests/integration/admin/test_user_scram_credentials.py | .py | # -*- coding: utf-8 -*-
# Copyright 2023 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 required by applicable law or... | 134 | 4,609 |
onnxruntime | onnxruntime/test/python/transformers/test_paged_attention.py | .py | # --------------------------------------------------------------------------
# Copyright 2020 The HuggingFace Inc. 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/l... | 2,976 | 134,510 |
cvxpy | cvxpy/reductions/complex2real/__init__.py | .py | """
Copyright 2017 Robin Verschueren
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, softw... | 16 | 566 |
textual | tests/test_animation.py | .py | from time import perf_counter
from textual.app import App, ComposeResult
from textual.reactive import var
from textual.widgets import Static
class AnimApp(App):
CSS = """
#foo {
height: 1;
}
"""
def compose(self) -> ComposeResult:
yield Static("foo", id="foo")
async def test_an... | 302 | 9,584 |
pyomo | pyomo/core/tests/transform/__init__.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... | 12 | 579 |
pdm | src/pdm/installers/synchronizers.py | .py | from __future__ import annotations
import functools
import traceback
from concurrent.futures import Future, ThreadPoolExecutor
from types import SimpleNamespace
from typing import TYPE_CHECKING
from pdm import termui
from pdm.exceptions import InstallationError
from pdm.installers.base import BaseSynchronizer
from pd... | 244 | 10,822 |
saleor | saleor/graphql/payment/mutations/stored_payment_methods/__init__.py | .py | from .payment_gateway_initialize_tokenization import (
PaymentGatewayInitializeTokenization,
)
from .payment_method_intialize_tokenization import PaymentMethodInitializeTokenization
from .payment_method_process_tokenization import PaymentMethodProcessTokenization
from .payment_method_request_delete import StoredPay... | 14 | 526 |
wagtail | wagtail/images/api/admin/serializers.py | .py | from ..fields import ImageRenditionField
from ..v2.serializers import ImageSerializer
class AdminImageSerializer(ImageSerializer):
thumbnail = ImageRenditionField("max-165x165", source="*", read_only=True)
| 7 | 212 |
beam | sdks/python/apache_beam/io/gcp/resource_identifiers.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... | 60 | 2,145 |
saleor | saleor/graphql/shipping/tests/mutations/test_shipping_zone_update.py | .py | import json
from unittest import mock
import graphene
import pytest
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....core.utils.json_serializer import CustomJsonEncoder
from .....shipping.error_codes import ShippingErrorCode
from .....shipping.models import ShippingMeth... | 770 | 23,379 |
textual | docs/examples/widgets/option_list_strings.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Footer, Header, OptionList
class OptionListApp(App[None]):
CSS_PATH = "option_list.tcss"
def compose(self) -> ComposeResult:
yield Header()
yield OptionList(
"Aerilon",
"Aquaria",
"Cance... | 29 | 618 |
textual | tests/snapshot_tests/snapshot_apps/dock_scroll2.py | .py | from textual.app import App
from textual.widgets import Header, Label, Footer
# Same as dock_scroll.py but with 2 labels
class TestApp(App):
BINDINGS = [("ctrl+q", "app.quit", "Quit")]
CSS = """
Label {
border: solid red;
}
Footer {
height: 4;
}
"""
def compose(se... | 31 | 600 |
probability | tensorflow_probability/python/experimental/fastgp/mbcg_test.py | .py | # Copyright 2024 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... | 203 | 7,401 |
sqlmap | tamper/oraclequote.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import os
import re
from lib.core.common import singleTimeWarnMessage
from lib.core.enums import DBMS
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.LOW
def depend... | 54 | 1,606 |
wandb | wandb/sdk/internal/file_pusher.py | .py | from __future__ import annotations
import concurrent.futures
import logging
import os
import queue
import tempfile
import threading
import time
from typing import TYPE_CHECKING
import wandb
import wandb.util
from wandb.filesync import stats, step_checksum, step_upload
from wandb.sdk.lib.paths import LogicalPath
if T... | 180 | 6,024 |
jupytext | jupyterlab/jupyterlab_jupytext/__init__.py | .py | """Jupyter server and lab extension entry points"""
import asyncio
from jupytext.reraise import reraise
try:
from jupytext.async_contentsmanager import (
build_async_jupytext_contents_manager_class,
)
except ImportError as err:
build_async_jupytext_contents_manager_class = reraise(err)
try:
... | 76 | 2,598 |
saleor | saleor/webhook/transport/utils.py | .py | import dataclasses
import datetime
import hashlib
import json
import logging
from collections.abc import Callable
from contextlib import contextmanager
from dataclasses import dataclass
from enum import Enum
from time import time
from typing import Optional
from urllib.parse import unquote, urlparse, urlunparse
from uu... | 812 | 26,803 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.