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 |
|---|---|---|---|---|---|
django-cms | cms/tests/test_startcmsproject.py | .py | import io
import json
import os
import sys
import tarfile
import tempfile
import urllib.error
from io import StringIO
from unittest import mock
from django.core.management import CommandError
from django.test import SimpleTestCase
from cms.management.commands.startcmsproject import Command
MANAGE_PY = """#!/usr/bin/... | 804 | 34,375 |
scikit-bio | skbio/stats/ordination/tests/test_principal_component_analysis.py | .py | # ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# --------------------------------------------... | 234 | 9,339 |
wandb | wandb/integration/metaflow/metaflow.py | .py | from __future__ import annotations
import inspect
import pickle
from functools import wraps
from pathlib import Path
import wandb
from wandb.sdk.lib import telemetry as wb_telemetry
from . import errors
try:
from metaflow import current
except ImportError as e:
raise Exception(
"Error: `metaflow` no... | 328 | 9,360 |
saleor | saleor/graphql/page/tests/queries/pages_with_where/test_with_where_references_collections.py | .py | import graphene
import pytest
from ......attribute import AttributeEntityType, AttributeInputType, AttributeType
from ......attribute.models import Attribute, AttributeValue
from ......attribute.utils import associate_attribute_values_to_instance
from .....core.utils import to_global_id_or_none
from .....tests.utils i... | 309 | 9,882 |
probability | tensorflow_probability/python/experimental/distributions/multitask_gaussian_process_regression_model_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... | 708 | 30,918 |
textual | tests/test_rlock.py | .py | import asyncio
import pytest
from textual.rlock import RLock
async def test_simple_lock():
lock = RLock()
# Starts not locked
assert not lock.is_locked
# Acquire the lock
await lock.acquire()
assert lock.is_locked
# Acquire a second time (should not block)
await lock.acquire()
as... | 57 | 1,270 |
pdm | src/pdm/project/lockfile/base.py | .py | from __future__ import annotations
import abc
import enum
from collections.abc import Iterable, Mapping
from collections.abc import Set as AbstractSet
from functools import cached_property
from typing import TYPE_CHECKING, Any
import tomlkit
from pdm import termui
from pdm.exceptions import PdmUsageError
from pdm.pr... | 130 | 4,739 |
biopython | Tests/test_GenBank.py | .py | # Copyright 2001-2004 by Brad Chapman. All rights reserved.
# Revisions copyright 2007-2016 by Peter Cock. All rights reserved.
# Revisions copyright 2013 by Kai Blin. All rights reserved.
# Revisions copyright 2015-2016 by Peter Cock.
# Revisions copyright 2019 by Sergio Valqui.
# This code is part of the Biopython d... | 8,680 | 384,161 |
owasp-mstg | src/scripts/tools_healthcheck.py | .py | import os
import re
import yaml
from urllib.parse import urlparse
def extract_frontmatter(file_path):
try:
with open(file_path, 'r', encoding='utf-8') as f:
frontmatter = next(yaml.safe_load_all(f)) or {}
except (UnicodeDecodeError, yaml.reader.ReaderError):
# Try to read with 'ISO-... | 50 | 2,108 |
saleor | saleor/graphql/product/mutations/product_variant/product_variant_reorder.py | .py | import graphene
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from .....core.tracing import traced_atomic_transaction
from .....permission.enums import ProductPermissions
from .....product import models
from .....product.error_codes import ProductErrorCode
from ....core import ResolveInfo
from... | 89 | 3,318 |
wagtail | wagtail/snippets/tests/test_viewset.py | .py | from datetime import datetime
from io import BytesIO
from unittest import mock
from django.conf import settings
from django.contrib.admin.utils import quote
from django.contrib.auth import get_permission_codename
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentTy... | 1,848 | 71,309 |
kafka | tests/kafkatest/services/consumer_property.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 ... | 22 | 923 |
gunicorn | tests/docker/asgi_framework_compat/tests/test_http_scope.py | .py | """
HTTP Scope Compliance Tests
Tests ASGI 3.0 HTTP scope compliance across frameworks.
"""
import pytest
from frameworks.contract import ASGI_HTTP_SCOPE_REQUIRED_KEYS
pytestmark = pytest.mark.http
class TestHttpScopeBasics:
"""Test basic HTTP scope attributes."""
async def test_scope_endpoint_returns_j... | 169 | 6,138 |
scikit-bio | skbio/io/format/tests/test_sample_metadata.py | .py | # ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# --------------------------------------------... | 82 | 2,763 |
saleor | saleor/graphql/app/dataloaders/thumbnail.py | .py | from ...core.dataloaders import BaseThumbnailBySizeAndFormatLoader
class ThumbnailByAppIdSizeAndFormatLoader(BaseThumbnailBySizeAndFormatLoader):
context_key = "thumbnail_by_app_size_and_format"
model_name = "app"
class ThumbnailByAppInstallationIdSizeAndFormatLoader(
BaseThumbnailBySizeAndFormatLoader
... | 14 | 425 |
kombu | kombu/asynchronous/aws/connection.py | .py | """Amazon AWS Connection."""
from __future__ import annotations
from email import message_from_bytes
from email.mime.message import MIMEMessage
from vine import promise, transform
from kombu.asynchronous.aws.ext import AWSRequest, get_cert_path, get_response
from kombu.asynchronous.http import Headers, Request, get... | 279 | 8,883 |
saleor | saleor/tests/e2e/vouchers/utils/voucher_channel_listing.py | .py | from ...utils import get_graphql_content
VOUCHER_CREATE_CHANNEL_LISTING_MUTATION = """
mutation VoucherChannelListingUpdate($id: ID!, $input: VoucherChannelListingInput!) {
voucherChannelListingUpdate(id: $id, input: $input) {
errors {
field
message
code
}
voucher {
id
start... | 64 | 1,305 |
probability | tensorflow_probability/python/distributions/truncated_cauchy_test.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... | 199 | 7,775 |
wagtail | wagtail/snippets/tests/test_chooser_block.py | .py | from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.test import TestCase
from wagtail.blocks.field_block import FieldBlockAdapter
from wagtail.models import Locale
from wagtail.snippets.blocks import SnippetChooserBlock
from wagtail.snippets.widgets import AdminSnippetChooser
from wagt... | 199 | 7,961 |
sqlmap | plugins/dbms/informix/__init__.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.enums import DBMS
from lib.core.settings import INFORMIX_SYSTEM_DBS
from lib.core.unescaper import unescaper
from plugins.dbms.informix.enumeration import Enumerati... | 31 | 929 |
mlflow | tests/store/tracking/sqlalchemy_store/test_sqlalchemy_store_schema.py | .py | import os
import re
import sqlite3
import pytest
import sqlalchemy
from alembic import command
from alembic.autogenerate import compare_metadata
from alembic.migration import MigrationContext
from alembic.script import ScriptDirectory
from click.testing import CliRunner
import mlflow.db
# Import workspace models tem... | 585 | 24,278 |
conda | tests/test_api.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
try:
from inspect import getfullargspec as getargspec
except ImportError:
from inspect import getargspec
import pytest
from conda.api import (
DepsModifier,
PackageCacheData,
PrefixData,
Solver,
SubdirData,
Upda... | 287 | 9,169 |
flit | flit_core/tests_core/samples/invalid_version1.py | .py | """Sample module with invalid __version__ string"""
__version__ = "not starting with a number"
| 4 | 96 |
probability | tensorflow_probability/python/internal/unnest_test.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... | 333 | 14,515 |
sqlmap | thirdparty/chardet/langthaimodel.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from .sbcharsetprober import SingleByteCharSetModel
# 3: Positive
# 2: Likely
# 1: Unlikely
# 0: Negative
THAI_LANG_MODEL = {
5: { # 'ก'
5: 2, # 'ก'
30: 2, # 'ข'
24: 2, # 'ค'
8: 2, # 'ง'
26: 2, # 'จ'
52: 0, # 'ฉ... | 4,384 | 103,293 |
pdm | src/pdm/project/project_file.py | .py | from __future__ import annotations
import hashlib
import json
from typing import Any, cast
import tomlkit
from pdm import termui
from pdm.exceptions import ProjectError
from pdm.project.toml_file import TOMLFile
from pdm.utils import normalize_name
def _remove_empty_tables(doc: dict) -> None:
for k, v in list(... | 132 | 4,809 |
voila | tests/app/progressive_rendering_test.py | .py | import asyncio
import os
import time
import pytest
@pytest.fixture
def progressive_rendering_mode():
return True
@pytest.fixture
def voila_notebook(notebook_directory):
return os.path.join(notebook_directory, "preheat", "pre_heat.ipynb")
NOTEBOOK_EXECUTION_TIME = 2
TIME_THRESHOLD = NOTEBOOK_EXECUTION_TIM... | 40 | 948 |
beam | learning/katas/python/Common Transforms/Aggregation/Largest/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,231 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_Where.py | .py | import numpy as np
import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
np.random.seed(42)
test_params = [
{'shape': [10]},
{'shape': [1, 2, 3, 4]},
{'shape': [8, 7, 6, 5, 4, 3, 2, 1]}
]
class TestTFLiteWhereLayerTest(TFLiteLayerTest):
inputs = ["Input"]
... | 40 | 1,219 |
biopython | Bio/PopGen/GenePop/FileParser.py | .py | # Copyright 2010 by Tiago Antao. 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.
"""Code to parse BIG GeneP... | 351 | 11,861 |
ipython | tests/test_displayhook.py | .py | import sys
from IPython.testing.tools import AssertPrints, AssertNotPrints
from IPython.core.displayhook import CapturingDisplayHook
from IPython.utils.capture import CapturedIO
def test_output_displayed():
"""Checking to make sure that output is displayed"""
with AssertPrints("2"):
ip.run_cell("1+1"... | 117 | 3,576 |
beam | sdks/python/apache_beam/examples/inference/vertex_ai_image_classification.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... | 173 | 6,034 |
coveragepy | lab/run_trace.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Run a simple trace function on a file of Python code."""
import os, sys
nest = 0
def trace(frame, event, arg):
global nest
if nest is None:
... | 45 | 989 |
hydra | hydra/core/config_search_path.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import MutableSequence, Optional, Union
class SearchPathElement:
def __init__(self, provider: str, search_path: str):
self.provider = provider
se... | 67 | 2,062 |
wandb | wandb/automations/_generated/enums.py | .py | # Generated by ariadne-codegen
# Source: core/api/graphql/schemas/schema-latest.graphql
from __future__ import annotations
from enum import Enum
class AlertSeverity(str, Enum):
ERROR = "ERROR"
INFO = "INFO"
WARN = "WARN"
class EventTriggeringConditionType(str, Enum):
ADD_ARTIFACT_ALIAS = "ADD_ARTI... | 44 | 1,219 |
pyomo | pyomo/contrib/solver/solvers/gurobi/gurobi_direct_minlp.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... | 649 | 22,330 |
onnxruntime | onnxruntime/test/python/onnxruntime_test_python_symbolic_shape_infer.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
import numpy
# -*- coding: UTF-8 -*-
import onnx
from onnx import AttributeProto, GraphProto, TensorProto, helper, numpy_helper # noqa: F401
if os.path.exists(
os.path.join(
os.path.dirname(__file__)... | 853 | 32,512 |
onnx | onnx/fuzz/fuzz_version_converter.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import sys
import atheris
with atheris.instrument_imports():
import onnx
from onnx import version_converter
def _default_opset_version(model):
for opset in model.opset_import:
if o... | 58 | 1,301 |
pymc | pymc/sampling/__init__.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... | 37 | 1,154 |
probability | tensorflow_probability/python/glm/proximal_hessian_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... | 427 | 15,588 |
textual | tests/snapshot_tests/snapshot_apps/footer_classic_styling.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Footer
class ClassicFooterStylingApp(App):
"""
This app attempts to replicate the styling of the classic footer in
Textual before v0.63.0, in particular the distinct background color
for the binding keys and spacing between the key... | 46 | 1,067 |
onnxruntime | orttraining/orttraining/python/training/onnxblock/optim/__init__.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from onnxruntime.training.onnxblock.optim.optim import SGD, AdamW, ClipGradNorm
__all__ = ["SGD", "AdamW", "ClipGradNorm"]
| 7 | 219 |
kombu | kombu/utils/functional.py | .py | """Functional Utilities."""
from __future__ import annotations
import inspect
import random
import threading
from collections import OrderedDict, UserDict
from collections.abc import Iterable, Mapping
from itertools import count, repeat
from time import sleep, time
from vine.utils import wraps
from .encoding import... | 362 | 10,708 |
loguru | tests/exceptions/source/ownership/string_lib.py | .py | import sys
import _init
from somelib import execute
from loguru import logger
def test(*, backtrace, colorize, diagnose):
logger.remove()
logger.add(sys.stderr, format="", colorize=colorize, backtrace=backtrace, diagnose=diagnose)
try:
execute()
except ZeroDivisionError:
logger.exce... | 24 | 594 |
saleor | saleor/product/utils/tasks_utils.py | .py | from typing import IO
from PIL import Image, UnidentifiedImageError
from requests.exceptions import HTTPError
from ...core.utils import create_file_from_response
from ...core.utils.validators import is_valid_image_content_type
from ...thumbnail.utils import ProcessedImage, get_filename_from_url
def validate_status_... | 60 | 1,786 |
kombu | kombu/utils/text.py | .py | """Text Utilities."""
# flake8: noqa
from __future__ import annotations
from difflib import SequenceMatcher
from typing import Iterable, Iterator
from kombu import version_info_t
def escape_regex(p, white=''):
# type: (str, str) -> str
"""Escape string for use within a regular expression."""
# what's ... | 74 | 2,200 |
beam | sdks/python/apache_beam/testing/benchmarks/nexmark/queries/query6.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 | 3,391 |
rq | rq/suspension.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from redis import Redis
from rq.worker import BaseWorker
WORKERS_SUSPENDED = 'rq:suspended'
def is_suspended(connection: Redis, worker: BaseWorker | None = None):
"""Checks whether a Worker is suspended on a given c... | 52 | 1,356 |
metrics | src/torchmetrics/segmentation/mean_iou.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... | 227 | 10,539 |
wandb | tests/unit_tests/test_launch/test_runner/test_kubernetes.py | .py | import asyncio
import base64
import json
import platform
import shlex
from unittest.mock import MagicMock, patch
import pytest
import wandb
import wandb.sdk.launch.runner.kubernetes_runner
from kubernetes_asyncio import client
from kubernetes_asyncio.client import ApiException
from wandb.sdk.launch._project_spec impor... | 2,131 | 68,306 |
mlflow | mlflow/store/db_migrations/versions/6953534de441_add_step_to_inputs_table.py | .py | """add step to inputs table
Create Date: 2025-02-13 11:50:07.098121
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "6953534de441"
down_revision = "400f98739977"
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table("inputs", sch... | 24 | 471 |
wandb | tests/unit_tests/test_public_api/test_runs.py | .py | import json
from unittest import mock
import pytest
import wandb
from wandb.apis.public.runs import Run, RunNotFoundError
from wandb.apis.public.sweeps import Sweep
from wandb.proto import wandb_api_pb2 as apb
def _make_upload_run(mocker, *, feature_enabled: bool):
service_api = mocker.MagicMock()
service_ap... | 364 | 11,607 |
mlflow | tests/tracing/utils/test_environment.py | .py | from unittest import mock
import pytest
from mlflow.tracing.utils.environment import resolve_env_metadata
from mlflow.utils.mlflow_tags import (
MLFLOW_DATABRICKS_NOTEBOOK_ID,
MLFLOW_DATABRICKS_NOTEBOOK_PATH,
MLFLOW_GIT_BRANCH,
MLFLOW_GIT_COMMIT,
MLFLOW_GIT_REPO_URL,
MLFLOW_SOURCE_NAME,
ML... | 61 | 2,020 |
mlflow | tests/dspy/test_dspy_autolog.py | .py | import importlib
import json
import time
from unittest import mock
import dspy
import dspy.teleprompt
import pytest
from dspy.evaluate import Evaluate
from dspy.evaluate.metrics import answer_exact_match
from dspy.predict import Predict
from dspy.primitives.example import Example
from dspy.teleprompt import BootstrapF... | 1,234 | 42,170 |
wagtail | wagtail/management/commands/convert_mariadb_uuids.py | .py | from django.apps import apps
from django.core.management.base import BaseCommand
from django.db import connection, models
from wagtail.models import (
BaseLogEntry,
BootstrapTranslatableMixin,
ReferenceIndex,
TranslatableMixin,
)
class Command(BaseCommand):
help = "Converts UUID columns from char... | 44 | 1,568 |
mlflow | mlflow/utils/timeout.py | .py | import signal
from contextlib import contextmanager
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import NOT_IMPLEMENTED
from mlflow.utils.os import is_windows
class MlflowTimeoutError(Exception):
pass
@contextmanager
def run_with_timeout(seconds):
"""
Context manager ... | 43 | 1,214 |
saleor | saleor/graphql/invoice/schema.py | .py | import graphene
from .mutations import (
InvoiceCreate,
InvoiceDelete,
InvoiceRequest,
InvoiceRequestDelete,
InvoiceSendNotification,
InvoiceUpdate,
)
class InvoiceMutations(graphene.ObjectType):
invoice_request = InvoiceRequest.Field()
invoice_request_delete = InvoiceRequestDelete.Fi... | 20 | 519 |
saleor | saleor/graphql/core/validators/__init__.py | .py | from typing import TYPE_CHECKING, Any, Optional
from uuid import UUID
import graphene
import graphql.validation
from babel.numbers import get_currency_precision
from django.conf import settings
from django.core.exceptions import ValidationError
from graphene.utils.str_converters import to_camel_case
from graphql.error... | 262 | 8,495 |
probability | discussion/adaptive_malt/adaptive_malt_test.py | .py | # Copyright 2022 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... | 66 | 2,117 |
sqlmap | plugins/dbms/clickhouse/__init__.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.enums import DBMS
from lib.core.settings import CLICKHOUSE_SYSTEM_DBS
from lib.core.unescaper import unescaper
from plugins.dbms.clickhouse.enumeration import Enume... | 31 | 949 |
sqlmap | plugins/dbms/mssqlserver/fingerprint.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.common import Backend
from lib.core.common import Format
from lib.core.convert import getUnicode
from lib.core.data import conf
from lib.core.data import kb
from lib... | 206 | 6,970 |
coremltools | coremltools/converters/sklearn/_random_forest_classifier.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from ..._deps import _HAS_SKLEARN
from ...models import MLModel as _MLModel
from ._tree_ensemble import ... | 71 | 1,916 |
astropy | astropy/samp/tests/test_web_profile.py | .py | """
Test the web profile using Python classes that have been adapted to act like a
web client. We can only put a single test here because only one hub can run
with the web profile active, and the user might want to run the tests in
parallel.
"""
import threading
from urllib.request import Request, urlopen
import pyte... | 89 | 2,988 |
sqlmap | thirdparty/chardet/version.py | .py | """
This module exists only to simplify retrieving the version number of chardet
from within setup.py and from chardet subpackages.
:author: Dan Blanchard (dan.blanchard@gmail.com)
"""
__version__ = "4.0.0"
VERSION = __version__.split('.')
| 10 | 242 |
kombu | t/unit/transport/virtual/test_base.py | .py | from __future__ import annotations
import io
import logging
import socket
import sys
import warnings
from array import array
from time import monotonic
from unittest.mock import MagicMock, Mock, patch
import pytest
from kombu import Connection
from kombu.compression import compress
from kombu.exceptions import Chann... | 688 | 22,864 |
onnxruntime | onnxruntime/test/python/onnxruntime_test_python_nested_control_flow_op.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import unittest
from collections.abc import Sequence
from copy import deepcopy
import numpy as np
from onnx import ModelProto, NodeProto, TensorProto, ValueInfoProto, checker, helper
import onnxruntime as ort
def make_vi_... | 260 | 9,037 |
saleor | saleor/graphql/csv/schema.py | .py | import graphene
from ...permission.enums import ProductPermissions
from ..core import ResolveInfo
from ..core.connection import create_connection_slice, filter_connection_queryset
from ..core.descriptions import DEPRECATED_EXPORT_MUTATIONS
from ..core.fields import FilterConnectionField, PermissionsField
from ..core.u... | 55 | 2,175 |
pyro | pyro/distributions/transforms/unit_cholesky.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.distributions import constraints
from torch.distributions.transforms import Transform
from pyro.distributions.constraints import unit_lower_cholesky
class UnitLowerCholeskyTransform(Transform):
"""
Tr... | 33 | 809 |
wagtail | wagtail/documents/tests/test_blocks.py | .py | from django.test import TestCase
from wagtail.documents import get_document_model
from wagtail.documents.blocks import DocumentChooserBlock
from .utils import get_test_document_file
class TestDocumentChooserBlock(TestCase):
def test_deconstruct(self):
block = DocumentChooserBlock(required=False)
... | 31 | 1,035 |
openvino | src/bindings/python/src/openvino/opset16/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# New operations added in Opset16
from openvino.opset16.ops import identity
from openvino.opset16.ops import istft
from openvino.opset16.ops import segment_max
from openvino.opset16.ops import sparse_fill_empty_ro... | 209 | 8,910 |
saleor | saleor/plugins/admin_email/notify_events.py | .py | from collections.abc import Callable
from typing import TYPE_CHECKING
from ..email_common import get_email_subject, get_email_template_or_default
from . import constants
from .tasks import (
send_email_with_link_to_download_file_task,
send_export_failed_email_task,
send_set_staff_password_email_task,
s... | 142 | 4,738 |
mlflow | dev/check_patch_prs.py | .py | import argparse
import concurrent.futures
import itertools
import os
import re
import subprocess
import sys
import tempfile
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import Any
import requests
from packaging.version import Version
MAX_COM... | 291 | 9,832 |
wagtail | wagtail/admin/tests/test_whats_new.py | .py | import unittest
from django.test import RequestFactory, TestCase, override_settings
from django.urls import reverse
from wagtail.admin.views.home import WhatsNewInWagtailVersionPanel
from wagtail.test.utils import WagtailTestUtils
from wagtail.users.models import UserProfile
class TestWhatsNewInWagtailVersionPanel(... | 133 | 5,570 |
wandb | wandb/sdk/lib/console_capture.py | .py | """Module for intercepting stdout/stderr.
This patches the `write()` method of `stdout` and `stderr` on import.
Once patched, it is not possible to unpatch or repatch, though individual
callbacks can be removed.
We assume that all other writing methods on the object delegate to `write()`,
like `writelines()`. This is... | 309 | 9,389 |
kafka | tests/kafkatest/tests/streams/streams_smoke_test.py | .py | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | 125 | 6,468 |
saleor | saleor/graphql/checkout/tests/mutations/test_checkout_create_from_order.py | .py | import datetime
import graphene
import pytest
from .....checkout.error_codes import CheckoutCreateFromOrderUnavailableVariantErrorCode
from .....checkout.models import Checkout
from .....product.models import ProductChannelListing, ProductVariantChannelListing
from .....warehouse.models import Stock
from ....tests.ut... | 903 | 32,782 |
probability | spinoffs/inference_gym/inference_gym/targets/neals_funnel_test.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... | 59 | 2,011 |
kafka | tests/kafkatest/tests/connect/connect_plugin_discovery_test.py | .py | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | 80 | 4,212 |
hydra | tools/landscape/analyze_hydra_usage.py | .py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""Analyze how dependent GitHub repositories use and document Hydra.
The analyzer reads repositories from the enriched github-to-sqlite database,
visits them in descending star order, and appends one JSON object per reposit... | 1,529 | 53,577 |
coveragepy | tests/modules/pkg1/sub/runmod3.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
# Used in the tests for PyRunner
import sys
print("runmod3: passed %s" % sys.argv[1])
| 8 | 245 |
confluent-kafka-python | tests/integration/share_consumer/test_share_consumer_deserialization.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2026 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 331 | 13,742 |
sqlmap | extra/esperanto/enumeration.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from .atlas import _BULK_AGG
from .atlas import _COLUMN_SPECS
from .atlas import _HEX_PAYLOAD_CODES
from .atlas import _IDENT_QUOTE
from .atlas import _KEY_SPECS
from .atlas impor... | 907 | 55,695 |
saleor | saleor/graphql/meta/tests/mutations/test_invoice.py | .py | import graphene
from .....invoice.models import Invoice
from .test_update_metadata import (
execute_update_public_metadata_for_item,
item_contains_proper_public_metadata,
)
from .test_update_private_metadata import (
execute_update_private_metadata_for_item,
item_contains_proper_private_metadata,
)
d... | 44 | 1,347 |
ipython | IPython/terminal/interactiveshell.py | .py | """IPython terminal interface using prompt_toolkit"""
import os
import sys
import inspect
from warnings import warn
from IPython.core.async_helpers import get_asyncio_loop
from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC
from IPython.core.kitty import (
display_formatter_default_act... | 1,148 | 41,019 |
openvino | tests/layer_tests/pytorch_tests/test_pixel_shuffle.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestPixelShuffle(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(*self.shape),)
def create_model(self, upscale_factor):
... | 99 | 3,385 |
mlflow | tests/data/test_delta_dataset_source.py | .py | import json
from unittest import mock
import pandas as pd
import pytest
from mlflow.data.dataset_source_registry import get_dataset_source_from_json
from mlflow.data.delta_dataset_source import DeltaDatasetSource
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_managed_catalog_messages_pb2 ... | 249 | 9,492 |
hydra | plugins/hydra_ray_launcher/hydra_plugins/hydra_ray_launcher/ray_aws_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from typing import Any, Optional, Sequence, cast
from hydra.core.utils import JobReturn
from hydra.plugins.launcher import Launcher
from hydra.types import HydraContext, TaskFunction
from omegaconf import DictConfig
from ._config im... | 67 | 1,961 |
mlflow | tests/h2o/test_h2o_model_export.py | .py | # pep8: disable=E501
import json
import os
from typing import Any, NamedTuple
from unittest import mock
import h2o
import numpy as np
import pandas as pd
import pytest
import yaml
from h2o.estimators.gbm import H2OGradientBoostingEstimator
from sklearn import datasets
import mlflow
import mlflow.h2o
import mlflow.py... | 391 | 14,427 |
luigi | luigi/contrib/target.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... | 89 | 2,812 |
astropy | astropy/units/utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Miscellaneous utilities for `astropy.units`.
None of the functions in the module are meant for use outside of the
package.
"""
from fractions import Fraction
from typing import SupportsFloat
import numpy as np
from numpy import finfo
from .errors i... | 143 | 5,012 |
confluent-kafka-python | tests/integration/consumer/test_consumer_wakeable_poll_consume.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2024 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 145 | 5,897 |
conda | docs/source/_extensions/conda_umls.py | .py | #!/usr/bin/env python
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import fileinput
import os
import sys
from pylint.pyreverse.main import Run
here = os.path.dirname(__file__)
# files and folders to ignore during generating the UML files
ignore = [
"_vendor.py",
"compat.py",
... | 111 | 3,174 |
mlflow | mlflow/store/db_migrations/versions/7ac759974ad8_update_run_tags_with_larger_limit.py | .py | """Update run tags with larger limit
Create Date: 2019-07-30 16:36:54.256382
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "7ac759974ad8"
down_revision = "df50e92ffc5e"
branch_labels = None
depends_on = None
def upgrade():
# Use batch mode so that we ca... | 35 | 966 |
openvino | tools/benchmark_tool/openvino/tools/benchmark/utils/utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from collections import defaultdict
from datetime import timedelta
import enum
from openvino import Core, Model, PartialShape, Dimension, Layout, Type, serialize, properties, OVAny
from openvino.preprocess import PrePostProcessor
from .... | 835 | 33,649 |
textual | src/textual/widgets/_switch.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, ClassVar
from rich.console import RenderableType
if TYPE_CHECKING:
from textual.app import RenderResult
from typing_extensions import Self
from textual.binding import Binding, BindingType
from textual.events import Click
from textual.geome... | 222 | 6,305 |
pyomo | pyomo/contrib/trustregion/plugins.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... | 23 | 1,081 |
pyomo | pyomo/contrib/mindtpy/util.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,021 | 37,480 |
clearml | clearml/backend_api/schema/action.py | .py | import attr
from attr.validators import and_, instance_of, optional
from typing import Any
# noinspection PyTypeChecker
sequence = instance_of((list, tuple))
def sequence_of(types: type) -> attr.validators._AndValidator:
def validator(_: Any, attrib: attr.Attribute, value: Any) -> None:
assert all(isinst... | 35 | 1,236 |
gunicorn | examples/streaming_chat/gunicorn_conf.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
bind = "0.0.0.0:8000"
workers = 2
worker_class = "asgi"
# Dirty worker config
dirty_apps = ["streaming_chat.chat_app:ChatApp"]
dirty_workers = 1
dirty_timeout = 60
| 13 | 271 |
probability | tensorflow_probability/python/experimental/vi/automatic_structured_vi_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... | 542 | 22,249 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.