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 |
|---|---|---|---|---|---|
clearml | clearml/utilities/requests_toolbelt/multipart/decoder.py | .py | # -*- coding: utf-8 -*-
"""
requests_toolbelt.multipart.decoder
===================================
This holds all the implementation details of the MultipartDecoder
"""
import sys
import email.parser
from .encoder import encode_with
from requests.structures import CaseInsensitiveDict
def _split_on_find(content, ... | 157 | 4,861 |
readthedocs.org | readthedocs/rtd_tests/tests/test_doc_builder.py | .py | import tempfile
from unittest import mock
from unittest.mock import patch
import py
import pytest
from django.test import TestCase
from django.test.utils import override_settings
from readthedocs.config.tests.test_config import get_build_config
from readthedocs.doc_builder.backends.mkdocs import BaseMkdocs
from readt... | 323 | 11,050 |
probability | tensorflow_probability/python/experimental/mcmc/gradient_based_trajectory_length_adaptation.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... | 1,140 | 47,484 |
pyomo | examples/pyomobook/pyomo-components-ch/set_options.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... | 20 | 743 |
saleor | saleor/graphql/account/mutations/customer_type/customer_type_assign_attributes.py | .py | from collections import defaultdict
import graphene
from django.core.exceptions import ValidationError
from .....account import models as account_models
from .....attribute import AttributeType
from .....attribute import models as attribute_models
from .....permission.enums import CustomerTypePermissions
from .....we... | 165 | 5,948 |
hatch | tests/cli/dep/show/test_requirements.py | .py | import os
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
def test_incompatible_environment(hatch, temp_dir, helpers, build_env_config):
project_name = "My.App"
with temp_dir.as_cwd():
result = hatch("n... | 270 | 7,621 |
saleor | saleor/core/db/patch.py | .py | from django.db.backends.base.validation import BaseDatabaseValidation
from django.db.backends.postgresql.client import DatabaseClient
from django.db.backends.postgresql.creation import DatabaseCreation
from django.db.backends.postgresql.features import DatabaseFeatures
from django.db.backends.postgresql.introspection i... | 33 | 1,471 |
sphinx | sphinx/environment/__init__.py | .py | """Global creation environment."""
from __future__ import annotations
import functools
import os
import pickle
import warnings
from collections import defaultdict
from copy import deepcopy
from pathlib import Path
from typing import TYPE_CHECKING
from sphinx import addnodes
from sphinx.deprecation import RemovedInSp... | 1,188 | 43,585 |
wagtail | wagtail/admin/tests/test_password_reset.py | .py | import unittest
from django.conf import settings
from django.core import mail
from django.test import TestCase, override_settings
from django.urls import reverse
from wagtail.test.utils import PageFixturesMixin, WagtailTestUtils
class TestUserPasswordReset(PageFixturesMixin, WagtailTestUtils, TestCase):
fixture... | 104 | 4,006 |
cvxpy | cvxpy/reductions/solvers/nlp_solvers/diff_engine/converters.py | .py | """
Copyright 2025, the CVXPY 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 law or agreed to in writing, s... | 148 | 6,035 |
wagtail | wagtail/actions/base.py | .py | from django.core.exceptions import PermissionDenied
from django.utils.functional import cached_property
class BaseAction:
"""
Base class for actions.
An action encapsulates a single mutation of a model instance (creating,
editing, deleting, publishing, and so on) along with its permission checks,
... | 86 | 3,139 |
rq | rq/scripts.py | .py | import calendar
import logging
import time
from datetime import timedelta, timezone
from typing import Any
from .exceptions import DuplicateJobError
from .logutils import blue, green
logger = logging.getLogger('rq.scripts')
# Lua script for atomic unique enqueue: check existence, save job, push to queue
UNIQUE_ENQUE... | 205 | 6,565 |
mlflow | mlflow/genai/scorers/ragas/__init__.py | .py | """
RAGAS integration for MLflow.
This module provides integration with RAGAS metrics, allowing them to be used
with MLflow's judge interface.
Example usage:
.. code-block:: python
from mlflow.genai.scorers.ragas import get_scorer
judge = get_scorer("Faithfulness", model="openai:/gpt-4")
feedback = jud... | 394 | 12,777 |
wagtail | wagtail/tests/tests.py | .py | import json
import re
from django import template
from django.core.cache import cache
from django.core.cache.utils import make_template_fragment_key
from django.http import HttpRequest
from django.template import TemplateSyntaxError, VariableDoesNotExist
from django.test import TestCase
from django.test.utils import o... | 909 | 32,368 |
httpie | httpie/internal/daemons.py | .py | """
This module provides an interface to spawn a detached task to be
run with httpie.internal.daemon_runner on a separate process. It is
based on DVC's daemon system.
https://github.com/iterative/dvc/blob/main/dvc/daemon.py
"""
import inspect
import os
import platform
import sys
import httpie.__main__
from contextlib ... | 122 | 3,403 |
ipython | IPython/external/qt_loaders.py | .py | """
This module contains factory functions that attempt
to return Qt submodules from the various python Qt bindings.
It also protects against double-importing Qt with different
bindings, which is unstable and likely to crash
This is used primarily by qt and qt_for_kernel, and shouldn't
be accessed directly from the o... | 424 | 11,867 |
readthedocs.org | manage.py | .py | #!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE", "readthedocs.settings.docker_compose"
)
sys.path.append(os.getcwd())
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
| 14 | 316 |
black | tests/data/cases/pep_572_remove_parens.py | .py | if (foo := 0):
pass
if (foo := 1):
pass
if (y := 5 + 5):
pass
y = (x := 0)
y += (x := 0)
(y := 5 + 5)
test: int = (test2 := 2)
a, b = (test := (1, 2))
# see also https://github.com/psf/black/issues/2139
assert (foo := 42 - 12)
foo(x=(y := f(x)))
def foo(answer=(p := 42)):
...
def foo2(answe... | 142 | 1,888 |
jupytext | tests/functional/simple_notebooks/test_read_simple_markdown.py | .py | from nbformat.v4.nbbase import (
new_code_cell,
new_markdown_cell,
new_notebook,
new_raw_cell,
)
import jupytext
from jupytext.combine import combine_inputs_with_outputs
from jupytext.compare import compare, compare_cells, compare_notebooks
def test_read_mostly_py_markdown_file(
markdown="""---
t... | 937 | 19,110 |
probability | tensorflow_probability/python/bijectors/weibull_cdf_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... | 111 | 4,594 |
beam | learning/katas/python/Examples/Word Count/Word Count/tests/test_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"); you may not... | 42 | 1,364 |
pyro | tests/ops/test_welford.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pyro.ops.welford import WelfordArrowheadCovariance, WelfordCovariance
from pyro.util import optional
from tests.common import assert_equal
@pytest.mark.filterwarnings("ignore:.*... | 83 | 3,133 |
wandb | wandb/integration/diffusers/autologger.py | .py | import logging
from wandb.sdk.integration_utils.auto_logging import AutologAPI
from .pipeline_resolver import DiffusersPipelineResolver
logger = logging.getLogger(__name__)
autolog = AutologAPI(
name="diffusers",
symbols=(
"DiffusionPipeline.__call__",
"AutoPipelineForText2Image.__call__",
... | 77 | 3,254 |
beam | sdks/python/apache_beam/testing/test_pipeline_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... | 132 | 4,625 |
biopython | Bio/UniProt/GOA.py | .py | #!/usr/bin/env python
# Copyright 2013, 2016 by Iddo Friedberg idoerg@gmail.com. All rights reserved.
# Copyright 2020 by Sergio Valqui. 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... | 510 | 15,791 |
sqlmap | tests/test_urls.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
URL encode/decode round-trips, parameter parsing, same-host checks.
"""
import os
import random
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.abspath(__file_... | 81 | 2,813 |
returns | returns/contrib/mypy/returns_plugin.py | .py | """
Custom mypy plugin to solve the temporary problem with python typing.
Important: we don't do anything ugly here.
We only solve problems of the current typing implementation.
``mypy`` API docs are here:
https://mypy.readthedocs.io/en/latest/extending_mypy.html
We use ``pytest-mypy-plugins`` to test that it works ... | 129 | 3,821 |
wandb | wandb/integration/kfp/kfp_patch.py | .py | from __future__ import annotations
import inspect
import itertools
import textwrap
from collections.abc import Callable, Mapping
import wandb
from ._patch_utils import patch, unpatch
try:
from kfp import __version__ as kfp_version
from packaging.version import parse
_KFP_V2 = parse(kfp_version) >= pars... | 301 | 9,107 |
openvino | tests/e2e_tests/common/infer/__init__.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from .dummy_infer_class import use_dummy
from .provider import StepProvider
try:
from .common_inference import Infer
except ImportError as e:
Infer = use_dummy('ie_sync', str(e))
| 11 | 271 |
coremltools | coremltools/converters/mil/experimental/passes/generic_conv_bias_fusion.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 os
import numpy as np
from coremltools import _logger as logger
from coremltools.converters.... | 368 | 12,523 |
sqlmap | tamper/equaltolike.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.HIGHEST
def dependencies():
pass
def tamper(payload, **kwargs):
"""
Replaces all occurrences ... | 53 | 1,310 |
beam | sdks/python/apache_beam/utils/thread_pool_executor_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... | 127 | 3,818 |
ipython | IPython/lib/latextools.py | .py | """Tools for handling LaTeX."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
from io import BytesIO
import os
import tempfile
import shutil
import subprocess
from base64 import encodebytes
import textwrap
from pathlib import Path
from IPython.utils.process imp... | 255 | 8,040 |
metrics | docs/source/pyplots/confusion_matrix.py | .py | import matplotlib.pyplot as plt
import torch
import torchmetrics
N = 10
num_updates = 10
num_steps = 5
fig, ax = plt.subplots(1, 1, figsize=(6.8, 4.8), dpi=500)
metric = torchmetrics.ConfusionMatrix(task="multiclass", num_classes=3)
for _ in range(N):
metric.update(torch.randint(3, (10,)), torch.randint(3, (10,... | 17 | 354 |
pyomo | doc/OnlineDocs/src/data/param2a.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... | 24 | 830 |
mlflow | tests/pyfunc/test_context.py | .py | import random
import time
from threading import Thread
import pytest
import mlflow
from mlflow.pyfunc.context import (
Context,
get_prediction_context,
set_prediction_context,
)
def test_prediction_context_thread_safe():
def set_context(context):
with set_prediction_context(context):
... | 67 | 2,150 |
astropy | astropy/wcs/tests/test_wcs.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import io
import os
import re
from contextlib import nullcontext
from datetime import datetime
from multiprocessing.pool import ThreadPool
import numpy as np
import pytest
from numpy.random import default_rng
from numpy.testing import (
assert_allclo... | 2,858 | 98,331 |
pyomo | pyomo/tpl/ply/lex.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... | 1,137 | 43,978 |
marshmallow | docs/conf.py | .py | import importlib.metadata
extensions = [
"autodocsumm",
"sphinx.ext.autodoc",
"sphinx.ext.autodoc.typehints",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinx_copybutton",
"sphinx_issues",
"sphinxext.opengraph",
]
primary_domain = "py"
default_role = "py:obj"
intersphinx_mappi... | 70 | 2,216 |
saleor | saleor/tests/e2e/product/utils/product_type_update.py | .py | from ...utils import get_graphql_content
PRODUCT_TYPE_UPDATE_MUTATION = """
mutation ProductTypeUpdate($id: ID!, $input: ProductTypeInput!) {
productTypeUpdate(id: $id, input: $input) {
errors {
field
message
code
}
productType {
id
name
slug
kind
isShippin... | 54 | 1,034 |
probability | tensorflow_probability/python/distributions/noncentral_chi2.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... | 667 | 24,372 |
onnx | onnx/backend/test/case/node/cos.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Cos(Base):
@staticmethod
def export() -> None:
node = ... | 29 | 713 |
sqlmap | tests/test_profiling.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Switch '--profile' (lib/core/profiling.py). The profiled statement must resolve
'start' from an explicit namespace: on pip installs __main__ is the console
script, not sqlmap.py, so r... | 60 | 1,823 |
mlflow | mlflow/store/fs2db/_registry.py | .py | """
Migrate model registry entities from FileStore to DB.
FileStore layout:
<mlruns>/models/
└── <model_name>/
├── meta.yaml -> registered_models
├── tags/<key> -> registered_model_tags
├── aliases/<alias_name> -> registered_model_aliases
└── version-... | 135 | 4,228 |
coremltools | coremltools/converters/mil/mil/ops/tests/iOS17/test_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
import itertools
import numpy as np
import pytest
import coremltools as ct
from coremltools._deps i... | 192 | 6,200 |
clearml | clearml/automation/scheduler.py | .py | import json
import logging
from datetime import datetime, timezone
from threading import Thread, enumerate as enumerate_threads
from time import sleep, time
from typing import List, Union, Optional, Callable, Sequence, Dict, Any
from attr import attrs, attrib
from dateutil.relativedelta import relativedelta
from .con... | 1,097 | 43,715 |
coveragepy | coverage/exceptions.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
"""Exceptions coverage.py can raise."""
from __future__ import annotations
from typing import Any
class CoverageException(Exception):
"""The base class of... | 68 | 1,550 |
mlflow | mlflow/utils/crypto.py | .py | import json
import logging
import os
from dataclasses import dataclass
from typing import Any
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
# KEK (Key Encryption Key) environment variables for envelope encryption
# These are defined here to avoid import... | 651 | 24,824 |
pymc | tests/logprob/test_tensor.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... | 921 | 34,693 |
saleor | saleor/payment/model_helpers.py | .py | from collections.abc import Iterable
from operator import attrgetter
from typing import TYPE_CHECKING
from ..core.taxes import zero_money, zero_taxed_money
from .models import Payment
if TYPE_CHECKING:
from ..order.models import OrderLine
def get_last_payment(payments: Iterable[Payment]):
return max(payment... | 27 | 904 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/__init__.py | .py | """Various implementations of the Lomb-Scargle Periodogram."""
from .chi2_impl import lombscargle_chi2
from .fast_impl import lombscargle_fast
from .fastchi2_impl import lombscargle_fastchi2
from .main import available_methods, lombscargle
from .scipy_impl import lombscargle_scipy
from .slow_impl import lombscargle_sl... | 9 | 323 |
astropy | astropy/units/function/mixin.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from astropy.units.core import IrreducibleUnit, Unit
class FunctionMixin:
"""Mixin class that makes UnitBase subclasses callable.
Provides a __call__ method that passes on arguments to a FunctionUnit.
Instances of this class should define ``... | 25 | 685 |
readthedocs.org | readthedocs/builds/tests/test_tasks.py | .py | from datetime import datetime, timedelta
from textwrap import dedent
from unittest import mock
from django.conf import settings
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from django.utils import timezone
from django_dynamic_fixture import get
from readthedocs.buil... | 691 | 27,758 |
bazel | third_party/py/mock/__init__.py | .py | # mock.py
# Test tools for mocking and patching.
# Copyright (C) 2007-2012 Michael Foord & the mock team
# E-mail: fuzzyman AT voidspace DOT org DOT uk
# mock 1.0
# http://www.voidspace.org.uk/python/mock/
# Released subject to the BSD License
# Please see http://www.voidspace.org.uk/python/license.shtml
# Scripts m... | 2,368 | 75,527 |
textual | src/textual/css/stylesheet.py | .py | from __future__ import annotations
import os
from collections import defaultdict
from itertools import chain
from operator import itemgetter
from pathlib import Path, PurePath
from typing import Final, Iterable, NamedTuple, Sequence, cast
import rich.repr
from rich.console import Console, ConsoleOptions, RenderableTy... | 738 | 27,148 |
probability | tensorflow_probability/python/bijectors/square.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,546 |
metrics | tests/unittests/wrappers/test_classwise.py | .py | import pytest
import torch
from torchmetrics import MetricCollection
from torchmetrics.classification import MulticlassAccuracy, MulticlassF1Score, MulticlassRecall
from torchmetrics.clustering import CalinskiHarabaszScore
from torchmetrics.wrappers import ClasswiseWrapper
def test_raises_error_on_wrong_input():
... | 179 | 6,687 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_QuantizeMultiOutputs.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import copy
import pytest
import numpy as np
import tensorflow as tf
from tensorflow.lite.python import schema_py_generated as schema_fb
from tensorflow.lite.tools import flatbuffer_utils as utils
from common.tflite_layer_test... | 184 | 8,382 |
saleor | saleor/tests/e2e/orders/test_cancel_partially_paid_order.py | .py | import pytest
from .. import DEFAULT_ADDRESS
from ..product.utils.preparing_product import prepare_product
from ..shop.utils.preparing_shop import prepare_default_shop
from ..transactions.utils import create_transaction
from ..utils import assign_permissions
from .utils import (
draft_order_complete,
draft_ord... | 125 | 3,995 |
gunicorn | tests/requests/invalid/rfc9110_field_value_ctl_del_01.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# RFC 9110 section 5.5: DEL (0x7F) is a control character and not a VCHAR;
# it must not appear in a field-value.
from gunicorn.http.errors import InvalidHeader
request = InvalidHeader
| 9 | 291 |
saleor | saleor/core/telemetry/tests/__init__.py | .py | from collections.abc import Mapping
from opentelemetry.sdk.metrics import (
Counter,
Histogram,
MeterProvider,
ObservableCounter,
ObservableGauge,
ObservableUpDownCounter,
UpDownCounter,
)
from opentelemetry.sdk.metrics.export import (
AggregationTemporality,
InMemoryMetricReader,
)... | 47 | 1,440 |
openvino | tests/layer_tests/pytorch_tests/test_clone.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestClone(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(1, 3, 224, 224),)
def create_model(self):
import torch... | 29 | 711 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script/plotly_graphs.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# This notebook contains complex outputs, including plotly javascript graphs.
# # Interactive plots
# We use Plotly's connected mode to make the notebook lighter - when connected, the notebook downloads the... | 25 | 613 |
jupytext | src/jupytext/jupytext.py | .py | """Read and write Jupyter notebooks as text files"""
import logging
import os
import sys
import warnings
from copy import copy, deepcopy
import nbformat
from nbformat.v4.nbbase import NotebookNode, new_code_cell, new_notebook
from nbformat.v4.rwbase import NotebookReader, NotebookWriter
from .cell_metadata import _I... | 592 | 23,870 |
mlflow | dev/clint/src/clint/__init__.py | .py | import argparse
import itertools
import json
import re
import sys
import tempfile
from concurrent.futures import ProcessPoolExecutor, as_completed
from dataclasses import dataclass
from pathlib import Path
from typing import Literal
from typing_extensions import Self
from clint.config import Config
from clint.index i... | 111 | 3,823 |
sphinx | sphinx/application.py | .py | """Sphinx application class and extensibility interface.
Gracefully adapted from the TextPress system by Armin.
"""
from __future__ import annotations
import contextlib
import pickle
import sys
from collections import deque
from io import StringIO
from pathlib import Path
from typing import TYPE_CHECKING, overload
... | 1,894 | 68,593 |
saleor | saleor/page/search.py | .py | from collections import defaultdict
from typing import NamedTuple
from django.conf import settings
from django.db import transaction
from django.db.models import Value
from ..attribute.models import Attribute, AttributeValue
from ..attribute.search import get_search_vectors_for_attribute_values
from ..core.context im... | 212 | 7,235 |
mlflow | mlflow/tracing/utils/copy.py | .py | from typing import Any
from mlflow.entities.span import LiveSpan, Span
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_STATE
from mlflow.tracing.trace_manager import InMemoryTraceManager
def copy_trace_to_experiment(trace_dict: dict[str, Any], experiment_id: str | None ... | 63 | 2,583 |
gunicorn | tests/docker/per_app_allocation/app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
WSGI and Dirty applications for per-app worker allocation testing.
Contains:
- A WSGI app that can make dirty client requests
- A lightweight dirty app (loads on all workers)
- A heavy dirty app (limited to 2 ... | 185 | 5,751 |
openvino | tests/layer_tests/pytorch_tests/test_view.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
@pytest.mark.parametrize('input_shapes',
[
[
[2, 3, 2], np.array(2), np.array(6)
],
[
[4], np.array(2), np... | 193 | 5,299 |
ipython | tests/test_importstring.py | .py | """Tests for IPython.utils.importstring."""
# -----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
# -----... | 66 | 1,701 |
astropy | astropy/wcs/utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import copy
from functools import lru_cache
import numpy as np
import astropy.units as u
from astropy.coordinates import (
ITRS,
BaseBodycentricRepresentation,
BaseCoordinateFrame,
BaseGeodeticRepresentation,
CartesianRepresentation,... | 1,363 | 46,913 |
saleor | saleor/tests/e2e/taxes/utils/__init__.py | .py | from .query_tax_configurations import get_tax_configurations
from .tax_class_create import create_tax_class
from .tax_class_update import update_tax_class
from .tax_configuration_update import update_tax_configuration
from .tax_country_configuration_update import update_country_tax_rates
__all__ = [
"get_tax_confi... | 14 | 446 |
cvxpy | cvxpy/constraints/finite_set.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... | 138 | 4,646 |
mlflow | tests/server/auth/test_auth.py | .py | import asyncio
import base64
import json
import re
import subprocess
import sys
import time
from pathlib import Path
from types import SimpleNamespace
from unittest import mock
import jwt
import pytest
import requests
from cachetools import TTLCache
from cryptography.fernet import Fernet
import mlflow
from mlflow imp... | 6,327 | 234,935 |
clearml | examples/frameworks/tensorflow/legacy/tensorflow_eager.py | .py | # ClearML - Example of tensorflow eager mode, model logging and tensorboard
#
# Copyright 2017 The TensorFlow Authors. 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
#
#... | 358 | 14,373 |
textual | tests/snapshot_tests/snapshot_apps/scroll_visible.py | .py | from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widgets import Label, Static
# Checks https://github.com/Textualize/textual/issues/2181
class MyCustomWidget(Static):
def compose(self) -> ComposeResult:
yield Label(("|\n" * 100)[:-1])
yield Lab... | 24 | 611 |
saleor | saleor/graphql/notifications/schema.py | .py | import graphene
from ..core.descriptions import DEFAULT_DEPRECATION_REASON
from .mutations.external_notification_trigger import ExternalNotificationTrigger
class ExternalNotificationMutations(graphene.ObjectType):
external_notification_trigger = ExternalNotificationTrigger.Field(
deprecation_reason=DEFAU... | 11 | 348 |
sqlmap | extra/shutils/duplicates.py | .py | #!/usr/bin/env python
# Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
# See the file 'LICENSE' for copying permission
# Removes duplicate entries in wordlist like files
from __future__ import print_function
import sys
if __name__ == "__main__":
if len(sys.argv) > 1:
items = list()
... | 31 | 796 |
saleor | saleor/tax/tests/fixtures/utils.py | .py | from ....tax import TaxCalculationStrategy
from ....tax.models import TaxConfiguration
def create_channel_tax_configuration(channel):
# Use TAX_APP strategy, to enable calculations with plugins by default.
tax_configuration = TaxConfiguration.objects.create(
channel=channel,
metadata={"key": "... | 21 | 727 |
wagtail | wagtail/management/commands/purge_embeds.py | .py | from django.core.management.base import BaseCommand
from wagtail.embeds.models import Embed
class Command(BaseCommand):
help = "Deletes all of the Embed model objects"
def handle(self, *args, **options):
embeds = Embed.objects.all()
deleted_embeds_count = embeds.delete()[0]
if delet... | 21 | 607 |
sqlmap | lib/core/optiondict.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
optDict = {
# Family: {"parameter name": "parameter datatype"},
# --OR--
# Family: {"parameter name": ("parameter datatype", "category name used for common outputs fea... | 311 | 8,502 |
cvxpy | cvxpy/reductions/solvers/conic_solvers/copt_conif.py | .py | """
This file is the CVXPY conic extension of the Cardinal Optimizer
"""
import numpy as np
import scipy.sparse as sp
import cvxpy.settings as s
from cvxpy.constraints import SOC, ExpCone, SvecPSD
from cvxpy.reductions.solution import Solution, failure_solution
from cvxpy.reductions.solvers import utilities
from cvxpy... | 434 | 16,279 |
mlflow | tests/genai/scorers/trulens/test_utils.py | .py | import pytest
import mlflow
from mlflow.genai.scorers.trulens.utils import (
format_rationale,
map_scorer_inputs_to_trulens_args,
)
def _create_test_trace(
inputs: dict[str, str] | None = None,
outputs: dict[str, str] | None = None,
):
with mlflow.start_span() as span:
if inputs is not No... | 128 | 3,813 |
sqlmap | lib/utils/xrange.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import numbers
class xrange(object):
"""
Advanced (re)implementation of xrange (supports slice/copy/etc.)
Reference: http://code.activestate.com/recipes/521885-a-pyth... | 120 | 3,509 |
wagtail | wagtail/test/routablepage/models.py | .py | import swapper
from django.http import HttpResponse
from django.shortcuts import redirect
from wagtail.contrib.routable_page.models import RoutablePageMixin, path, re_path, route
from wagtail.models import PreviewableMixin
if swapper.is_swapped("wagtailcore", "Page"):
from wagtail.test.basepage.models import Base... | 97 | 3,434 |
pyomo | pyomo/core/tests/unit/test_expression.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... | 1,077 | 36,822 |
openvino | tests/layer_tests/pytorch_tests/test_xor.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestXor(PytorchLayerTest):
def _prepare_input(self):
return self.input_data
def create_model_tensor_input(self)... | 84 | 2,882 |
pyomo | examples/performance/misc/bilinear1_100000.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... | 31 | 1,004 |
luigi | test/contrib/streaming_test.py | .py | import os
import unittest
import mock
import pytest
from luigi import Parameter
from luigi.contrib import mrrunner
from luigi.contrib.hadoop import HadoopJobRunner, JobTask
from luigi.contrib.hdfs import HdfsTarget
class MockStreamingJob(JobTask):
package_binary = Parameter(default=None)
def output(self):
... | 84 | 3,118 |
astropy | astropy/units/format/cds_lextab.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This file was automatically generated from ply. To re-generate this file,
# remove it from this folder, then build astropy and run the tests in-place:
#
# python setup.py build_ext --inplace
# pytest astropy/units
#
# You can then commit the changes... | 21 | 1,397 |
pyfilesystem2 | fs/wildcard.py | .py | """Match wildcard filenames.
"""
# Adapted from https://hg.python.org/cpython/file/2.7/Lib/fnmatch.py
from __future__ import print_function, unicode_literals
import typing
import re
from functools import partial
from .lrucache import LRUCache
if typing.TYPE_CHECKING:
from typing import Callable, Iterable, Patt... | 179 | 4,982 |
pynacl | src/nacl/bindings/__init__.py | .py | # Copyright 2013-2019 Donald Stufft and individual contributors
#
# 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 applicabl... | 524 | 19,466 |
ipython | IPython/terminal/pt_inputhooks/__init__.py | .py | import importlib
import os
from collections.abc import Callable
aliases = {
'qt4': 'qt',
'gtk2': 'gtk',
}
backends = [
"qt",
"qt5",
"qt6",
"gtk",
"gtk2",
"gtk3",
"gtk4",
"tk",
"wx",
"pyglet",
"glut",
"osx",
"asyncio",
]
registered = {}
def register(name, i... | 140 | 3,608 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/jupyterlab-slideshow_1441.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: region,endregion
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---
# region [markdown] @deathbeds/jupyterlab-fonts={"styles": {"": {"body[data-jp-deck-mode='presenting'] &": {"right": "0", "top": "30%", "width": ... | 16 | 454 |
coremltools | coremltools/converters/mil/mil/ops/tests/iOS17/test_normalization.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
import itertools
import numpy as np
import pytest
from coremltools._deps import _HAS_TF_2, _HAS_TOR... | 177 | 6,358 |
beam | sdks/python/apache_beam/utils/multi_process_shared.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... | 543 | 18,324 |
confluent-kafka-python | src/confluent_kafka/admin/_listoffsets.py | .py | # Copyright 2023 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... | 169 | 4,593 |
gunicorn | gunicorn/dirty/protocol.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Dirty Worker Binary Protocol
Binary message framing over Unix sockets, inspired by OpenBSD msgctl/msgsnd.
Replaces JSON protocol for efficient binary data transfer.
Header Format (16 bytes):
+--------+-------... | 811 | 24,862 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Roll.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 TestTFRoll(CommonTFLayerTest):
def create_tf_roll_net(self, shift, axis, x_shape, input_type, ir_version):
tf.compat.v1.re... | 45 | 1,996 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.