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 |
|---|---|---|---|---|---|
astropy | astropy/modeling/tests/test_quantities_fitting.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Tests that relate to fitting models with quantity parameters
"""
import numpy as np
import pytest
from astropy import units as u
from astropy.modeling import fitting, models
from astropy.modeling.core import Fittable1DModel, compose_models_with_units... | 308 | 10,549 |
eve | eve/methods/delete.py | .py | # -*- coding: utf-8 -*-
"""
eve.methods.delete
~~~~~~~~~~~~~~~~~~
This module implements the DELETE method.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
import copy
from flask import abort
from flask import current_app as app
from eve.auth import req... | 258 | 9,400 |
onnxruntime | onnxruntime/contrib_ops/cuda/llm/moe_gemm/launchers/generate_moe_gemm_tma_ws_sm90_fp4.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
CLUSTER_K = 1
OLD_GENERATED_PREFIX = "moe_gemm_tma_ws_sm90_mixed_fp4"
NEW_GENERATED_PREFIX = "moe_gemm_tma... | 141 | 5,302 |
saleor | saleor/graphql/account/mutations/customer_type/__init__.py | .py | from .customer_type_assign_attributes import CustomerTypeAssignAttributes
from .customer_type_create import CustomerTypeCreate
from .customer_type_delete import CustomerTypeDelete
from .customer_type_reorder_attributes import CustomerTypeReorderAttributes
from .customer_type_unassign_attributes import CustomerTypeUnass... | 16 | 591 |
wandb | wandb/sdk/lib/logger_capture.py | .py | from __future__ import annotations
import logging
from typing_extensions import override
import wandb
class LoggerHandler(logging.Handler):
"""A logging.Handler that forwards log records using `run.write_logs()`."""
def __init__(
self,
run: wandb.Run,
level: int | str = logging.NOT... | 28 | 685 |
metrics | src/torchmetrics/metric.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... | 1,312 | 57,049 |
python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/focus.py | .py | from __future__ import annotations
from prompt_toolkit.key_binding.key_processor import KeyPressEvent
__all__ = [
"focus_next",
"focus_previous",
]
E = KeyPressEvent
def focus_next(event: E) -> None:
"""
Focus the next visible Window.
(Often bound to the `Tab` key.)
"""
event.app.layout... | 27 | 507 |
beam | sdks/python/apache_beam/runners/worker/data_plane_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... | 145 | 5,245 |
metrics | src/torchmetrics/detection/_deprecated.py | .py | from collections.abc import Collection
from typing import Any
from torchmetrics.detection import ModifiedPanopticQuality, PanopticQuality
from torchmetrics.utilities.prints import _deprecated_root_import_class
class _ModifiedPanopticQuality(ModifiedPanopticQuality):
"""Wrapper for deprecated import.
>>> fro... | 64 | 2,359 |
python-prompt-toolkit | src/prompt_toolkit/styles/style_transformation.py | .py | """
Collection of style transformations.
Think of it as a kind of color post processing after the rendering is done.
This could be used for instance to change the contrast/saturation; swap light
and dark colors or even change certain colors for other colors.
When the UI is rendered, these transformations can be appli... | 375 | 12,436 |
pyomo | pyomo/contrib/appsi/cmodel/tests/test_import.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... | 35 | 1,437 |
pyomo | examples/pyomo/p-median/solver1.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... | 81 | 2,975 |
coremltools | coremltools/proto/GLMRegressor_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: GLMRegressor.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... | 50 | 2,418 |
wandb | wandb/sdk/lib/service/service_connection.py | .py | from __future__ import annotations
import atexit
import pathlib
from collections.abc import Callable
from wandb.proto import wandb_api_pb2, wandb_settings_pb2, wandb_sync_pb2
from wandb.proto import wandb_server_pb2 as spb
from wandb.sdk import wandb_settings
from wandb.sdk.interface.interface import InterfaceBase
fr... | 392 | 13,096 |
readthedocs.org | readthedocs/domains/querysets.py | .py | """Querysets for domain related models."""
from datetime import timedelta
from django.conf import settings
from django.db.models import Q
from django.utils import timezone
from readthedocs.projects.constants import SSL_STATUS_VALID
from readthedocs.projects.querysets import RelatedProjectQuerySet
class DomainQuery... | 42 | 1,636 |
pyomo | pyomo/contrib/parmest/examples/reactor_design/parameter_estimation_example.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 | 1,632 |
wandb | wandb/sdk/data_types/saved_model.py | .py | from __future__ import annotations
import os
import pathlib
import shutil
import sys
from types import ModuleType
from typing import TYPE_CHECKING, Any, ClassVar, Generic, TypeVar, cast
import wandb
from wandb import util
from wandb.sdk.lib import runid
from wandb.sdk.lib.hashutil import md5_file_hex
from wandb.sdk.l... | 440 | 16,423 |
saleor | saleor/graphql/utils/validators.py | .py | from django.core.exceptions import ValidationError
from graphql import GraphQLDocument
from graphql.error import GraphQLError
from graphql.language.ast import (
Field,
FragmentDefinition,
InlineFragment,
OperationDefinition,
)
from ..core.utils import get_duplicates_items
def check_for_duplicates(
... | 111 | 4,228 |
mlflow | tests/utils/test_autologging_utils.py | .py | import warnings
from threading import Thread
from mlflow import MlflowClient
from mlflow.entities import Metric
from mlflow.utils.autologging_utils.logging_and_warnings import (
_WarningsController,
)
from mlflow.utils.autologging_utils.metrics_queue import (
_metrics_queue,
_metrics_queue_lock,
flush_... | 96 | 3,592 |
onnxruntime | orttraining/orttraining/python/training/ortmodule/_gradient_accumulation_manager.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from onnxruntime.capi import _pybind_state as C
from . import _utils
c... | 89 | 4,084 |
pyomo | pyomo/contrib/piecewise/piecewise_linear_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... | 51 | 1,888 |
openvino | src/frontends/onnx/tests/tests_python/test_ops_variadic.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from functools import reduce
import numpy as np
import onnx
import pytest
from tests.tests_python.utils import run_node
@pytest.mark.parametrize(
("onnx_op", "numpy_func"), [("Sum", np.add), ("Min", np.min... | 45 | 1,245 |
astropy | astropy/samp/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
.. warning::
``astropy.samp`` was deprecated in version 8.0 and will be removed in a future version;
please use ``pyvo.samp`` instead.
This subpackage provides classes to communicate with other applications via the
`Simple Application Messagin... | 58 | 1,512 |
qutip | qutip/solver/integrator/scipy_integrator.py | .py | """ODE integrator from scipy."""
__all__ = [
'IntegratorScipyAdams',
'IntegratorScipyBDF',
'IntegratorScipyDop853',
'IntegratorScipylsoda',
]
import numpy as np
from scipy.integrate import ode
from scipy.integrate._ode import zvode
from qutip.core import data as _data
from qutip.core.data.reshape impo... | 537 | 18,739 |
sphinx | sphinx/util/_inventory_file_reader.py | .py | from __future__ import annotations
import zlib
from typing import TYPE_CHECKING
from sphinx.util import logging
BUFSIZE = 16 * 1024
logger = logging.getLogger(__name__)
if TYPE_CHECKING:
from collections.abc import Iterator
from typing import Protocol
# Readable file stream for inventory loading
cl... | 77 | 2,027 |
probability | tensorflow_probability/python/bijectors/bijector_test_util.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... | 401 | 14,827 |
deap | doc/code/tutorials/part_3/logbook.py | .py | import pickle
from deap import tools
from stats import record
logbook = tools.Logbook()
logbook.record(gen=0, evals=30, **record)
print(logbook)
gen, avg = logbook.select("gen", "avg")
with open("logbook.pkl", "w") as lb_file:
pickle.dump(logbook, lb_file)
# Cleaning the pickle file ...
import os
os.remove("log... | 62 | 1,407 |
openvino | tests/e2e_tests/pipelines/tf_hub/tf_hub.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
from e2e_tests.test_utils.test_utils import class_factory
from e2e_tests.pipelines.production.tf_hub_case_class import TFHUB_eltwise_Base
def get_models_list(file_name: str):
models = []
with open(file_nam... | 51 | 1,851 |
coveragepy | tests/test_execfile.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage.execfile"""
from __future__ import annotations
import compileall
import json
import os
import os.path
import pathlib
import py_compile
imp... | 352 | 11,562 |
pyomo | pyomo/solvers/tests/models/LP_simple.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... | 100 | 3,747 |
mlflow | mlflow/genai/scorers/trulens/__init__.py | .py | """
TruLens evaluation framework integration for MLflow.
This module provides integration with TruLens feedback functions, allowing them to be used
with MLflow's scorer interface.
Example usage:
.. code-block:: python
from mlflow.genai.scorers.trulens import get_scorer
scorer = get_scorer("Groundedness", m... | 301 | 8,531 |
conda | tests/cli/test_find_commands.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import os
from typing import TYPE_CHECKING
import pytest
from conda.common.compat import on_win
with pytest.deprecated_call():
from conda.cli.find_commands import find_commands, find_executable
if TYPE... | 117 | 3,437 |
mkdocs | mkdocs/tests/utils/utils_tests.py | .py | #!/usr/bin/env python
import dataclasses
import datetime
import logging
import os
import posixpath
import stat
import unittest
from unittest import mock
from mkdocs import exceptions, utils
from mkdocs.tests.base import dedent, tempdir
from mkdocs.utils import meta
BASEYML = """
INHERIT: parent.yml
foo: bar
baz:
... | 603 | 21,662 |
mlflow | dev/clint/tests/rules/conftest.py | .py | import pytest
from clint.index import SymbolIndex
@pytest.fixture(scope="session")
def index() -> SymbolIndex:
return SymbolIndex.build()
| 8 | 144 |
pymc | pymc/distributions/dist_math.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... | 433 | 13,559 |
saleor | saleor/attribute/tests/models/test_base.py | .py | from saleor.attribute import AttributeType
from saleor.attribute.models import Attribute, AttributeValue
def test_attribute_value_setting_up_max_sort_order():
# given
attribute = Attribute.objects.create(
slug="test-slug",
name="test name",
type=AttributeType.PRODUCT_TYPE,
)
as... | 179 | 4,800 |
beam | sdks/python/apache_beam/ml/rag/embeddings/base.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... | 69 | 2,392 |
textual | tests/test_rule.py | .py | import pytest
from textual.widgets import Rule
from textual.widgets.rule import InvalidLineStyle, InvalidRuleOrientation
async def test_invalid_rule_orientation():
with pytest.raises(InvalidRuleOrientation):
Rule(orientation="invalid orientation!")
async def test_invalid_rule_line_style():
with pyt... | 27 | 742 |
onnx | onnx/backend/test/case/node/unique.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
def specify_int64(indices, inverse_indices, counts):
return (
np... | 230 | 7,025 |
hydra | examples/tutorials/basic/running_your_hydra_app/3_working_directory/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
from omegaconf import DictConfig
import hydra
from hydra.core.hydra_config import HydraConfig
@hydra.main()
def my_app(_cfg: DictConfig) -> None:
print(f"Working directory : {os.getcwd()}")
print(f"Output directory : {HydraCon... | 18 | 394 |
beam | sdks/python/apache_beam/transforms/enrichment.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... | 211 | 8,034 |
mlflow | mlflow/ml_package_versions.py | .py | # This file was auto-generated by `flavors update`.
# Please do not edit it manually.
_ML_PACKAGE_VERSIONS = {
"semantic_kernel": {
"package_info": {
"pip_release": "semantic-kernel"
},
"autologging": {
"minimum": "1.35.1",
"maximum": "1.44.0"
}
... | 490 | 11,453 |
qutip | doc/guide/scripts/correlation_ex2.py | .py | import numpy as np
import matplotlib.pyplot as plt
import qutip
times = np.linspace(0, 10.0, 200)
a = qutip.destroy(10)
x = a.dag() + a
H = a.dag() * a
alpha = 2.5
rho0 = qutip.coherent_dm(10, alpha)
corr = qutip.correlation_2op_2t(H, rho0, times, times, [np.sqrt(0.25) * a], x, x)
plt.pcolor(np.real(corr))
plt.xlabel... | 18 | 423 |
gunicorn | tests/requests/valid/031compat.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.config import Config
cfg = Config()
cfg.set("permit_unconventional_http_method", True)
cfg.set("casefold_http_method", True)
request = {
"method": "-BLARGH",
"uri": uri("/foo"),
"version... | 18 | 368 |
probability | discussion/robust_inverse_graphics/util/camera_util.py | .py | # Copyright 2024 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 155 | 4,897 |
beam | sdks/python/apache_beam/examples/ml_transform/vocab_tfidf_processing.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... | 194 | 6,448 |
wagtail | wagtail/admin/views/pages/create.py | .py | from urllib.parse import quote, urlencode
import swapper
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied
from django.http import Http404, JsonResponse
from django.shortcuts import get_object_or_404, redirect
from django.url... | 582 | 21,062 |
onnxruntime | onnxruntime/test/python/onnxruntime_test_python_global_threadpool.py | .py | # pylint: disable=C0115,W0212,C0103,C0114
import unittest
import numpy as np
from helper import get_name
import onnxruntime as onnxrt
class TestGlobalThreadPool(unittest.TestCase):
@classmethod
def setUpClass(cls):
onnxrt.set_global_thread_pool_sizes(2, 2)
def test_global_threadpool(self):
... | 37 | 1,363 |
marshmallow | src/marshmallow/error_store.py | .py | """Utilities for storing collections of error messages.
.. warning::
This module is treated as private API.
Users should not need to use this module directly.
"""
from marshmallow.exceptions import SCHEMA
class ErrorStore:
def __init__(self):
#: Dictionary of errors stored during serialization
... | 72 | 2,444 |
funcy | docs/conf.py | .py | # -*- coding: utf-8 -*-
#
# funcy documentation build configuration file, created by
# sphinx-quickstart on Tue Dec 18 21:32:23 2012.
#
# 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 c... | 268 | 8,371 |
saleor | saleor/graphql/checkout/mutations/order_create_from_checkout.py | .py | from typing import Union
import graphene
from django.core.exceptions import ValidationError
from ....account.models import User
from ....app.models import App
from ....checkout.checkout_cleaner import validate_checkout
from ....checkout.complete_checkout import create_order_from_checkout
from ....checkout.delivery_co... | 262 | 9,592 |
conda | conda/gateways/disk/update.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Disk utility functions for modifying existing files or directories."""
from __future__ import annotations
import os
import re
import tempfile
from contextlib import contextmanager
from errno import EINVAL, EPERM, EXDEV
from logging import g... | 175 | 6,176 |
ipython | IPython/utils/_process_posix.py | .py | """Posix-specific implementation of process utilities.
This file is only meant to be imported by process.py, not by end-users.
"""
from __future__ import annotations
#-----------------------------------------------------------------------------
# Imports
#--------------------------------------------------------------... | 195 | 7,497 |
cvxpy | cvxpy/reductions/solvers/nlp_solvers/diff_engine/__init__.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... | 39 | 1,211 |
wagtail | wagtail/images/views/chooser.py | .py | from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.shortcuts import get_object_or_404
from django.template.loader import render_to_string
from django.urls import path, reverse
from django.utils.functional import cached_property
from django.utils.http import urlencode
from d... | 439 | 14,837 |
black | tests/data/cases/fmtskip_class_header.py | .py | class Body(model.BaseBody[
"Keyword", "For", "While", "Group", "If", "Try", "Var", "Return", "Continue",
"Break", "model.Message", "Error"
]): # fmt: skip
__slots__ = ()
class Foo(Base[\
"A", "B"\
]): # fmt: skip
def a(self): ...
def make_result(
first : int,
second: str,
): # fmt... | 48 | 844 |
hatch | tests/publish/plugin/test_interface.py | .py | import pytest
from hatch.publish.plugin.interface import PublisherInterface
class MockPublisher(PublisherInterface): # no cov
PLUGIN_NAME = "mock"
def publish(self, artifacts, options):
pass
class TestDisable:
def test_default(self, isolation):
project_config = {}
plugin_confi... | 57 | 1,986 |
biopython | Bio/motifs/jaspar/db.py | .py | # Copyright 2013 by David Arenillas and Anthony Mathelier. 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.
""... | 785 | 27,976 |
openvino | src/bindings/python/tests/test_utils/test_utils.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import os
import numpy as np
import openvino as ov
from pathlib import Path
from openvino.utils import deprecated, get_cmake_path, make_postponed_constant
from tests.utils.helpers import compare_mode... | 197 | 6,213 |
wandb | tests/unit_tests/test_launch/test_inputs/test_files_helpers.py | .py | import json
import pytest
from wandb.sdk.launch.errors import LaunchError
from wandb.sdk.launch.inputs.files import (
FileOverrides,
config_path_is_valid,
override_file,
)
@pytest.fixture
def fresh_config_singleton():
"""Fixture to reset the config singleton."""
FileOverrides._instance = None
d... | 202 | 5,096 |
astropy | astropy/utils/metadata/tests/test_metadata.py | .py | from collections import OrderedDict, defaultdict
from dataclasses import dataclass
import numpy as np
import pytest
from astropy.io import fits
from astropy.utils import metadata
from astropy.utils.metadata import (
MergeConflictError,
MetaData,
common_dtype,
enable_merge_strategies,
merge,
)
from... | 368 | 9,658 |
onnxruntime | onnxruntime/test/testdata/transform/convert_qdq_ops_to_ms_domain.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
"""
Loads a model and updates the domain of QuantizeLinear and Dequantize... | 189 | 8,284 |
saleor | saleor/graphql/core/filters/shared_filters.py | .py | from django.core.exceptions import ValidationError
from django.forms import CharField, Field, MultipleChoiceField
from django_filters import Filter, MultipleChoiceFilter
from graphql_relay import from_global_id
class GlobalIDFormField(Field):
default_error_messages = {"invalid": "Invalid ID specified."}
def ... | 71 | 2,168 |
flit | flit_core/flit_core/_spdx_data.py | .py | # This file is generated from SPDX license data; don't edit it manually.
licenses = \
{'0bsd': {'id': '0BSD'},
'3d-slicer-1.0': {'id': '3D-Slicer-1.0'},
'aal': {'id': 'AAL'},
'abstyles': {'id': 'Abstyles'},
'adacore-doc': {'id': 'AdaCore-doc'},
'adobe-2006': {'id': 'Adobe-2006'},
'adobe-display-postscript': {'id... | 652 | 25,493 |
astropy | astropy/io/registry/tests/test_registry_help.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from io import StringIO
import pytest
from astropy.nddata import CCDData
from astropy.table import Table
@pytest.mark.no_optimized_interpreter
def test_table_read_help_fits():
"""
Test dynamically created documentation help via the I/O registr... | 183 | 5,485 |
django-cms | cms/extensions/extension_pool.py | .py | from cms.exceptions import SubClassNeededError
from .models import PageContentExtension, PageExtension
class ExtensionPool:
def __init__(self):
self.page_extensions = set()
self.page_content_extensions = set()
def register(self, extension):
"""
Registers the given extension.
... | 95 | 3,440 |
wagtail | wagtail/contrib/settings/apps.py | .py | from django.apps import AppConfig
class WagtailSettingsAppConfig(AppConfig):
name = "wagtail.contrib.settings"
label = "wagtailsettings"
verbose_name = "Wagtail settings"
| 8 | 185 |
wagtail | wagtail/tests/test_api_tokens.py | .py | import json
from io import StringIO
from django.conf import settings
from django.core.management import call_command
from django.core.management.base import CommandError
from django.test import SimpleTestCase, TestCase, override_settings
from wagtail.models import APIToken
from wagtail.models.api import KEY_CHECKSUM_... | 137 | 5,526 |
beam | sdks/python/apache_beam/examples/inference/tfx_bsl/tfx_bsl_inference_it_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... | 100 | 4,347 |
httpie | httpie/__main__.py | .py | """The main entry point. Invoke as `http' or `python -m httpie'.
"""
def main():
try:
from httpie.core import main
exit_status = main()
except KeyboardInterrupt:
from httpie.status import ExitStatus
exit_status = ExitStatus.ERROR_CTRL_C
return exit_status.value
if __nam... | 20 | 394 |
beam | sdks/python/apache_beam/ml/rag/ingestion/bigquery.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... | 197 | 7,421 |
pyro | pyro/contrib/tracking/assignment.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import itertools
import math
import numbers
import torch
import pyro.distributions as dist
from pyro.util import warn_if_nan
def _product(factors):
result = 1.0
for factor in factors:
result = result * factor
... | 459 | 19,243 |
pyomo | pyomo/contrib/mpc/modeling/tests/test_input_constraints.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... | 110 | 4,942 |
beam | sdks/python/apache_beam/io/gcp/gcsfilesystem_test.py | .py | # -*- coding: utf-8 -*-
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "L... | 392 | 14,055 |
wandb | tests/system_tests/test_notebooks/test_jupyter_server/test_jupyter_server_notebooks.py | .py | """Test executing notebooks against running Jupyter servers."""
import nbformat
def test_jupyter_server_code_saving(wandb_backend_spy, jupyter_server, notebook_client):
notebook_name = "test_metadata.ipynb"
nb = nbformat.v4.new_notebook()
nb.cells = [
nbformat.v4.new_code_cell(
"""
... | 69 | 2,330 |
onnxruntime | onnxruntime/test/python/onnxruntime_test_python.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
import copy
import ctypes
import gc
import importlib.util
import os
import pathlib
import platform
import queue
import sys
import threading
import unittest
import numpy as np
from helper im... | 2,447 | 115,805 |
beam | sdks/python/apache_beam/runners/interactive/recording_manager_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... | 1,238 | 47,484 |
openvino | docs/optimization_guide/nncf/ptq/code/ptq_torch.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#! [dataset]
import nncf
import torch
calibration_loader = torch.utils.data.DataLoader(...)
def transform_fn(data_item):
images, _ = data_item
return images
calibration_dataset = nncf.Dataset(calibration_loader, transform_fn)
... | 40 | 935 |
hydra | tests/standalone_apps/discovery_test_plugin/hydra_plugins/discovery_test/_hidden_plugin.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from hydra.plugins.plugin import Plugin
class HiddenTestPlugin(Plugin): ...
| 6 | 149 |
qutip | qutip/solver/nonmarkov/transfertensor.py | .py | # @author: Arne L. Grimsmo
# @email1: arne.grimsmo@gmail.com
# @organization: University of Sherbrooke
"""
This module contains an implementation of the non-Markovian transfer tensor
method (TTM), introduced in [1].
[1] Javier Cerrillo and Jianshu Cao, Phys. Rev. Lett 112, 110401 (2014)
"""
import numpy as np
import... | 176 | 5,420 |
structlog | docs/conf.py | .py | # SPDX-License-Identifier: MIT OR Apache-2.0
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the MIT License. See the LICENSE file in the root of this
# repository for complete details.
import os
from importlib import metadata
# Set canonical URL from the Read the Docs Domain... | 164 | 4,533 |
pyomo | pyomo/core/tests/unit/test_indexed.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... | 426 | 16,865 |
metrics | src/torchmetrics/detection/iou.py | .py | # Copyright The PyTorch 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 i... | 313 | 13,195 |
coveragepy | coverage/config.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
"""Config file for coverage.py"""
from __future__ import annotations
import base64
import collections
import configparser
import copy
import json
import os
impo... | 733 | 26,013 |
saleor | saleor/graphql/payment/tests/queries/test_transaction.py | .py | from decimal import Decimal
import graphene
import pytest
from django.utils import timezone
from freezegun import freeze_time
from .....giftcard.const import (
SALEOR_GIFT_CARD_BRAND,
SALEOR_GIFT_CARD_PAYMENT_METHOD_NAME,
)
from .....page.models import Page
from .....payment import PaymentMethodType, Transact... | 1,196 | 36,875 |
wandb | wandb/apis/_generated/get_default_entity.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/api/
from __future__ import annotations
from wandb._pydantic import GQLId, GQLResult
class GetDefaultEntity(GQLResult):
viewer: GetDefaultEntityViewer | None
class GetDefaultEntityViewer(GQLResult):
id: GQLId
entity: str | None
GetDefaul... | 19 | 344 |
ipython | setupbase.py | .py | # encoding: utf-8
"""
This module defines the things that are used in setup.py for building IPython
This includes:
* The basic arguments to setup
* Functions for finding things like packages, package data, etc.
* A function for checking dependencies.
"""
# Copyright (c) IPython Development Team.
# Distri... | 213 | 7,218 |
loguru | tests/exceptions/source/ownership/usersite/somelib/__init__.py | .py | def divide(x, y):
x / y
def divide_indirect(a, b):
divide(a, b)
def callme(callback):
callback()
def execute():
exec("divide(1, 0)")
def syntaxerror():
exec("foo =")
def assertionerror(x, y):
assert x == y
| 23 | 240 |
coremltools | coremltools/converters/mil/mil/passes/defs/optimize_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 copy
from typing import List, Optional, Tuple
import numpy as np
from coremltools import _lo... | 1,336 | 48,161 |
flit | flit/__main__.py | .py | from . import main
main()
| 4 | 27 |
probability | tensorflow_probability/python/layers/weight_norm.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... | 194 | 7,086 |
onnxruntime | onnxruntime/python/tools/transformers/models/llama/llama_parity.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from __f... | 344 | 11,557 |
clearml | examples/frameworks/scikit-learn/sklearn_joblib_example.py | .py | try:
import joblib
except ImportError:
from sklearn.externals import joblib
from sklearn import datasets
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
import numpy as np
import matplotlib.pyplot as plt
from clearml import Task
# Connecting ClearML w... | 48 | 1,358 |
sqlmap | plugins/dbms/mimersql/fingerprint.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.common import Backend
from lib.core.common import Format
from lib.core.data import conf
from lib.core.data import kb
from lib.core.data import logger
from lib.core.e... | 95 | 2,599 |
clearml | examples/pipeline/decorated_pipeline_step_functions.py | .py | from clearml import PipelineController
def our_decorator(func):
def function_wrapper(*args, **kwargs):
return func(*args, **kwargs) + 1
return function_wrapper
@our_decorator
def step():
return 1
def evaluate(step_return):
assert step_return == 2
if __name__ == "__main__":
pipeline =... | 28 | 695 |
openvino | src/bindings/python/src/openvino/utils/data_helpers/data_dispatcher.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from functools import singledispatch
from typing import Any, Union, Optional
import numpy as np
from openvino._pyopenvino import ConstOutput, Tensor, Type, RemoteTensor
from openvino.utils.data_helpers.wrappers ... | 473 | 15,540 |
mlflow | tests/store/tracking/test_file_store.py | .py | import pytest
pytestmark = pytest.mark.skip(reason="FileStore is no longer supported")
import hashlib
import json
import os
import posixpath
import random
import re
import shutil
import time
import uuid
from copy import deepcopy
from pathlib import Path
from typing import NamedTuple
from unittest import mock
import ... | 4,075 | 152,126 |
mlflow | mlflow/assistant/gateway_connection.py | .py | """Store Assistant-managed vendor keys as Gateway LLM Connections."""
from mlflow.entities.gateway_endpoint import GatewayEndpointModelConfig, GatewayModelLinkageType
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import RESOURCE_DOES_NOT_EXIST, ErrorCode
from mlflow.tracking._tracking... | 79 | 2,774 |
sqlmap | lib/utils/purge.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import functools
import os
import random
import shutil
import stat
import string
from lib.core.common import getSafeExString
from lib.core.convert import getUnicode
from lib.core... | 98 | 3,425 |
clearml | clearml/utilities/plotlympl/mplexporter/renderers/__init__.py | .py | """
Matplotlib Renderers
====================
This submodule contains renderer objects which define renderer behavior used
within the Exporter class. The base renderer class is :class:`Renderer`, an
abstract base class
"""
from .base import Renderer
from .fake_renderer import FakeRenderer, FullFakeRenderer
from .vega... | 23 | 584 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.