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
beam
sdks/python/apache_beam/examples/snippets/transforms/aggregation/top_smallest_per_key.py
.py
# coding=utf-8 # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License");...
60
1,800
hatch
src/hatch/cli/types/core.py
.py
from __future__ import annotations import os from functools import cached_property from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from hatch.env.plugin.interface import EnvironmentInterface from hatch.utils.fs import Path class TypeCheckEnvironment: def __init__(self, env: EnvironmentInterface)...
236
9,729
wagtail
wagtail/management/commands/create_log_entries_from_revisions.py
.py
from django.core.management.base import BaseCommand from wagtail.models import PageLogEntry, Revision def get_comparison(page, revision_a, revision_b): comparison = ( page.get_edit_handler() .get_bound_panel(instance=page, form=None, request=None) .get_comparison() ) comparison = ...
119
5,020
readthedocs.org
readthedocs/builds/automation_actions.py
.py
""" Actions used for the automation rules. Each function will receive the following args: - version: The version object where the action will be applied - action_arg: An additional argument to apply the action """ import structlog from readthedocs.core.utils import trigger_build from readthedocs.projects.constants ...
85
2,192
jupyterlab
scripts/watch_dev.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from jupyterlab.commands import watch_dev if __name__ == "__main__": procs = watch_dev() procs[0].wait()
9
216
readthedocs.org
readthedocs/api/v2/permissions.py
.py
"""Defines access permissions for the API.""" from rest_framework import permissions from rest_framework_api_key.permissions import BaseHasAPIKey from rest_framework_api_key.permissions import KeyParser from readthedocs.api.v2.models import BuildAPIKey class IsOwner(permissions.BasePermission): """Custom permis...
93
2,630
textual
tests/snapshot_tests/snapshot_apps/line_api_scrollbars.py
.py
from rich.text import Text from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widget import Widget from textual.widgets import RichLog class MyWidget(Widget): def render(self): return Text( "\n".join(f"{n} 0123456789" for n in range(20)), ...
55
1,108
pyomo
pyomo/repn/plugins/__init__.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...
60
1,987
confluent-kafka-python
src/confluent_kafka/aio/producer/_AIOProducer.py
.py
# Copyright 2025 Confluent Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
332
14,362
wandb
wandb/integration/sb3/__init__.py
.py
from .sb3 import WandbCallback __all__ = ["WandbCallback"]
4
60
mlflow
mlflow/protos/databricks_managed_catalog_service_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: databricks_managed_catalog_service.proto # Protobuf Python Version: 5.26.0 """Generated protocol buffer...
87
5,182
cvxpy
cvxpy/utilities/versioning.py
.py
""" Copyright 2022, the CVXPY authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, sof...
58
1,851
mlflow
mlflow/tracking/default_experiment/abstract_context.py
.py
from abc import ABCMeta, abstractmethod from mlflow.utils.annotations import developer_stable @developer_stable class DefaultExperimentProvider: """ Abstract base class for objects that provide the ID of an MLflow Experiment based on the current client context. For example, when the MLflow client is runn...
44
1,675
readthedocs.org
readthedocs/core/finders.py
.py
import os from debug_toolbar.apps import DebugToolbarConfig from django.contrib.staticfiles.finders import AppDirectoriesFinder class DebugToolbarFinder(AppDirectoriesFinder): """ Finder to copy the static files for `debug_toolbar` even if it's not installed. We want to do this because we run `collectst...
31
1,084
astropy
astropy/utils/tests/test_misc.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import json import locale import urllib.error from datetime import datetime import numpy as np import pytest from astropy.io import fits from astropy.tests.helper import CI from astropy.utils import misc from astropy.utils.exceptions import AstropyDepre...
164
5,237
probability
tensorflow_probability/python/stats/moving_stats_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...
166
6,741
biopython
Tests/test_SearchIO_hmmer3_domtab_index.py
.py
# Copyright 2012 by Wibowo Arindrarto. 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. """Tests for SearchIO hmmer3-domtab indexing.""" import os import unittest from search_t...
84
5,490
returns
tests/test_examples/test_context/test_reader_future_result.py
.py
from collections.abc import Sequence from typing import Final, cast import anyio # you would need to `pip install anyio` import httpx # you would need to `pip install httpx` from typing_extensions import TypedDict from returns.context import RequiresContextFutureResultE from returns.functions import tap from return...
82
2,465
coveragepy
coverage/plugin.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 """ .. version-added:: 4.0 Plug-in interfaces for coverage.py. Coverage.py supports a few different kinds of plug-ins that change its behavior: * File tracers ...
617
21,500
wagtail
wagtail/admin/rich_text/converters/html_ruleset.py
.py
import re from collections.abc import Mapping ELEMENT_SELECTOR = re.compile(r"^([\w-]+)$") ELEMENT_WITH_ATTR_SELECTOR = re.compile(r"^([\w-]+)\[([\w-]+)\]$") ELEMENT_WITH_ATTR_EXACT_SINGLE_QUOTE_SELECTOR = re.compile( r"^([\w-]+)\[([\w-]+)='(.*)'\]$" ) ELEMENT_WITH_ATTR_EXACT_DOUBLE_QUOTE_SELECTOR = re.compile( ...
109
4,117
gunicorn
tests/test_asgi_websocket_enhanced.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """ Enhanced WebSocket ASGI tests. Tests for WebSocket message size limits, connection rejection, subprotocol negotiation, and compression per ASGI 3.0 and RFC 6455. """ import struct from unittest import mock i...
499
16,338
coremltools
coremltools/proto/SVM_pb2.py
.py
# -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: SVM.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 google.p...
162
9,114
luigi
luigi/contrib/scalding.py
.py
# -*- coding: utf-8 -*- # # Copyright 2012-2015 Spotify AB # # 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...
298
10,409
saleor
saleor/graphql/tests/test_utils.py
.py
import re import pytest from django.test import override_settings from graphql import GraphQLError from graphql.utils import schema_printer from ..api import backend, schema from ..utils import ( ALLOWED_ERRORS, INTERNAL_ERROR_MESSAGE, format_error, get_source_service_name_value, ) from ..utils.valida...
359
8,757
pyomo
pyomo/contrib/mpc/interfaces/copy_values.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...
50
2,024
ipython
IPython/terminal/ptutils.py
.py
"""prompt-toolkit utilities Everything in this module is a private API, not to be used outside IPython. """ from __future__ import annotations # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. import unicodedata from wcwidth import wcwidth from IPython.core.complet...
265
9,136
wagtail
wagtail/admin/views/pages/revisions.py
.py
import swapper from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404, redirect from django.template.loader import render_to_string from django.urls import reverse from django.utils.decorators import method_decorator from django.utils.safestring import mark_safe from django.u...
149
5,238
django-cms
cms/tests/test_cms_config_wizards.py
.py
from unittest.mock import Mock from django.apps import apps from django.core.exceptions import ImproperlyConfigured from cms.app_registration import get_cms_config_apps, get_cms_extension_apps from cms.cms_config import CMSCoreExtensions from cms.cms_wizards import cms_page_wizard, cms_subpage_wizard from cms.test_ut...
93
3,572
onnxruntime
orttraining/orttraining/test/python/orttraining_test_sampler.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # orttraining_test_sampler.py import random import torch from onnxruntime.training.utils.data import sampler class MyDataset(torch.utils.data.Dataset): def __init__(self, samples): self.samples = samples ...
161
6,195
sphinx
tests/roots/test-build-text/conf.py
.py
source_suffix = { '.txt': 'restructuredtext', } exclude_patterns = ['_build']
5
82
astropy
astropy/utils/tests/test_xml.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import io import pytest from astropy.utils.compat.optional_deps import HAS_BLEACH from astropy.utils.xml import check, unescaper, writer def test_writer(): fh = io.StringIO() w = writer.XMLWriter(fh) with w.tag("html"): with w.tag(...
120
3,235
sqlmap
plugins/dbms/mckoi/filesystem.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ from lib.core.exception import SqlmapUnsupportedFeatureException from plugins.generic.filesystem import Filesystem as GenericFilesystem class Filesystem(GenericFilesystem): d...
19
668
biopython
Bio/Graphics/GenomeDiagram/_Track.py
.py
# Copyright 2003-2008 by Leighton Pritchard. 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. # # Contact: ...
285
11,662
pyomo
pyomo/util/tests/test_calc_var_value.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...
469
18,110
deap
deap/benchmarks/movingpeaks.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 ...
402
18,331
jupytext
src/jupytext/kernels.py
.py
"""Find kernel specifications for a given language""" import os import sys from .languages import same_language from .reraise import reraise try: # I prefer not to take a dependency on jupyter_client from jupyter_client.kernelspec import find_kernel_specs, get_kernel_spec except ImportError as err: find_...
57
2,158
ipython
IPython/core/displayhook.py
.py
"""Displayhook for IPython. This defines a callable class that IPython uses for `sys.displayhook`. """ # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. import builtins as builtin_mod import sys import io as _io import tokenize from traitlets.config.configurable im...
346
13,225
wagtail
wagtail/admin/views/generic/lock.py
.py
from django.utils import timezone from django.utils.text import capfirst from django.utils.translation import gettext as _ from wagtail.admin.utils import get_latest_str from wagtail.admin.views.generic.base import BaseOperationView from wagtail.log_actions import log class LockView(BaseOperationView): success_m...
43
1,435
beam
sdks/python/gen_xlang_wrappers.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...
440
16,588
saleor
saleor/graphql/webhook/tests/queries/test_event_delivery_sort.py
.py
from ....tests.utils import get_graphql_content EVENT_DELIVERY_SORT_QUERY = """ query webhook( $id: ID! $first: Int, $last: Int, $after: String, $before: String, $sortBy: EventDeliverySortingInput ){ webhook(id: $id){ eventDeliveries( first: $first, last: $last, afte...
160
4,716
saleor
saleor/graphql/app/sorters.py
.py
from ..core.doc_category import DOC_CATEGORY_APPS from ..core.types import BaseEnum, SortInputObjectType class AppSortField(BaseEnum): NAME = ["name", "pk"] CREATION_DATE = ["created_at", "name", "pk"] class Meta: doc_category = DOC_CATEGORY_APPS @property def description(self): ...
25
711
textual
src/textual/widgets/_loading_indicator.py
.py
from __future__ import annotations from time import time from typing import TYPE_CHECKING from rich.style import Style from rich.text import Text if TYPE_CHECKING: from textual.app import RenderResult from textual import on from textual.color import Gradient from textual.events import InputEvent, Mount from tex...
94
2,545
wagtail
wagtail/api/v3/form_data.py
.py
from collections.abc import Iterable from typing import Any, cast import swapper from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import AnonymousUser from django.core.exceptions import FieldDoesNotExist, ValidationError from django.db.models import Model from django.forms imp...
442
19,835
sphinx
tests/roots/test-root/autodoc_target.py
.py
import enum from io import StringIO __all__ = ['Class'] #: documentation for the integer integer = 1 def raises(exc, func, *args, **kwds): """Raise AssertionError if ``func(*args, **kwds)`` does not raise *exc*.""" pass class CustomEx(Exception): """My custom exception.""" def f(self): ""...
222
4,632
kombu
examples/simple_eventlet_send.py
.py
""" Example that sends a single message and exits using the simple interface. You can use `simple_receive.py` (or `complete_receive.py`) to receive the message sent. """ from __future__ import annotations import eventlet from kombu import Connection eventlet.monkey_patch() def send_many(n): #: Create conn...
44
1,181
saleor
saleor/tests/e2e/sales/utils/sale_catalogues_add.py
.py
from ...utils import get_graphql_content SALE_CATALOGUES_ADD_MUTATION = """ mutation SaleCataloguesAdd($id: ID!, $input: CatalogueInput!, $first: Int) { saleCataloguesAdd(id: $id, input: $input) { errors { field message code } sale { id name channelListings { c...
73
1,324
beam
sdks/python/apache_beam/io/snowflake.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...
489
18,563
black
tests/data/cases/remove_except_types_parens.py
.py
# flags: --minimum-version=3.14 # SEE PEP 758 FOR MORE DETAILS # remains unchanged try: pass except: pass # remains unchanged try: pass except ValueError: pass try: pass except* ValueError: pass # parenthesis are removed try: pass except (ValueError): pass try: pass except* (Valu...
250
3,386
textual
docs/examples/widgets/checkbox.py
.py
from textual.app import App, ComposeResult from textual.containers import VerticalScroll from textual.widgets import Checkbox class CheckboxApp(App[None]): CSS_PATH = "checkbox.tcss" def compose(self) -> ComposeResult: with VerticalScroll(): yield Checkbox("Arrakis :sweat:") y...
26
764
mlflow
mlflow/genai/agent_server/validator.py
.py
from dataclasses import asdict, is_dataclass from typing import Any from pydantic import BaseModel from mlflow.types.responses import ( ResponsesAgentRequest, ResponsesAgentResponse, ResponsesAgentStreamEvent, ) class BaseAgentValidator: """Base validator class with common validation methods""" ...
67
2,527
pyomo
pyomo/contrib/appsi/solvers/tests/test_gurobi_persistent.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...
742
26,392
coremltools
deps/protobuf/generate_changelog.py
.py
#!/usr/bin/env python """Generates a friendly list of changes per language since the last release.""" import sys import os class Language(object): def __init__(self, name, pathspec): self.name = name self.pathspec = pathspec languages = [ Language("C++", [ "':(glob)src/google/protobuf/*'", "...
66
1,549
pymc
tests/progress_bar/test_marimo.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...
201
7,382
probability
tensorflow_probability/python/experimental/nn/util/__init__.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...
73
3,899
coremltools
coremltools/test/optimize/torch/conversion/conversion_utils.py
.py
# Copyright (c) 2024, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import random import sys import numpy as np import torch import coremltools as ct torch.manual_see...
141
4,215
biopython
Bio/Phylo/TreeConstruction.py
.py
# Copyright (C) 2013 by Yanbo Ye (yeyanbo289@gmail.com) # # This file is part of the Biopython distribution and governed by your # choice of the "Biopython License Agreement" or the "BSD 3-Clause License". # Please see the LICENSE file that should have been included as part of this # package. """Classes and methods fo...
1,290
48,988
onnxruntime
onnxruntime/test/python/quantization/test_op_gavgpool.py
.py
#!/usr/bin/env python # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # ---------------------------------------------------------------...
143
5,578
probability
tensorflow_probability/python/distributions/pixel_cnn.py
.py
# Copyright 2019 The TensorFlow Probability Authors. # Copyright 2019 OpenAI (http://openai.com). # # 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/LICENS...
1,013
43,739
wandb
wandb/sdk/launch/_launch_add.py
.py
from __future__ import annotations import asyncio import pprint from typing import Any import wandb import wandb.apis.public as public from wandb.apis.internal import Api from wandb.errors import CommError from wandb.sdk.launch.builder.build import build_image_from_project from wandb.sdk.launch.errors import LaunchEr...
258
8,670
probability
tensorflow_probability/python/experimental/nn/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...
180
5,273
astropy
astropy/utils/tests/test_decorators.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import concurrent.futures import inspect import pickle import sys import pytest from astropy.tests.helper import _skip_docstring_tests_with_optimized_python from astropy.utils.decorators import ( classproperty, deprecated, deprecated_attribu...
948
28,427
pymc
benchmarks/benchmarks/__init__.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...
16
641
onnxruntime
onnxruntime/python/tools/transformers/fusion_qordered_gelu.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_base import Fusion from fusi...
119
4,292
scikit-optimize
examples/sampler/sampling_comparison.py
.py
""" ========================================== Comparing initial point generation methods ========================================== Holger Nahrstaedt 2020 .. currentmodule:: skopt Bayesian optimization or sequential model-based optimization uses a surrogate model to model the expensive to evaluate function `func`. ...
192
6,903
biopython
Bio/Align/bigmaf.py
.py
# Copyright 2022 by Michiel de Hoon. 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.Align support fo...
354
13,702
conda
conda/gateways/repodata/__init__.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Repodata interface.""" from __future__ import annotations import abc import datetime import errno import hashlib import logging import os import pathlib import re import time import warnings from collections import UserDict from contextlib ...
1,045
35,787
sqlmap
lib/core/convert.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import base64 import binascii import codecs import datetime import decimal import json import re import sys import time from lib.core.bigarray import BigArray from lib.core.compa...
698
24,850
pyomo
examples/pyomobook/scripts-ch/sudoku/sudoku.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...
122
4,365
openvino
tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_embedding.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 TestKerasEmbedding(CommonTF2LayerTest): def create_keras_emb_net(self, input_names, input_shapes, input_type, input_dim, output...
71
3,515
pyomo
pyomo/mpec/plugins/mpec1.py
.py
# ____________________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and Engineering # Solutions of...
109
4,012
pyro
pyro/poutine/indep_messenger.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 from typing import Iterator, NamedTuple, Optional, Tuple, Union import torch from typing_extensions import Self from pyro.poutine.messenger import Messenger from pyro.poutine.runtime import _DIM_ALLOCATOR, Message from pyro.util ...
148
4,723
probability
tensorflow_probability/python/experimental/parallel_filter/__init__.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...
25
1,162
saleor
saleor/core/utils/tests/test_validators.py
.py
import pytest from ..validators import get_mime_type, is_image_mimetype, is_valid_image_content_type def test_is_image_mimetype_valid_mimetype(): # given valid_mimetype = "image/jpeg" # when result = is_image_mimetype(valid_mimetype) # then assert result def test_is_image_mimetype_invalid...
69
1,709
beam
learning/katas/python/Streaming/Windows/Fixed Windows/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...
56
2,551
onnxruntime
onnxruntime/python/tools/transformers/models/t5/t5_encoder.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # ------------------------------------------------------------------------- import logging import random import torch from transformers import MT5Co...
71
2,249
wagtail
wagtail/contrib/frontend_cache/backends/azure.py
.py
import logging import warnings from urllib.parse import urlsplit, urlunsplit from django.core.exceptions import ImproperlyConfigured from wagtail.utils.deprecation import RemovedInWagtail90Warning from .base import BaseBackend logger = logging.getLogger("wagtail.frontendcache") __all__ = ["AzureBaseBackend", "Azu...
268
9,310
beam
sdks/python/apache_beam/runners/portability/expansion_service_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...
421
13,959
django-cms
cms/test_utils/project/app_with_two_cms_feature_classes/cms_config.py
.py
from cms.app_base import CMSAppConfig, CMSAppExtension class CMSFeatureConfig(CMSAppExtension): pass class CMSFeatureConfig2(CMSAppExtension): pass class CMSConfig(CMSAppConfig): pass
14
202
textual
docs/examples/how-to/containers02.py
.py
from textual.app import App, ComposeResult from textual.containers import Vertical from textual.widgets import Placeholder class Box(Placeholder): """Example widget.""" DEFAULT_CSS = """ Box { width: 16; height: 8; } """ class ContainerApp(App): """Simple app to play...
30
555
pyomo
doc/OnlineDocs/src/scripting/spy4scripts.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...
220
6,560
beam
sdks/python/apache_beam/examples/online_clustering.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...
339
12,076
qutip
qutip/tests/solver/test_nm_mcsolve.py
.py
from copy import copy import numpy as np import pytest import qutip from qutip.solver.nm_mcsolve import nm_mcsolve, NonMarkovianMCSolver @pytest.mark.slow @pytest.mark.parametrize("improved_sampling", [True, False]) @pytest.mark.parametrize("mixed_initial_state", [True, False]) def test_agreement_with_mesolve_for_n...
832
30,534
pyomo
examples/pyomobook/python-ch/functions.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
905
coveragepy
coverage/__init__.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 """ Code coverage measurement for Python. Ned Batchelder https://coverage.readthedocs.io """ from __future__ import annotations # mypy's convention is that "i...
39
1,045
probability
discussion/adaptive_malt/grid_search_runner.py
.py
# Copyright 2022 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...
92
3,317
textual
tests/snapshot_tests/snapshot_apps/nested_specificity.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class BaseTester(Static, can_focus=True): DEFAULT_CSS = """ BaseTester:focus { background: yellow; border: thick magenta; } """ class NonNestedCSS(BaseTester): DEFAULT_CSS = """ NonNestedCSS { ...
63
1,151
mlflow
mlflow/tracing/otel/translation/vercel_ai.py
.py
import json from typing import Any from mlflow.entities.span import SpanType from mlflow.tracing.constant import SpanAttributeKey from mlflow.tracing.otel.translation.base import OtelSchemaTranslator class VercelAITranslator(OtelSchemaTranslator): """Translator for Vercel AI SDK spans.""" # https://ai-sdk.d...
92
3,350
mamba
micromamba/tests/test-server/reposerver.py
.py
import argparse import base64 import os import re import sys import http.server class ChannelHandler(http.server.SimpleHTTPRequestHandler): url_pattern = re.compile(r"^/(?:t/[^/]+/)?([^/]+)") def do_GET(self) -> None: # First extract channel name channel_name = None if tuple(channels....
193
6,145
saleor
saleor/graphql/order/types.py
.py
import logging from decimal import Decimal from typing import cast from uuid import UUID import graphene import prices from django.core.exceptions import ValidationError from graphene import relay from promise import Promise from ...account.models import Address from ...account.models import User as UserModel from .....
3,206
116,080
hydra
tests/test_apps/config_source_test/structured.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from dataclasses import dataclass from typing import Any from omegaconf import MISSING from hydra.core.config_store import ConfigStore @dataclass class ConfigWithoutGroup: group: bool = False @dataclass class ConfigWithUnicode: group: ...
108
2,572
ipython
IPython/core/error.py
.py
""" Global exception classes for IPython.core. Authors: * Brian Granger * Fernando Perez * Min Ragan-Kelley Notes ----- """ #----------------------------------------------------------------------------- # Copyright (C) 2008 The IPython Development Team # # Distributed under the terms of the BSD License. The full...
60
1,716
clearml
clearml/automation/auto_scaler.py
.py
import logging import re from collections import defaultdict, deque from enum import Enum from itertools import chain from threading import Event, Thread from time import sleep, time from typing import Tuple, Dict, Optional, List, Generator, Any import attr from attr.validators import instance_of from .cloud_driver i...
483
19,698
clearml
clearml/utilities/dicts.py
.py
""" Utilities """ from typing import Optional, Any _epsilon = 0.00001 class ReadOnlyDict(dict): """A read-only dictionary that can only be accessed via its keys.""" def __readonly__(self, *args: Any, **kwargs: Any) -> None: raise ValueError("This is a read only dictionary") __setitem__ = __reado...
203
5,870
pdm
src/pdm/formats/poetry.py
.py
from __future__ import annotations import functools import operator import os import re from collections.abc import Iterable, Mapping from pathlib import Path from typing import TYPE_CHECKING, Any, cast from pdm.compat import tomllib from pdm.formats.base import ( MetaConverter, Unset, array_of_inline_tab...
256
9,063
wandb
wandb/apis/_generated/create_invite.py
.py
# Generated by ariadne-codegen # Source: tools/graphql_codegen/api/ from __future__ import annotations from pydantic import Field from wandb._pydantic import GQLId, GQLResult class CreateInvite(GQLResult): result: CreateInviteResult | None class CreateInviteResult(GQLResult): invite: CreateInviteResultIn...
34
728
sphinx
sphinx/search/sv.py
.py
"""Swedish search language.""" from __future__ import annotations import snowballstemmer from sphinx.search import SearchLanguage from sphinx.search._stopwords.sv import SWEDISH_STOPWORDS class SearchSwedish(SearchLanguage): lang = 'sv' language_name = 'Swedish' js_stemmer_rawcode = 'swedish-stemmer.js...
23
596
pymc
tests/test_model_graph.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...
697
22,389
beam
sdks/python/apache_beam/testing/benchmarks/chicago_taxi/trainer/model.py
.py
# Copyright 2019 Google LLC. All Rights Reserved. # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
163
6,138
beam
sdks/python/apache_beam/runners/worker/channel_factory.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...
54
1,881
metrics
tests/unittests/classification/test_precision_recall_curve.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...
492
21,988