repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
openvino
tests/e2e_tests/test_utils/get_test_info.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from collections import defaultdict class TestInfo: extra_info = None e2e_models_info = None def fill_mo_args(self, **mo_params): if self.extra_info is None: self.extra_info = defaultdict(list) ...
67
2,859
beam
sdks/python/apache_beam/examples/snippets/transforms/aggregation/sum_per_key.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");...
60
1,700
coremltools
deps/protobuf/python/google/protobuf/internal/message_test.py
.py
# -*- coding: utf-8 -*- # 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 a...
2,542
102,958
textual
src/textual/validation.py
.py
""" This module provides a number of classes for validating input. See [Validating Input](/widgets/input/#validating-input) for details. """ from __future__ import annotations import math import re from abc import ABC, abstractmethod from dataclasses import dataclass, field from typing import Callable, Pattern, Se...
520
18,715
qutip
qutip/tests/solver/test_steadystate.py
.py
import numpy as np import scipy import pytest import qutip import warnings from packaging import version as pac_version from qutip.solver.steadystate import _permute_rcm, _permute_wbm import qutip.core.data as _data @pytest.mark.parametrize(['method', 'kwargs'], [ pytest.param('direct', {}, id="direct"), pyte...
340
12,281
pyomo
doc/OnlineDocs/src/data/ABCD8.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...
29
1,021
mlflow
tests/gateway/test_gateway_config_parsing.py
.py
import re import pytest import yaml from mlflow.exceptions import MlflowException from mlflow.gateway.config import ( AnthropicConfig, EndpointConfig, LiteLLMConfig, OpenAIConfig, _load_gateway_config, _resolve_api_key_from_input, _save_route_config, ) from mlflow.gateway.utils import asse...
454
15,759
saleor
saleor/core/utils/url.py
.py
from urllib.parse import urlparse, urlsplit from django.conf import settings from django.core.exceptions import ValidationError from django.core.files.storage import default_storage from django.http.request import split_domain_port, validate_host from . import build_absolute_uri def validate_storefront_url(url): ...
64
2,304
probability
tensorflow_probability/python/distributions/von_mises_fisher_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...
469
19,918
pdm
src/pdm/models/repositories/lock.py
.py
from __future__ import annotations import dataclasses import itertools import posixpath from collections.abc import Collection from functools import cached_property from pathlib import Path from typing import TYPE_CHECKING, cast from dep_logic.markers import AnyMarker, BaseMarker from pdm.cli.utils import normalize_...
305
14,416
beam
sdks/python/apache_beam/ml/anomaly/base_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...
249
7,905
openvino
tools/ovc/unit_tests/moc_tf_fe/test_models/mul_with_unknown_rank_y.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import tensorflow.compat.v1 as tf tf.reset_default_graph() with tf.Session() as sess: x = tf.placeholder(tf.float32, [3], 'x') keep_prob = tf.placeholder(tf.float32, None, 'y') tf.multiply(x, keep_prob) tf.global_variab...
16
438
beam
sdks/python/apache_beam/testing/test_utils_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...
138
4,524
beam
learning/tour-of-beam/learning-content/triggers/data-driven-trigger/python-example/task.py
.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); y...
55
2,013
biopython
Tests/test_align.py
.py
# Copyright 2000-2001 by Brad Chapman. All rights reserved. # Revisions copyright 2007-2003 by Peter Cock. All rights reserved. # This code is part of the Biopython distribution and governed by its # license. Please see the LICENSE file that should have been included # as part of this package. """Test alignment stu...
1,113
75,232
openvino
tests/layer_tests/tensorflow_lite_tests/test_tfl_Unique.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest import tensorflow as tf from common.tflite_layer_test_class import TFLiteLayerTest np.random.seed(42) test_params = [ {'shape': [15]}, {'shape': [1]} ] class TestTFLiteUniqueLayerTest(TFLiteL...
38
1,161
openvino
docs/articles_en/assets/snippets/compile_model_npu.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import openvino as ov from snippets import get_model def main(): model = get_model() core = ov.Core() if "NPU" not in core.available_devices: return 0 #! [compile_model_default_npu] core = ov.Core() co...
19
403
saleor
saleor/core/taxes.py
.py
from dataclasses import dataclass from decimal import Decimal from prices import Money, TaxedMoney TAX_ERROR_FIELD_LENGTH = 255 class TaxError(Exception): """Default tax error.""" class TaxDataError(Exception): """Error in tax data received from tax app or plugin.""" def __init__(self, message: str, ...
64
1,495
pyomo
pyomo/mpec/plugins/solver1.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...
136
5,111
saleor
saleor/plugins/avatax/tests/test_tasks.py
.py
import os from dataclasses import asdict from urllib.parse import urljoin import pytest from ....core.taxes import TaxError from ....order import OrderEvents from .. import AvataxConfiguration, get_api_url, get_order_request_data from ..tasks import api_post_request_task @pytest.mark.vcr def test_api_post_request_t...
154
5,240
onnxruntime
plugin-ep-webgpu/csharp/test/WebGpuEpNuGetTest/generate_mul_model.py
.py
"""Generate a simple Mul ONNX model for testing. Produces mul.onnx in the same directory as this script. The model computes z = x * y (element-wise) for float32 tensors of shape [2, 3]. """ import os from onnx import TensorProto, checker, helper, save X = helper.make_tensor_value_info("x", TensorProto.FLOAT, [2, 3]...
26
851
textual
docs/examples/events/dictionary.py
.py
import asyncio try: import httpx except ImportError: raise ImportError("Please install httpx with 'pip install httpx' ") from rich.json import JSON from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widgets import Input, Static class DictionaryApp(App): ...
46
1,387
qutip
qutip/legacy/__init__.py
.py
import warnings warnings.warn("Function in legacy are untested.") del warnings from .nonmarkov.memorycascade import MemoryCascade
6
131
coremltools
coremltools/converters/mil/frontend/tensorflow/tfssa.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 copy from coremltools import _logger as logger from coremltools.converters.mil.mil import typ...
550
21,046
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/jupyter_with_raw_cell_with_invalid_yaml.py
.py
# --- # title: Exception: Test # jupyter: # jupytext: # cell_markers: region,endregion # kernelspec: # display_name: Python 3 (ipykernel) # language: python # name: python3 # --- 1 + 2 + 3
13
210
onnxruntime
onnxruntime/test/python/quantization/test_qdq.py
.py
#!/usr/bin/env python # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # ---------------------------------------------------------------...
2,604
119,537
saleor
saleor/graphql/app/mutations/app_reenable_sync_webhooks.py
.py
import logging import time from typing import cast import graphene from django.core.exceptions import ValidationError from ....app import models as app_models from ....app.error_codes import AppErrorCode from ....graphql.app.enums import CircuitBreakerState from ....graphql.app.types import App from ....permission.en...
76
2,527
probability
discussion/robust_inverse_graphics/util/plot_util.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...
361
10,781
wagtail
wagtail/tests/streamfield_migrations/test_migrations.py
.py
import datetime import json from django.db import connection from django.db.models import F, JSONField, TextField from django.db.models.functions import Cast from django.test import TestCase from django.utils import timezone from wagtail.blocks.migrations.operations import ( RenameStreamChildrenOperation, Str...
333
11,933
onnxruntime
orttraining/orttraining/python/training/ortmodule/_graph_execution_manager_factory.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import Logger from ._fallback import _FallbackManager from...
31
1,093
hydra
examples/plugins/example_launcher_plugin/example/my_app.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import hydra from omegaconf import OmegaConf, DictConfig @hydra.main(config_path="conf", config_name="config") def my_app(cfg: DictConfig) -> None: print(OmegaConf.to_yaml(cfg)) if __name__ == "__main__": my_app()
13
297
mlflow
examples/evaluation/evaluate_with_custom_code_metrics.py
.py
import os import openai import pandas as pd import mlflow from mlflow.metrics import make_metric from mlflow.metrics.base import MetricValue, standard_aggregations assert "OPENAI_API_KEY" in os.environ, "Please set the OPENAI_API_KEY environment variable." # Helper function to check if a string is valid python cod...
68
1,783
conda
tests/plugins/test_virtual_packages.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from __future__ import annotations import os import platform from typing import TYPE_CHECKING import pytest from pytest import MonkeyPatch import conda.core.index from conda import __version__, plugins from conda.auxlib import NULL from conda...
520
17,039
onnx
onnx/backend/test/report/coverage.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import csv import datetime import os from collections import OrderedDict, defaultdict from typing import IO, Any from tabulate import tabulate import onnx from onnx import GraphProto, defs, helper _al...
267
10,942
beam
sdks/python/apache_beam/io/mongodbio.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...
824
28,907
sphinx
tests/test_pycode/test_pycode_parser.py
.py
"""Test pycode.parser.""" from __future__ import annotations from sphinx.pycode.parser import Parser from sphinx.util.inspect import signature_from_str def test_comment_picker_basic() -> None: source = ( 'a = 1 + 1 #: assignment\n' 'b = 1 +\\\n 1 #: assignment including a CR\n' 'c ...
598
16,317
eve
eve/default_settings.py
.py
# -*- coding: utf-8 -*- """ eve.settings ~~~~~~~~~~~~ Default API settings. These can be overridden by editing this file or, more appropriately, by using a custom settings module (see the optional 'settings' argument or the EVE_SETTING environment variable). :copyright: (c) 2017 by Nicola Iar...
280
9,793
slimit
src/slimit/minifier.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...
71
2,652
coremltools
coremltools/test/optimize/torch/quantization/test_utils.py
.py
# Copyright (c) 2024, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import pytest import torch import torch.ao.quantization as _aoquant from coremltools.optimize.torch....
117
3,776
scikit-optimize
examples/exploration-vs-exploitation.py
.py
""" =========================== Exploration vs exploitation =========================== Sigurd Carlen, September 2019. Reformatted by Holger Nahrstaedt 2020 .. currentmodule:: skopt We can control how much the acqusition function favors exploration and exploitation by tweaking the two parameters kappa and xi. Highe...
188
8,244
pyomo
pyomo/repn/tests/test_standard_form.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...
362
13,142
textual
tests/renderables/test_sparkline.py
.py
from collections import UserList, deque from typing import Sequence import pytest from tests.utilities.render import render from textual.renderables.sparkline import Sparkline GREEN = "\x1b[38;2;0;255;0m" RED = "\x1b[38;2;255;0;0m" BLENDED = "\x1b[38;2;127;127;0m" # Color between red and green STOP = "\x1b[0m" de...
105
2,754
sqlmap
plugins/dbms/oracle/enumeration.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ from lib.core.common import getLimitRange from lib.core.common import isAdminFromPrivileges from lib.core.common import isInferenceAvailable from lib.core.common import isNoneValu...
166
6,001
attrs
src/attr/_config.py
.py
# SPDX-License-Identifier: MIT __all__ = ["get_run_validators", "set_run_validators"] _run_validators = True def set_run_validators(run): """ Set whether or not validators are run. By default, they are run. .. deprecated:: 21.3.0 It will not be removed, but it also will not be moved to new ``at...
32
841
beam
sdks/python/apache_beam/io/watermark_estimators.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...
153
5,265
deap
doc/code/tutorials/part_2/2_2_3_arithmetic_expression.py
.py
## 2.2.3 Arithmetic expression import operator from deap import base from deap import creator from deap import gp from deap import tools pset = gp.PrimitiveSet("MAIN", arity=1) pset.addPrimitive(operator.add, 2) pset.addPrimitive(operator.sub, 2) pset.addPrimitive(operator.mul, 2) creator.create("FitnessMin", base.F...
22
644
mamba
libmambapy/src/libmambapy/version.py
.py
version_info = ("2", "9", "0") version_prerelease = "" __version__ = ".".join(map(str, version_info)) if version_prerelease != "": __version__ = f"{__version__}.{version_prerelease}"
6
187
cvxpy
cvxpy/__init__.py
.py
""" Copyright, the CVXPY authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software ...
127
3,645
mlflow
mlflow/tracing/otel/translation/spring_ai.py
.py
""" Translation utilities for Spring AI semantic conventions. Spring AI uses OpenTelemetry GenAI semantic conventions but stores prompt/completion content in events rather than attributes: - gen_ai.content.prompt event with gen_ai.prompt attribute - gen_ai.content.completion event with gen_ai.completion attribute Ref...
98
3,218
probability
tensorflow_probability/python/experimental/bayesopt/acquisition/__init__.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...
47
2,704
wagtail
wagtail/models/pages.py
.py
from __future__ import annotations import functools import logging import posixpath import uuid import warnings from typing import TYPE_CHECKING import swapper from django.conf import settings from django.contrib.auth.models import Group, Permission from django.contrib.contenttypes.fields import GenericRelation from ...
3,006
111,749
saleor
saleor/plugins/webhook/conftest.py
.py
import pytest from ..manager import get_plugins_manager @pytest.fixture def webhook_plugin(settings): def factory(): settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"] manager = get_plugins_manager(allow_replica=False) manager.get_all_plugins() return manager.globa...
15
353
kombu
kombu/transport/confluentkafka.py
.py
"""confluent-kafka transport module for Kombu. Kafka transport using confluent-kafka library. **References** - http://docs.confluent.io/current/clients/confluent-kafka-python **Limitations** The confluent-kafka transport does not support PyPy environment. Features ======== * Type: Virtual * Supports Direct: Yes *...
381
12,141
onnx
onnx/backend/test/case/base.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import inspect from collections import defaultdict from textwrap import dedent from typing import Any, ClassVar import numpy as np def process_snippet(op_name: str, name: str, export: Any) -> tuple[st...
48
1,504
deap
examples/de/dynamic.py
.py
# This file is part of DEAP. # # DEAP is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation, either version 3 of # the License, or (at your option) any later version. # # DEAP is distributed ...
155
5,807
saleor
saleor/attribute/tests/test_utils.py
.py
import pytest from ...attribute.models import AssignedPageAttributeValue from ...product.models import ProductType from .. import AttributeInputType, AttributeType from ..models import Attribute, AttributeValue from ..utils import ( associate_attribute_values_to_instance, validate_attribute_owns_values, ) from...
288
9,664
openvino
tests/layer_tests/pytorch_tests/test_kthvalue.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest import torch from pytorch_layer_test_class import PytorchLayerTest class aten_kthvalue(torch.nn.Module): def __init__(self, k, dim, keepdim): super().__init__() self.k = k s...
55
1,676
textual
tests/test_compositor_regions_to_spans.py
.py
from textual._compositor import Compositor from textual.geometry import Region def test_regions_to_ranges_no_regions(): assert list(Compositor._regions_to_spans([])) == [] def test_regions_to_ranges_single_region(): regions = [Region(0, 0, 3, 2)] assert list(Compositor._regions_to_spans(regions)) == [ ...
55
1,520
python-prompt-toolkit
examples/prompts/up-arrow-partial-string-matching.py
.py
#!/usr/bin/env python """ Simple example of a CLI that demonstrates up-arrow partial string matching. When you type some input, it's possible to use the up arrow to filter the history on the items starting with the given input text. """ from prompt_toolkit import PromptSession from prompt_toolkit.history import InMem...
43
1,216
lemur
lemur/common/fields.py
.py
""" .. module: lemur.common.fields :platform: Unix :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. .. moduleauthor:: Kevin Glisson <kglisson@netflix.com> """ import ipaddress import warnings from datetime import datetime as dt import arrow from cry...
442
16,090
sqlmap
plugins/dbms/clickhouse/filesystem.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.filesystem import Filesystem as GenericFilesystem class Filesystem(GenericFilesystem): d...
19
678
wagtail
wagtail/test/streamfield_migrations/apps.py
.py
from django.apps import AppConfig class WagtailSnippetsTestsAppConfig(AppConfig): default_auto_field = "django.db.models.AutoField" name = "wagtail.test.streamfield_migrations" label = "streamfield_migration_tests" verbose_name = "Wagtail StreamField migration tests"
9
286
hydra
hydra/_internal/sources_registry.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from typing import Any, Dict, Type from hydra.core.singleton import Singleton from hydra.plugins.config_source import ConfigSource class SourcesRegistry(metaclass=Singleton): types: Dict[str, Type[ConfigSource]] def __init__(self) -> Non...
37
1,298
sqlmap
extra/vulnserver/vulnserver.py
.py
#!/usr/bin/env python """ vulnserver.py - Trivial SQLi vulnerable HTTP server (Note: for testing purposes) Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ from __future__ import print_function import base64 import hashlib import hmac import json impor...
1,797
88,842
saleor
saleor/graphql/account/tests/mutations/authentication/test_external_verify.py
.py
import json from unittest.mock import Mock from .....tests.utils import get_graphql_content MUTATION_EXTERNAL_VERIFY = """ mutation externalVerify($pluginId: String!, $input: JSONString!){ externalVerify(pluginId:$pluginId, input: $input){ verifyData user{ email ...
46
1,600
pyomo
examples/doc/samples/comparisons/cutstock/cutstock_cplex.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...
100
2,929
wagtail
wagtail/admin/ui/sidebar.py
.py
from collections.abc import Mapping from typing import Any from django import forms from django.urls import reverse from django.utils.functional import cached_property from wagtail.admin.staticfiles import versioned_static from wagtail.admin.telepath import Adapter, adapter class BaseSidebarAdapter(Adapter): @c...
256
6,713
openvino
tools/ovc/openvino/tools/ovc/telemetry_utils.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import argparse import numbers import os from openvino import get_version as get_rt_version # pylint: disable=no-name-in-module,import-error from openvino.tools.ovc.cli_parser import get_params_with_paths_list from openvino.tools.ovc.te...
129
4,642
mlflow
mlflow/crewai/autolog.py
.py
import inspect import json import logging import warnings from contextlib import contextmanager, nullcontext from typing import Any from packaging.version import Version import mlflow from mlflow.entities import SpanType from mlflow.entities.span import LiveSpan from mlflow.tracing.constant import SpanAttributeKey, T...
481
16,629
probability
tensorflow_probability/python/bijectors/ldj_ratio_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...
104
4,349
marshmallow
src/marshmallow/validate.py
.py
"""Validation classes for various types of data.""" from __future__ import annotations import re import typing from abc import ABC, abstractmethod from operator import attrgetter from marshmallow.exceptions import ValidationError if typing.TYPE_CHECKING: from marshmallow import types _T = typing.TypeVar("_T") ...
709
24,880
openvino
src/frontends/tensorflow/tests/test_models/gen_scripts/generate_saved_model_oob_index.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # What: Generates 7 malicious TF SavedModel directories that trigger security guards in # VariablesIndex::map_assignvariable() (variables_index.cpp). # No TF runtime needed β€” all protobuf and SSTable structures are built by h...
776
34,667
pyomo
pyomo/contrib/appsi/writers/lp_writer.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...
199
7,163
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_generate_proposal_v2.py
.py
# # pool2d paddle model generator # import numpy as np from save_model import saveModel import sys def generate_proposals_v2(name: str, input_data: dict, attr: dict): scores_np = input_data["scores"] bbox_deltas_np = input_data["bbox_deltas"] im_shape_np = input_data["im_shape"] anchors_np = input_data...
167
6,422
biopython
Doc/examples/www_blast.py
.py
#!/usr/bin/env python # Copyright 2000 Brad Chapman. All rights reserved. # # This code is part of the Biopython distribution and governed by its # license. Please see the LICENSE file that should have been included # as part of this package. """Example showing how to deal with internet BLAST from Biopython. This c...
53
1,754
openvino
tests/layer_tests/pytorch_tests/test_or.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest import torch from pytorch_layer_test_class import PytorchLayerTest class TestOr(PytorchLayerTest): def _prepare_input(self): return self.input_data def create_model_tensor_input(self):...
84
2,868
mlflow
mlflow/tracing/utils/exception.py
.py
import functools from mlflow.exceptions import MlflowTracingException def raise_as_trace_exception(f): """ A decorator to make sure that the decorated function only raises MlflowTracingException. Any exceptions are caught and translated to MlflowTracingException before exiting the function. This is ...
22
618
sqlmap
tests/test_jwt.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission Offline tests for the JWT auditor: the dependency-free codec/crypto helpers in lib/utils/jwt.py (parse/forge/crack/audit/detect) and the active scan engine in lib/techniques/jwt/injec...
236
11,349
django-cms
cms/test_utils/project/urls_2.py
.py
from django.conf import settings from django.conf.urls.i18n import i18n_patterns from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.urls import include, re_path from django.views.i18n import JavaScriptCatalog from django.views.static import serve from cms.t...
30
980
pyomo
pyomo/solvers/tests/piecewise_linear/problems/step_vararray.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...
69
1,873
metrics
src/torchmetrics/text/edit.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...
176
7,369
openvino
docs/articles_en/assets/snippets/gpu/custom_kernels_api.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import openvino as ov def main(): core = ov.Core() if "GPU" not in core.available_devices: return 0 # TODO: missing property to replace string #! [part0] core = ov.Core() core.set_property("GPU", {"CON...
18
373
onnxruntime
tools/ci_build/gen_def.py
.py
#!/usr/bin/python3 import argparse import os import sys def parse_arguments(): parser = argparse.ArgumentParser() parser.add_argument("--src_root", required=True, help="input symbol file") parser.add_argument("--output", required=True, help="output file") parser.add_argument("--output_source", require...
114
3,903
funcy
funcy/seqs.py
.py
import sys from itertools import islice, chain, tee, groupby, filterfalse, accumulate, \ takewhile as _takewhile, dropwhile as _dropwhile from collections.abc import Sequence from collections import defaultdict, deque import operator from .primitives import EMPTY from .types import is_seqcont fro...
505
15,340
pyomo
pyomo/dae/tests/test_contset.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...
374
13,293
saleor
saleor/permission/auth_filters.py
.py
from .enums import BasePermissionEnum def is_app(context): return bool(context.app) def is_user(context): user = context.user return user and user.is_active def is_staff_user(context): return is_user(context) and context.user.is_staff class AuthorizationFilters(BasePermissionEnum): # Grants ...
42
1,193
luigi
luigi/contrib/prometheus_metric.py
.py
from prometheus_client import CONTENT_TYPE_LATEST, CollectorRegistry, Counter, Gauge, generate_latest from luigi import parameter from luigi.metrics import MetricsCollector from luigi.task import Config class prometheus(Config): use_task_family_in_labels = parameter.BoolParameter(default=True, parsing=parameter....
55
3,039
textual
docs/examples/guide/layout/grid_layout_auto.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class GridLayoutExample(App): CSS_PATH = "grid_layout_auto.tcss" def compose(self) -> ComposeResult: yield Static("First column", classes="box") yield Static("Two", classes="box") yield Static("Three", class...
20
534
pyomo
pyomo/contrib/pynumero/examples/parallel_vector_ops.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...
43
1,426
beam
sdks/python/apache_beam/io/gcp/datastore/v1new/datastore_write_it_test.py
.py
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not us...
79
2,570
sphinx
tests/test_util/test_util_docutils.py
.py
"""Tests util.utils functions.""" from __future__ import annotations import os from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx.util.docutils import ( SphinxFileOutput, SphinxTranslator, docutils_namespace, new_document, register_node, ) if TYPE_CHECKING: ...
104
3,126
gunicorn
gunicorn/workers/__init__.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. # supported gunicorn workers. SUPPORTED_WORKERS = { "sync": "gunicorn.workers.sync.SyncWorker", "gevent": "gunicorn.workers.ggevent.GeventWorker", "gevent_wsgi": "gunicorn.workers.ggevent.GeventPyWSGIWo...
15
560
beam
sdks/python/apache_beam/runners/portability/fn_api_runner/trigger_manager.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...
457
19,008
astropy
astropy/cosmology/_src/parameter/core.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst __all__ = ("MISSING", "Parameter") import copy from collections.abc import Sequence from dataclasses import KW_ONLY, dataclass, field, fields, is_dataclass, replace from enum import Enum, auto from typing import TYPE_CHECKING, Any, Union import astropy....
305
11,317
returns
returns/pointfree/bind_future_result.py
.py
from collections.abc import Callable from typing import TypeVar from returns.future import FutureResult from returns.interfaces.specific.future_result import FutureResultLikeN from returns.primitives.hkt import Kinded, KindN, kinded _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = ...
77
2,242
openvino
src/bindings/python/tests/test_graph/test_dyn_attributes.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import openvino.opset8 as ov import pytest @pytest.fixture def proposal_node(): attributes = { "base_size": np.uint16(1), "pre_nms_topn": np.uint16(20), "post_nms_t...
158
5,760
conda
tests/shell/test_powershell.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from __future__ import annotations import os from logging import getLogger from os.path import join from typing import TYPE_CHECKING import pytest from conda import __version__ as CONDA_VERSION from conda.common.compat import on_win from . i...
184
6,175
saleor
saleor/graphql/giftcard/tests/benchmark/test_gift_card_queries.py
.py
import graphene import pytest from .....giftcard.models import GiftCard from ....tests.utils import get_graphql_content FRAGMENT_EVENTS = """ fragment GiftCardEvents on GiftCardEvent { id date type user { email } app { name } ...
312
7,445
onnxruntime
onnxruntime/test/testdata/transform/computation_reduction.py
.py
import numpy as np import onnx from onnx import OperatorSetIdProto, TensorProto, helper, numpy_helper vocab_size = 256 # 30258 X = helper.make_tensor_value_info("input", TensorProto.FLOAT, ["batch", "seqlen", 128]) unsqueezed_masked_lm_positions = helper.make_tensor_value_info( "unsqueezed_masked_lm_positions", ...
145
5,147
pyro
tests/contrib/oed/test_glmm.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import pytest import torch from torch.distributions.transforms import AffineTransform, SigmoidTransform import pyro import pyro.distributions as dist import pyro.poutine as poutine from pyro.contrib.oed.glmm import ( group_lin...
178
5,729