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
probability
tensorflow_probability/python/internal/backend/numpy/bitwise.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...
34
1,159
mlflow
mlflow/store/fs2db/cli.py
.py
from pathlib import Path import click from mlflow.store.fs2db import migrate from mlflow.utils.uri import get_uri_scheme @click.command("migrate-filestore") @click.option( "--source", required=True, type=click.Path(exists=True, file_okay=False, resolve_path=True), help="Root directory containing mlr...
46
1,383
wagtail
wagtail/contrib/redirects/middleware.py
.py
from urllib.parse import urlparse from django import http from django.utils.encoding import uri_to_iri try: from django.middleware import MiddlewareMixin except ImportError: # DJANGO_VERSION < (6, 2) from django.utils.deprecation import MiddlewareMixin from wagtail.contrib.redirects import models from wagta...
74
2,633
structlog
src/structlog/contextvars.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. """ Primitives to deal with a concurrency supporting context, as introduced in Python 3.7 as ...
195
5,648
scikit-bio
skbio/_base.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. # --------------------------------------------...
58
1,709
openvino
tests/model_hub_tests/transformation_tests/test_pa_transformation.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from huggingface_hub import snapshot_download from openvino._offline_transformations import paged_attention_transformation from openvino._pyopenvino.op import _PagedAttentionExtension from openvino._pyopenvino import Type as OVType from ...
231
10,892
astropy
astropy/modeling/tests/test_quantities_parameters.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Tests that relate to using quantities/units on parameters of models. """ import numpy as np import pytest from astropy import coordinates as coord from astropy import units as u from astropy.modeling.core import Fittable1DModel, InputParameterError ...
405
12,123
sphinx
tests/roots/test-ext-autodoc/target/singledispatch.py
.py
import inspect from functools import singledispatch def assign_signature(func): # This is intended to cover more complex signature-rewriting decorators. func.__signature__ = inspect.signature(func) return func @singledispatch def func(arg, kwarg=None): """A function for general use.""" pass @f...
36
704
mlflow
mlflow/tracing/otel/translation/langfuse.py
.py
""" Translation utilities for Langfuse observation attributes. Maps ``langfuse.observation.*`` attributes to MLflow span semantics so that spans forwarded from Langfuse via the generic OTEL processor are stored with correct span types, inputs, and outputs. """ from mlflow.entities.span import SpanType from mlflow.tra...
30
965
astropy
astropy/io/misc/parquet.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This package contains functions for reading and writing Parquet tables that are not meant to be used directly, but instead are available as readers/writers in `astropy.table`. See :ref:`astropy:table_io` for more details. """ import os import warning...
701
26,780
voila
tests/app/progressive_rendering_activation_test.py
.py
import os import voila.app import pytest @pytest.fixture def progressive_rendering_mode(): return True @pytest.fixture def preheat_mode(): return True @pytest.fixture def voila_notebook(notebook_directory): return os.path.join(notebook_directory, "preheat", "pre_heat.ipynb") class VoilaTest(voila.ap...
38
847
pyomo
examples/mpec/bard1.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...
46
1,545
probability
tensorflow_probability/python/distributions/wishart.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...
558
22,009
onnx
onnx/backend/test/case/node/slice.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np import onnx from onnx.backend.test.case.base import Base from onnx.backend.test.case.node import expect class Slice(Base): @staticmethod def export_slice() -> None: ...
179
5,270
lemur
lemur/plugins/lemur_acme/ultradns.py
.py
import time import requests import json import sys import dns import dns.exception import dns.name import dns.query import dns.resolver from flask import current_app from sentry_sdk import capture_exception from lemur.extensions import metrics class Record: """ This class implements an Ultra DNS record. ...
448
13,815
mlflow
mlflow/ai_commands/__init__.py
.py
"""CLI commands for managing MLflow AI commands.""" import click from mlflow.ai_commands.ai_command_utils import ( get_command, get_command_body, list_commands, parse_frontmatter, ) from mlflow.telemetry.events import AiCommandRunEvent from mlflow.telemetry.track import _record_event __all__ = ["get_...
71
2,010
probability
tensorflow_probability/python/internal/backend/numpy/private.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...
149
4,461
jupytext
src/jupytext/config.py
.py
"""Find and read Jupytext configuration files""" import json import os from pathlib import Path try: import tomllib except ImportError: import tomli as tomllib import warnings import yaml from traitlets import Bool, Dict, Enum, Float, List, Unicode, Union from traitlets.config import Configurable from trait...
528
20,567
beam
sdks/python/apache_beam/transforms/periodicsequence.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...
366
14,368
hatch
backend/src/hatchling/metadata/custom.py
.py
from __future__ import annotations import os from typing import Any from hatchling.metadata.plugin.interface import MetadataHookInterface from hatchling.plugin.utils import load_plugin_from_script from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT class CustomMetadataHook: PLUGIN_NAME = "custom" de...
42
1,424
pymc
pymc/dims/distributions/core.py
.py
# Copyright 2025 - 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...
383
15,258
saleor
saleor/tests/e2e/orders/discounts/test_manual_order_discount_and_voucher.py
.py
from decimal import Decimal import pytest from .....core.prices import quantize_price from .....discount import DiscountType, DiscountValueType from ... import DEFAULT_ADDRESS from ...product.utils.preparing_product import prepare_product from ...shop.utils.preparing_shop import prepare_shop from ...taxes.utils impor...
308
12,391
probability
tensorflow_probability/python/internal/unnest.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...
354
12,494
sphinx
tests/test_builders/test_build_html_maths.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.errors import ConfigError if TYPE_CHECKING: from collections.abc import Callable from sphinx.testing.fixtures import _app_params from sphinx.testing.util ...
100
3,006
pyomo
pyomo/util/tests/test_subsystems.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...
759
30,550
saleor
saleor/plugins/webhook/tests/test_payment_webhook.py
.py
import datetime import json from typing import NamedTuple from unittest import mock import pytest from django.conf import settings from django.contrib.sites.models import Site from django.utils import timezone from requests import RequestException, TooManyRedirects from requests_hardened import HTTPSession from ....a...
589
20,862
pyomo
examples/mpec/munson1a.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...
34
1,102
jupyterlab
jupyterlab/handlers/extension_manager_handler.py
.py
"""Tornado handlers for extension management.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import dataclasses import json from urllib.parse import urlencode, urlunparse from jupyter_server.base.handlers import APIHandler from tornado import web from jupyter...
147
5,291
onnxruntime
orttraining/orttraining/python/training/ortmodule/_onnx_models.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # _onnx_models.py import os from dataclasses import dataclass import onnx import torch def _get_onnx_file_name(name_prefix, name, export_mode): suffix = "training" if export_mode == torch.onnx.TrainingMode.TRAINING els...
40
1,424
pyomo
pyomo/opt/base/solvers.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...
844
28,974
confluent-kafka-python
tests/avro/mock_schema_registry_client.py
.py
#!/usr/bin/env python # # Copyright 2016 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...
192
6,566
probability
tensorflow_probability/python/experimental/fastgp/fast_mtgp_test.py
.py
# Copyright 2024 The TensorFlow Probability Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
463
17,175
onnx
tests/python/helper_test.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import math import random from typing import Any import ml_dtypes import numpy as np import pytest from onnx import ( AttributeProto, GraphProto, ModelProto, OptionalProto, Sequence...
1,173
44,142
astropy
astropy/io/tests/safeio.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import io class CatchZeroByteWriter(io.BufferedWriter): """File handle to intercept 0-byte writes.""" def write(self, buffer): nbytes = super().write(buffer) if nbytes == 0: raise ValueError("This writer does not all...
14
360
saleor
saleor/discount/utils/order.py
.py
from collections.abc import Iterable from decimal import Decimal from typing import TYPE_CHECKING from uuid import UUID from django.conf import settings from django.db import transaction from django.db.models import prefetch_related_objects from prices import TaxedMoney from ...channel.models import Channel from ...c...
422
15,220
saleor
saleor/graphql/order/mutations/order_refund.py
.py
import graphene from django.core.exceptions import ValidationError from ....giftcard.utils import order_has_gift_card_lines from ....order import FulfillmentStatus, models from ....order.actions import order_refunded from ....order.error_codes import OrderErrorCode from ....payment import TransactionKind, gateway from...
118
3,978
sphinx
tests/test_ext_autodoc/test_ext_autodoc_autoattribute.py
.py
"""Test the autodoc extension. This tests mainly the Documenters; the auto directives are tested in a test source file translated by test_build. """ from __future__ import annotations import pytest from tests.test_ext_autodoc.autodoc_util import do_autodoc pytestmark = pytest.mark.usefixtures('inject_autodoc_root_...
169
4,231
biopython
Bio/GenBank/Scanner.py
.py
# Copyright 2007-2017 by Peter Cock. All rights reserved. # Revisions copyright 2010 by Uri Laserson. 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. """Internal code for parsin...
1,942
87,936
kombu
kombu/asynchronous/semaphore.py
.py
"""Semaphores and concurrency primitives.""" from __future__ import annotations import sys from collections import deque from typing import TYPE_CHECKING if TYPE_CHECKING: from types import TracebackType from typing import Callable, Deque if sys.version_info < (3, 10): from typing_extensions impor...
128
3,561
textual
docs/examples/tutorial/stopwatch03.py
.py
from textual.app import App, ComposeResult from textual.containers import HorizontalGroup, VerticalScroll from textual.widgets import Button, Digits, Footer, Header class TimeDisplay(Digits): """A widget to display elapsed time.""" class Stopwatch(HorizontalGroup): """A stopwatch widget.""" def compose...
43
1,237
sqlmap
plugins/dbms/postgresql/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 Backend from lib.core.data import logger from lib.core.data import queries from lib.core.enums import DBMS from lib.core.enums import FORK from plugin...
72
3,154
coremltools
coremltools/optimize/torch/_utils/state_dict_utils.py
.py
# Copyright (c) 2024, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from typing import Any, Dict, Mapping, NamedTuple import torch class AddMetadataStateDictHook: ...
61
2,228
hatch
tests/helpers/templates/wheel/standard_default_namespace_package.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): ...
52
1,374
astropy
astropy/wcs/wcslint.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Script support for validating the WCS keywords in a FITS file. """ def main(args=None): import argparse from . import wcs parser = argparse.ArgumentParser( description=( "Check the WCS keywords in a FITS file for com...
24
633
python-prompt-toolkit
src/prompt_toolkit/styles/defaults.py
.py
""" The default styling. """ from __future__ import annotations from prompt_toolkit.cache import memoized from .base import ANSI_COLOR_NAMES, BaseStyle from .named_colors import NAMED_COLORS from .style import Style, merge_styles __all__ = [ "default_ui_style", "default_pygments_style", ] #: Default stylin...
237
8,699
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_unsupported_relu.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # relu paddle model generator # import os.path import sys import os import numpy as np import paddle from save_model import saveModel # print numpy array like C structure def print_alike(arr): shape = arr.shape rank = len(s...
86
2,182
mlflow
tests/metrics/genai/test_base.py
.py
import re from mlflow.metrics.genai import EvaluationExample def test_evaluation_example_str(): example1 = str( EvaluationExample( input="This is an input", output="This is an output", score=5, justification="This is a justification", grading_co...
73
1,827
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_tril_triu.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # tril_triu ops paddle model generator # import sys import numpy as np import paddle from save_model import saveModel def triu(name: str, x, diagonal=0, dtype="float32"): paddle.enable_static() x = x.astype(dtype) with...
86
2,240
mlflow
mlflow/utils/credentials.py
.py
import configparser import getpass import logging import os from typing import NamedTuple from mlflow.environment_variables import ( MLFLOW_TRACKING_AUTH, MLFLOW_TRACKING_AWS_SIGV4, MLFLOW_TRACKING_CLIENT_CERT_PATH, MLFLOW_TRACKING_INSECURE_TLS, MLFLOW_TRACKING_PASSWORD, MLFLOW_TRACKING_SERVER_...
241
8,692
probability
tensorflow_probability/python/glm/family_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...
291
9,854
saleor
saleor/tests/e2e/checkout/utils/checkout_lines_update.py
.py
from ...utils import get_graphql_content CHECKOUT_LINES_UPDATE_MUTATION = """ mutation checkoutLinesUpdate($checkoutId: ID!, $lines: [CheckoutLineUpdateInput!]!) { checkoutLinesUpdate(lines: $lines, checkoutId: $checkoutId) { checkout { discountName discount { amount } subtotalPri...
76
1,354
coremltools
docs/examples/optimize/torch/quantization/linear_quantization.py
.py
# -*- coding: utf-8 -*- """ .. _linear_quantization_tutorial: Linear Quantization =================== """ ######################################################################## # In this tutorial, you learn how to train a simple convolutional neural network on # `MNIST <http://yann.lecun.com/exdb/mnist/>`_ using :...
245
8,655
mkdocs
mkdocs/tests/new_tests.py
.py
#!/usr/bin/env python import os import unittest from mkdocs.commands import new from mkdocs.tests.base import change_dir, tempdir class NewTests(unittest.TestCase): @tempdir() def test_new(self, temp_dir): with change_dir(temp_dir): new.new("myproject") expected_paths = [ ...
25
699
beam
sdks/python/apache_beam/testing/analyzers/load_test_perf_analysis.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...
99
3,919
wandb
wandb/proto/v5/wandb_api_pb2.py
.py
# -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: wandb/proto/wandb_api.proto # Protobuf Python Version: 5.26.0 """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from goog...
157
21,318
metrics
tests/unittests/bases/test_hashing.py
.py
import pytest from unittests._helpers.testers import DummyListMetric, DummyMetric @pytest.mark.parametrize( "metric_cls", [ DummyMetric, DummyListMetric, ], ) def test_metric_hashing(metric_cls): """Tests that hashes are different. See the Metric's hash function for details on wh...
24
502
beam
sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineglobally_test.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");...
114
3,971
saleor
saleor/graphql/discount/tests/mutations/test_voucher_catalogues_remove.py
.py
import graphene from ....tests.utils import get_graphql_content VOUCHER_REMOVE_CATALOGUES = """ mutation voucherCataloguesRemove($id: ID!, $input: CatalogueInput!) { voucherCataloguesRemove(id: $id, input: $input) { voucher { name } errors { ...
64
1,924
pyro
tests/infer/reparam/test_structured.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import pytest import torch import pyro import pyro.distributions as dist from pyro import optim from pyro.infer import MCMC, NUTS, SVI, JitTrace_ELBO, Trace_ELBO from pyro.infer.autoguide import AutoStructured from pyro.infer.reparam ...
66
2,029
coremltools
deps/protobuf/python/google/protobuf/internal/wire_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...
269
8,444
probability
spinoffs/autobnn/autobnn/bnn.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...
173
6,324
saleor
saleor/tests/e2e/promotions/test_staff_can_change_channel_in_promotion_rule.py
.py
import pytest from ....product.tasks import recalculate_discounted_price_for_products_task from ..product.utils import ( get_product, raw_create_product_channel_listing, raw_create_product_variant_channel_listing, ) from ..product.utils.preparing_product import prepare_product from ..promotions.utils impor...
176
5,211
python-prompt-toolkit
examples/prompts/operate-and-get-next.py
.py
#!/usr/bin/env python """ Demo of "operate-and-get-next". (Actually, this creates one prompt application, and keeps running the same app over and over again. -- For now, this is the only way to get this working.) """ from prompt_toolkit.shortcuts import PromptSession def main(): session = PromptSession("prompt>...
20
405
ipython
examples/IPython Kernel/gui/gui-glut.py
.py
#!/usr/bin/env python """Simple GLUT example to manually test event loop integration. This is meant to run tests manually in ipython as: In [5]: %gui glut In [6]: %run gui-glut.py In [7]: gl.glClearColor(1,1,1,1) """ #!/usr/bin/env python import sys import OpenGL.GL as gl import OpenGL.GLUT as glut def close(): ...
52
1,297
metrics
src/torchmetrics/classification/average_precision.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...
545
25,457
wandb
wandb/sdk/artifacts/storage_policy.py
.py
"""Storage policy.""" from __future__ import annotations import concurrent.futures from abc import ABC, abstractmethod from typing import TYPE_CHECKING, Any from wandb.sdk.internal.internal_api import Api as InternalApi from wandb.sdk.lib.paths import FilePathStr, URIStr if TYPE_CHECKING: from wandb.filesync.st...
90
2,546
mlflow
tests/genai/scorers/test_builtin_scorers_registration.py
.py
from pathlib import Path from typing import Iterator from unittest import mock import pytest import mlflow from mlflow.exceptions import MlflowException from mlflow.genai.scorers import RetrievalRelevance, Safety, Scorer from mlflow.genai.scorers.base import ScorerSamplingConfig @pytest.fixture def mock_databricks_...
138
4,817
python-prompt-toolkit
src/prompt_toolkit/widgets/dialogs.py
.py
""" Collection of reusable components for building full screen applications. """ from __future__ import annotations from collections.abc import Sequence from prompt_toolkit.filters import has_completions, has_focus from prompt_toolkit.formatted_text import AnyFormattedText from prompt_toolkit.key_binding.bindings.fo...
109
3,389
saleor
saleor/csv/notifications.py
.py
from typing import TYPE_CHECKING from ..core.notification.utils import get_site_context from ..core.notify import NotifyEventType, NotifyHandler from ..core.utils import build_absolute_uri from ..graphql.core.utils import to_global_id_or_none from ..plugins.manager import get_plugins_manager if TYPE_CHECKING: fro...
74
2,899
pymc
pymc/func_utils.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...
207
7,869
mlflow
mlflow/entities/link.py
.py
import base64 from dataclasses import dataclass from typing import Any from mlflow.entities._mlflow_object import _MlflowObject @dataclass class Link(_MlflowObject): """ Represents an OpenTelemetry Span Link that connects spans across traces. Span Links allow you to link spans that don't have a parent-c...
65
2,270
hydra
plugins/hydra_ax_sweeper/tests/apps/polynomial_with_dict_coefficients.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from typing import Any import hydra from omegaconf import DictConfig @hydra.main(config_path=".", config_name="polynomial_with_dict_coefficients") def polynomial_with_dict_coefficients(cfg: DictConfig) -> Any: coeff = cfg.polynomial.coefficie...
19
482
saleor
saleor/graphql/discount/tests/mutations/test_voucher_delete.py
.py
import json from unittest.mock import patch import graphene import pytest from django.utils.functional import SimpleLazyObject from freezegun import freeze_time from .....core.utils.json_serializer import CustomJsonEncoder from .....webhook.event_types import WebhookEventAsyncType from .....webhook.payloads import ge...
92
2,803
mlflow
mlflow/store/analytics/trace_correlation.py
.py
import math from dataclasses import dataclass # Recommended smoothing parameter for NPMI calculation # Using Jeffreys prior (alpha=0.5) to minimize bias while providing robust estimates JEFFREYS_PRIOR = 0.5 @dataclass class TraceCorrelationCounts: """ Count statistics for trace correlation analysis. Thi...
208
7,127
black
tests/data/cases/fmtskip12.py
.py
with open("file.txt") as f: content = f.read() # fmt: skip # Ideally, only the last line would be ignored # But ignoring only part of the asexpr_test causes a parse error # Same with ignoring the asexpr_test without also ignoring the entire with_stmt with open ( "file.txt" , ) as f: content = f.read() # ...
20
671
kombu
kombu/clocks.py
.py
"""Logical Clocks and Synchronization.""" from __future__ import annotations from itertools import islice from operator import itemgetter from threading import Lock from typing import Any __all__ = ('LamportClock', 'timetuple') R_CLOCK = '_lamport(clock={0}, timestamp={1}, id={2} {3!r})' class timetuple(tuple): ...
157
4,825
coremltools
coremltools/converters/mil/frontend/tensorflow/parsed_tf_node.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 coremltools.converters.mil.mil import types from .tfssa import ParsedNode class ParsedTFNode(...
81
3,234
pyro
tests/contrib/autoname/test_autoname.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import torch import pyro import pyro.distributions.torch as dist import pyro.poutine as poutine from pyro.contrib.autoname import autoname, sample def test_basic_scope(): @autoname def f1(): sample(dist.Normal(0, 1))...
373
9,663
onnxruntime
onnxruntime/test/testdata/transform/fusion/matmul_scale_gen.py
.py
import onnx from onnx import OperatorSetIdProto, TensorProto, helper onnxdomain = OperatorSetIdProto() onnxdomain.version = 12 # The empty string ("") or absence of this field implies the operator set that is defined as part of the ONNX specification. onnxdomain.domain = "" msdomain = OperatorSetIdProto() msdomain.ver...
282
9,276
openvino
src/bindings/python/tests/test_runtime/test_model.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os import sys import numpy as np import pytest import math from contextlib import nullcontext as does_not_raise from copy import copy import tempfile import openvino.opset13 as ops from openvino import ( ...
955
36,664
saleor
saleor/graphql/giftcard/dataloaders.py
.py
from collections import defaultdict from uuid import UUID from django.db.models import Q from ...checkout.models import Checkout from ...giftcard.models import GiftCard, GiftCardEvent, GiftCardTag from ...order.models import Order from ..core.dataloaders import DataLoader class GiftCardsByUserLoader(DataLoader[int,...
106
4,265
probability
tensorflow_probability/python/distributions/inverse_gaussian.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...
352
14,767
biopython
Tests/test_BioSQL_mysql_connector.py
.py
# 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. """Run BioSQL tests using MySQL.""" import unittest # Really do want "import *" to get all the test classes: from common_BioSQL import * # noqa: F40...
28
827
saleor
saleor/graphql/channel/mutations/channel_update.py
.py
from typing import cast import graphene from django.core.exceptions import ValidationError from django.utils.text import slugify from ....channel import models from ....channel.error_codes import ChannelErrorCode from ....core.tracing import traced_atomic_transaction from ....core.utils.update_mutation_manager import...
322
12,769
saleor
saleor/graphql/warehouse/tests/benchmark/test_stocks.py
.py
import pytest from .....warehouse.models import Stock, Warehouse from ....tests.utils import get_graphql_content @pytest.fixture def stocks(address, variant): warehouses = Warehouse.objects.bulk_create( [ Warehouse( address=address.get_copy(), name=f"Warehouse ...
59
1,180
mlflow
mlflow/protos/scalapb/scalapb_pb2.py
.py
import google.protobuf from packaging.version import Version if Version(google.protobuf.__version__).major >= 5: # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: scalapb/scalapb.proto # Protobuf Python Version: 5.26.0 """Generated protocol buffer code.""" from go...
105
5,628
attrs
src/attr/_cmp.py
.py
# SPDX-License-Identifier: MIT import functools import types from ._make import __ne__ _operation_names = {"eq": "==", "lt": "<", "le": "<=", "gt": ">", "ge": ">="} def cmp_using( eq=None, lt=None, le=None, gt=None, ge=None, require_same_type=True, class_name="Comparable", ): """ ...
161
4,117
onnxruntime
orttraining/orttraining/python/training/utils/data/__init__.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # __init__.py from .sampler import LoadBalancingDistributedBatchSampler, LoadBalancingDistributedSampler # noqa: F401
6
214
probability
tensorflow_probability/python/distributions/deterministic_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...
502
20,189
wandb
tests/unit_tests/test_lib/test_sparkline.py
.py
from wandb.sdk.lib import sparkline def test_sparkline(): assert sparkline.sparkify([1, 2, 3]) == "▁▅█" def test_sparkline_nan(): assert sparkline.sparkify([float("nan"), 2, 3]) == " ▁█" def test_sparkline_inf(): assert sparkline.sparkify([float("inf"), 2, 3]) == " ▁█" def test_sparkline_1finite(): ...
26
592
toolz
tlz/_build_tlz.py
.py
import sys import types import toolz from importlib import import_module from importlib.machinery import ModuleSpec class TlzLoader: """ Finds and loads ``tlz`` modules when added to sys.meta_path""" def __init__(self): self.always_from_toolz = { toolz.pipe, } def _load_toolz...
94
3,144
pyomo
pyomo/opt/plugins/res.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...
58
1,854
beam
sdks/python/apache_beam/examples/snippets/transforms/elementwise/tostring_iterables.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,807
probability
tensorflow_probability/python/experimental/mcmc/particle_filter_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 ...
804
34,704
pyomo
examples/pyomobook/python-ch/example2.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...
16
634
mlflow
examples/openai/chat_completions.py
.py
import logging import os import openai import pandas as pd import mlflow from mlflow.models.signature import ModelSignature from mlflow.types.schema import ColSpec, ParamSchema, ParamSpec, Schema logging.getLogger("mlflow").setLevel(logging.ERROR) # Uncomment the following lines to run this script without using a r...
189
4,976
wandb
tests/unit_tests/test_weave_media_adapters.py
.py
"""Unit tests for Weave media adapter helpers.""" from __future__ import annotations import sys import types from io import BytesIO import pytest import wandb from wandb.integration.weave.media_adapters import ( handle_nested_wandb_values, unwrap_value, ) def _install_fake_weave(monkeypatch, **attrs): ...
593
17,756
openvino
tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_depthwiseconv2D.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest import tensorflow as tf from common.tf2_layer_test_class import CommonTF2LayerTest class TestKerasDepthwiseConv2D(CommonTF2LayerTest): def create_keras_dconv2D_net(self, input_names, input_shapes, input_type, kernel_...
108
6,043
clearml
clearml/backend_api/session/jsonmodels/collections.py
.py
from typing import Any class ModelCollection(list): """`ModelCollection` is list which validates stored values. Validation is made with use of field passed to `__init__` at each point, when new value is assigned. """ def __init__(self, field: Any) -> None: self.field = field def ap...
22
618
wagtail
wagtail/embeds/embeds.py
.py
from datetime import datetime from django.utils.timezone import now from wagtail.coreutils import accepts_kwarg, safe_md5 from .exceptions import EmbedUnsupportedProviderException from .finders import get_finders from .models import Embed def get_finder_for_embed(url, max_width=None, max_height=None): for find...
77
2,372