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
readthedocs.org
readthedocs/invitations/templatetags/invitations.py
.py
"""Invitation template filters.""" from django import template from readthedocs.invitations.models import Invitation register = template.Library() @register.filter def can_revoke_invitation(user, object): if isinstance(object, Invitation): return object.can_revoke_invitation(user) return False
16
317
onnxruntime
tools/python/onnx2tfevents.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # # This tool is to convert ONNX model to TensorBoard events file so that we can visualize the model in TensorBoard. # this is especially useful for debugging large models that cannot be visualized in Netron. # # Usage: python...
373
14,253
pyomo
pyomo/contrib/solver/solvers/knitro/api.py
.py
# ____________________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and Engineering # Solutions of...
19
767
probability
spinoffs/inference_gym/inference_gym/internal/test_util_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...
246
8,513
probability
tensorflow_probability/python/experimental/mcmc/nuts_autobatching_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...
422
17,300
saleor
saleor/core/utils/cache.py
.py
import collections class CacheDict(collections.OrderedDict): def __init__(self, capacity: int): self.capacity = capacity super().__init__() def __getitem__(self, key): value = super().__getitem__(key) super().move_to_end(key) return value def __setitem__(self, key...
21
525
mlflow
mlflow/genai/labeling/labeling.py
.py
from typing import TYPE_CHECKING, Any, Iterable, Union from mlflow.entities import Trace from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE if TYPE_CHECKING: import pandas as pd from databricks.agents.review_app import ( LabelSchema as _Label...
316
10,355
scikit-bio
skbio/util/__init__.py
.py
r"""Utilities for Developers (:mod:`skbio.util`) ============================================ .. currentmodule:: skbio.util This package provides general exception/warning definitions used throughout scikit-bio, as well as various utility functionality, including I/O and unit-testing convenience functions. Testing ...
139
2,872
loguru
tests/exceptions/source/diagnose/multilines_repr.py
.py
import sys from loguru import logger logger.remove() logger.add(sys.stderr, format="", colorize=True, backtrace=False, diagnose=True) class A: def __repr__(self): return "[[1, 2, 3]\n" " [4, 5, 6]\n" " [7, 8, 9]]" def multiline(): a = b = A() a + b try: multiline() except TypeError: ...
23
341
pdm
tests/models/test_specifiers.py
.py
import pytest from pdm.exceptions import InvalidPyVersion from pdm.models.specifiers import PySpecSet, _convert_spec, _fix_py4k, get_specifier from pdm.models.versions import Version @pytest.mark.filterwarnings("ignore::FutureWarning") @pytest.mark.parametrize( "original,normalized", [ (">=3.6", ">=3...
184
5,486
coremltools
coremltools/converters/mil/mil/types/type_spec.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 class Type: """ - Type.name : A string with the name of the object - Type.tparam : For ...
90
2,994
astropy
astropy/cosmology/_src/parameter/descriptors.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst __all__: list[str] = ["ParametersAttribute"] from dataclasses import dataclass, field from types import MappingProxyType from typing import TYPE_CHECKING, Any, NoReturn, Union if TYPE_CHECKING: import astropy.cosmology @dataclass(frozen=True, slot...
70
2,489
saleor
saleor/channel/__init__.py
.py
class AllocationStrategy: """Determine the allocation strategy for the channel. PRIORITIZE_SORTING_ORDER - allocate stocks according to the warehouses' order within the channel PRIORITIZE_HIGH_STOCK - allocate stock in a warehouse with the most stock """ PRIORITIZE_SORTING_ORDER = "prioritize...
50
1,409
pyro
pyro/contrib/examples/nextstrain.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import logging import os import subprocess import urllib import torch from .util import _mkdir_p, get_data_directory DATA = get_data_directory(__file__) URL = "https://github.com/pyro-ppl/datasets/raw/master/nextstrain.data.pt.gz" ...
45
1,567
saleor
saleor/asgi/tests/test_cors.py
.py
import pytest from asgiref.typing import ( ASGI3Application, ASGIReceiveEvent, HTTPResponseBodyEvent, HTTPResponseStartEvent, HTTPScope, ) from ..cors_handler import cors_handler ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin" ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Cr...
147
5,070
beam
sdks/python/apache_beam/ml/anomaly/univariate/mean_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...
162
4,890
conda
conda/notices/cache.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """ Handles all caching logic including: - Retrieving from cache - Saving to cache - Determining whether not certain items have expired and need to be refreshed """ from __future__ import annotations import logging import os from datetim...
213
6,591
pyro
examples/cvae/cvae.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 from pathlib import Path import numpy as np import torch import torch.nn as nn from tqdm import tqdm import pyro import pyro.distributions as dist from pyro.infer import SVI, Trace_ELBO class Encoder(nn.Module): def __init__(se...
190
6,899
openvino
tests/e2e_tests/common/infer/network_modifiers/container.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import inspect from e2e_tests.common.common.base_provider import BaseProvider class ClassProvider(BaseProvider): registry = {} @classmethod def validate(cls): methods = [ f[0] for f in inspect.getmember...
31
914
beam
sdks/python/apache_beam/tools/microbenchmarks_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...
56
1,998
readthedocs.org
readthedocs/projects/apps.py
.py
"""Project app config.""" import socket from django.apps import AppConfig from django.conf import settings from django.core.checks.registry import registry class ProjectsConfig(AppConfig): name = "readthedocs.projects" def ready(self): # Load and register notification messages for this application ...
30
1,276
scikit-bio
skbio/stats/ordination/__init__.py
.py
r"""Ordination methods (:mod:`skbio.stats.ordination`) ================================================== .. currentmodule:: skbio.stats.ordination This module provides functions for ordination -- a category of methods that aim at arranging data so that similar data points are proximate to each other. Ordination can ...
210
5,418
biopython
Bio/SeqIO/XdnaIO.py
.py
# Copyright 2017-2019 Damien Goutte-Gattat. 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. """Bio.SeqIO sup...
366
12,404
mlflow
tests/spark/autologging/datasource/test_spark_datasource_autologging_crossframework.py
.py
import time import numpy as np import pytest from sklearn.linear_model import LinearRegression import mlflow import mlflow.spark from tests.spark.autologging.utils import _assert_spark_data_logged @pytest.fixture def http_tracking_uri_mock(): mlflow.set_tracking_uri("http://some-cool-uri") yield mlflow...
121
3,836
deap
examples/eda/emna.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 ...
95
3,411
saleor
saleor/shipping/__init__.py
.py
class ShippingMethodType: PRICE_BASED = "price" WEIGHT_BASED = "weight" CHOICES = [ (PRICE_BASED, "Price based shipping"), (WEIGHT_BASED, "Weight based shipping"), ] class PostalCodeRuleInclusionType: INCLUDE = "include" EXCLUDE = "exclude" CHOICES = [ (INCLUDE, "...
19
447
openvino
src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/partition.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # mypy: ignore-errors import torch from torch.nn import Module from torch.fx import GraphModule, Node from torch.fx.passes.infra.partitioner import CapabilityBasedPartitioner, Partition from torch.fx.experiment...
149
6,663
confluent-kafka-python
examples/context_manager_example.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...
130
4,630
wagtail
wagtail/tests/test_streamfield.py
.py
import json import pickle from django.apps import apps from django.db import connection, models from django.template import Context, Template, engines from django.test import TestCase, skipUnlessDBFeature from django.utils.safestring import SafeString from wagtail import blocks from wagtail.admin.forms import Wagtail...
1,217
47,569
sphinx
tests/roots/test-extensions/write_serial.py
.py
def setup(app): return { 'parallel_write_safe': False, }
5
73
textual
docs/examples/widgets/progress_bar_isolated.py
.py
from textual.app import App, ComposeResult from textual.containers import Center, Middle from textual.timer import Timer from textual.widgets import Footer, ProgressBar class IndeterminateProgressBar(App[None]): BINDINGS = [("s", "start", "Start")] progress_timer: Timer """Timer to simulate progress happ...
35
1,047
clearml
clearml/backend_api/services/v2_23/projects.py
.py
""" projects service Provides support for defining Projects containing Tasks, Models and Dataset Versions. """ from typing import List, Optional, Any import six from datetime import datetime from dateutil.parser import parse as parse_datetime from clearml.backend_api.session import ( Request, Response, Non...
4,548
161,018
qutip
qutip/core/metrics.py
.py
""" This module contains a collection of functions for calculating metrics (distance measures) between states and operators. """ __all__ = ['fidelity', 'tracedist', 'bures_dist', 'bures_angle', 'hellinger_dist', 'hilbert_dist', 'average_gate_fidelity', 'process_fidelity', 'unitarity', 'dnorm'] f...
607
20,609
jupytext
tests/integration/jupytext_config/test_jupytext_config.py
.py
from jupytext.cli import system def test_jupytext_config_cli(tmp_path): settings_file = tmp_path / "default_setting_overrides.json" system("jupytext-config", "-h") system( "jupytext-config", "--settings-file", str(settings_file), "set-default-viewer", "python", ...
27
833
pyomo
pyomo/contrib/pynumero/interfaces/external_grey_box.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...
470
18,381
beam
sdks/python/apache_beam/io/aws/clients/s3/messages.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...
154
4,023
pyomo
pyomo/contrib/trustregion/tests/test_TRF.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...
329
12,191
wandb
wandb/sdk/wandb_summary.py
.py
import abc import typing as t from .interface.summary_record import SummaryItem, SummaryRecord class SummaryDict(metaclass=abc.ABCMeta): """dict-like wrapper for the nested dictionaries in a SummarySubDict. Triggers self._root._callback on property changes. """ @abc.abstractmethod def _as_dict(...
143
4,369
probability
tensorflow_probability/python/bijectors/reciprocal_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...
89
2,886
scikit-bio
skbio/tree/tests/test_nj.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. # --------------------------------------------...
195
8,260
onnxruntime
onnxruntime/test/python/transformers/test_sparse_attention.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Parity test and benchmark performance of SparseAttention. Requires ...
865
35,907
sphinx
sphinx/builders/linkcheck.py
.py
"""The CheckExternalLinksBuilder class.""" from __future__ import annotations import contextlib import json import re import socket import time from enum import StrEnum from html.parser import HTMLParser from queue import PriorityQueue, Queue from threading import Thread from typing import TYPE_CHECKING, NamedTuple, ...
862
31,226
sqlmap
tests/test_ssti.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 SSTI detection and fingerprinting engine. Mock _send() stands in for the HTTP/Jinja2 layer so engine table integrity, arithmetic proof, error detection, boolean ...
830
37,501
textual
tests/input/test_input_validation.py
.py
import pytest from textual import on from textual.app import App, ComposeResult from textual.validation import Number, ValidationResult from textual.widgets import Input class InputApp(App): def __init__(self, validate_on=None): super().__init__() self.messages = [] self.validator = Numbe...
225
6,449
gunicorn
gunicorn/workers/base_async.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. from datetime import datetime import errno import socket import ssl import sys from gunicorn import http from gunicorn.http import wsgi from gunicorn import util from gunicorn import sock as gunicorn_sock from gun...
258
9,763
wandb
tests/unit_tests/test_mailbox.py
.py
import asyncio import math import unittest.mock import pytest from wandb.proto import wandb_internal_pb2 as pb from wandb.proto import wandb_server_pb2 as spb from wandb.sdk import mailbox as mb from wandb.sdk.lib import asyncio_manager from wandb.sdk.mailbox.mailbox_handle import HandleAbandonedError from wandb.sdk.m...
264
7,709
loguru
tests/exceptions/source/backtrace/function.py
.py
import sys from loguru import logger logger.remove() logger.add(sys.stderr, format="", colorize=False, backtrace=True, diagnose=False) @logger.catch() def a(): 1 / 0 def b(): 2 / 0 def c(): 3 / 0 a() with logger.catch(): b() try: c() except ZeroDivisionError: logger.exception("")
31
317
saleor
saleor/tests/e2e/product/utils/product_variant.py
.py
from ...utils import get_graphql_content PRODUCT_VARIANT_CREATE_MUTATION = """ mutation createVariant($input: ProductVariantCreateInput!) { productVariantCreate(input: $input) { errors { field message code } productVariant { id name quantityLimitPerCustomer produ...
79
1,630
mlflow
examples/model_config/simple.py
.py
import mlflow with mlflow.start_run(): model_info = mlflow.pyfunc.log_model( name="model", python_model="model.py", model_config={"timeout": 10}, input_example=["hello"], ) # model = mlflow.pyfunc.load_model(model_info.model_uri, model_config={"timeout": 10}) # print(model.pre...
14
335
saleor
manage.py
.py
#!/usr/bin/env python3 import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "saleor.settings") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
11
250
voila
tests/skip_template/setup.py
.py
import os from setuptools import setup data_files = [] for dirpath, _dirnames, filenames in os.walk("share/jupyter/voila/templates"): if filenames: data_files.append( (dirpath, [os.path.join(dirpath, filename) for filename in filenames]) ) setup( name="skip_template", version...
22
517
conda
tests/common/test_json.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Tests for conda.common.serialize.json module.""" from __future__ import annotations import json from frozendict import frozendict from conda.common.serialize.json import CondaJSONEncoder, dumps def test_condajsonencoder_serialises_froze...
39
1,096
black
tests/data/cases/trailing_comma_optional_parens1.py
.py
if e1234123412341234.winerror not in (_winapi.ERROR_SEM_TIMEOUT, _winapi.ERROR_PIPE_BUSY) or _check_timeout(t): pass if x: if y: new_id = max(Vegetable.objects.order_by('-id')[0].id, Mineral.objects.order_by('-id')[0].id) + 1 class X: def get_help_text(...
64
1,615
probability
tensorflow_probability/python/math/hypergeometric.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...
681
26,541
pyomo
doc/OnlineDocs/src/expr/managing.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...
256
5,999
mlflow
mlflow/cli/eval.py
.py
""" CLI commands for evaluating traces with scorers. """ import json from typing import Literal import click import pandas as pd import mlflow from mlflow.cli.genai_eval_utils import ( extract_assessments_from_results, format_table_output, resolve_scorers, ) from mlflow.entities import Trace from mlflow....
129
4,217
pyomo
pyomo/common/deprecation.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...
758
27,879
coremltools
coremltools/proto/WordTagger_pb2.py
.py
# -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: WordTagger.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 message as _message from g...
42
1,986
metrics
src/torchmetrics/wrappers/classwise.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...
245
10,520
onnxruntime
tools/python/wgsl_gen.py
.py
#!/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """CLI entry point for the WGSL template generator. Invoked from CMake during the WebGPU EP build to translate ``*.wgsl.template`` files into C++ headers. Usage:: python wgsl_gen.py \\ -i ...
156
4,795
wandb
tests/unit_tests/test_artifacts/saved_model_constructors.py
.py
# This file is separated from the main test file in # order to simulate models defined in external modules. import pytest torch = pytest.importorskip("torch") tensorflow = pytest.importorskip("tensorflow") keras = tensorflow.keras svm = pytest.importorskip("sklearn.svm") np = pytest.importorskip("numpy") def sklearn...
53
1,582
biopython
Bio/Graphics/GenomeDiagram/__init__.py
.py
# Copyright 2003-2008 by Leighton Pritchard. All rights reserved. # Revisions copyright 2009 by Peter Cock. # # 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 ...
38
1,172
mlflow
mlflow/telemetry/__init__.py
.py
from mlflow.telemetry.client import get_telemetry_client, set_telemetry_client __all__ = ["get_telemetry_client", "set_telemetry_client"]
4
139
mlflow
tests/agent/test_prompt.py
.py
from __future__ import annotations from pathlib import Path import pytest from mlflow.agent.agents import AGENTS from mlflow.agent.setup.prompt import _render, build_prompt def test_render_substitutes_placeholder(): assert _render("hello {{ name }}", name="world") == "hello world" def test_render_accepts_no_...
114
3,798
biopython
Bio/PDB/__init__.py
.py
# Copyright (C) 2002, Thomas Hamelryck (thamelry@binf.ku.dk) # # 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. """Classes that deal...
115
3,092
saleor
saleor/graphql/app/mutations/app_problem_dismiss.py
.py
from typing import Any, cast import graphene from django.core.exceptions import ValidationError from ....account.models import User from ....app.error_codes import ( AppProblemDismissErrorCode as AppProblemDismissErrorCodeEnum, ) from ....app.lock_objects import app_problem_qs_select_for_update from ....app.model...
328
11,390
coveragepy
tests/test_goldtest.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 the helpers in goldtest.py""" from __future__ import annotations import os.path import re import pytest from tests.coveragetest import CoverageTes...
189
7,275
saleor
saleor/tests/e2e/account/utils/me.py
.py
from ...utils import get_graphql_content from .fragments import ADDRESS_FRAGMENT ME_QUERY = ( """ query Me{ me{ id orders(first:10){ edges{ node{ number status } } } addresses { ...Address } } } """ + ADDRESS_FRAGMENT ) def get_own...
39
564
onnx
onnx/reference/ops/op_sequence_at.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from onnx.reference.op_run import OpRun class SequenceAt(OpRun): def _run(self, seq, index): return (seq[index],)
12
245
onnxruntime
onnxruntime/python/tools/transformers/fusion_bias_add.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_base import Fusion from numpy...
58
1,984
pymc
pymc/model/transform_values.py
.py
# Copyright 2026 - 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...
205
6,824
sphinx
sphinx/environment/collectors/asset.py
.py
"""The image collector for sphinx.environment.""" from __future__ import annotations import os import os.path from glob import glob from pathlib import Path from typing import TYPE_CHECKING from docutils import nodes from sphinx import addnodes from sphinx.environment.collectors import EnvironmentCollector from sph...
186
6,925
saleor
saleor/app/lock_objects.py
.py
from django.db.models import QuerySet from .models import App, AppProblem def app_qs_select_for_update() -> QuerySet[App]: return App.objects.order_by("pk").select_for_update(of=["self"]) def app_problem_qs_select_for_update() -> QuerySet[AppProblem]: return AppProblem.objects.order_by("pk").select_for_upd...
12
337
lemur
lemur/plugins/lemur_sftp/plugin.py
.py
""" .. module: lemur.plugins.lemur_sftp.plugin :platform: Unix :synopsis: Allow the uploading of certificates to SFTP. :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. Allow the uploading of certificates to SFTP. NGINX and Apache export...
301
11,403
beam
sdks/python/apache_beam/examples/snippets/transforms/elementwise/flatmap_multiple_arguments.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,830
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/jupyter_with_raw_cell_with_invalid_yaml.py
.py
# --- # title: Exception: Test # jupyter: # jupytext: # cell_markers: '{{{,}}}' # kernelspec: # display_name: Python 3 (ipykernel) # language: python # name: python3 # --- 1 + 2 + 3
13
203
pyro
pyro/ops/dual_averaging.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 class DualAveraging: """ Dual Averaging is a scheme to solve convex optimization problems. It belongs to a class of subgradient methods which uses subgradients to update parameters (in primal space) of a model. Und...
80
3,402
pdm
tests/cli/test_update.py
.py
import pytest from pdm.cli.commands.update import Command from pdm.cli.filters import GroupSelection def make_workspace_member(project, core): project.pyproject.settings["workspace"] = {"members": ["packages/*"]} project.pyproject.write() member_path = project.root / "packages" / "foo" member_path.mk...
379
15,220
openvino
tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_upsampling2d.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.tf2_layer_test_class import CommonTF2LayerTest rng = np.random.default_rng() class TestKerasUpSampling2D(CommonTF2LayerTest): def _prepare_input(self, inputs_inf...
62
3,019
sqlmap
lib/utils/dialect.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ from lib.core.common import Backend from lib.core.common import popValue from lib.core.common import pushValue from lib.core.data import conf from lib.core.data import kb from lib...
167
9,856
readthedocs.org
readthedocs/builds/tests/test_buildconfig.py
.py
"""Tests for BuildConfig model and Build.readthedocs_yaml_config field.""" import django_dynamic_fixture as fixture import pytest from readthedocs.builds.models import Build from readthedocs.builds.models import BuildConfig from readthedocs.builds.models import Version from readthedocs.projects.models import Project ...
104
4,149
pyomo
pyomo/contrib/doe/tests/test_doe_build.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...
638
22,076
mlflow
tests/store/artifact/test_http_artifact_repo.py
.py
import os import posixpath import shutil from unittest import mock import pytest from requests import HTTPError from mlflow.entities.multipart_upload import ( CreateMultipartUploadResponse, MultipartUploadCredential, MultipartUploadPart, ) from mlflow.entities.presigned_download import PresignedDownloadUr...
802
28,154
mlflow
mlflow/genai/judges/tools/__init__.py
.py
from mlflow.genai.judges.tools.base import JudgeTool from mlflow.genai.judges.tools.get_root_span import GetRootSpanTool from mlflow.genai.judges.tools.get_span import GetSpanTool from mlflow.genai.judges.tools.get_span_image import GetSpanImageTool, SpanImageResult from mlflow.genai.judges.tools.get_span_performance_a...
47
1,524
coveragepy
tests/test_api.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 for coverage.py's API.""" from __future__ import annotations import fnmatch import glob import io import os import os.path import re import shutil impo...
1,682
60,031
mlflow
tests/check_mlflow_lazily_imports_ml_packages.py
.py
""" Tests that `import mlflow` and `mlflow.autolog()` do not import ML packages. """ import importlib import logging import sys import mlflow logger = logging.getLogger() def main(): ml_packages = { "catboost", "h2o", "lightgbm", "onnx", "pytorch_lightning", "pys...
57
1,380
onnxruntime
onnxruntime/test/testdata/packed_attention_fp16.rbp.py
.py
""" Run this script to recreate the original onnx model. Example usage: python packed_attention_fp16.model.py out_model_path.onnx """ import sys import numpy as np import onnx from onnx import TensorProto, helper, numpy_helper def clear_field(proto, field): proto.ClearField(field) return proto def order_r...
132
4,801
coremltools
coremltools/optimize/coreml/experimental/test_post_training_quantization.py
.py
# Copyright (c) 2025, 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 numpy as np import torch from io import StringIO import sys import coremltools as ct from coreml...
203
7,785
sphinx
sphinx/ext/autodoc/_names.py
.py
"""Importer utilities for autodoc""" from __future__ import annotations import re from typing import TYPE_CHECKING from sphinx.ext.autodoc._shared import LOGGER from sphinx.locale import __ if TYPE_CHECKING: from collections.abc import Mapping, Sequence from sphinx.environment import _CurrentDocument f...
182
6,260
sqlmap
thirdparty/chardet/eucjpprober.py
.py
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is mozilla.org code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Con...
93
3,749
pyomo
pyomo/mpec/plugins/pathampl.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...
51
1,816
openvino
tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_cropping_3d.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 TestKerasCropping3D(CommonTF2LayerTest): def create_keras_cropping_3d_net(self, cropping, input_names, input_shapes, input_type...
42
1,819
tablib
src/tablib/formats/_sql.py
.py
"""Tablib - SQL INSERT Export Support.""" __lazy_modules__ = { "datetime", "decimal", "tablib.exceptions", } import datetime import decimal from ..exceptions import UnsupportedFormat class SQLFormat: """Export Dataset rows as SQL INSERT statements.""" title = 'sql' extensions = ('sql',) ...
78
2,598
sqlmap
tamper/luanginxmore.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import random import string import os from lib.core.compat import xrange from lib.core.common import singleTimeWarnMessage from lib.core.enums import HINT from lib.core.enums imp...
47
1,456
pyro
pyro/poutine/reparam_messenger.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import warnings from typing import ( TYPE_CHECKING, Callable, Dict, Generic, List, Optional, TypeVar, Union, ) import torch from typing_extensions import ParamSpec from pyro.poutine.messenger impor...
166
6,175
ipython
tests/test_frame.py
.py
"""Tests for IPython.utils.frame""" import collections.abc from IPython.utils.frame import extract_module_locals def test_extract_module_locals_returns_tuple(): module, locals_ = extract_module_locals() assert hasattr(module, "__name__") # On Python 3.13+, f.f_locals returns FrameLocalsProxy, not dict ...
17
501
coremltools
coremltools/converters/mil/frontend/tensorflow/load.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 gc import os from tempfile import NamedTemporaryFile import tensorflow as tf from packaging.v...
317
12,897
beam
sdks/python/apache_beam/runners/direct/direct_runner.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...
674
28,081
wagtail
wagtail/workflows.py
.py
TASK_TYPES = [] def get_concrete_descendants(model_class, inclusive=True): """Retrieves non-abstract descendants of the given model class. If `inclusive` is set to True, includes model_class""" subclasses = model_class.__subclasses__() if subclasses: for subclass in subclasses: yie...
28
867
textual
docs/examples/guide/input/key01.py
.py
from textual import events from textual.app import App, ComposeResult from textual.widgets import RichLog class InputApp(App): """App to display key events.""" def compose(self) -> ComposeResult: yield RichLog() def on_key(self, event: events.Key) -> None: self.query_one(RichLog).write(e...
19
390