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 |
|---|---|---|---|---|---|
openvino | tests/e2e_tests/common/ref_collector/precollected.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import torch
from e2e_tests.common.ref_collector.provider import ClassProvider
from e2e_tests.test_utils.path_utils import resolve_file_path
import numpy as np
import logging as log
import sys
class PrecollectedRefs(ClassProvider):
... | 49 | 1,584 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_floor.py | .py | #
# floor paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle
import sys
def floor(name: str, x):
paddle.enable_static()
with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()):
data = paddle.static.data(name='x', shape=x.shape, dtype=... | 41 | 996 |
astropy | astropy/cosmology/_src/traits/hubble.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Hubble parameter trait.
This is private API. See `~astropy.cosmology.traits` for public API.
"""
__all__ = ("HubbleParameter",)
from collections.abc import Callable
from functools import cached_property
from typing import Any
import numpy as np
from... | 61 | 1,607 |
conda | tests/cli/test_main_compare.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from conda.core.prefix_data import PrefixData
from conda.exceptions import EnvironmentLocationNotFound
if TYPE_CHECKING:
from pathlib import Path
from... | 43 | 1,210 |
onnx | tests/python/function_inference_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from shape_inference_test import TestShapeInferenceHelper
import onnx
import onnx.helper
import onnx.parser
import onnx.shape_inference
from onnx import A... | 122 | 4,525 |
slimit | src/slimit/tests/test_minifier.py | .py | ###############################################################################
#
# Copyright (c) 2011 Ruslan Spivak
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, inc... | 471 | 14,736 |
sphinx | tests/roots/test-ext-inheritance_diagram/example/sphinx.py | .py | # example.sphinx
class DummyClass:
pass
| 6 | 46 |
python-prompt-toolkit | src/prompt_toolkit/shortcuts/dialogs.py | .py | from __future__ import annotations
import functools
from collections.abc import Callable, Sequence
from typing import Any, TypeVar
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.completion import Co... | 332 | 9,049 |
returns | returns/interfaces/specific/future.py | .py | """
Represents the base interfaces for types that do fearless async operations.
This type means that ``Future`` cannot fail.
Don't use this type for async that can. Instead, use
:class:`returns.interfaces.specific.future_result.FutureResultBasedN` type.
"""
from __future__ import annotations
from abc import abstract... | 148 | 4,601 |
kombu | kombu/utils/time.py | .py | """Time Utilities."""
from __future__ import annotations
__all__ = ('maybe_s_to_ms',)
def maybe_s_to_ms(v: int | float | None) -> int | None:
"""Convert seconds to milliseconds, but return None for None."""
return int(float(v) * 1000.0) if v is not None else v
| 10 | 272 |
onnxruntime | onnxruntime/python/tools/microbench/benchmark.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import logging
import time
from abc import ABC, abstractmethod
from argp... | 166 | 4,900 |
pdm | tests/cli/test_remove.py | .py | import pytest
from pdm.cli import actions
from pdm.cli.commands.remove import Command
from pdm.cli.filters import GroupSelection
from pdm.models.specifiers import PySpecSet
from pdm.utils import cd
def make_workspace_member(project, core):
project.pyproject.settings["workspace"] = {"members": ["packages/*"]}
... | 211 | 8,082 |
readthedocs.org | docs/conf.py | .py | """
Shared Sphinx configuration using sphinx-multiproject.
To build each project, the ``PROJECT`` environment variable is used.
.. code:: console
$ make html # build default project
$ PROJECT=dev make html # build the dev project
for more information read https://sphinx-multiproject.readthedocs.io/.
"""
im... | 232 | 7,639 |
onnx | onnx/reference/ops/op_acosh.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.ops._op import OpRunUnaryNum
class Acosh(OpRunUnaryNum):
def _run(self, x):
return (np.arccosh(x),)
| 14 | 271 |
saleor | saleor/tests/e2e/checkout/shipping/test_use_external_shipping_methods_in_checkout.py | .py | import pytest
import vcr
from ...apps.utils import add_app
from ...product.utils.preparing_product import prepare_product
from ...shop.utils.preparing_shop import prepare_default_shop
from ...utils import assign_permissions, request_matcher
from ...webhooks.utils import create_webhook
from ..utils import (
checkou... | 144 | 5,213 |
onnxruntime | tools/ci_build/github/windows/jar_packaging.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Packages ONNX Runtime Java artifacts by combining native libraries from
various platform builds into final Java archive (JAR) files using 7z.
"""
import argparse
import glob
import os
import re
import shutil
import subpr... | 315 | 11,786 |
pyomo | pyomo/contrib/gdpopt/tests/common_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... | 61 | 3,134 |
saleor | saleor/webhook/response_schemas/utils/annotations.py | .py | import logging
from datetime import UTC, datetime
from enum import Enum
from typing import Annotated, Any, TypeVar
import pydantic
from pydantic import (
AfterValidator,
BeforeValidator,
Field,
GetCoreSchemaHandler,
TypeAdapter,
ValidationError,
ValidationInfo,
ValidatorFunctionWrapHand... | 174 | 4,989 |
onnxruntime | onnxruntime/python/tools/transformers/models/llama/llama_inputs.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... | 505 | 20,222 |
coremltools | coremltools/test/sklearn_tests/test_NuSVC.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import random
import tempfile
import unittest
import pandas as pd
import pytest
from coremltools._deps... | 309 | 11,841 |
wagtail | wagtail/test/earlypage/models.py | .py | # This module DOES NOT import from wagtail.admin -
# this tests that we are able to define Page models before wagtail.admin is loaded.
import swapper
from django.db import models
# Ensure that we look at the setting WAGTAIL_PAGE_MODEL rather than WAGTAILCORE_PAGE_MODEL.
# This is set in wagtail.models, but we need to... | 23 | 712 |
probability | tensorflow_probability/python/math/psd_kernels/feature_scaled_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... | 156 | 5,579 |
mlflow | tests/tracking/test_client.py | .py | import json
import os
import pickle
import threading
import time
import uuid
from pathlib import Path
from unittest import mock
from unittest.mock import Mock, patch
import pytest
from opentelemetry import trace as trace_api
from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan
from pydantic import Base... | 4,042 | 151,764 |
openvino | tests/layer_tests/onnx_tests/test_fusedgemm.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
class TestFusedGemm(OnnxRuntimeLayerTest):
def _prepare_input(self, inputs_dict):
for input in inputs_dict.keys... | 150 | 5,284 |
saleor | saleor/tests/e2e/product/utils/preparing_product.py | .py | from . import (
create_category,
create_product,
create_product_channel_listing,
create_product_type,
create_product_variant,
create_product_variant_channel_listing,
)
def prepare_product(
e2e_staff_api_client,
warehouse_id,
channel_id,
variant_price,
product_type_slug="def... | 92 | 2,202 |
wagtail | wagtail/snippets/tests/test_copy_view.py | .py | from django.contrib.auth.models import Permission
from django.test import TestCase
from django.urls import reverse
from wagtail.test.snippets.models import StandardSnippet
from wagtail.test.utils import WagtailTestUtils
class TestSnippetCopyView(WagtailTestUtils, TestCase):
def setUp(self):
self.snippet ... | 39 | 1,445 |
mlflow | mlflow/genai/label_schemas/__init__.py | .py | """
Label schemas define how reviewers annotate traces in the review UI.
By default a schema is managed in the MLflow tracking store and scoped to an
experiment (identity ``(experiment_id, name)``, with a server-generated
``schema_id``). On a Databricks tracking URI the same functions route to the
workspace's ReviewAp... | 318 | 11,349 |
saleor | saleor/invoice/error_codes.py | .py | from enum import Enum
class InvoiceErrorCode(Enum):
REQUIRED = "required"
NOT_READY = "not_ready"
URL_NOT_SET = "url_not_set"
EMAIL_NOT_SET = "email_not_set"
NUMBER_NOT_SET = "number_not_set"
NOT_FOUND = "not_found"
INVALID_STATUS = "invalid_status"
NO_INVOICE_PLUGIN = "no_invoice_plug... | 13 | 324 |
mlflow | tests/projects/test_kubernetes.py | .py | from unittest import mock
import kubernetes
import pytest
import yaml
from kubernetes.config.config_exception import ConfigException
from mlflow.entities import RunStatus
from mlflow.exceptions import ExecutionException
from mlflow.projects import kubernetes as kb
def test_run_command_creation():
command = [
... | 359 | 13,313 |
pyro | pyro/logger.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
default_format = "%(levelname)s \t %(message)s"
log = logging.getLogger("pyro")
log.setLevel(logging.INFO)
if not logging.root.handlers:
default_handler = logging.StreamHandler()
default_handler.setLevel(l... | 17 | 463 |
jupyterlab | packages/services/examples/node/main.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import json
import os.path as osp
from jupyterlab_server.process import which
from jupyterlab_server.process_app import ProcessApp
HERE = osp.dirname(osp.realpath(__file__))
def _jupyter_server_extension_points() -... | 40 | 1,154 |
python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/completion.py | .py | """
Key binding handlers for displaying completions.
"""
from __future__ import annotations
import asyncio
import math
from typing import TYPE_CHECKING
from prompt_toolkit.application.run_in_terminal import in_terminal
from prompt_toolkit.completion import (
CompleteEvent,
Completion,
get_common_complete... | 207 | 6,903 |
coremltools | coremltools/converters/mil/mil/ops/defs/iOS15/random.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
from coremltools.converters.mil.mil import (get_new_symbol,
... | 301 | 9,533 |
beam | sdks/python/apache_beam/testing/benchmarks/inference/vllm_gemma_benchmarks.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 45 | 1,609 |
pyomo | pyomo/core/tests/unit/test_external.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... | 686 | 24,474 |
coremltools | coremltools/optimize/torch/quantization/_coreml_quantizer.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 operator as _operator
from typing import Callable as _Callable
from typing import List as _Lis... | 625 | 19,656 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_global_maxpool1D.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasGlobalMaxPool1D(CommonTF2LayerTest):
def create_keras_global_max_pooling1D_net(self, input_names, input_shapes, input_... | 42 | 1,733 |
astropy | astropy/coordinates/polarization.py | .py | from collections.abc import Generator
from contextlib import contextmanager
from typing import NamedTuple
import numpy as np
from astropy.utils import unbroadcast
from astropy.utils.data_info import MixinInfo
from astropy.utils.shapes import ShapedLikeNDArray
__all__ = ["StokesCoord", "StokesSymbol", "custom_stokes_... | 259 | 8,111 |
coremltools | coremltools/models/neural_network/__init__.py | .py | # Copyright (c) 2018, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from . import (flexible_shape_utils, optimization_utils, printer,
quantization_utils, spe... | 11 | 486 |
beam | examples/multi-language/python/javadatagenerator.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... | 90 | 3,154 |
onnxruntime | tools/nuget/generate_nuspec_for_custom_nuget.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import glob
import os
import re
import shutil
from generate_nuspec_for_native_nuget import generate_metadata
def generate_files(lines, args):
files_list = ["<files>"]
platform_map = {
"win-a... | 172 | 6,077 |
mkdocs-material | material/templates/__init__.py | .py | # Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, c... | 60 | 3,102 |
clearml | examples/frameworks/tensorboardx/moviepy_tensorboardx.py | .py | # ClearML - Example of pytorch with tensorboardX add_video.
#
from __future__ import print_function
import torch
from tensorboardX import SummaryWriter
from clearml import Task
def main():
# Connecting ClearML with the current process,
# from here on everything is logged automatically
task = Task.init(... | 29 | 758 |
astropy | astropy/units/tests/test_quantity_typing.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Test the Quantity class and related."""
from typing import Annotated, Any, get_args, get_origin, get_type_hints
import numpy as np
from astropy import units as u
class TestQuantityTyping:
"""Test Quantity Typing Annotations."""
def test_qu... | 79 | 2,573 |
mkdocs | mkdocs/commands/build.py | .py | from __future__ import annotations
import gzip
import logging
import os
import time
from typing import TYPE_CHECKING, Sequence
from urllib.parse import urljoin, urlsplit
import jinja2
from jinja2.exceptions import TemplateNotFound
import mkdocs
from mkdocs import utils
from mkdocs.exceptions import Abort, BuildError... | 370 | 13,615 |
jupytext | tests/functional/simple_notebooks/test_read_simple_java.py | .py | import jupytext
from jupytext.compare import compare
def test_read_simple_file(
script="""// ---
// title: Simple file
// ---
// Here we have some text
// And below we have some code
System.out.println("Hello World");
""",
):
nb = jupytext.reads(script, "java")
assert len(nb.cells) == 3
assert nb.ce... | 27 | 733 |
openvino | tests/layer_tests/onnx_tests/test_and.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
pytest.importorskip("openvino.tools.mo", reason="Ticket - 157136")
from common.layer_test_class import check_ir_version
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
fro... | 274 | 9,860 |
pyomo | pyomo/solvers/tests/checks/test_CPLEXDirect.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... | 600 | 21,571 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_ExpandDims.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng(62362)
class TestExpandDims(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
... | 93 | 3,553 |
jupyterlab | jupyterlab/tests/mock_packages/interop/provider/jlab_mock_provider.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import json
import os.path as osp
HERE = osp.abspath(osp.dirname(__file__))
with open(osp.join(HERE, "static", "package.json")) as fid:
data = json.load(fid)
def _jupyter_labextension_paths():
return [{"src... | 15 | 393 |
metrics | src/torchmetrics/classification/negative_predictive_value.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... | 523 | 24,587 |
cvxpy | cvxpy/utilities/linalg.py | .py | import numpy as np
import qdldl
import scipy.linalg as la
import scipy.sparse as sp
import scipy.sparse.linalg as sparla
from scipy.sparse import csc_array
import cvxpy.settings as settings
def orth(V, tol=1e-12):
"""Return a matrix whose columns are an orthonormal basis for range(V)"""
Q, R, p = la.qr(V, mo... | 390 | 15,014 |
bazel | tools/build_defs/pkg/archive.py | .py | # Copyright 2015 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... | 228 | 7,410 |
scikit-bio | skbio/diversity/_util.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.
# --------------------------------------------... | 186 | 5,919 |
onnx | tests/python/serialization_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import os
import tempfile
import pytest
import onnx
_TEST_MODEL = """\
<
ir_version: 8,
opset_import: ["" : 17, "local" : 1]
>
agraph (float[N] X) => (float[N] Y) {
Y = local.foo (X)
}
<o... | 99 | 3,210 |
wandb | tests/system_tests/backend_fixtures.py | .py | from __future__ import annotations
import json
import secrets
import subprocess
import sys
from collections import deque
from dataclasses import InitVar, asdict, dataclass, field
from pathlib import Path
from string import ascii_lowercase, digits
from typing import Any, ClassVar, Final, Literal
import httpx
#: The r... | 282 | 7,985 |
black | tests/test_blackd.py | .py | import asyncio
import gc
import re
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime, timezone
from threading import Event
from unittest.mock import patch
import pytest
from click.testing import CliRunner
from tests.util import DETERMINISTIC_HEADER, read_data
try:
from aiohttp impor... | 450 | 17,497 |
wagtail | wagtail/contrib/redirects/base_formats.py | .py | import csv
from io import BytesIO, StringIO
class Dataset(list):
def __init__(self, rows=(), headers=None):
super().__init__(rows)
self.headers = headers or (self.pop(0) if len(self) > 0 else [])
def __str__(self):
"""Print a table"""
result = [[]]
widths = []
... | 82 | 1,985 |
astropy | astropy/cosmology/_src/tests/traits/test_trait_scale_factor.py | .py | import pytest
from numpy.testing import assert_allclose
from astropy.cosmology._src.traits.scale_factor import ScaleFactor
from .helper import is_positional_only
class DummyScale(ScaleFactor):
pass
@pytest.fixture
def dummy_scale():
return DummyScale()
def test_scale_factor_behavior_and_signature(dummy_... | 40 | 940 |
mlflow | tests/store/tracking/test_read_write_routing.py | .py | import os
import shutil
from pathlib import Path
from unittest import mock
import pytest
import sqlalchemy
import sqlalchemy.orm
from mlflow.entities import Metric, ViewType
from mlflow.exceptions import MlflowException
from mlflow.store.db.utils import _get_routing_session_maker
from mlflow.store.tracking.sqlalchemy... | 317 | 11,255 |
wagtail | wagtail/documents/tests/test_rich_text.py | .py | from django.test import TestCase
from django.urls import reverse_lazy
from wagtail.documents import get_document_model
from wagtail.documents.rich_text import (
DocumentLinkHandler as FrontendDocumentLinkHandler,
)
from wagtail.documents.rich_text.editor_html import (
DocumentLinkHandler as EditorHtmlDocumentL... | 77 | 2,964 |
onnx | onnx/reference/ops/op_scatter_elements.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 scatter_elements(data, indices, updates, axis=0, reduction=None):
"""Scatter elements.
::
for 3-dim and axis=0
... | 120 | 3,806 |
mlflow | tests/tensorflow/test_tensorflow2_core_model_export.py | .py | import os
from typing import Any, NamedTuple
from unittest import mock
import numpy as np
import pytest
import tensorflow as tf
import mlflow.tensorflow
from mlflow.models import Model, infer_signature
class ToyModel(tf.Module):
def __init__(self, w, b):
super().__init__()
self.w = w
sel... | 130 | 3,954 |
conda | tests/gateways/test_zstd.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Test that SubdirData is able to use zstd repodata downloads.
"""
import json
from pathlib import Path
from socket import socket
import pytest
import requests
from pytest import MonkeyPatch
import conda.gateways.repodata
from conda._privat... | 266 | 7,925 |
pyro | pyro/distributions/testing/naive_dirichlet.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from pyro.distributions.torch import Beta, Dirichlet, Gamma
from pyro.distributions.util import copy_docs_from
@copy_docs_from(Dirichlet)
class NaiveDirichlet(Dirichlet):
"""
Implementation of ``Dirichlet`` ... | 48 | 1,598 |
saleor | saleor/graphql/translations/mutations/__init__.py | .py | from .attribute_bulk_translate import AttributeBulkTranslate
from .attribute_translate import AttributeTranslate
from .attribute_value_bulk_translate import AttributeValueBulkTranslate
from .attribute_value_translate import AttributeValueTranslate
from .category_translate import CategoryTranslate
from .collection_trans... | 40 | 1,521 |
probability | tensorflow_probability/python/sts/anomaly_detection/__init__.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 30 | 1,262 |
coremltools | coremltools/optimize/torch/layerwise_compression/algorithms.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
# Original implementation from https://github.com/IST-DASLab/sparsegpt
# Copyright 2023 IST Austria D... | 717 | 31,336 |
mlflow | tests/tensorflow/test_mlflow_callback.py | .py | import numpy as np
import pytest
import tensorflow as tf
from tensorflow import keras
import mlflow
from mlflow.tensorflow.callback import MlflowCallback
@pytest.mark.parametrize(("log_every_epoch", "log_every_n_steps"), [(True, None), (False, 1)])
def test_tf_mlflow_callback(log_every_epoch, log_every_n_steps):
... | 58 | 1,835 |
gunicorn | tests/requests/valid/021.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
request = {
"method": "GET",
"uri": uri("/first"),
"version": (1, 1),
"headers": [("CONNECTION", "Close")],
"body": b""
}
| 12 | 248 |
mlflow | mlflow/models/docker_utils.py | .py | import logging
import os
import subprocess
from subprocess import Popen
from typing import Literal
from urllib.parse import urlparse
from packaging.version import Version
from mlflow.environment_variables import MLFLOW_DOCKER_OPENJDK_VERSION
from mlflow.utils import env_manager as em
from mlflow.utils.file_utils impo... | 230 | 8,519 |
tqdm | tqdm/contrib/itertools.py | .py | """
Thin wrappers around `itertools`.
"""
import itertools
import math
from ..auto import tqdm as tqdm_auto
__author__ = {"github.com/": ["casperdcl"]}
__all__ = [
'chain', 'product', 'permutations', 'combinations', 'combinations_with_replacement', 'batched']
def chain(*iterables, total=None, tqdm_class=tqdm_au... | 93 | 2,949 |
mlflow | tests/data/test_meta_dataset.py | .py | import json
from unittest.mock import patch
import pytest
pd = pytest.importorskip("pandas")
from mlflow.data.delta_dataset_source import DeltaDatasetSource
from mlflow.data.http_dataset_source import HTTPDatasetSource
from mlflow.data.huggingface_dataset_source import HuggingFaceDatasetSource
from mlflow.data.meta_... | 120 | 4,140 |
hatch | src/hatch/cli/python/show.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
import click
if TYPE_CHECKING:
from hatch.cli.application import Application
@click.command(short_help="Show the available Python distributions")
@click.option("--ascii", "force_ascii", is_flag=True, help="Whether or not to only use ASCII char... | 39 | 1,609 |
mlflow | examples/uv-dependency-management/log_model.py | .py | """
Example: Using uv for dependency management with MLflow models.
This script demonstrates three ways to use uv lockfile-based dependencies
when logging MLflow models:
1. Auto-detection: MLflow detects uv.lock + pyproject.toml in the current
working directory and uses ``uv export`` to capture pinned dependencies... | 218 | 7,071 |
saleor | saleor/graphql/product/tests/mutations/test_product_type_create.py | .py | import json
from unittest import mock
from unittest.mock import ANY
import graphene
import pytest
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....attribute import AttributeType
from .....core.utils.json_serializer import CustomJsonEncoder
from .....product.error_codes ... | 616 | 20,000 |
bazel | third_party/py/mock/docs/conf.py | .py | # -*- coding: utf-8 -*-
#
# Mock documentation build configuration file, created by
# sphinx-quickstart on Mon Nov 17 18:12:00 2008.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't pickleable... | 209 | 6,310 |
astropy | astropy/nddata/mixins/ndarithmetic.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module implements the Arithmetic mixin to the NDData class.
import warnings
from copy import deepcopy
from typing import TypeVar
import numpy as np
from astropy.nddata.nduncertainty import NDUncertainty
from astropy.units import Quantity, dimensi... | 859 | 34,195 |
biopython | Bio/Affy/CelFile.py | .py | # Copyright 2004 by Harry Zuzan. All rights reserved.
# Copyright 2016 by Adam Kurkiewicz. 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... | 573 | 23,562 |
mlflow | tests/db/test_workspace_move.py | .py | import uuid
from pathlib import Path
from unittest import mock
import pytest
import sqlalchemy as sa
from mlflow.entities import ExperimentTag, TraceInfo
from mlflow.entities.model_registry import ModelVersionTag, RegisteredModelTag
from mlflow.entities.trace_location import TraceLocation
from mlflow.entities.trace_s... | 762 | 28,803 |
saleor | saleor/thumbnail/validators.py | .py | from collections.abc import Collection
from django.core.exceptions import ValidationError
from PIL import Image, UnidentifiedImageError
from . import (
ICON_MIME_TYPES,
MIME_TYPE_TO_PIL_IDENTIFIER,
MIN_ICON_SIZE,
PIL_IDENTIFIER_TO_MIME_TYPE,
)
def validate_image_format(
img: Image.Image,
err... | 73 | 2,483 |
biopython | Tests/test_KGML_graphics_online.py | .py | #
# Copyright 2014 by Leighton Pritchard. 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 online functionality of the KGML modules."""
# Builtins
import os
import ... | 87 | 2,711 |
pyomo | pyomo/repn/tests/ampl/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 22 | 796 |
textual | tests/toggles/test_labels.py | .py | """Test that setting a toggle button's label has the desired effect."""
from textual.app import App, ComposeResult
from textual.content import Content
from textual.widgets import Checkbox, RadioButton, RadioSet
class LabelChangeApp(App[None]):
def compose(self) -> ComposeResult:
yield Checkbox("Before")
... | 36 | 1,431 |
pyomo | examples/pyomo/concrete/sp_data.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... | 14 | 611 |
clearml | examples/reporting/config_files.py | .py | # ClearML - example code for logging configuration files to Task":
#
import json
from pathlib import Path
import yaml
from clearml import Task
# Connecting ClearML with the current process,
# from here on everything is logged automatically
task = Task.init(project_name='FirstTrial', task_name='config_files_example')... | 37 | 1,084 |
pyomo | pyomo/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 30 | 1,153 |
textual | tests/test_case.py | .py | from textual.case import camel_to_snake
def test_camel_to_snake():
assert camel_to_snake("FooBar") == "foo_bar"
| 6 | 118 |
textual | src/textual/keys.py | .py | from __future__ import annotations
import unicodedata
from enum import Enum
from functools import lru_cache
# Adapted from prompt toolkit https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/prompt_toolkit/keys.py
class Keys(str, Enum): # type: ignore[no-redef]
"""
List of keys for use in key... | 369 | 10,258 |
pyomo | doc/OnlineDocs/src/scripting/parallel.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... | 37 | 1,266 |
saleor | saleor/tests/e2e/product/utils/product_variant_channel_listing.py | .py | from ...utils import get_graphql_content
PRODUCT_CHANNEL_LISTING_UPDATE_MUTATION = """
mutation UpdateProductVariantChannelListing(
$productVariantId: ID!, $input: [ProductVariantChannelListingAddInput!]!
) {
productVariantChannelListingUpdate(id: $productVariantId, input: $input) {
errors {
field
... | 79 | 1,712 |
cvxpy | cvxpy/atoms/sum_squares.py | .py | """
Copyright 2013 Steven Diamond
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | 49 | 1,638 |
astropy | astropy/timeseries/io/tests/test_kepler.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from unittest import mock
import pytest
from astropy.io.fits import BinTableHDU, HDUList, Header, PrimaryHDU
from astropy.timeseries.io.kepler import kepler_fits_reader
from astropy.units import UnitsWarning
from astropy.utils.data import get_pkg_data_f... | 158 | 5,649 |
saleor | saleor/graphql/account/tests/mutations/authentication/test_external_refresh.py | .py | import datetime
import json
from unittest.mock import Mock, patch
from freezegun import freeze_time
from ......plugins.base_plugin import ExternalAccessTokens
from .....tests.utils import get_graphql_content
MUTATION_EXTERNAL_REFRESH = """
mutation externalRefresh($pluginId: String!, $input: JSONString!){
... | 159 | 5,804 |
onnxruntime | onnxruntime/test/python/quantization/test_quant_issues.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import os
... | 217 | 10,084 |
cvxpy | cvxpy/reductions/solvers/qp_solvers/qpalm_qpif.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
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
... | 153 | 5,665 |
onnx | tests/python/backend_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import itertools
import platform
from typing import TYPE_CHECKING, Any
import onnx.backend.base
import onnx.backend.test
import onnx.shape_inference
import onnx.version_converter
from onnx import ModelP... | 121 | 3,985 |
saleor | saleor/tests/e2e/checkout/test_checkout_complete_with_gift_card_recalculcates_status_for_other_checkout.py | .py | import pytest
from ..gift_cards.utils import create_gift_card
from ..product.utils.preparing_product import prepare_product
from ..shop.utils import prepare_shop
from ..utils import assign_permissions
from .utils import (
checkout_add_promo_code,
checkout_complete,
checkout_create,
checkout_delivery_me... | 182 | 5,670 |
mlflow | tests/server/jobs/test_jobs_workspace.py | .py | import json
import uuid
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from mlflow.entities import Workspace
from mlflow.environment_variables import MLFLOW_ENABLE_WORKSPACES
from mlflow.exceptions import MlflowException
from mlflow.genai.scorers.builtin_scorers import Completeness
... | 132 | 5,213 |
mlflow | tests/entities/test_issue.py | .py | import uuid
import pytest
from mlflow.entities.issue import Issue, IssueSeverity, IssueStatus
from mlflow.protos.issues_pb2 import Issue as ProtoIssue
def create_issue(severity: IssueSeverity) -> Issue:
return Issue(
issue_id="iss-" + str(uuid.uuid4()),
experiment_id="exp-123",
name="Hig... | 488 | 18,280 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.