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
onnxruntime
onnxruntime/python/tools/transformers/fusion_rotary_attention.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import logging import numpy as np from fusion_attention import FusionAt...
1,789
77,850
conda
tests/test_exceptions.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause import getpass import json import sys from contextlib import nullcontext from datetime import timedelta from unittest.mock import patch import pytest import requests from pytest import CaptureFixture, MonkeyPatch from pytest_mock import MockerF...
1,724
51,940
probability
tensorflow_probability/python/experimental/util/jit_public_methods_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...
148
5,654
wandb
tests/system_tests/test_artifacts/test_artifact_saver.py
.py
from __future__ import annotations from unittest.mock import Mock from pytest import mark, raises from wandb.sdk.artifacts.artifact_saver import ArtifactSaver from wandb.sdk.internal import file_pusher, file_stream, internal_api def mock_upload_urls( project: str, files, run=None, entity=None, d...
132
3,829
hatch
tests/cli/check/test_check_types.py
.py
from __future__ import annotations import pytest from hatch.config.constants import ConfigEnvVars from hatch.utils.toml import load_toml_data class TestDefaults: def test_check(self, hatch, temp_dir, config_file, env_run): config_file.model.template.plugins["default"]["tests"] = False config_fil...
207
6,955
openvino
setup.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os.path import sys import errno import subprocess # nosec import platform import re import shutil import multiprocessing import logging as log from fnmatch import fnmatchcase from pathlib import Path from ...
839
34,321
sqlmap
lib/request/dns.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ from __future__ import print_function import binascii import collections import errno import os import re import socket import struct import threading import time try: from ...
320
11,382
black
tests/data/cases/fmtskip10.py
.py
def foo(): return "mock" # fmt: skip if True: print("yay") # fmt: skip for i in range(10): print(i) # fmt: skip if True: print("this"); print("that") # fmt: skip while True: print("loop"); break # fmt: skip for x in [1, 2]: print(x); print("done") # fmt: skip def f(x: int): return x # fmt: skip j = 1 # fmt: ...
22
644
astropy
astropy/modeling/tests/test_fitting_parallel.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import os import re import pytest pytest.importorskip("dask") import numpy as np from dask import array as da from numpy.testing import assert_allclose from astropy import units as u from astropy.modeling.fitting import ( FitInfoArrayContainer, ...
1,195
36,237
jupytext
tests/functional/others/test_pytest.py
.py
import pytest from jupytext.cli import jupytext def test_run_pytest_ok( tmpdir, text="""This is a notebook with a test that is supposed to pass ```python def test_ok(): assert True ``` """, ): tmp_md = str(tmpdir.join("notebook.md")) with open(tmp_md, "w") as fp: fp.write(text) jupyte...
36
712
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_softmax.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # softmax paddle model generator # import numpy as np import sys from save_model import saveModel def softmax(name: str, x, axis): import paddle paddle.enable_static() node_x = paddle.static.data(name='x', shape=x.shape,...
49
1,189
wandb
tests/unit_tests/test_weave.py
.py
from __future__ import annotations import sys import types from unittest.mock import MagicMock import pytest import wandb import wandb.integration.weave.weave as wandb_weave_integration from wandb.errors import UsageError from tests.fixtures.mock_wandb_log import MockWandbLog @pytest.fixture() def fake_weave_init(...
262
7,793
beam
sdks/python/apache_beam/io/gcp/gcsio_integration_test.py
.py
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not us...
333
12,912
saleor
saleor/graphql/context.py
.py
from typing import cast from django.contrib.auth import authenticate from django.http import HttpRequest from django.utils import timezone from django.utils.functional import SimpleLazyObject from ..account.models import User from ..app.models import App from ..core.auth import get_token_from_request from ..core.jwt ...
97
3,530
python-prompt-toolkit
examples/prompts/terminal-title.py
.py
#!/usr/bin/env python from prompt_toolkit import prompt from prompt_toolkit.shortcuts import set_title if __name__ == "__main__": set_title("This is the terminal title") answer = prompt("Give me some input: ") set_title("") print(f"You said: {answer}")
11
271
confluent-kafka-python
src/confluent_kafka/admin/_cluster.py
.py
# Copyright 2022 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 agreed to in writing, s...
54
1,819
lemur
lemur/tests/test_endpoints.py
.py
import pytest from lemur.endpoints.views import * # noqa from lemur.tests.factories import EndpointFactory, CertificateFactory from .vectors import ( VALID_ADMIN_API_TOKEN, VALID_ADMIN_HEADER_TOKEN, VALID_USER_HEADER_TOKEN, ) def test_rotate_certificate(client, source_plugin): from lemur.deploymen...
219
5,956
wagtail
wagtail/api/validators.py
.py
from functools import cached_property from typing import Any, Optional from django.db.models import Model from django.shortcuts import get_object_or_404 from pydantic import BaseModel, TypeAdapter, computed_field, model_validator from wagtail.api import APIField from wagtail.models import Site class APIFieldValidat...
109
3,376
kafka
tests/kafkatest/services/connect.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 ...
594
28,264
black
scripts/make_width_table.py
.py
"""Generates a width table for Unicode characters. This script generates a width table for Unicode characters that are not narrow (width 1). The table is written to src/black/_width_table.py (note that although this file is generated, it is checked into Git) and is used by the char_width() function in src/black/string...
67
2,356
mlflow
tests/autogen/test_autogen_autolog.py
.py
import pytest from autogen_agentchat.agents import AssistantAgent from autogen_agentchat.messages import MultiModalMessage from autogen_core import FunctionCall, Image from autogen_core.models import CreateResult from autogen_ext.models.replay import ReplayChatCompletionClient import mlflow from mlflow.entities.span i...
372
11,367
mlflow
tests/utils/test_oss_registry_utils.py
.py
from unittest import mock import pytest from mlflow.exceptions import MlflowException from mlflow.utils.oss_registry_utils import get_oss_host_creds from mlflow.utils.rest_utils import MlflowHostCreds @pytest.mark.parametrize( ("server_uri", "expected_creds"), [ ("uc:databricks-uc", MlflowHostCreds(...
42
1,546
probability
tensorflow_probability/python/internal/backend/numpy/gen/linear_operator_circulant.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. # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...
1,599
63,092
probability
tensorflow_probability/python/internal/hypothesis_testlib.py
.py
# Copyright 2018 The TensorFlow Probability Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
1,021
39,204
openvino
tests/layer_tests/onnx_tests/test_embedding_bag.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os import numpy as np import pytest pytest.importorskip("openvino.tools.mo", reason="Ticket - 157136") import torch import torch.nn as nn from common.layer_test_class import CommonLayerTest, check_ir_version from unit_tests.util...
139
6,264
mlflow
tests/genai/judges/optimizers/test_dspy_utils.py
.py
import json import time from unittest.mock import MagicMock, Mock, patch import dspy import pytest from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan from mlflow.entities.assessment import Feedback from mlflow.entities.assessment_source import AssessmentSource, AssessmentSourceType from mlflow.entit...
769
26,718
beam
sdks/python/apache_beam/examples/snippets/transforms/aggregation/batchelements.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");...
65
1,760
astropy
astropy/coordinates/tests/test_sky_coord.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Tests for the SkyCoord class. Note that there are also SkyCoord tests in test_api_ape5.py """ import copy from copy import deepcopy import numpy as np import numpy.testing as npt import pytest from erfa import ErfaWarning from astropy import units...
2,148
73,239
django-cms
cms/extensions/__init__.py
.py
from .admin import PageContentExtensionAdmin, PageExtensionAdmin from .extension_pool import extension_pool from .models import PageContentExtension, PageExtension __all__ = [ 'extension_pool', 'PageContentExtension', 'PageContentExtensionAdmin', 'PageExtension', 'PageExtensionAdmin' ]
12
308
pyomo
pyomo/contrib/mcpp/tests/test_mcpp.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...
340
12,664
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/demo_txt2img_xl.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Modified from TensorRT demo diffusion, which has the following license...
270
9,948
gunicorn
examples/dirty_example/test_protocol.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. #!/usr/bin/env python """ Test script to demonstrate the Dirty Binary Protocol layer. The binary protocol uses a 16-byte header + TLV-encoded payloads for efficient binary data transfer without base64 encoding ove...
252
7,981
saleor
saleor/graphql/order/mutations/order_line_update.py
.py
import graphene from django.core.exceptions import ValidationError from ....core.exceptions import InsufficientStock from ....core.tracing import traced_atomic_transaction from ....order import models from ....order.error_codes import OrderErrorCode from ....order.fetch import OrderLineInfo from ....order.utils import...
130
4,785
pyomo
pyomo/contrib/pyros/uncertainty_sets.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...
4,387
144,686
coremltools
deps/protobuf/objectivec/DevTools/pddm.py
.py
#! /usr/bin/python # # Protocol Buffers - Google's data interchange format # Copyright 2015 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 ...
691
24,062
metrics
src/torchmetrics/retrieval/fall_out.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...
200
8,186
biopython
Bio/Phylo/NexusIO.py
.py
# Copyright (C) 2009 by Eric Talevich (eric.talevich@gmail.com) # # 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. """I/O function w...
84
2,672
ipython
tests/test_sysinfo.py
.py
# coding: utf-8 """Test suite for our sysinfo utilities.""" # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. import json import sys import platform import pytest from IPython.utils import sysinfo def test_json_getsysinfo(): """Test that get_sys_info returns ...
68
1,501
saleor
saleor/tests/e2e/shipping_zone/utils/shipping_method.py
.py
import base64 from ...utils import get_graphql_content SHIPPING_PRICE_CREATE_MUTATION = """ mutation CreateShippingRate($input: ShippingPriceInput!) { shippingPriceCreate(input: $input) { errors { field code message } shippingZone { id } shippingMethod { id ch...
85
1,940
pyomo
examples/pyomo/columngeneration/cutting_stock.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...
161
4,584
textual
src/textual/map_geometry.py
.py
from __future__ import annotations from typing import NamedTuple from textual.geometry import Region, Size, Spacing class MapGeometry(NamedTuple): """Defines the absolute location of a Widget.""" region: Region """The (screen) [region][textual.geometry.Region] occupied by the widget.""" order: tupl...
35
1,363
mkdocs
mkdocs/tests/gh_deploy_tests.py
.py
import unittest from unittest import mock from ghp_import import GhpError # type: ignore from mkdocs import __version__ from mkdocs.commands import gh_deploy from mkdocs.exceptions import Abort from mkdocs.tests.base import load_config class TestGitHubDeploy(unittest.TestCase): @mock.patch('subprocess.Popen') ...
186
7,544
saleor
saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_user_cannot_use_voucher_for_staff_only.py
.py
import pytest from ....product.utils.preparing_product import prepare_product from ....shop.utils import prepare_default_shop from ....utils import assign_permissions from ....vouchers.utils import create_voucher, create_voucher_channel_listing from ...utils import checkout_create, raw_checkout_add_promo_code def pr...
112
3,074
coremltools
coremltools/converters/mil/mil/ops/registry.py
.py
# Copyright (c) 2020, 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 collections import defaultdict from coremltools import _logger as logger from coremltools.conve...
192
8,946
coremltools
coremltools/converters/mil/mil/passes/pass_registry.py
.py
# Copyright (c) 2020, 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 inspect from typing import Dict, Optional, Text, Type from coremltools import _logger as logg...
66
2,275
textual
tests/workers/test_work_decorator.py
.py
import asyncio from time import sleep from typing import Callable, List, Tuple import pytest from textual import work from textual._work_decorator import WorkerDeclarationError from textual.app import App from textual.worker import Worker, WorkerState, WorkType class WorkApp(App): worker: Worker def __init...
187
6,140
textual
tests/command_palette/test_interaction.py
.py
from textual.app import App from textual.command import CommandList, CommandPalette, Hit, Hits, Provider class SimpleSource(Provider): async def search(self, query: str) -> Hits: def goes_nowhere_does_nothing() -> None: pass for _ in range(100): yield Hit(1, query, goes_no...
54
2,190
gunicorn
tests/requests/invalid/009.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. from gunicorn.http.errors import LimitRequestHeaders request = LimitRequestHeaders
7
189
mlflow
tests/pyfunc/custom_model/loader.py
.py
import pickle from custom_model.mod1 import mod2 __all__ = ["mod2"] def _load_pyfunc(path): with open(path, "rb") as f: return pickle.load(f, encoding="latin1")
11
177
mlflow
dev/clint/tests/rules/test_subprocess_check_call.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules import SubprocessCheckCall def test_subprocess_check_call(index: SymbolIndex) -> None: code = """ import subprocess # Bad subprocess.run(["echo", "hel...
30
800
sqlmap
lib/controller/controller.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ from __future__ import division import os import re import subprocess import time from lib.controller.action import action from lib.controller.checks import checkConnection from...
961
44,751
metrics
tests/unittests/wrappers/test_transformations.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...
269
11,393
onnx
onnx/reference/ops/op_clip.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 Clip_6(OpRun): def _run(self, data, min=None, max=None): # type: ignore[override] # noqa: A002 amin = min amax = ...
26
806
saleor
saleor/graphql/account/tests/mutations/account/test_account_delete.py
.py
import datetime from unittest.mock import MagicMock, patch from django.core.files import File from django.utils import timezone from freezegun import freeze_time from ......account.models import User from ......attribute.models import AssignedUserAttributeValue, AttributeValue from ......core.tokens import ( acco...
260
9,038
probability
tensorflow_probability/python/math/psd_kernels/rational_quadratic.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...
240
10,084
mlflow
tests/store/tracking/test_plugin_validation.py
.py
import subprocess import sys from mlflow.store.tracking.sqlalchemy_store import SqlAlchemyStore def test_sqlalchemy_store_import_does_not_cause_circular_import(): """ Regression test for circular import issue (https://github.com/mlflow/mlflow/issues/18386). Store plugins that inherit from SqlAlchemyStor...
105
4,153
lemur
lemur/plugins/lemur_csr/tests/test_csr_export.py
.py
import pytest from lemur.tests.vectors import INTERNAL_PRIVATE_KEY_A_STR, INTERNAL_CERTIFICATE_A_STR def test_export_certificate_to_csr(app): from lemur.plugins.base import plugins p = plugins.get("openssl-csr") options = [] with pytest.raises(Exception): p.export(INTERNAL_CERTIFICATE_A_STR, ...
15
448
clearml
clearml/utilities/pigar/unpack.py
.py
# -*- coding: utf-8 -*- from __future__ import print_function, division, absolute_import import io import re import string import tarfile import zipfile from types import TracebackType from typing import List, Optional, Type, Any class Archive(object): """Archive provides a consistent interface for unpacking ...
127
3,870
mlflow
tests/tracing/test_archival.py
.py
from unittest import mock import pytest from mlflow.tracing.archival import ( disable_databricks_trace_archival, enable_databricks_trace_archival, ) from mlflow.version import IS_TRACING_SDK_ONLY if IS_TRACING_SDK_ONLY: pytest.skip("Databricks archival enablement requires skinny", allow_module_level=True...
79
2,939
sphinx
sphinx/environment/collectors/toctree.py
.py
"""Toctree collector for sphinx.environment.""" from __future__ import annotations from typing import TYPE_CHECKING, cast from docutils import nodes from sphinx import addnodes from sphinx.domains.std import StandardDomain from sphinx.environment.adapters.toctree import note_toctree from sphinx.environment.collecto...
400
17,543
loguru
tests/test_add_option_context.py
.py
import multiprocessing import os from unittest.mock import patch import pytest from loguru import logger def test_using_multiprocessing_directly_if_context_is_none(): logger.add(lambda _: None, enqueue=True, context=None) assert multiprocessing.get_start_method(allow_none=True) is not None @pytest.mark.sk...
68
2,563
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/Notebook with html and latex cells.py
.py
# --- # jupyter: # jupytext: # cell_markers: region,endregion # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # region language="html" # <p><a href="https://github.com/mwouts/jupytext", style="color: rgb(0,0,255)">Jupytext</a> on GitHub</p> # endregion # region lang...
29
625
openvino
tests/layer_tests/jax_tests/test_sub.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import jax.numpy as jnp import numpy as np import pytest from jax_layer_test_class import JaxLayerTest def get_rand_jnp_array(shape, dtype): if dtype in [np.float32, np.float16, np.float64]: return jnp.array(np.random.unif...
138
4,499
deap
doc/code/tutorials/part_4/installSN.py
.py
from distutils.core import setup, Extension module1 = Extension('SNC', sources = ['SNC.cpp']) setup (name = 'SNC', version = '1.0', description = 'Sorting network evaluator', ext_modules = [module1])
10
244
pyomo
pyomo/scripting/convert.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...
242
7,234
hatch
tests/backend/metadata/test_custom_hook.py
.py
import re import pytest from hatchling.metadata.custom import CustomMetadataHook from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT def test_no_path(isolation): config = {"path": ""} with pytest.raises(ValueError, match="Option `path` for metadata hook `custom` must not be empty if defined"): ...
110
2,927
structlog
src/structlog/_frames.py
.py
# SPDX-License-Identifier: MIT OR Apache-2.0 # This file is dual licensed under the terms of the Apache License, Version # 2.0, and the MIT License. See the LICENSE file in the root of this # repository for complete details. from __future__ import annotations import sys import traceback from collections.abc import ...
94
2,394
coremltools
coremltools/models/nearest_neighbors/__init__.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 from .builder import KNearestNeighborsClassifierBuilder
7
272
astropy
astropy/samp/tests/test_hub.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import platform import time import pytest from astropy.samp import conf from astropy.samp.hub import SAMPHubServer def setup_module(module): conf.use_internet = False @pytest.mark.skipif(platform.system() == "Darwin", reason="Takes too long on O...
48
1,224
sqlmap
plugins/dbms/mimersql/syntax.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.convert import getOrds from plugins.generic.syntax import Syntax as GenericSyntax class Syntax(GenericSyntax): @staticmethod def escape(expression, quote=Tr...
24
806
pyomo
examples/dae/simulator_dae_example.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...
109
3,200
mlflow
tests/langgraph/sample_code/langgraph_prebuilt.py
.py
import itertools from typing import Literal from langchain_core.messages import AIMessage, ToolCall from langchain_core.outputs import ChatGeneration, ChatResult from langchain_core.tools import tool from langchain_openai import ChatOpenAI from langgraph.prebuilt import create_react_agent import mlflow class FakeOp...
50
1,556
saleor
saleor/warehouse/tests/fixtures/stock.py
.py
import pytest from ...models import Stock @pytest.fixture def stock(variant, warehouse): return Stock.objects.create( product_variant=variant, warehouse=warehouse, quantity=15 ) @pytest.fixture def stocks_for_cc(warehouses_for_cc, product_variant_list, product_with_two_variants): return Stock.o...
64
1,889
lemur
lemur/plugins/lemur_acme/challenge_types.py
.py
""" .. module: lemur.plugins.lemur_acme.plugin :platform: Unix :synopsis: This module contains the different challenge types for ACME implementations :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. .. moduleauthor:: Mathias Petermann <mathias.p...
310
13,304
wagtail
wagtail/api/tests/test_rich_text_format.py
.py
from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase, TestCase, override_settings from wagtail.api.rich_text import APIRichText, RichTextFormatError from wagtail.api.v2.serializers import RichTextFieldSerializer from wagtail.test.utils import Page class TestRichTextFormatRes...
177
7,031
astropy
astropy/modeling/tabular.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Tabular models. Tabular models of any dimension can be created using `tabular_model`. For convenience `Tabular1D` and `Tabular2D` are provided. Examples -------- >>> table = np.array([[ 3., 0., 0.], ... [ 0., 2., 0.], ... ...
414
12,603
textual
src/textual/widgets/tree.py
.py
"""Make non-widget Tree support classes available.""" from textual.widgets._tree import ( AddNodeError, EventTreeDataType, NodeID, RemoveRootError, TreeDataType, TreeNode, UnknownNodeID, ) __all__ = [ "AddNodeError", "EventTreeDataType", "NodeID", "RemoveRootError", "Tr...
22
372
textual
docs/examples/app/suspend.py
.py
from os import system from textual import on from textual.app import App, ComposeResult from textual.widgets import Button class SuspendingApp(App[None]): def compose(self) -> ComposeResult: yield Button("Open the editor", id="edit") @on(Button.Pressed, "#edit") def run_external_editor(self) ->...
21
445
astropy
astropy/utils/collections.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ A module containing specialized collection classes. """ class HomogeneousList(list): """ A subclass of list that contains only elements of a given type or types. If an item that is not of the specified type is added to the list, a `T...
59
1,508
textual
docs/examples/guide/layout/dock_layout1_sidebar.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static TEXT = """\ Docking a widget removes it from the layout and fixes its position, aligned to either the top, right, bottom, or left edges of a container. Docked widgets will not scroll out of view, making them ideal for sticky headers, footer...
23
620
onnx
onnx/_mapping.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from typing import NamedTuple import ml_dtypes import numpy as np from onnx.onnx_pb import TensorProto class TensorDtypeMap(NamedTuple): np_dtype: np.dtype storage_dtype: int name: str ...
120
4,207
textual
docs/examples/styles/grid_size_both.py
.py
from textual.app import App from textual.containers import Grid from textual.widgets import Label class MyApp(App): CSS_PATH = "grid_size_both.tcss" def compose(self): yield Grid( Label("1"), Label("2"), Label("3"), Label("4"), Label("5"), ...
22
390
sqlmap
plugins/dbms/maxdb/connector.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 SqlmapUnsupportedFeatureException from plugins.generic.connector import Connector as GenericConnector class Connector(GenericConnector): def co...
16
506
scikit-bio
skbio/io/format/fastq.py
.py
r"""FASTQ format (:mod:`skbio.io.format.fastq`) =========================================== .. currentmodule:: skbio.io.format.fastq The FASTQ file format (``fastq``) stores biological (e.g., nucleotide) sequences and their quality scores in a simple plain text format that is both human-readable and easy to parse. Th...
674
22,405
black
tests/data/cases/pyi_docstring_blank_lines.py
.py
# flags: --preview --pyi import sys from typing import overload def top_level_comment() -> None: """docs""" # leading comment for the next statement top_level_attr: int def top_level_if() -> None: """docs""" if sys.version_info >= (3, 12): top_level_if_attr: int class C: def before_comment(self) -> N...
165
3,892
returns
returns/pointfree/bind_io.py
.py
from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING, TypeVar from returns.interfaces.specific.io import IOLikeN from returns.primitives.hkt import Kinded, KindN, kinded if TYPE_CHECKING: from returns.io import IO # noqa: WPS433 _FirstType_contra = TypeVar('_...
62
1,794
jupytext
tests/data/notebooks/outputs/ipynb_to_script/Notebook with metadata and long cells.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # # Part one - various cells # Here we have a markdown cell # # # with two blank lines # Now we have a markdown cell # with a code block inside it # # ```python # 1 + 1 # ``` # # After that cell we'll have ...
50
764
beam
sdks/python/apache_beam/io/external/gcp/pubsub.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...
182
6,861
probability
spinoffs/fun_mc/fun_mc/backends/rewrite.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...
234
8,109
openvino
tests/model_hub_tests/transformation_tests/sdpa2pa_ref_diff.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 nodes_to_compare = ("ScaledDotProductAttention", "PagedAttentionExtension", "Parameter", "ReadValue", "Assign") ref_diff_map = { "optimum-intel-internal-testing/opt-125m" : { "Assign" : -24, "PagedAttentionExtension" : 12, "Param...
921
25,103
mlflow
mlflow/demo/generators/__init__.py
.py
from mlflow.demo.generators.evaluation import EvaluationDemoGenerator from mlflow.demo.generators.issues import IssuesDemoGenerator from mlflow.demo.generators.judges import JudgesDemoGenerator from mlflow.demo.generators.prompts import PromptsDemoGenerator from mlflow.demo.generators.review_queues import ReviewQueuesD...
29
1,277
wagtail
wagtail/locales/views.py
.py
from typing import TYPE_CHECKING, Any from django.core.exceptions import PermissionDenied from django.utils.translation import gettext_lazy, ngettext_lazy from wagtail.admin import messages from wagtail.admin.ui.tables import Column, TitleColumn from wagtail.admin.views import generic from wagtail.admin.viewsets.mode...
153
4,875
beam
sdks/python/apache_beam/ml/inference/gemini_inference.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...
258
10,713
openvino
docs/articles_en/assets/snippets/ov_stateful_models_intro.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import logging as log import numpy as np import openvino as ov from openvino import opset13 as ops from openvino.op.util import VariableInfo, Variable from openvino.passes import LowLatency2, MakeStateful, Manager from openvino.utils i...
211
7,406
pyro
pyro/poutine/plate_messenger.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 from contextlib import contextmanager from typing import TYPE_CHECKING, Iterator, Optional from pyro.poutine.broadcast_messenger import BroadcastMessenger from pyro.poutine.messenger import Messenger, block_messengers from pyro.po...
91
3,167
beam
sdks/python/apache_beam/examples/complete/tfidf.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...
216
8,773
pyomo
pyomo/contrib/pynumero/exceptions.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...
19
837
tqdm
examples/wrapping_generators.py
.py
import numpy as np from tqdm.contrib import tenumerate, tmap, tzip for _ in tenumerate(range(int(1e6)), desc="builtin enumerate"): pass for _ in tenumerate(np.random.random((999, 999)), desc="numpy.ndenumerate"): pass for _ in tzip(np.arange(1e6), np.arange(1e6) + 1, desc="builtin zip"): pass mapped = ...
16
428
mlflow
tests/pytorch/test_pytorch_metric_value_conversion_utils.py
.py
import pytest import torch import mlflow from mlflow import tracking from mlflow.exceptions import INVALID_PARAMETER_VALUE, ErrorCode, MlflowException from mlflow.tracking.fluent import start_run from mlflow.tracking.metric_value_conversion_utils import convert_metric_value_to_float_if_possible def test_reraised_val...
34
1,180
sqlmap
tests/test_property.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission Property/fuzz tests for the pure parsers and transforms. Where the other test files pin specific examples, these assert INVARIANTS over hundreds of randomized (but deterministic, cros...
279
12,865