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 |
|---|---|---|---|---|---|
jupytext | tests/functional/others/test_custom_cell_magics.py | .py | import nbformat
from nbformat.v4.nbbase import new_code_cell, new_notebook
from jupytext.cli import jupytext as jupytext_cli
from jupytext.compare import compare_notebooks
from jupytext.languages import _JUPYTER_LANGUAGES_LOWER_AND_UPPER
def test_custom_cell_magics(
tmpdir,
nb=new_notebook(
cells=[
... | 43 | 1,253 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_2in_2out.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import paddle
import numpy as np
import os
import sys
from save_model import saveModel
if paddle.__version__ >= '2.6.0':
import paddle.base as fluid
else:
from paddle import fluid
paddle.enable_static()
inp_blob1 = np.random.r... | 70 | 2,774 |
mlflow | tests/resources/mlflow-test-plugin/mlflow_test_plugin/sqlalchemy_store.py | .py | import urllib.parse
from mlflow.store.model_registry.sqlalchemy_store import SqlAlchemyStore
class PluginRegistrySqlAlchemyStore(SqlAlchemyStore):
def __init__(self, store_uri=None):
path = urllib.parse.urlparse(store_uri).path if store_uri else None
self.is_plugin = True
super().__init__... | 11 | 327 |
pyomo | pyomo/contrib/cp/tests/test_interval_var.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... | 239 | 8,407 |
pyomo | examples/pyomobook/dae-ch/path_constraint.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... | 91 | 2,087 |
metrics | src/torchmetrics/functional/audio/_deprecated.py | .py | from typing import Any, Callable, Optional
from torch import Tensor
from typing_extensions import Literal
from torchmetrics.functional.audio.pit import permutation_invariant_training, pit_permutate
from torchmetrics.functional.audio.sdr import scale_invariant_signal_distortion_ratio, signal_distortion_ratio
from torc... | 127 | 4,431 |
biopython | Tests/test_Align_msf.py | .py | # Copyright 2021 by Michiel de Hoon. All rights reserved.
#
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Tests for Bio.Align.msf module."""
import unittest
import warnings
from io import Strin... | 458 | 25,061 |
saleor | saleor/shipping/tests/test_shipping.py | .py | import pytest
from django_countries import countries
from measurement.measures import Weight
from prices import Money
from ..models import (
ShippingMethod,
ShippingMethodChannelListing,
ShippingMethodType,
ShippingZone,
)
from ..utils import default_shipping_zone_exists, get_countries_without_shipping... | 384 | 13,457 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_dort.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import unittest
import torch
import torch._dynamo
from torch import nn
from torch.nn import functional as F
from torch.onnx import ExportOptions
from torch.onnx import _OrtBackend as OrtBackend
from torch.onnx import _OrtBac... | 383 | 15,414 |
saleor | saleor/graphql/csv/mutations/export_voucher_codes.py | .py | import graphene
from django.core.exceptions import ValidationError
from ....csv import models as csv_models
from ....csv.error_codes import ExportErrorCode
from ....csv.events import export_started_event
from ....csv.tasks import export_voucher_codes_task
from ....permission.enums import DiscountPermissions
from ....w... | 109 | 3,771 |
bazel | src/tools/singlejar/data/log4j2_plugins_gen.py | .py | # Copyright 2024 The Bazel 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 219 | 6,770 |
metrics | src/torchmetrics/functional/image/tv.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... | 78 | 2,799 |
coremltools | coremltools/proto/NearestNeighbors_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: NearestNeighbors.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
... | 112 | 6,531 |
wagtail | wagtail/test/customuser/models.py | .py | from django.contrib.auth.models import (
AbstractBaseUser,
BaseUserManager,
PermissionsMixin,
)
from django.db import models
# Custom user models are a common source of circular import errors, since the user model is often
# referenced in Wagtail core code that we may want to import here. To prevent this, ... | 97 | 3,248 |
probability | tensorflow_probability/python/distributions/matrix_t_linear_operator_test.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 218 | 8,979 |
python-prompt-toolkit | src/prompt_toolkit/eventloop/win32.py | .py | from __future__ import annotations
import sys
assert sys.platform == "win32"
from ctypes import pointer
from ..utils import SPHINX_AUTODOC_RUNNING
# Do not import win32-specific stuff when generating documentation.
# Otherwise RTD would be unable to generate docs for this module.
if not SPHINX_AUTODOC_RUNNING:
... | 73 | 2,286 |
mlflow | tests/spacy/test_spacy_model_export.py | .py | import json
import os
import random
from pathlib import Path
from typing import Any, NamedTuple
from unittest import mock
import pandas as pd
import pytest
import spacy
import yaml
from packaging.version import Version
from spacy.util import compounding, minibatch
import mlflow.pyfunc.scoring_server as pyfunc_scoring... | 512 | 19,731 |
pyomo | examples/mpec/munson1c.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 34 | 1,094 |
mlflow | mlflow/bedrock/genai_semconv_converter.py | .py | """
Bedrock Converse API message converter for GenAI Semantic Convention export.
Translates Bedrock's Converse API format (content blocks with text, toolUse,
toolResult, image) into the GenAI semconv parts array format.
"""
import base64
import json
from typing import Any
from mlflow.tracing.constant import GenAiSem... | 149 | 5,306 |
sphinx | sphinx/ext/autodoc/_dynamic/_docstrings.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, TypeVar
from sphinx.errors import PycodeError
from sphinx.ext.autodoc._dynamic._importer import (
_get_attribute_comment,
_is_runtime_instance_attribute_not_commented,
)
from sphinx.ext.autodoc._property_types import _ClassDefProperties
from... | 333 | 10,677 |
httpie | tests/test_binary.py | .py | """Tests for dealing with binary request and response data."""
import requests
from .fixtures import BIN_FILE_PATH, BIN_FILE_CONTENT, BIN_FILE_PATH_ARG
from httpie.output.streams import BINARY_SUPPRESSED_NOTICE
from .utils import MockEnvironment, http
class TestBinaryRequestData:
def test_binary_stdin(self, htt... | 51 | 1,974 |
probability | tensorflow_probability/python/util/deferred_tensor_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... | 915 | 38,719 |
luigi | luigi/task_status.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 29 | 892 |
pyomo | pyomo/network/decomposition.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,045 | 39,217 |
beam | sdks/python/apache_beam/io/gcp/gcsio_retry.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... | 99 | 3,575 |
pyro | pyro/contrib/funsor/__init__.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pyroapi
from pyro.contrib.funsor.handlers import condition, do, markov, vectorized_markov
from pyro.contrib.funsor.handlers import plate as _plate
from pyro.contrib.funsor.handlers.primitives import to_data, to_funsor
from pyro... | 59 | 1,223 |
conda | conda/models/prefix_graph.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Implements directed graphs to sort and manipulate packages within a prefix.
Object inheritance:
.. autoapi-inheritance-diagram:: PrefixGraph GeneralGraph
:top-classes: conda.models.prefix_graph.PrefixGraph
:parts: 1
"""
from __future... | 467 | 17,510 |
mlflow | tests/groq/test_groq_autolog.py | .py | import json
from unittest.mock import patch
import groq
import pytest
from groq.types.audio.transcription import Transcription
from groq.types.audio.translation import Translation
from groq.types.chat import ChatCompletionMessageToolCall
from groq.types.chat.chat_completion import (
ChatCompletion,
ChatComplet... | 372 | 11,527 |
mlflow | mlflow/entities/gateway_budget_policy.py | .py | from __future__ import annotations
from dataclasses import dataclass
from enum import Enum
from mlflow.entities._mlflow_object import _MlflowObject
from mlflow.protos.service_pb2 import BudgetAction as ProtoBudgetAction
from mlflow.protos.service_pb2 import BudgetDuration as ProtoBudgetDuration
from mlflow.protos.ser... | 190 | 6,599 |
qutip | qutip/tests/solver/test_parallel.py | .py | import numpy as np
import time
import pytest
import threading
from qutip.solver.parallel import (
parallel_map, serial_map, loky_pmap, mpi_pmap, MapExceptions
)
def _func1(x):
return x**2
def _func2(x, a, b, c, d=0, e=0, f=0):
assert d > 0
assert e > 0
assert f > 0
time.sleep(np.random.rand... | 165 | 4,528 |
wagtail | wagtail/admin/views/generic/multiple_upload.py | .py | import os.path
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseBadRequest, JsonResponse
from django.shortcuts import get_object_or_404
from django.template.loader import render_to_string
from django.urls import reverse
f... | 401 | 13,593 |
coveragepy | coverage/types.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
"""
Types for use throughout coverage.py.
"""
from __future__ import annotations
import os
import pathlib
from collections.abc import Callable, Iterable, Mappin... | 198 | 5,503 |
saleor | saleor/graphql/account/enums.py | .py | from typing import Final
import graphene
from django_countries import countries
from ...account import CustomerEvents
from ...checkout import AddressType
from ...graphql.core.enums import to_enum
from ..core.doc_category import DOC_CATEGORY_USERS
from ..core.types import BaseEnum
from ..core.utils import str_to_enum
... | 55 | 1,561 |
saleor | saleor/graphql/product/mutations/utils.py | .py | from django.db.models import Q
from ....tax.models import TaxClass
PRODUCT_VARIANT_UPDATE_FIELDS = {
"external_reference",
"is_preorder",
"metadata",
"name",
"preorder_end_date",
"preorder_global_threshold",
"private_metadata",
"quantity_limit_per_customer",
"sku",
"track_inven... | 35 | 1,025 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_one_hot_v2.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# one_hot_v2 paddle model generator
#
import paddle
import numpy as np
from save_model import saveModel
import sys
def one_hot_v2(name: str, x, num_classes, is_tensor):
paddle.enable_static()
with paddle.static.program_guard... | 48 | 1,738 |
bazel | tools/aquery_differ/resolvers/path_fragment_resolver.py | .py | # Copyright 2020 The Bazel 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 46 | 1,528 |
pyfilesystem2 | tests/test_glob.py | .py | from __future__ import unicode_literals
import re
import unittest
from parameterized import parameterized
from fs import glob, open_fs
class TestGlob(unittest.TestCase):
def setUp(self):
fs = self.fs = open_fs("mem://")
fs.writetext("foo.py", "Hello, World")
fs.touch("bar.py")
f... | 151 | 6,224 |
sqlmap | plugins/dbms/virtuoso/__init__.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 DBMS
from lib.core.settings import VIRTUOSO_SYSTEM_DBS
from lib.core.unescaper import unescaper
from plugins.dbms.virtuoso.enumeration import Enumeratio... | 30 | 928 |
hatch | src/hatch/plugin/manager.py | .py | from hatchling.plugin.manager import PluginManager as _PluginManager
class PluginManager(_PluginManager):
def initialize(self):
super().initialize()
from hatch.plugin import specs
self.manager.add_hookspecs(specs)
def hatch_register_environment(self):
from hatch.env.plugin i... | 36 | 887 |
mlflow | tests/diffusers/test_diffusers_model_export.py | .py | import importlib.util
import json
from pathlib import Path
import numpy as np
import pytest
import yaml
pytest.importorskip("diffusers")
pytest.importorskip("safetensors")
from unittest.mock import MagicMock, Mock, patch
from safetensors.numpy import save_file
import mlflow
import mlflow.diffusers
from mlflow.diff... | 724 | 22,570 |
pyro | tests/params/test_param.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from copy import copy
from unittest import TestCase
import numpy as np
import torch
import torch.optim
from torch import nn as nn
from torch.distributions import constraints
import pyro
from tests.common import assert_equal
cla... | 246 | 8,707 |
mlflow | dev/clint/src/clint/rules/missing_notebook_h1_header.py | .py | from clint.rules.base import Rule
class MissingNotebookH1Header(Rule):
def _message(self) -> str:
return "Notebook should have at least one H1 header for the title."
| 7 | 180 |
saleor | saleor/core/tests/test_jwt_manager.py | .py | import json
import jwt
import pytest
from cryptography.hazmat.primitives import serialization
from django.core.exceptions import ImproperlyConfigured
from django.test import override_settings
from ..jwt_manager import JWTManager, get_jwt_manager
def test_get_jwt_manager(settings):
# given
assert settings.JW... | 123 | 3,253 |
black | tests/data/cases/power_op_spacing_long.py | .py | a = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
b = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
c = 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1
d ... | 97 | 2,500 |
saleor | saleor/graphql/product/tests/deprecated/test_utils.py | .py | from .....tax.models import TaxClass
from ...mutations.utils import clean_tax_code
def test_clean_tax_code_does_nothing_when_empty_data():
# given
data = {}
# when
clean_tax_code(data)
# then
assert data == {}
def test_clean_tax_code_does_nothing_when_tax_class_provided():
# given
... | 79 | 1,686 |
mlflow | mlflow/metrics/genai/model_utils.py | .py | import logging
import os
from typing import TYPE_CHECKING, Any
import requests
from pydantic import BaseModel
from mlflow.environment_variables import MLFLOW_GENAI_EVAL_LLM_TIMEOUT
from mlflow.exceptions import MlflowException
from mlflow.gateway.config import EndpointConfig
from mlflow.gateway.providers.openai impor... | 639 | 25,017 |
wandb | wandb/proto/v7/wandb_base_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: wandb/proto/wandb_base.proto
# Protobuf Python Version: 7.34.0
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_... | 42 | 1,821 |
beam | scripts/tools/bomupgrader.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... | 383 | 14,115 |
textual | tests/input/test_cut_copy_paste.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Input
class InputApp(App):
def compose(self) -> ComposeResult:
yield Input()
async def test_cut():
"""Check that cut removes text and places it in the clipboard."""
app = InputApp()
async with app.run_test() as pilot:
... | 53 | 1,714 |
beam | learning/katas/python/Common Transforms/WithKeys/WithKeys/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... | 37 | 1,366 |
pymc | tests/model/test_core.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... | 2,178 | 84,771 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/tests/test_mle.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.timeseries.periodograms.lombscargle.implementations.mle import (
design_matrix,
periodic_fit,
)
@pytest.fixture
def t():
rand = np.random.default_rng(42)
return 10 * rand.random(10)
@pytest.mark.parametrize("fre... | 66 | 2,007 |
ipython | IPython/extensions/deduperreload/deduperreload_patching.py | .py | from __future__ import annotations
import ctypes
from typing import Any
NOT_FOUND: object = object()
NULL: object = object()
_MAX_FIELD_SEARCH_OFFSET = 50
POINTER_N_BYTES = ctypes.sizeof(ctypes.c_void_p)
class DeduperReloaderPatchingMixin:
@staticmethod
def infer_field_offset(
obj: object,
f... | 142 | 4,974 |
pyomo | pyomo/contrib/mpc/examples/cstr/run_openloop.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... | 85 | 2,933 |
saleor | saleor/core/editorjs/tests/test_editorjs.py | .py | import json
import warnings
from copy import deepcopy
import django.core.exceptions
import pydantic_core
import pytest
from django.utils.html import strip_tags
from ...cleaners.html import HtmlCleanerSettings
from .. import clean_editorjs, editorjs_to_text
from ..cleaners import _clean_url_value
from .conftest import... | 1,561 | 49,417 |
onnx | tests/python/checker_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import os
import tempfile
from typing import TYPE_CHECKING
import numpy as np
import pytest
import onnx.defs
import onnx.parser
from onnx import (
GraphProto,
SparseTensorProto,
TensorProto... | 1,605 | 67,412 |
mlflow | mlflow/autogen/__init__.py | .py | import logging
from typing import Any
from pydantic import BaseModel
import mlflow
from mlflow.autogen.chat import log_tools
from mlflow.entities import SpanType
from mlflow.telemetry.events import AutologgingEvent
from mlflow.telemetry.track import _record_event
from mlflow.tracing.constant import SpanAttributeKey, ... | 150 | 5,667 |
openvino | src/bindings/python/tests/test_transformations/test_model_pass.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino.passes import Manager
from tests.test_transformations.utils.utils import get_relu_model, MyModelPass
def test_model_pass():
manager = Manager()
model_pass = manager.register_pass(MyModelPas... | 22 | 555 |
pyfilesystem2 | fs/_url_tools.py | .py | import typing
import platform
import re
import six
if typing.TYPE_CHECKING:
from typing import Text
_WINDOWS_PLATFORM = platform.system() == "Windows"
def url_quote(path_snippet):
# type: (Text) -> Text
"""Quote a URL without quoting the Windows drive letter, if any.
On Windows, it will separate d... | 56 | 1,525 |
onnx | onnx/backend/test/case/node/nonmaxsuppression.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 NonMaxSuppression(Base):
@staticmethod
def export_nonmaxsuppre... | 476 | 16,032 |
scikit-bio | skbio/sequence/tests/test_rna.py | .py | # ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# --------------------------------------------... | 50 | 1,913 |
onnxruntime | onnxruntime/python/tools/transformers/import_utils.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import importlib.metadata
import importlib.util
def is_installed(packa... | 21 | 631 |
textual | docs/examples/guide/css/nesting01.py | .py | from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Static
class NestingDemo(App):
"""App that doesn't have nested CSS."""
CSS_PATH = "nesting01.tcss"
def compose(self) -> ComposeResult:
with Horizontal(id="questions"):
yie... | 20 | 492 |
pymc | pymc/dims/distributions/censored.py | .py | # Copyright 2026 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 68 | 2,942 |
pyomo | pyomo/contrib/piecewise/tests/common_inner_repn_tests.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... | 79 | 3,206 |
probability | spinoffs/inference_gym/inference_gym/targets/vectorized_stochastic_volatility_test.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 376 | 13,752 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/Notebook with function and cell metadata 164.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: '{{{,}}}'
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
1 + 1
# A markdown cell
# And below, the cell for function f has non trivial cell metadata. And the next cell as well.
# {{{ attributes={"classes": [], "id": "",... | 30 | 448 |
wagtail | wagtail/blocks/list_block.py | .py | import uuid
from collections.abc import Mapping, MutableSequence
from django import forms
from django.core.exceptions import ValidationError
from django.forms.utils import ErrorList
from django.utils.functional import cached_property
from django.utils.html import format_html, format_html_join
from django.utils.transla... | 515 | 19,102 |
omegaconf | docs/source/conf.py | .py | # type: ignore
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup ---------------------------------------------... | 174 | 5,208 |
pyomo | pyomo/common/collections/component_set.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... | 138 | 4,563 |
coremltools | coremltools/test/optimize/torch/pruning/test_magnitude_pruner.py | .py | # Copyright (c) 2024, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import copy
from collections import OrderedDict
import numpy as np
import pytest
import torch
import... | 624 | 21,827 |
probability | tensorflow_probability/python/experimental/mcmc/with_reductions.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... | 177 | 6,861 |
kafka | tests/kafkatest/services/kafka/__init__.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 use ... | 19 | 878 |
onnx | onnx/reference/ops/op_affine_grid.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
def construct_original_grid(data_size, align_corners):
is_2d = len(data_size) == 2
size_zeros = np.zeros(data_size)
original_grid... | 91 | 3,490 |
ipython | tests/test_terminal_utils.py | .py | """Tests for IPython.utils.terminal"""
import pytest
from unittest import mock
import IPython.utils.terminal as terminal_mod
from IPython.utils.terminal import (
toggle_set_term_title,
set_term_title,
restore_term_title,
get_terminal_size,
)
def test_get_terminal_size_returns_tuple():
result = ge... | 83 | 2,438 |
textual | docs/examples/guide/layout/grid_layout5_col_span.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Static
class GridLayoutExample(App):
CSS_PATH = "grid_layout5_col_span.tcss"
def compose(self) -> ComposeResult:
yield Static("One", classes="box")
yield Static("Two [b](column-span: 2)", classes="box", id="two")
y... | 20 | 560 |
openvino | tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import argparse
import logging as log
import sys
import numpy as np
import os
from openvino.frontend import FrontEnd, InputModel, NotImplementedFailure, \
Place # pylint: disable=no-name-in-module,import-error
from openvino import... | 295 | 14,073 |
beam | sdks/python/apache_beam/testing/test_utils.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... | 293 | 8,606 |
pynacl | tests/test_public.py | .py | # Copyright 2013 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 applicable law... | 168 | 5,999 |
mlflow | mlflow/genai/judges/tools/get_root_span.py | .py | """
Get root span tool for MLflow GenAI judges.
This module provides a tool for retrieving the root span of a trace,
which contains the top-level inputs and outputs.
"""
from mlflow.entities.trace import Trace
from mlflow.genai.judges.tools.base import JudgeTool
from mlflow.genai.judges.tools.constants import ToolNam... | 109 | 4,316 |
beam | sdks/python/apache_beam/runners/interactive/caching/cacheable.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... | 104 | 2,947 |
beam | sdks/python/apache_beam/yaml/yaml_mapping_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... | 565 | 19,520 |
probability | spinoffs/autobnn/autobnn/util.py | .py | # Copyright 2023 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... | 76 | 2,639 |
saleor | saleor/graphql/payment/tests/mutations/test_payment_refund.py | .py | from unittest.mock import patch
import graphene
from .....payment import TransactionKind
from .....payment.models import ChargeStatus
from ....core.enums import PaymentErrorCode
from ....tests.utils import assert_no_permission, get_graphql_content
REFUND_QUERY = """
mutation PaymentRefund($paymentId: ID!, $amoun... | 219 | 7,221 |
mlflow | mlflow/store/db_migrations/versions/e1f2a3b4c5d6_add_budget_policies_table.py | .py | """add budget_policies table
Create Date: 2026-02-24 00:00:00.000000
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "e1f2a3b4c5d6"
down_revision = "1b5f0d9ad7c1"
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
"budget_polic... | 45 | 1,587 |
beam | sdks/python/apache_beam/io/gcp/bigtableio_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... | 398 | 15,379 |
ipython | tests/test_alias.py | .py | from IPython.utils.capture import capture_output
import pytest
def test_alias_lifecycle():
name = "test_alias1"
cmd = 'echo "Hello"'
am = _ip.alias_manager
am.clear_aliases()
am.define_alias(name, cmd)
assert am.is_alias(name)
assert am.retrieve_alias(name) == cmd
assert (name, cmd) i... | 69 | 1,988 |
gunicorn | tests/test_asgi_forwarded_headers.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
ASGI forwarded headers tests.
Tests for X-Forwarded-For, X-Forwarded-Proto, and related
proxy header handling in ASGI applications.
"""
from unittest import mock
import pytest
from gunicorn.config import Co... | 417 | 13,743 |
saleor | saleor/checkout/tests/test_delivery_assignent_to_checkout.py | .py | from decimal import Decimal
from ..delivery_context import (
assign_collection_point_to_checkout,
assign_shipping_method_to_checkout,
remove_delivery_method_from_checkout,
)
def test_remove_delivery_method_from_checkout_with_cc(
checkout_with_delivery_method_for_cc,
):
# given
expected_update... | 247 | 8,025 |
sphinx | tests/roots/test-inheritance/dummy/test.py | .py | r"""Test with a class diagram like this::
A
/ \
B C
/ \ / \
E D F
""" # NoQA: D208
class A:
pass
class B(A):
pass
class C(A):
pass
class D(B, C):
pass
class E(B):
pass
class F(C):
pass
| 34 | 275 |
beam | sdks/python/apache_beam/utils/histogram.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... | 307 | 10,149 |
onnxruntime | onnxruntime/test/python/transformers/test_qmoe_fp4_cuda.py | .py | # --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
#
# Tes... | 1,178 | 48,551 |
mlflow | mlflow/models/utils.py | .py | import base64
import datetime as dt
import decimal
import importlib
import json
import logging
import os
import re
import shutil
import sys
import tempfile
import uuid
from contextlib import contextmanager
from copy import deepcopy
from pathlib import Path
from typing import Any, Dict, List, Union
import numpy as np
i... | 2,077 | 84,552 |
mlflow | mlflow/genai/discovery/utils.py | .py | from __future__ import annotations
import logging
from collections import defaultdict
import mlflow
from mlflow.entities.assessment import Feedback
from mlflow.entities.trace import Trace
from mlflow.genai.discovery.constants import (
TRACE_CONTENT_TRUNCATION,
)
from mlflow.genai.discovery.entities import Issue, ... | 272 | 9,454 |
luigi | luigi/target.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 358 | 12,753 |
pyomo | pyomo/solvers/tests/checks/test_gurobi.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... | 55 | 1,883 |
luigi | test/contrib/beam_dataflow_test.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2019 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | 339 | 12,065 |
mlflow | tests/tensorflow/test_keras_pyfunc_model_works_with_all_input_types.py | .py | import json
import os
import numpy as np
import pandas as pd
import pytest
import tensorflow as tf
from packaging.version import Version
from pyspark.sql.functions import struct
from sklearn import datasets
from tensorflow.keras.layers import Concatenate, Dense, Input, Lambda
from tensorflow.keras.models import Model,... | 417 | 14,658 |
astropy | astropy/cosmology/_src/flrw/wpwazpcdm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ("FlatwpwaCDM", "wpwaCDM")
from numpy import exp
from numpy.typing import ArrayLike
from astropy.cosmology import units as cu
from astropy.cosmology._src.core import dataclass_decorator
from astropy.cosmology._src.parameter import Parameter
fr... | 352 | 12,902 |
probability | tensorflow_probability/python/vi/optimization.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... | 734 | 33,154 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.