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
pymc
pymc/progress_bar/rich_progress.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...
405
13,504
onnxruntime
onnxruntime/python/tools/transformers/models/longformer/benchmark_longformer.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- # # This...
822
29,409
mlflow
dev/clint/src/clint/rules/missing_docstring_param.py
.py
from clint.rules.base import Rule class MissingDocstringParam(Rule): def __init__(self, params: set[str]) -> None: self.params = params def _message(self) -> str: return f"Missing parameters in docstring: {self.params}"
10
247
django-cms
cms/management/commands/subcommands/delete_orphaned_plugins.py
.py
from django.contrib.contenttypes.models import ContentType from django.db import transaction from django.db.models import Exists, OuterRef from cms.management.commands.subcommands.list import plugin_report from cms.models.placeholdermodel import Placeholder from cms.models.pluginmodel import CMSPlugin from .base impo...
122
5,116
saleor
saleor/graphql/page/mutations/page_type_delete.py
.py
import graphene from django.db.models.expressions import Exists, OuterRef from ....attribute import AttributeInputType from ....attribute import models as attribute_models from ....core.tracing import traced_atomic_transaction from ....page import models from ....permission.enums import PageTypePermissions from ....pr...
80
3,154
saleor
saleor/thumbnail/models.py
.py
from django.core.exceptions import ValidationError from django.db import models from ..account.models import User from ..app.models import App, AppInstallation from ..product.models import Category, Collection, ProductMedia from . import THUMBNAIL_SIZES, ThumbnailFormat def validate_thumbnail_size(size: int): if...
58
1,757
pyro
scripts/update_headers.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import argparse import glob import os import sys root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) blacklist = ["/build/", "/dist/", "/pyro/_version.py"] file_types = [ ("*.py", "# {}"), ("*.cpp", "// {}"), ] ...
78
2,276
cvxpy
cvxpy/reductions/solvers/conic_solvers/glpk_conif.py
.py
""" Copyright 2013 Steven Diamond Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software...
120
4,223
openvino
tests/model_hub_tests/pytorch/test_edsr.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os import platform import pytest import random import torch from models_hub_common.constants import hf_cache_dir, clean_hf_cache_dir from models_hub_common.utils import cleanup_dir from torch_utils import TestTorchConvertModel, ...
106
3,258
probability
tensorflow_probability/python/distributions/finite_discrete.py
.py
# Copyright 2018 The TensorFlow Probability Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
355
14,395
attrs
src/attr/converters.py
.py
# SPDX-License-Identifier: MIT """ Commonly useful converters. """ from ._compat import _AnnotationExtractor from ._make import NOTHING, Converter, Factory, pipe __all__ = [ "default_if_none", "optional", "pipe", "to_bool", ] def optional(converter): """ A converter that allows an attribut...
161
3,826
textual
tests/snapshot_tests/snapshot_apps/scroll_visible_margin.py
.py
from textual.app import App, ComposeResult from textual.containers import VerticalScroll, Container from textual.widgets import Button class ScrollVisibleMargin(App): CSS = """ Container { height: auto; margin-top: 8; border: solid red; } """ def compose(self) -> ComposeRe...
29
686
coremltools
coremltools/converters/mil/mil/ops/defs/iOS17/conv.py
.py
# Copyright (c) 2023, 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 coremltools.converters.mil.mil.input_type impor...
70
3,110
sqlmap
thirdparty/chardet/escsm.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...
247
10,510
sphinx
tests/test_domains/test_domain_js.py
.py
"""Tests the JavaScript Domain""" from __future__ import annotations from unittest.mock import Mock import docutils.utils import pytest from docutils import nodes from sphinx import addnodes from sphinx.addnodes import ( desc, desc_annotation, desc_content, desc_name, desc_parameter, desc_pa...
945
28,309
textual
docs/examples/how-to/layout03.py
.py
from textual.app import App, ComposeResult from textual.screen import Screen from textual.widgets import Placeholder class Header(Placeholder): DEFAULT_CSS = """ Header { height: 3; dock: top; } """ class Footer(Placeholder): DEFAULT_CSS = """ Footer { height: 3; ...
49
871
probability
spinoffs/inference_gym/inference_gym/tools/stan/sparse_logistic_regression.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...
156
4,839
coremltools
coremltools/test/sklearn_tests/test_utils.py
.py
# Copyright (c) 2017, 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 unittest from ..utils import load_boston from coremltools._deps import _HAS_SKLEARN from coremltoo...
51
1,864
openvino
tests/layer_tests/pytorch_tests/test_deformable_convolution.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from copy import deepcopy import pytest import torch from pytorch_layer_test_class import PytorchLayerTest from torchvision.ops import deform_conv2d params = [ { "weights_shape": [64, 64, 3, 3], "offset_shape": [1,...
181
5,329
jupyterlab
jupyterlab/labextensions.py
.py
"""Jupyter LabExtension Entry Points.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import os import subprocess import sys from collections.abc import Sequence from copy import copy from jupyter_core.application import JupyterApp, base_aliases, base_flags fro...
547
18,538
saleor
saleor/graphql/discount/tests/mutations/test_sale_bulk_delete.py
.py
from unittest import mock import graphene from django.conf import settings from .....discount.error_codes import DiscountErrorCode from .....discount.models import Promotion, PromotionRule from .....product.models import ProductChannelListing, ProductVariant from ....tests.utils import get_graphql_content SALE_BULK_...
251
8,062
astropy
astropy/constants/utils.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Utility functions for ``constants`` sub-package.""" __all__ = [] def _get_c(codata, iaudata, module, not_in_module_only=True): """ Generator to return a Constant object. Parameters ---------- codata, iaudata : obj Modules...
85
2,365
mlflow
dev/clint/tests/rules/test_except_bool_op.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules import ExceptBoolOp def test_except_bool_op(index: SymbolIndex) -> None: code = """ # Bad - or in except try: pass except ValueError or KeyError: ...
55
1,016
python-prompt-toolkit
src/prompt_toolkit/clipboard/in_memory.py
.py
from __future__ import annotations from collections import deque from .base import Clipboard, ClipboardData __all__ = [ "InMemoryClipboard", ] class InMemoryClipboard(Clipboard): """ Default clipboard implementation. Just keep the data in memory. This implements a kill-ring, for Emacs mode. ...
45
1,060
mlflow
mlflow/utils/arguments_utils.py
.py
import inspect def _get_arg_names(f): """Get the argument names of a function. Args: f: A function. Returns: A list of argument names. """ # `inspect.getargspec` or `inspect.getfullargspec` doesn't work properly for a wrapped function. # See https://hynek.me/articles/decorat...
17
412
voila
tests/app/contents_handler_test.py
.py
import json import pytest import tornado @pytest.fixture def preheat_mode(): return False @pytest.fixture def contents_prefix(base_url): return base_url + "voila/api/contents" @pytest.fixture def voila_args(notebook_directory, voila_args_extra): return ["--VoilaTest.root_dir=%r" % notebook_directory, ...
50
1,527
saleor
saleor/graphql/payment/mutations/payment/checkout_payment_create.py
.py
import graphene from django.conf import settings from django.core.exceptions import ValidationError from django.db import transaction from .....checkout import models as checkout_models from .....checkout.calculations import calculate_checkout_total_with_gift_cards from .....checkout.checkout_cleaner import ( clea...
353
13,416
pyfilesystem2
tests/test_tree.py
.py
from __future__ import print_function, unicode_literals import io import unittest from fs import tree from fs.memoryfs import MemoryFS class TestInfo(unittest.TestCase): def setUp(self): self.fs = MemoryFS() self.fs.makedir("foo") self.fs.makedir("bar") self.fs.makedir("baz") ...
79
4,759
openvino
src/bindings/python/src/openvino/properties/intel_npu/__init__.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # Enums from openvino._pyopenvino.properties.intel_npu import CompilerType # Properties import openvino._pyopenvino.properties.intel_npu as __intel_npu from openvino.properties._properties import __make_propertie...
13
364
pyomo
pyomo/contrib/mindtpy/__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...
11
571
metrics
src/torchmetrics/regression/__init__.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...
61
2,675
textual
src/textual/rlock.py
.py
from __future__ import annotations from asyncio import Lock, Task, current_task class RLock: """A re-entrant asyncio lock.""" def __init__(self) -> None: self._owner: Task | None = None self._count = 0 self._lock = Lock() async def acquire(self) -> None: """Wait until th...
62
1,657
pyomo
examples/pyomo/quadratic/example1.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...
27
1,026
sqlmap
tamper/sp_password.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.enums import PRIORITY __priority__ = PRIORITY.LOWEST def tamper(payload, **kwargs): """ Appends (MsSQL) function 'sp_password' to the end of the payload fo...
33
826
onnxruntime
onnxruntime/core/flatbuffers/schema/compile_schema.py
.py
#!/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import argparse import pathlib import shutil import subprocess import tempfile SCRIPT_DIR = pathlib.Path(__file__).parent.resolve() def update_schema_names(schema_path: pathlib.Path, updated_schema_p...
150
6,249
pymc
tests/gp/test_cov.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...
949
33,596
sqlmap
tests/test_serialize.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission Exhaustive lock on the safe (JSON-based, no code execution) serializer that backs the session store (HashDB) and BigArray disk chunks - the replacement for the former code-executing s...
463
20,504
sqlmap
tests/test_grpcweb.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission gRPC-Web body support (lib/utils/grpcweb.py, grpc-web-text/unary). Covers the peer-review merge gate: exact round-trip, injection with length recomputation, strict framing validation ...
269
13,496
django-cms
cms/models/settingmodels.py
.py
from django.conf import settings from django.db import models from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ class PlaceholderForeignKey(models.ForeignKey): def run_checks(self, placeholder, user): # A clipboard is private to its owner: only they have pe...
47
1,613
sqlmap
thirdparty/chardet/euckrfreq.py
.py
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Communicator client 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 R...
196
13,546
readthedocs.org
readthedocs/api/v3/tests/test_projects.py
.py
from unittest import mock import django_dynamic_fixture as fixture from django.test import override_settings from django.urls import reverse from django_dynamic_fixture import get from readthedocs.oauth.models import RemoteRepository, RemoteRepositoryRelation from readthedocs.projects.constants import PRIVATE, SINGLE...
994
35,490
httpie
httpie/output/ui/palette.py
.py
from dataclasses import dataclass, field from enum import Enum, auto from typing import Optional, List PYGMENTS_BRIGHT_BLACK = 'ansibrightblack' AUTO_STYLE = 'auto' # Follows terminal ANSI color styles class Styles(Enum): PIE = auto() ANSI = auto() class PieStyle(str, Enum): UNIVERSAL = 'pie' DA...
270
7,226
saleor
saleor/graphql/order/tests/mutations/test_fulfillment_update_tracking.py
.py
from unittest.mock import ANY, patch import graphene import pytest from .....webhook.event_types import WebhookEventAsyncType from ....tests.utils import assert_no_permission, get_graphql_content FULFILLMENT_UPDATE_TRACKING_QUERY = """ mutation updateFulfillment( $id: ID! $tracking: String ...
176
6,142
pyro
pyro/poutine/messenger.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 from contextlib import contextmanager from functools import partial from types import TracebackType from typing import ( Any, Callable, Iterator, List, Optional, Type, TypeVar, ) from typing_extensions ...
288
9,475
ipython
tests/test_latextools.py
.py
"""Tests for IPython.utils.path.py""" # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. from contextlib import contextmanager from unittest.mock import patch import pytest from IPython.lib import latextools from IPython.testing.decorators import ( onlyif_cmds_e...
210
5,715
onnx
onnx/reference/ops/op_min.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.ops._op import OpRunBinaryNumpy class Min(OpRunBinaryNumpy): def __init__(self, onnx_node, run_params): OpRunBinaryNumpy.__init__(self, np.minimum, o...
26
729
django-cms
cms/tests/test_widgets.py
.py
from cms.api import create_page from cms.forms.widgets import PageSelectWidget, PageSmartLinkWidget from cms.test_utils.testcases import CMSTestCase class WidgetTestCases(CMSTestCase): def test_pageselectwidget(self): page = create_page("Test page", "nav_playground.html", "en") page2 = create_page...
25
1,173
onnx
onnx/reference/ops/op_hard_sigmoid.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.ops._op import OpRunUnaryNum class HardSigmoid(OpRunUnaryNum): def _run(self, x, alpha=None, beta=None): alpha = alpha or self.alpha beta = b...
17
432
cvxpy
cvxpy/reductions/dcp2cone/canonicalizers/perspective_canon.py
.py
""" Copyright, the CVXPY authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software...
105
4,409
saleor
saleor/graphql/tests/test_storefront_traffic.py
.py
from types import SimpleNamespace import pytest from jwt import InvalidTokenError from saleor.core.auth import SALEOR_AUTH_HEADER from saleor.graphql.storefront_traffic import ( clear_allow_storefront_traffic_cache, is_storefront_traffic_blocked, ) def _make_request(app=None, user=None, authenticated=False)...
135
4,265
probability
tensorflow_probability/python/experimental/auto_batching/numpy_backend_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...
83
3,439
saleor
saleor/graphql/account/tests/test_account_utils.py
.py
from ....account.models import Group, User from ....account.tests.fixtures.user import dangerously_create_test_user from ....app.models import App from ....channel.models import Channel from ....permission.enums import ( AccountPermissions, OrderPermissions, ProductPermissions, ) from ..utils import ( c...
1,080
32,518
beam
learning/tour-of-beam/learning-content/core-transforms/motivating-challenge-2/python-solution/task.py
.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); y...
55
1,959
beam
sdks/python/apache_beam/io/aws/s3io.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...
667
22,899
pyro
pyro/distributions/conjugate.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import numbers import torch from torch.distributions.utils import broadcast_all from pyro.ops.special import log_beta, log_binomial from . import constraints from .torch import Beta, Binomial, Dirichlet, Gamma, Multinomial, Pois...
296
10,898
mlflow
mlflow/tracing/utils/token.py
.py
from dataclasses import dataclass from typing import TYPE_CHECKING from mlflow.entities import LiveSpan if TYPE_CHECKING: from mlflow.tracing.provider import SpanContextToken @dataclass class SpanWithToken: """ A utility container to hold an MLflow span and its corresponding OpenTelemetry token. Th...
23
751
returns
returns/interfaces/specific/reader_ioresult.py
.py
from __future__ import annotations from abc import abstractmethod from collections.abc import Callable, Sequence from typing import TYPE_CHECKING, ClassVar, TypeVar, final from returns.interfaces.specific import ioresult, reader, reader_result from returns.primitives.hkt import KindN from returns.primitives.laws impo...
120
3,428
omegaconf
setup.py
.py
# type: ignore import os import pathlib from typing import Any, cast import setuptools from build_helpers.build_helpers import ( ANTLRCommand, BuildPyCommand, CleanCommand, DevelopCommand, SDistCommand, find_version, ) def read_requirements(path): requirements = [] req_path = pathlib...
90
2,698
conda
conda/plugins/environment_specifiers/__init__.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Register the built-in environment specifier hook implementations.""" from . import cep_24, environment_yml, explicit, requirements_txt plugins = [cep_24, requirements_txt, environment_yml, explicit] """The list of environment specifier plug...
9
364
lemur
lemur/logs/schemas.py
.py
""" .. module: lemur.logs.schemas :platform: unix :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. .. moduleauthor:: Kevin Glisson <kglisson@netflix.com> """ from marshmallow import fields from lemur.common.schema import LemurOutputSchema from lemur...
24
731
openvino
tests/layer_tests/tensorflow_tests/test_tf_RaggedTensorToTensor.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.tf_layer_test_class import CommonTFLayerTest from common.utils.tf_utils import run_in_jenkins rng = np.random.default_rng() class TestRaggedTensorToTensor(CommonTFLa...
117
6,770
metrics
src/torchmetrics/functional/image/lpips.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...
456
17,630
qutip
qutip/solver/multitrajresult.py
.py
""" This module provides result classes for multi-trajectory solvers. Note that single trajectories are described by regular `Result` objects from the `qutip.solver.result` module. """ # Required for Sphinx to follow autodoc_type_aliases from __future__ import annotations from typing import TypedDict from ..core.numpy...
1,796
64,101
biopython
Bio/SearchIO/BlatIO.py
.py
# Copyright 2012 by Wibowo Arindrarto. 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.SearchIO parser ...
756
31,398
openvino
tests/layer_tests/tensorflow_tests/test_tf_SpaceToDepth.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest import tensorflow as tf from common.tf_layer_test_class import CommonTFLayerTest class TestSpaceToDepth(CommonTFLayerTest): def create_space_to_depth_net(self, input_shape, block_size, data_format): tf.compat....
34
1,377
mlflow
mlflow/genai/evaluation/rate_limiter.py
.py
"""Thread-safe rate limiters for evaluation harness.""" from __future__ import annotations import abc import contextlib import logging import threading import time from typing import Callable _logger = logging.getLogger(__name__) @contextlib.contextmanager def eval_retry_context(): """Disable downstream 429 re...
194
6,570
biopython
Bio/Graphics/GenomeDiagram/_Colors.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: ...
235
9,678
toolz
examples/wordcount.py
.py
from toolz import * def stem(word): """ Stem word to primitive form """ return word.lower().rstrip(",.!:;'-\"").lstrip("'\"") wordcount = comp(frequencies, partial(map, stem), str.split) if __name__ == '__main__': print(wordcount("This cat jumped over this other cat!")) # prints {'this': 2, 'cat': 2...
13
358
notebook
docs/source/conf.py
.py
# Jupyter Notebook documentation build configuration file, created by # sphinx-quickstart on Mon Apr 13 09:51:11 2015. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration ...
407
13,174
mlflow
tests/db/check_migration.py
.py
""" Usage ----- export MLFLOW_TRACKING_URI=sqlite:///mlruns.db # pre migration python tests/db/check_migration.py pre-migration # post migration python tests/db/check_migration.py post-migration """ import os import uuid from pathlib import Path import click import pandas as pd import sqlalchemy as sa import mlflo...
188
5,490
hatch
tests/utils/test_linehaul.py
.py
import json import platform import pytest from hatch._version import __version__ from hatch.utils.linehaul import get_linehaul_component, get_linehaul_data class TestGetLinehaulData: def test_installer_info(self): data = get_linehaul_data() assert data["installer"]["name"] == "hatch" as...
166
4,730
onnxruntime
onnxruntime/test/python/quantization/test_op_topk.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import un...
104
4,121
beam
sdks/python/apache_beam/testing/benchmarks/inference/pytorch_imagenet_rightfit_benchmarks.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...
43
1,598
pyomo
pyomo/contrib/solver/solvers/knitro/base.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...
238
8,853
saleor
saleor/graphql/product/mutations/product_type/product_type_create.py
.py
import graphene from django.core.exceptions import ValidationError from .....attribute import AttributeType from .....permission.enums import ProductTypePermissions from .....product import ProductTypeKind, models from .....product.error_codes import ProductErrorCode from ....core import ResolveInfo from ....core.desc...
160
6,564
wagtail
wagtail/signal_handlers.py
.py
import logging from contextlib import contextmanager import swapper from asgiref.local import Local from django.core.cache import cache from django.db import transaction from django.db.models.signals import ( post_delete, post_migrate, post_save, pre_delete, pre_migrate, ) from wagtail.models impo...
124
4,064
pyro
examples/cvae/main.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import argparse import baseline import cvae import pandas as pd import torch from util import generate_table, get_data, visualize import pyro def main(args): device = torch.device( "cuda:0" if torch.cuda.is_available() ...
138
4,148
wagtail
wagtail/test/utils/wagtail_factories/factories.py
.py
import logging import factory import swapper from django.utils.text import slugify from factory import errors, utils from factory.declarations import ParameteredAttribute from factory.django import DjangoModelFactory from wagtail.documents import get_document_model from wagtail.images import get_image_model from wagt...
151
4,348
wandb
wandb/integration/sklearn/calculate/__init__.py
.py
"""Calculates and formats metrics and charts for introspecting sklearn models. The functions in these modules are designed to be called by functions from the plot submodule that have been exported into the namespace of the wandb.sklearn submodule, rather than being called directly. """ from .calibration_curves import...
33
1,055
lemur
lemur/tests/test_validators.py
.py
from datetime import datetime import pytest from marshmallow.exceptions import ValidationError from lemur.common.utils import parse_private_key from lemur.common.validators import verify_private_key_match from lemur.tests.vectors import INTERMEDIATE_CERT, SAN_CERT, SAN_CERT_KEY def test_private_key(session): pa...
57
1,560
onnxruntime
docs/python/examples/plot_common_errors.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """ .. _l-example-common-error: Common errors with onnxruntime ============================== This example looks into several common situations in which *onnxruntime* does not return the model prediction but raises an excep...
120
4,036
beam
sdks/python/apache_beam/io/textio_test.py
.py
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not us...
2,287
85,898
readthedocs.org
readthedocs/rtd_tests/tests/test_urls.py
.py
from django.test import TestCase from django.urls import reverse class TestProfileDetailURLs(TestCase): def test_profile_detail_url(self): url = reverse( "profiles_profile_detail", kwargs={"username": "foo+bar"}, ) self.assertEqual(url, "/profiles/foo+bar/") ...
24
675
onnxruntime
plugin-ep-webgpu/python/onnxruntime_ep_webgpu/__init__.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """ONNX Runtime WebGPU Plugin Execution Provider Python Package. Provides helper functions to locate the plugin EP shared library and retrieve the EP name for registration with ONNX Runtime. """ from __future__ import annot...
47
1,301
mlflow
mlflow/store/workspace/dbmodels/models.py
.py
from __future__ import annotations import sqlalchemy as sa from sqlalchemy import Column, String, Text from mlflow.entities.workspace import Workspace from mlflow.store.db.base_sql_model import Base class SqlWorkspace(Base): __tablename__ = "workspaces" # Workspace-aware tables intentionally do not declare...
37
1,402
sphinx
sphinx/builders/epub3.py
.py
"""Build epub3 files. Originally derived from epub.py. """ from __future__ import annotations import html import os import re import time from typing import TYPE_CHECKING, NamedTuple from sphinx import package_dir from sphinx.builders import _epub_base from sphinx.config import ENUM from sphinx.locale import __ fro...
364
12,745
jupyterlab
scripts/unpack_snapshots.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. #!/usr/bin/env python3 """ Process Playwright test reports and unpack snapshots to their correct locations. This script reads JSON test reports from Playwright's JSON reporter and extracts snapshot files from the test...
294
9,470
openvino
tests/layer_tests/tensorflow_tests/test_tf_TensorListPushBack.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.tf_layer_test_class import CommonTFLayerTest from sys import platform class TestTensorListPushBack(CommonTFLayerTest): def _prepare_input(self, inputs_info): ...
53
2,608
textual
examples/splash.py
.py
from time import time from textual.app import App, ComposeResult, RenderableType from textual.containers import Container from textual.renderables.gradient import LinearGradient from textual.widgets import Static COLORS = [ "#881177", "#aa3355", "#cc6666", "#ee9944", "#eedd00", "#99dd55", ...
59
1,223
textual
src/textual/_immutable_sequence_view.py
.py
"""Provides an immutable sequence view class.""" from __future__ import annotations from sys import maxsize from typing import TYPE_CHECKING, Generic, Iterator, Sequence, TypeVar, overload T = TypeVar("T") class ImmutableSequenceView(Generic[T]): """Class to wrap a sequence of some sort, but not allow modifica...
70
1,859
mlflow
mlflow/genai/optimize/util.py
.py
from __future__ import annotations import functools from contextlib import contextmanager, nullcontext from typing import TYPE_CHECKING, Any, Callable from pydantic import BaseModel, create_model from mlflow.entities import Trace from mlflow.exceptions import MlflowException from mlflow.genai.scorers import Scorer f...
217
8,385
confluent-kafka-python
tests/oauthbearer/aws/test_aws_iam_marker.py
.py
# Copyright 2026 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...
49
1,754
onnxruntime
orttraining/orttraining/python/training/ort_triton/_common.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from abc import abstractmethod from typing import Any import sympy from...
267
9,718
wandb
wandb/automations/events.py
.py
"""Events that trigger W&B Automations.""" from __future__ import annotations from typing import TYPE_CHECKING, Annotated, Any, Literal, get_args from pydantic import AfterValidator, BeforeValidator, Discriminator, Field from wandb._filters import And, FilterableField, MongoLikeFilter from wandb._pydantic import GQ...
496
15,639
conda
conda/plugins/post_solves/__init__.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Register the built-in post_solves hook implementations.""" plugins = [] """The list of post-solve plugins for easier registration with pluggy."""
7
225
wagtail
wagtail/utils/deprecation.py
.py
import warnings from importlib import import_module class RemovedInWagtail90Warning(DeprecationWarning): pass removed_in_next_version_warning = RemovedInWagtail90Warning class RemovedInWagtail100Warning(PendingDeprecationWarning): pass class MovedDefinitionHandler: """ A wrapper for module objec...
88
2,967
coveragepy
tests/modules/pkg2/__init__.py
.py
# This is an __init__.py file, with no executable statements in it. # This comment shouldn't confuse the parser.
3
113
mlflow
tests/store/tracking/test_databricks_rest_store.py
.py
import base64 import json import time from unittest import mock import pytest from google.protobuf.json_format import MessageToDict from opentelemetry.proto.trace.v1.trace_pb2 import Span as OTelProtoSpan import mlflow from mlflow.entities import Span from mlflow.entities.assessment import ( AssessmentSource, ...
2,418
90,351
pyomo
pyomo/contrib/pynumero/examples/external_grey_box/param_est/models.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...
281
9,351
openvino
tests/layer_tests/onnx_tests/test_softsign.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest pytest.importorskip("openvino.tools.mo", reason="Ticket - 157136") from common.layer_test_class import check_ir_version from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model from unit_tests.utils....
188
6,297