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
saleor
saleor/core/tracing.py
.py
from collections.abc import Sequence from contextlib import contextmanager from django.db import transaction from ..app.models import App from ..core.telemetry import Link, Scope, SpanKind, saleor_attributes, tracer @contextmanager def traced_atomic_transaction(): with transaction.atomic(): with tracer....
52
1,629
saleor
saleor/account/tests/test_search.py
.py
from ..search import update_user_search_vector def test_update_user_search_vector(customer_user, address, address_usa): # given customer_user.addresses.set((address, address_usa)) customer_user.search_vector = None # when update_user_search_vector(customer_user) # then customer_user.refr...
42
1,155
marshmallow
src/marshmallow/experimental/__init__.py
.py
"""Experimental features. The features in this subpackage are experimental. Breaking changes may be introduced in minor marshmallow versions. """
6
147
coremltools
deps/protobuf/python/google/protobuf/json_format.py
.py
# Protocol Buffers - Google's data interchange format # Copyright 2008 Google Inc. All rights reserved. # https://developers.google.com/protocol-buffers/ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redi...
857
32,690
coveragepy
tests/test_python.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 """Tests of coverage/python.py""" from __future__ import annotations import pathlib import sys import pytest from coverage import env from coverage.python imp...
88
2,914
onnx
onnx/reference/ops/op_sign.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.ops._op import OpRunUnaryNum class Sign(OpRunUnaryNum): def _run(self, x): return (np.sign(x),)
14
267
textual
tests/animations/test_scrolling_animation.py
.py
""" Tests for scrolling animations, which are considered a basic animation. (An animation that also plays on the level BASIC.) """ from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widgets import Label class TallApp(App[None]): def compose(self) -> ComposeResul...
70
2,414
astropy
astropy/cosmology/_src/tests/flrw/test_parameters.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Parameter test mixin classes.""" import copy from inspect import BoundArguments import numpy as np import pytest import astropy.constants as const import astropy.units as u from astropy.cosmology import Cosmology, FlatFLRWMixin, Parameter from astro...
507
20,267
wandb
wandb/sdk/artifacts/storage_policies/_factories.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Final from ..storage_handler import StorageHandler from ..storage_handlers.azure_handler import AzureHandler from ..storage_handlers.gcs_handler import GCSHandler from ..storage_handlers.http_handler import HTTPHandler from ..storage_handlers.local_...
78
2,819
python-prompt-toolkit
src/prompt_toolkit/buffer.py
.py
""" Data structures for the Buffer. It holds the text, cursor position, history, etc... """ from __future__ import annotations import asyncio import logging import os import re import shlex import shutil import subprocess import tempfile from collections import deque from collections.abc import Callable, Coroutine, I...
2,031
74,540
scikit-bio
skbio/io/format/_sequence_feature_vocabulary.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. # --------------------------------------------...
395
12,177
gunicorn
tests/test_asgi_invalid_requests.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Test invalid HTTP requests against ASGI callback parser. Runs the same .http test files as test_invalid_requests.py but using the ASGI callback parsers (PythonProtocol and H1CProtocol). """ import glob import ...
88
3,190
loguru
tests/exceptions/source/others/exception_formatting_coroutine.py
.py
import sys from loguru import logger logger.remove() logger.add(sys.stderr, format="", diagnose=False, backtrace=False, colorize=False) logger.add(sys.stderr, format="", diagnose=True, backtrace=False, colorize=False) logger.add(sys.stderr, format="", diagnose=False, backtrace=True, colorize=False) logger.add(sys.std...
23
500
openvino
docs/scripts/tests/utils/log.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 """ Doxygen and Sphinx logs parsing routines """ import re from pathlib import Path class LogParser: """ This class reads a log file and converts it to a structured format represented as a python `dict` """ exclude_sym...
121
4,354
saleor
saleor/plugins/webhook/tests/test_tax_webhook.py
.py
from unittest.mock import sentinel import pytest from ....core.taxes import TaxType @pytest.fixture def tax_type(): return TaxType( code="code_2", description="description_2", ) def test_get_tax_code_from_object_meta_no_app( webhook_plugin, product, ): # given plugin = webh...
67
1,339
gunicorn
tests/docker/asgi_compliance/apps/framework_apps.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """ Framework integration test applications. Tests integration with popular ASGI frameworks like Starlette and FastAPI. These apps require the frameworks to be installed. """ import json import os # Framework av...
397
12,741
wandb
tests/unit_tests/test_wandb_config.py
.py
"""config tests.""" import pytest import yaml from wandb import sdk as wandb_sdk def get_callback(d): def callback_func(key=None, val=None, data=None): if data: d.update(data) if key: d[key] = val return callback_func @pytest.fixture() def consolidated(): return...
133
3,742
pyomo
pyomo/contrib/gdpopt/ric.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...
116
4,382
textual
docs/examples/how-to/inline01.py
.py
from datetime import datetime from textual.app import App, ComposeResult from textual.widgets import Digits class ClockApp(App): CSS = """ Screen { align: center middle; } #clock { width: auto; } """ def compose(self) -> ComposeResult: yield Digits("", id="clock")...
32
642
openvino
src/frontends/tensorflow/tests/test_models/gen_scripts/generate_string_lower.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os import sys import tensorflow as tf tf.compat.v1.reset_default_graph() # Create the graph and model with tf.compat.v1.Session() as sess: sentences = tf.compat.v1.placeholder(tf.string, [2], name='sentences') tf.raw_ops...
17
544
probability
tensorflow_probability/python/internal/backend/numpy/data_structures.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...
23
804
wagtail
wagtail/api/v3/api.py
.py
from ninja import NinjaAPI from wagtail.api.v3.errors import register_exception_handlers from wagtail.api.v3.routers.pages import router as pages_router from wagtail.api.v3.routers.schema import router as schema_router from wagtail.api.v3.routers.sites import router as sites_router from wagtail.api.v3.routers.whoami i...
24
748
jupyterlab
jupyterlab/__main__.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import sys from jupyterlab.labapp import main sys.exit(main())
9
167
saleor
saleor/graphql/core/validators/file.py
.py
import logging import os import magic from django.conf import settings from django.core.exceptions import ValidationError from django.core.files.uploadedfile import UploadedFile from PIL import Image, UnidentifiedImageError from ....thumbnail import MIME_TYPE_TO_PIL_IDENTIFIER from ....thumbnail.utils import Processe...
203
6,870
mlflow
mlflow/keras/callback.py
.py
"""Keras 3 callback to log information to MLflow.""" import keras from mlflow import log_metrics, log_params, log_text from mlflow.utils.autologging_utils import ExceptionSafeClass class MlflowCallback(keras.callbacks.Callback, metaclass=ExceptionSafeClass): """Callback for logging Keras metrics/params/model/.....
103
3,968
python-prompt-toolkit
examples/telnet/chat-app.py
.py
#!/usr/bin/env python """ A simple chat application over telnet. Everyone that connects is asked for his name, and then people can chat with each other. """ import logging import random from asyncio import Future, run from prompt_toolkit.contrib.telnet.server import TelnetServer from prompt_toolkit.formatted_text imp...
105
2,522
probability
tensorflow_probability/python/math/generic_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...
754
27,398
attrs
src/attrs/validators.py
.py
# SPDX-License-Identifier: MIT from attr.validators import * # noqa: F403
4
76
mlflow
mlflow/utils/env_manager.py
.py
from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE LOCAL = "local" CONDA = "conda" VIRTUALENV = "virtualenv" UV = "uv" def validate(env_manager): allowed_values = [LOCAL, CONDA, VIRTUALENV, UV] if env_manager not in allowed_values: raise Mlf...
17
488
saleor
saleor/account/tests/fixtures/customer_type.py
.py
import pytest from ...models import CustomerType __all__ = [ "customer_type", "customer_type_with_attributes", "default_customer_type", "get_or_create_default_customer_type", ] def get_or_create_default_customer_type() -> CustomerType: # Transactional tests (django_db(transaction=True)) flush al...
47
1,236
saleor
saleor/graphql/webhook/tests/test_subscription_payload.py
.py
import graphene from django.test import override_settings from django.utils import timezone from ....webhook.event_types import WebhookEventAsyncType, WebhookEventSyncType from ....webhook.models import Webhook from ..subscription_payload import ( generate_payload_from_subscription, generate_payload_promise_fr...
438
11,448
mlflow
mlflow/entities/experiment.py
.py
from __future__ import annotations from mlflow.entities._mlflow_object import _MlflowObject from mlflow.entities.experiment_tag import ExperimentTag from mlflow.entities.trace_location import UnityCatalog from mlflow.protos.service_pb2 import Experiment as ProtoExperiment from mlflow.protos.service_pb2 import Experime...
182
6,729
textual
tests/snapshot_tests/snapshot_apps/fr_units.py
.py
from textual.app import App, ComposeResult from textual.containers import Horizontal, VerticalScroll from textual.widgets import Static class StaticText(Static): pass class FRApp(App): CSS = """ StaticText { height: 1fr; background: $boost; border: heavy white; } #foo { ...
55
964
pyomo
pyomo/repn/linear_template.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...
481
18,221
black
tests/data/cases/bracketmatch.py
.py
for ((x in {}) or {})['a'] in x: pass pem_spam = lambda l, spam = { "x": 3 }: not spam.get(l.strip()) lambda x=lambda y={1: 3}: y['x':lambda y: {1: 2}]: x # output for ((x in {}) or {})["a"] in x: pass pem_spam = lambda l, spam={"x": 3}: not spam.get(l.strip()) lambda x=lambda y={1: 3}: y["x" : lambda y...
16
333
beam
sdks/python/apache_beam/ml/inference/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...
2,438
91,822
confluent-kafka-python
src/confluent_kafka/schema_registry/rules/cel/cel_field_presence.py
.py
# Copyright 2024 Confluent, Inc. # Copyright 2023 Buf Technologies, 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 require...
48
1,574
beam
sdks/python/apache_beam/runners/interactive/cache_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...
405
14,235
wagtail
wagtail/admin/tests/test_rich_text.py
.py
import re import unittest from django.conf import settings from django.test import SimpleTestCase, TestCase from django.test.utils import override_settings from django.urls import reverse, reverse_lazy from django.utils import translation from wagtail.admin.rich_text import DraftailRichTextArea, get_rich_text_editor_...
672
23,543
rq
rq/cli/workers.py
.py
import logging import logging.config import os import sys import warnings import click from redis.exceptions import ConnectionError from rq.cli.cli import main from rq.cli.helpers import ( import_attribute, pass_cli_config, read_config_file, setup_loghandlers_from_args, ) from rq.defaults import ( ...
233
8,462
mlflow
mlflow/spacy/__init__.py
.py
""" The ``mlflow.spacy`` module provides an API for logging and loading spaCy models. This module exports spacy models with the following flavors: spaCy (native) format This is the main flavor that can be loaded back into spaCy. :py:mod:`mlflow.pyfunc` Produced for use by generic pyfunc-based deployment tools ...
380
14,045
openvino
tests/layer_tests/onnx_tests/test_slice.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model class TestSlice(OnnxRuntimeLayerTest): def create_net(self, shape, axes, ends, starts, ir_version, opset=6, steps=None...
419
17,063
beam
sdks/python/apache_beam/testing/load_tests/group_by_key_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...
119
4,120
wandb
xpu/hatch.py
.py
"""Builds the wandb-xpu binary for monitoring hardware accelerators.""" import json import pathlib import subprocess class WandbXpuBuildError(Exception): """Raised when building wandb-xpu service fails.""" def build_wandb_xpu( cargo_binary: pathlib.Path, output_path: pathlib.Path, target_triple: st...
71
2,404
mlflow
tests/langgraph/sample_code/langgraph_chat_agent_custom_inputs.py
.py
import json import os from typing import Any, Generator, Sequence from uuid import uuid4 from langchain_core.language_models import LanguageModelLike from langchain_core.messages import AIMessage, ToolCall from langchain_core.outputs import ChatGeneration, ChatResult from langchain_core.runnables import RunnableConfig...
194
6,299
metrics
src/torchmetrics/collections.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...
731
33,319
probability
spinoffs/inference_gym/inference_gym/targets/radon_contextual_effects_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...
234
8,509
onnxruntime
orttraining/orttraining/test/python/orttraining_test_ortmodule_triton.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import copy import json import os import random import uuid import _test_helpers import onnx import pytest import torch from onnx import TensorProto, helper from torch._C import _from_dlpack from torch.utils.dlpack import to...
907
36,554
probability
tensorflow_probability/python/internal/backend/numpy/ops.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...
763
23,456
saleor
saleor/graphql/webhook/tests/benchmark/test_webhook_events.py
.py
import pytest from ....tests.utils import get_graphql_content WEBHOOKS_QUERY = """ query { apps(first:100) { edges { node { webhooks { id name targetUrl isActive asyncEvents { ...
45
1,014
confluent-kafka-python
tests/schema_registry/data/proto/nested_pb2.py
.py
# -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: nested.proto """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_da...
51
3,500
textual
tests/test_shutdown.py
.py
from textual.app import App from textual.containers import Horizontal from textual.widgets import Footer, Tree class TreeApp(App[None]): def compose(self): yield Horizontal(Tree("Dune")) yield Footer() async def test_shutdown(): # regression test for https://github.com/Textualize/textual/iss...
19
504
loguru
tests/test_recattr.py
.py
import re import loguru._recattrs as recattrs from loguru import logger def test_patch_record_file(writer): def patch(record): record["file"].name = "456" record["file"].path = "123/456" logger.add(writer, format="{file} {file.name} {file.path}") logger.patch(patch).info("Test") ass...
78
2,164
gunicorn
examples/embedding_service/main.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. from fastapi import FastAPI from pydantic import BaseModel from gunicorn.dirty.client import get_dirty_client app = FastAPI() class EmbedRequest(BaseModel): texts: list[str] class EmbedResponse(BaseModel):...
34
723
biopython
Bio/PDB/mmcifio.py
.py
# Copyright 2017 Joe Greener. 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. """Write an mmCIF file. See h...
380
15,454
beam
sdks/python/apache_beam/testing/datatype_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...
131
3,725
django-cms
cms/test_utils/testcases.py
.py
import json import sys import warnings from urllib.parse import unquote, urljoin from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.auth.models import AnonymousUser, Permission from django.contrib.sessions.backends.base import SessionBase from django.contrib.sites.model...
679
25,008
wandb
wandb/sdk/data_types/html.py
.py
from __future__ import annotations import os import pathlib from collections.abc import Sequence from typing import TYPE_CHECKING from wandb.sdk.lib import filesystem, runid from . import _dtypes from ._private import MEDIA_TMP from .base_types.media import BatchableMedia if TYPE_CHECKING: # pragma: no cover f...
167
4,932
astropy
astropy/visualization/wcsaxes/frame.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import abc import warnings from collections import OrderedDict import numpy as np from matplotlib import rcParams from matplotlib.lines import Line2D, Path from matplotlib.patches import PathPatch from astropy.utils.exceptions import AstropyDeprecation...
445
13,052
hatch
tests/helpers/templates/wheel/standard_default_build_script_configured_build_hooks.py
.py
from hatch.template import File from hatch.utils.fs import Path from hatchling.__about__ import __version__ from hatchling.metadata.spec import DEFAULT_METADATA_VERSION from ..new.feature_no_src_layout import get_files as get_template_files from .utils import update_record_file_contents def get_files(**kwargs): ...
51
1,359
mlflow
mlflow/utils/annotations.py
.py
import inspect import re import types import warnings from functools import wraps from typing import Callable, ParamSpec, TypeVar, overload def _get_min_indent_of_docstring(docstring_str: str) -> str: """ Get the minimum indentation string of a docstring, based on the assumption that the closing triple qu...
339
11,558
probability
tensorflow_probability/python/internal/backend/numpy/misc.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...
225
7,214
python-prompt-toolkit
examples/dialogs/password_dialog.py
.py
#!/usr/bin/env python """ Example of an password input dialog. """ from prompt_toolkit.shortcuts import input_dialog def main(): result = input_dialog( title="Password dialog example", text="Please type your password:", password=True, ).run() print(f"Result = {result}") if __na...
21
351
pyro
pyro/infer/autoguide/initialization.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 r""" The pyro.infer.autoguide.initialization module contains initialization functions for automatic guides. The standard interface for initialization is a function that inputs a Pyro trace ``site`` dict and returns an appropriatel...
258
8,271
scikit-bio
skbio/io/_exception.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. # --------------------------------------------...
145
3,122
marshmallow
tests/test_schema.py
.py
import datetime as dt import math import random from collections import OrderedDict from typing import NamedTuple, cast import pytest import simplejson as json from marshmallow import ( EXCLUDE, INCLUDE, RAISE, Schema, class_registry, fields, validate, validates, validates_schema, ...
2,552
78,701
cvxpy
cvxpy/transforms/linearize.py
.py
""" Copyright 2013 Steven Diamond and Xinyue Shen. 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 ...
63
2,101
saleor
saleor/graphql/order/mutations/order_fulfill.py
.py
from collections import defaultdict from uuid import UUID import graphene from django.core.exceptions import ValidationError from ....core.exceptions import InsufficientStock from ....order import models as order_models from ....order.actions import OrderFulfillmentLineInfo, create_fulfillments from ....order.error_c...
306
11,311
saleor
saleor/graphql/page/tests/mutations/test_page_update.py
.py
import datetime from functools import partial from unittest import mock from unittest.mock import ANY import graphene import pytest from django.conf import settings from django.utils import timezone from django.utils.functional import SimpleLazyObject from django.utils.text import slugify from freezegun import freeze_...
2,089
64,251
mlflow
mlflow/genai/scorers/ragas/utils.py
.py
from __future__ import annotations from typing import Any from mlflow.entities.trace import Trace from mlflow.exceptions import MlflowException from mlflow.genai.scorers.scorer_utils import parse_tool_call_expectations from mlflow.genai.utils.trace_utils import ( extract_retrieval_context_from_trace, extract_...
307
10,230
probability
tensorflow_probability/python/optimizer/__init__.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...
52
2,590
pyro
tests/contrib/test_minipyro.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import warnings import pytest import torch from pytest import approx from torch.distributions import constraints from pyro.generic import distributions as dist from pyro.generic import infer, ops, optim, pyro, pyro_backend from t...
261
8,701
beam
sdks/python/apache_beam/transforms/batch_dofn_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...
302
10,435
mlflow
examples/evaluation/evaluate_on_binary_classifier.py
.py
import shap import xgboost from sklearn.model_selection import train_test_split import mlflow from mlflow.models import infer_signature # Load the UCI Adult Dataset X, y = shap.datasets.adult() # Split the data into training and test sets X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, rand...
42
1,169
clearml
clearml/utilities/async_manager.py
.py
import os import time from typing import Optional, Callable, Any from .process.mp import SingletonLock class AsyncManagerMixin: _async_results_lock = SingletonLock() # per pid (process) list of async jobs (support for sub-processes forking) _async_results = {} @classmethod def _add_async_result(...
69
2,415
probability
tensorflow_probability/python/bijectors/categorical_to_discrete.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...
159
5,880
saleor
saleor/plugins/openid_connect/tests/test_ip_filtering.py
.py
import pytest from django.core import signing from requests_hardened.ip_filter import InvalidIPAddress from ....core.http_client import HTTPClient def test_rejects_private_ips(openid_plugin, id_token, rf, monkeypatch): """Ensure private IP addresses are rejected by OIDC.""" monkeypatch.setattr(HTTPClient.con...
21
720
pyomo
pyomo/contrib/mindtpy/tests/test_mindtpy_lp_nlp.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...
306
12,053
pymc
tests/backends/fixtures.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...
607
21,343
saleor
saleor/graphql/shipping/tests/mutations/test_shipping_price_create.py
.py
import json from unittest import mock import graphene import pytest from django.utils.functional import SimpleLazyObject from freezegun import freeze_time from .....core.utils.json_serializer import CustomJsonEncoder from .....shipping.error_codes import ShippingErrorCode from .....shipping.models import ShippingMeth...
553
16,827
hydra
hydra/core/override_parser/overrides_visitor.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import sys import warnings from typing import Any, Dict, List, Optional, Tuple, Union, cast from omegaconf.vendor.antlr4 import ( # type: ignore[attr-defined] ParserRuleContext, TerminalNode, Token, ) from omegaconf.vendor.antlr4.error...
444
16,919
probability
tensorflow_probability/python/experimental/nn/convolutional_transpose_layers.py
.py
# Copyright 2019 The TensorFlow Probability Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
722
30,463
mkdocs
mkdocs/livereload/__init__.py
.py
from __future__ import annotations import functools import io import ipaddress import logging import mimetypes import os import os.path import pathlib import posixpath import re import socket import socketserver import string import sys import threading import time import traceback import urllib.parse import webbrowse...
382
13,530
mlflow
mlflow/models/wheeled_model.py
.py
import os import platform import shutil import subprocess import sys import yaml import mlflow from mlflow import MlflowClient from mlflow.environment_variables import MLFLOW_WHEELED_MODEL_PIP_DOWNLOAD_OPTIONS from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import BAD_REQUEST from mlfl...
318
13,312
httpie
docs/contributors/fetch.py
.py
""" Generate the contributors database. FIXME: replace `requests` calls with the HTTPie API, when available. """ import json import os import re import sys from copy import deepcopy from datetime import datetime from pathlib import Path from subprocess import check_output from time import sleep from typing import Any,...
282
8,916
qutip
qutip/solver/sode/__init__.py
.py
from .ssystem import * from .sode import * from .itotaylor import * from .rouchon import *
5
91
gunicorn
tests/config/test_cfg.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. bind = "unix:/tmp/bar/baz" workers = 3 proc_name = "fooey" default_proc_name = "blurgh"
9
194
openvino
docs/articles_en/assets/snippets/ShapeInference.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import openvino as ov from utils import get_model, get_image model = get_model() #! [picture_snippet] model.reshape([8, 3, 448, 448]) #! [picture_snippet] #! [set_batch] model.get_parameters()[0].set_layout(ov.Layout("N...")) ov.set_b...
56
1,382
pyomo
pyomo/core/tests/unit/test_xfrm_discrete_vars.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...
278
9,614
metrics
tests/unittests/regression/test_kendall.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...
129
5,664
mkdocs
mkdocs/tests/base.py
.py
from __future__ import annotations import contextlib import os import textwrap from functools import wraps from tempfile import TemporaryDirectory import markdown from mkdocs import utils from mkdocs.config.defaults import MkDocsConfig def dedent(text): return textwrap.dedent(text).strip() def get_markdown_t...
130
4,374
python-prompt-toolkit
examples/prompts/custom-vi-operator-and-text-object.py
.py
#!/usr/bin/env python """ Example of adding a custom Vi operator and text object. (Note that this API is not guaranteed to remain stable.) """ from prompt_toolkit import prompt from prompt_toolkit.enums import EditingMode from prompt_toolkit.key_binding import KeyBindings from prompt_toolkit.key_binding.bindings.vi im...
72
2,173
beam
sdks/python/apache_beam/yaml/yaml_enrichment.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...
109
5,163
beam
learning/katas/python/Core Transforms/CoGroupByKey/CoGroupByKey/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...
69
2,383
sqlmap
plugins/dbms/hana/connector.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ try: from hdbcli import dbapi except ImportError: pass from lib.core.common import getSafeExString from lib.core.data import logger from lib.core.exception import SqlmapC...
65
1,824
pyomo
pyomo/contrib/incidence_analysis/dulmage_mendelsohn.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...
168
7,101
gunicorn
tests/requests/valid/026.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. from gunicorn.config import Config cfg = Config() # Header line is 8209 bytes (name + ": " + value + CRLF) cfg.set('limit_request_field_size', 8210) request = { "method": "GET", "uri": uri("/"), "versi...
19
8,593
openvino
src/bindings/python/tests/test_transformations/test_replacement_api.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from openvino import Model, PartialShape from openvino import opset13 as ops from openvino.utils import replace_node, replace_output_update_name def get_relu_model(): # Parameter->Relu->Result param = op...
66
2,226
mlflow
mlflow/metrics/__init__.py
.py
import os from mlflow.metrics import genai from mlflow.metrics.base import MetricValue from mlflow.metrics.genai.utils import _MIGRATION_GUIDE from mlflow.metrics.metric_definitions import ( _accuracy_eval_fn, _ari_eval_fn, _bleu_eval_fn, _f1_score_eval_fn, _flesch_kincaid_eval_fn, _mae_eval_fn...
512
16,829
saleor
saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_list_payment_methods.py
.py
import json import graphene from ....payment.interface import ListStoredPaymentMethodsRequestData from ...event_types import WebhookEventSyncType from ...transport.asynchronous.transport import ( create_deliveries_for_subscriptions, ) LIST_STORED_PAYMENT_METHODS = """ subscription { event { ... on ListStor...
55
1,321