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 |
|---|---|---|---|---|---|
pyomo | pyomo/gdp/__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 | 861 |
readthedocs.org | readthedocs/api/v3/tests/mixins.py | .py | import datetime
import json
from pathlib import Path
import django_dynamic_fixture as fixture
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.core.cache import cache
from django.test import TestCase
from django.test.utils import override_settings
from ... | 264 | 9,117 |
loguru | tests/test_reinstall.py | .py | import multiprocessing
import os
import pytest
from loguru import logger
@pytest.fixture
def fork_context():
return multiprocessing.get_context("fork")
@pytest.fixture
def spawn_context():
return multiprocessing.get_context("spawn")
class Writer:
def __init__(self):
self._output = ""
de... | 107 | 2,332 |
django-cms | cms/context_processors.py | .py | from functools import cache
from django.utils.functional import lazy
from cms.utils.conf import get_cms_setting
from cms.utils.page import get_page_template_from_request
def cms_settings(request):
"""
Adds cms-related variables to the context.
"""
from menus.menu_pool import MenuRenderer
@cache... | 32 | 969 |
mamba | micromamba/tests/helpers.py | .py | import errno
import json
import os
import platform
import random
import re
import shutil
import string
import subprocess
from enum import Enum
from pathlib import Path
import pytest
import yaml
def subprocess_run(*args: str, **kwargs) -> str:
"""Execute a command in a subprocess while properly capturing stderr i... | 733 | 23,265 |
qutip | qutip/tests/solver/test_correlation.py | .py | import pytest
import functools
from itertools import product
import numpy as np
from scipy.integrate import trapezoid
import qutip
pytestmark = [pytest.mark.usefixtures("in_temporary_directory")]
_equivalence_dimension = 15
_equivalence_fock = qutip.fock(_equivalence_dimension, 1)
_equivalence_coherent = qutip.cohere... | 477 | 18,013 |
cvxpy | cvxpy/tests/nlp_tests/stress_tests_diff_engine/test_matmul_sparse.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
... | 210 | 7,889 |
biopython | Bio/Phylo/PAML/yn00.py | .py | # Copyright (C) 2011, 2018 by Brandon Invergo (b.invergo@gmail.com)
#
# 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.
"""Classes fo... | 157 | 6,168 |
metrics | src/torchmetrics/functional/image/d_s.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... | 268 | 11,095 |
wandb | tests/unit_tests/test_lib/test_service_port_file.py | .py | from unittest import mock
import pytest
from wandb.sdk.lib.service import ipc_support, service_port_file, service_token
@pytest.fixture(autouse=True)
def make_sleep_instant(monkeypatch):
test_time = 0
def fake_sleep(seconds: float) -> None:
nonlocal test_time
test_time += seconds
monkey... | 132 | 3,391 |
jupytext | tests/external/cli/test_cli_check.py | .py | import pytest
from nbformat.v4.nbbase import new_code_cell, new_notebook
from jupytext import write
from jupytext.cli import jupytext
@pytest.fixture
def non_black_notebook(python_notebook):
return new_notebook(metadata=python_notebook.metadata, cells=[new_code_cell("1+1")])
@pytest.mark.requires_black
def tes... | 32 | 1,049 |
astropy | astropy/coordinates/builtin_frames/supergalactic_transforms.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from astropy.coordinates.baseframe import frame_transform_graph
from astropy.coordinates.matrix_utilities import matrix_transpose, rotation_matrix
from astropy.coordinates.transformations import StaticMatrixTransform
from .galactic import Galactic
from .... | 23 | 801 |
pyomo | examples/pyomo/amplbook2/steel4.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... | 58 | 1,526 |
mlflow | examples/evaluation/evaluate_with_custom_metrics_comprehensive.py | .py | import numpy as np
import pandas as pd
from matplotlib.figure import Figure
from sklearn.datasets import load_diabetes
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
import mlflow
from mlflow.models import infer_signature, make_metric
# loading the diabetes data... | 85 | 2,642 |
jupytext | demo/Jupytext's word cloud.py | .py | # This is a notebook that I used to generate Jupytext's word cloud.
# To open this script as a notebook in JupyterLab, right-click on this file, and select _Open with/Notebook_.
from wordcloud import WordCloud
text = """
Jupytext
Notebook
JupyterLab
Git
GitHub
Version control
Markdown
R Markdown
Text
Scripts
Code
Not... | 62 | 860 |
onnx | onnx/bin/checker.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import argparse
from onnx import NodeProto, checker, load
def check_model() -> None:
parser = argparse.ArgumentParser("check-model")
parser.add_argument("model_pb", type=argparse.FileType("rb... | 28 | 693 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_DivNoNan.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
from common.utils.tf_utils import mix_array_with_value
rng = np.random.default_rng(23235)
class TestDivNoNan(CommonTFLay... | 50 | 1,955 |
kombu | kombu/resource.py | .py | """Generic resource pool implementation."""
from __future__ import annotations
import os
from contextlib import nullcontext
from queue import Empty, LifoQueue
from . import exceptions
from .utils.compat import register_after_fork
from .utils.functional import lazy
def _after_fork_cleanup_resource(resource):
tr... | 232 | 7,379 |
hatch | src/hatch/env/context.py | .py | from abc import ABC, abstractmethod
from hatch.env.utils import get_verbosity_flag
from hatchling.utils.context import ContextFormatter
class EnvironmentContextFormatterBase(ContextFormatter, ABC):
@abstractmethod
def formatters(self):
return {}
class EnvironmentContextFormatter(EnvironmentContextF... | 85 | 2,798 |
django-cms | cms/wizards/urls.py | .py | from django.urls import re_path
from .views import WizardCreateView
urlpatterns = [
re_path(r"^create/$", WizardCreateView.as_view(), name="cms_wizard_create"),
]
| 8 | 169 |
cvxpy | cvxpy/lin_ops/backends/scipy_backend.py | .py | """
Copyright 2025, 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, sof... | 1,231 | 49,060 |
mlflow | mlflow/store/artifact/uc_volume_artifact_repo.py | .py | import mlflow.utils.databricks_utils
from mlflow.environment_variables import MLFLOW_ENABLE_UC_VOLUME_FUSE_ARTIFACT_REPO
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
from mlflow.store.artifact.databricks_sdk_artifact_repo import DatabricksSdkArtifactRepo... | 82 | 3,629 |
astropy | astropy/utils/tests/test_shapes.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from hypothesis import given
from hypothesis.extra.numpy import basic_indices
from numpy.testing import assert_equal
from astropy.utils.exceptions import AstropyDeprecationWarning
from astropy.utils.shapes import (
Sh... | 99 | 2,966 |
pyomo | pyomo/core/tests/unit/kernel/test_variable.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,072 | 37,430 |
mlflow | tests/genai/scorers/google_adk/test_google_adk.py | .py | from unittest.mock import Mock, patch
import pytest
import mlflow
from mlflow.entities.assessment import Feedback
from mlflow.entities.assessment_source import AssessmentSource, AssessmentSourceType
from mlflow.entities.span import SpanType
from mlflow.genai.judges.utils import CategoricalRating
from mlflow.genai.sco... | 929 | 31,241 |
openvino | src/frontends/tensorflow/tests/test_models/gen_scripts/generate_saved_model_intermediate_output.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import tensorflow as tf
# Create the graph and model
tf.compat.v1.reset_default_graph()
with tf.compat.v1.Session() as sess:
input1 = tf.compat.v1.placeholder(dtype=tf.float32, shape=[2], name='input1')
inp... | 19 | 793 |
ipython | IPython/core/profiledir.py | .py | """An object for managing IPython profile directories."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import os
import errno
from pathlib import Path
from traitlets.config.configurable import LoggingConfigurable
from ..paths import get_ipython_package_dir
from... | 240 | 8,278 |
pyro | tests/integration_tests/test_tracegraph_elbo.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
from unittest import TestCase
import numpy as np
import pytest
import torch
from torch import nn as nn
import pyro
import pyro.distributions as dist
import pyro.optim as optim
from pyro.distributions.testing import... | 633 | 25,003 |
kombu | kombu/transport/base.py | .py | """Base transport interface."""
# flake8: noqa
from __future__ import annotations
import errno
import socket
from typing import TYPE_CHECKING
from amqp.exceptions import RecoverableConnectionError
from kombu.exceptions import ChannelError, ConnectionError
from kombu.message import Message
from kombu.utils.function... | 272 | 7,687 |
probability | spinoffs/fun_mc/fun_mc/smc_test.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... | 1,302 | 40,618 |
kafka | tests/kafkatest/tests/produce_consume_validate.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 ... | 133 | 5,957 |
ipython | tests/test_crashhandler.py | .py | """Tests for IPython.core.crashhandler"""
import sys
from unittest.mock import MagicMock
import pytest
from IPython.core import crashhandler
from IPython.core.crashhandler import CrashHandler, crash_handler_lite
from IPython.core.interactiveshell import InteractiveShell
class FakeApp:
"""Minimal stand-in for a... | 214 | 7,326 |
conda | conda/plugins/virtual_packages/__init__.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from . import archspec, conda, cuda, freebsd, linux, osx, windows
plugins = [archspec, conda, cuda, freebsd, linux, osx, windows]
"""The list of virtual package plugins for easier registration with pluggy."""... | 9 | 321 |
openvino | src/bindings/python/src/openvino/opset14/ops.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Factory functions for ops added to openvino opset14."""
from functools import partial
from typing import Union, Optional
from openvino import Node, Type
from openvino.utils.node_factory import _get_node_facto... | 175 | 7,121 |
textual | tests/listview/test_inherit_listview.py | .py | from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.widgets import Label, ListItem, ListView
class MyListView(ListView):
"""Test child class of a ListView."""
BINDINGS = [Binding(key="s", action="set", description="Set")]
def __init__(self, items: int = 0) -> None... | 61 | 1,993 |
wandb | tests/system_tests/test_core/test_resume.py | .py | import json
from pathlib import Path
import numpy as np
import pytest
import wandb
import wandb.errors
from wandb.sdk.lib import runid
@pytest.mark.parametrize("resume", ("allow", "never"))
def test_resume__no_run__success(user, resume):
_ = user # Create a fake user for the test.
with wandb.init(resume=re... | 306 | 8,891 |
scikit-bio | web/conf.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.
# --------------------------------------------... | 121 | 3,170 |
hatch | tests/helpers/templates/new/licenses_multiple.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from ..licenses import MIT, Apache_2_0
def get_files(**kwargs):
return [
File(Path("LICENSES", "Apache-2.0.txt"), Apache_2_0),
File(
Path("LICENSES", "MIT.txt"),
MIT.replace("<year>", f"{kwargs['year']}-presen... | 138 | 3,982 |
conda | conda/models/records.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Implements the data model for conda packages.
A PackageRecord is the record of a package present in a channel. A PackageCache is the record of a
downloaded and cached package. A PrefixRecord is the record of a package installed into a conda
... | 751 | 25,624 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Bincount.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng()
class TestBincount(CommonTFLayerTest):
def _prepare_input(self, inputs... | 65 | 2,466 |
textual | tests/test_content.py | .py | from __future__ import annotations
import pytest
from rich.text import Text
from textual.color import Color
from textual.content import Content, Span
from textual.style import Style
from textual.visual import RenderOptions
from textual.widget import Widget
def test_blank():
"""Check blank content."""
blank ... | 590 | 17,878 |
ipython | tools/tests/embed/embed_flufl.py | .py | """This tests that future compiler flags are passed to the embedded IPython."""
from __future__ import barry_as_FLUFL
from IPython import embed
embed(banner1='', header='check 1 <> 2 == True')
embed(banner1='', header='check 1 <> 2 cause SyntaxError', compile_flags=0)
| 6 | 269 |
pyomo | pyomo/util/tests/test_config_domains.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... | 98 | 3,614 |
mlflow | mlflow/gateway/app.py | .py | import os
from pathlib import Path
from typing import Any
from fastapi import FastAPI, HTTPException, Request
from fastapi.openapi.docs import get_swagger_ui_html
from fastapi.responses import FileResponse, RedirectResponse
from pydantic import BaseModel, ConfigDict
from slowapi import Limiter, _rate_limit_exceeded_ha... | 487 | 18,533 |
probability | tensorflow_probability/python/mcmc/transformed_kernel.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... | 504 | 20,558 |
mlflow | mlflow/pytest/plugin.py | .py | """Pytest plugin for ``@mlflow.test`` + ``mlflow.genai.evaluate``.
Opt-in: the plugin is intentionally not auto-registered (loading it would make
every pytest run on the machine import mlflow at startup). Enable it by adding
the following to your root ``conftest.py``::
pytest_plugins = ["mlflow.pytest.plugin"]
o... | 79 | 2,654 |
coremltools | coremltools/converters/mil/frontend/torch/ops.py | .py | # Copyright (c) 2020, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import builtins
import math as _math
import numbers
import re
from collections.abc import Iterable
fr... | 9,987 | 359,013 |
hatch | src/hatch/cli/fmt/core.py | .py | from __future__ import annotations
from functools import cached_property
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from hatch.env.plugin.interface import EnvironmentInterface
from hatch.utils.fs import Path
class StaticAnalysisEnvironment:
def __init__(self, env: EnvironmentInterface) -> N... | 929 | 16,044 |
hatch | src/hatch/template/files_feature_cli.py | .py | from hatch.template import File
from hatch.utils.fs import Path
class PackageEntryPoint(File):
TEMPLATE = """\
import sys
if __name__ == "__main__":
from {package_name}.cli import {package_name}
sys.exit({package_name}())
"""
def __init__(
self,
template_config: dict,
plugin... | 44 | 1,092 |
loguru | tests/exceptions/source/modern/notes.py | .py | from loguru import logger
import sys
logger.remove()
logger.add(sys.stderr, format="", diagnose=False, backtrace=False, colorize=False)
logger.add(sys.stderr, format="", diagnose=True, backtrace=True, colorize=True)
with logger.catch():
e = ValueError("invalid value")
e.add_note("Note")
raise e
with l... | 44 | 934 |
mlflow | mlflow/utils/semver_utils.py | .py | from __future__ import annotations
import re
from dataclasses import dataclass
from mlflow.exceptions import MlflowException
# Keep this SemVer-specific implementation instead of ``packaging.Version``:
# MLflow needs SemVer 2.0.0 precedence, while ``packaging.Version`` implements
# PEP 440 and would normalize or rej... | 178 | 6,892 |
tablib | tests/test_tablib_dbfpy_packages_utils.py | .py | #!/usr/bin/env python
"""Tests for tablib._vendor.dbfpy."""
import datetime as dt
import unittest
from tablib._vendor.dbfpy import utils
class UtilsUnzfillTestCase(unittest.TestCase):
"""dbfpy.utils.unzfill test cases."""
def test_unzfill_with_nul(self):
# Arrange
text = b"abc\0xyz"
... | 171 | 4,082 |
django-cms | cms/utils/compat/forms.py | .py | import importlib
from django.apps import apps
from django.conf import settings
# override with custom classes if they exist
if settings.AUTH_USER_MODEL != "auth.User": # pragma: no cover
# UserAdmin class
user_app_name = settings.AUTH_USER_MODEL.split(".")[0]
app = apps.get_app_config(user_app_name).mode... | 43 | 1,504 |
bazel | src/test/py/bazel/bzlmod/repo_contents_cache_test.py | .py | # pylint: disable=g-backslash-continuation
# Copyright 2025 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/LICEN... | 784 | 28,353 |
wandb | wandb/sdk/lib/asyncio_manager.py | .py | """Implements an asyncio thread suitable for internal wandb use."""
from __future__ import annotations
import asyncio
import concurrent.futures
import contextlib
import logging
import os
import threading
from collections.abc import Awaitable, Callable
from typing import TypeVar
from . import asyncio_compat
_T = Typ... | 290 | 10,196 |
clearml | clearml/backend_api/services/v2_20/pipelines.py | .py | """
pipelines service
Provides a management API for pipelines in the system.
"""
from typing import List, Optional, Any
import six
from clearml.backend_api.session import Request, Response, schema_property
class StartPipelineRequest(Request):
"""
Start a pipeline
:param task: ID of the task on which the... | 159 | 4,837 |
onnxruntime | onnxruntime/test/providers/cpu/nn/deform_conv_expected_gen.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Generate expected outputs for DeformConv tests using torchvision.ops.deform_conv2d.
Run with: .venv/bin/python onnxruntime/test/providers/cpu/nn/deform_conv_expected_gen.py
Outputs C++-friendly std::vector<float> initiali... | 181 | 5,890 |
pyomo | pyomo/contrib/solver/tests/unit/test_util.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... | 125 | 5,434 |
clearml | clearml/utilities/distutils_version.py | .py | #
# distutils/version.py
#
# Implements multiple version numbering conventions for the
# Python Module Distribution Utilities.
#
# $Id$
#
"""Provides classes to represent module version numbers (one class for
each style of version numbering). There are currently two such classes
implemented: StrictVersion and LooseVe... | 335 | 12,566 |
mlflow | examples/paddle/train_high_level_api.py | .py | import numpy as np
import paddle
import mlflow.paddle
train_dataset = paddle.text.datasets.UCIHousing(mode="train")
eval_dataset = paddle.text.datasets.UCIHousing(mode="test")
class UCIHousing(paddle.nn.Layer):
def __init__(self):
super().__init__()
self.fc_ = paddle.nn.Linear(13, 1, None)
... | 35 | 965 |
wagtail | wagtail/admin/action_menu.py | .py | """Handles rendering of the list of actions in the footer of the page create/edit views."""
from django.conf import settings
from django.forms import Media
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils import timezone
from django.utils.functional import cached_pr... | 354 | 12,513 |
textual | tests/test_cache.py | .py | from __future__ import annotations, unicode_literals
import pytest
from textual.cache import FIFOCache, LRUCache
def test_lru_cache():
cache = LRUCache(3)
assert str(cache) == "<LRUCache size=0 maxsize=3 hits=0 misses=0>"
# insert some values
cache["foo"] = 1
cache["bar"] = 2
cache["baz"] ... | 288 | 6,698 |
saleor | saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_fulfilled.py | .py | import json
from unittest.mock import patch
import graphene
from django.test import override_settings
from ......core.models import EventDelivery
from ......graphql.webhook.subscription_query import SubscriptionQuery
from ......webhook.event_types import WebhookEventAsyncType
from .....manager import get_plugins_mana... | 231 | 7,005 |
mlflow | mlflow/entities/scorer.py | .py | import json
from functools import cached_property
from mlflow.entities._mlflow_object import _MlflowObject
from mlflow.protos.service_pb2 import Scorer as ProtoScorer
class ScorerVersion(_MlflowObject):
"""
A versioned scorer entity that represents a specific version of a scorer within an MLflow
experime... | 207 | 7,409 |
saleor | saleor/core/notify.py | .py | from collections.abc import Callable
from functools import cache
class NotifyHandler:
"""Helper class for handling payload generation for notify event.
Payload is generated only when required and only once for the instance.
In case when plugins/webhooks don't use notfiy event, payload is not generated.
... | 76 | 2,477 |
openvino | tests/layer_tests/onnx_tests/test_reduce_lp.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
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, onn... | 282 | 11,026 |
mlflow | mlflow/utils/env_pack.py | .py | import shutil
import subprocess
import sys
import tarfile
import tempfile
from contextlib import contextmanager
from dataclasses import dataclass
from pathlib import Path
from typing import Generator, Literal
import yaml
from mlflow.artifacts import download_artifacts
from mlflow.exceptions import MlflowException
fro... | 216 | 7,998 |
clearml | clearml/backend_api/services/v2_13/workers.py | .py | """
workers service
Provides an API for worker machines, allowing workers to report status and get tasks for execution
"""
from typing import List, Optional, Any
import enum
from datetime import datetime
import six
from clearml.backend_api.session import (
Request,
Response,
NonStrictDataModel,
schema_... | 2,444 | 85,380 |
mlflow | tests/langchain/test_langchain_output_parsers.py | .py | import pytest
from langchain_core.messages.base import BaseMessage
from langchain_core.runnables.config import RunnableConfig
from mlflow.langchain.output_parsers import (
ChatAgentOutputParser,
ChatCompletionOutputParser,
ChatCompletionsOutputParser,
StringResponseOutputParser,
)
from mlflow.types.llm... | 121 | 3,939 |
wandb | tests/assets/scripts/train.py | .py | import argparse
import math
import os
import pathlib
import random
import subprocess
import time
import tqdm
import wandb
def main(
project: str = "igena",
sleep: int = 1,
num_steps: int = 10,
eval_rate: int = 4,
):
run = wandb.init(
project=project,
settings=wandb.Settings(
... | 84 | 2,127 |
openvino | tests/layer_tests/onnx_tests/test_ceil.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
pytest.importorskip("openvino.tools.mo", reason="Ticket - 157136")
from common.layer_test_class import check_ir_version
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
from unit_tests.utils.... | 199 | 6,800 |
readthedocs.org | readthedocs/redirects/validators.py | .py | from django.conf import settings
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _
from readthedocs.redirects.constants import CLEAN_URL_TO_HTML_REDIRECT
from readthedocs.redirects.constants import EXACT_REDIRECT
from readthedocs.redirects.constants import HTML_T... | 64 | 2,814 |
probability | tensorflow_probability/python/experimental/bayesopt/acquisition/weighted_power_scalarization_test.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... | 117 | 4,586 |
wandb | tests/system_tests/test_registries/test_registry.py | .py | from __future__ import annotations
from collections.abc import Callable, Generator
from itertools import islice, product
from unittest.mock import patch
import wandb
from pytest import fixture, mark, param, raises
from wandb import Api, Artifact
from wandb._strutils import b64decode_ascii
from wandb.apis.public.regis... | 801 | 28,584 |
saleor | saleor/giftcard/tasks.py | .py | from celery.utils.log import get_task_logger
from django.conf import settings
from django.utils import timezone
from ..celeryconf import app
from ..core.db.connection import allow_writer
from .events import gift_cards_deactivated_event
from .models import GiftCard
from .search import update_gift_cards_search_vector
t... | 40 | 1,301 |
django-cms | cms/test_utils/project/third_urls_for_apphook_tests.py | .py | from django.conf import settings
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
from django.urls import include, re_path
from django.views.i18n import JavaScriptCatalog
from django.views.static import serve
from cms.utils.conf import get_cms_setting
admin.autodiscover()
urlpatterns ... | 24 | 805 |
beam | sdks/python/apache_beam/runners/dask/transform_evaluator.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... | 277 | 9,010 |
hydra | tests/test_errors.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import pickle
from hydra.errors import MissingConfigException
def test_pickle_missing_config_exception() -> None:
exception = MissingConfigException("msg", "filename", ["option1", "option2"])
x = pickle.dumps(exception)
loaded = pickl... | 15 | 530 |
sqlmap | plugins/dbms/frontbase/takeover.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.exception import SqlmapUnsupportedFeatureException
from plugins.generic.takeover import Takeover as GenericTakeover
class Takeover(GenericTakeover):
def osCmd(s... | 29 | 982 |
saleor | saleor/graphql/product/tests/benchmark/test_homepage.py | .py | import pytest
from ....core.enums import ReportingPeriod
from ....tests.utils import get_graphql_content
@pytest.mark.django_db
@pytest.mark.count_queries(autouse=False)
def test_retrieve_product_list(
api_client,
category,
categories_tree,
count_queries,
):
query = """
query ProductsList... | 69 | 1,706 |
saleor | saleor/checkout/tests/fixtures/checkout_line.py | .py | import datetime
import pytest
from django.utils import timezone
from ....plugins.manager import get_plugins_manager
from ....warehouse.models import PreorderReservation, Reservation
from ...fetch import fetch_checkout_info
from ..utils import add_variant_to_checkout
@pytest.fixture
def checkout_line(checkout_with_i... | 115 | 3,213 |
saleor | saleor/graphql/page/mutations/page_update.py | .py | from typing import cast
import graphene
from django.db.models import Exists, OuterRef, QuerySet
from ....attribute import models as attribute_models
from ....core.utils.update_mutation_manager import InstanceTracker
from ....page import models
from ....page.error_codes import PageErrorCode
from ....permission.enums i... | 92 | 3,324 |
wagtail | wagtail/admin/views/pages/bulk_actions/__init__.py | .py | from .delete import DeleteBulkAction
from .move import MoveBulkAction
from .publish import PublishBulkAction
from .unpublish import UnpublishBulkAction
__all__ = [
"DeleteBulkAction",
"MoveBulkAction",
"PublishBulkAction",
"UnpublishBulkAction",
]
| 12 | 265 |
probability | tensorflow_probability/python/distributions/spherical_uniform_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... | 249 | 8,532 |
openvino | tests/layer_tests/pytorch_tests/test_argmax_argmin.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestArgMinArgMax(PytorchLayerTest):
def _prepare_input(self, dtype="float32"):
a = self.random.randn(1, 3, 10, 10, dtype=dtype)
... | 84 | 2,718 |
python-prompt-toolkit | examples/prompts/auto-completion/fuzzy-custom-completer.py | .py | #!/usr/bin/env python
"""
Demonstration of a custom completer wrapped in a `FuzzyCompleter` for fuzzy
matching.
"""
from prompt_toolkit.completion import Completer, Completion, FuzzyCompleter
from prompt_toolkit.shortcuts import CompleteStyle, prompt
colors = [
"red",
"blue",
"green",
"orange",
"p... | 58 | 1,369 |
pyomo | pyomo/contrib/community_detection/tests/test_detection.py | .py | """Community Detection Test File"""
# Structure for this file was adapted from:
# ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms... | 1,485 | 63,472 |
wandb | wandb/integration/fastai/__init__.py | .py | """Hooks that add fast.ai v1 Learners to Weights & Biases through a callback.
Requested logged data can be configured through the callback constructor.
Examples:
WandbCallback can be used when initializing the Learner::
```
from wandb.fastai import WandbCallback
[...]
learn = Learner(... | 248 | 9,372 |
cvxpy | cvxpy/reductions/eliminate_pwl/canonicalizers/maximum_canon.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... | 41 | 1,363 |
astropy | astropy/table/scripts/showtable.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
``showtable-astropy`` is a command-line script based on ``astropy.io`` and
``astropy.table`` for printing ASCII, FITS, HDF5 or VOTable files(s) to the
standard output.
Example usage of ``showtable-astropy``:
1. FITS::
$ showtable-astropy astropy... | 199 | 6,114 |
sqlmap | lib/takeover/xp_cmdshell.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.agent import agent
from lib.core.common import Backend
from lib.core.common import flattenValue
from lib.core.common import getLimitRange
from lib.core.common import... | 303 | 11,852 |
beam | sdks/python/apache_beam/io/gcp/bigquery_biglake_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... | 118 | 4,507 |
onnxruntime | onnxruntime/test/python/onnxruntime_test_python_ep_compatibility.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
import platform
import sys
import tempfile
import unittest
import onnx
from onnxruntime.capi.onnxruntime_pybind11_state import (
OrtCompiledModelCompatibility,
OrtDeviceEpIncompatibilityReason,
get_com... | 188 | 8,330 |
openvino | tests/model_hub_tests/pytorch/test_torchvision_models.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import platform
import pytest
import torch
from torchvision.models import list_models, get_model
from models_hub_common.utils import get_models_list, retry
from torch_utils import TestTorchConvertModel, skip_npu_precommit
d... | 131 | 5,569 |
pyomo | pyomo/scripting/plugins/extras.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... | 142 | 4,137 |
coremltools | coremltools/converters/mil/test_inputs_outputs_shape.py | .py | # Copyright (c) 2021, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import itertools
import os
import tempfile
import numpy as _np
import PIL.Image
import pytest
import c... | 739 | 28,344 |
wagtail | wagtail/documents/tests/test_api_v3/test_listing.py | .py | from django.contrib.auth.models import Group
from django.db import connection
from django.test.utils import CaptureQueriesContext
from django.urls import reverse
from wagtail.models import CollectionViewRestriction
from .base import TestV3DocumentsBase
class TestV3DocumentListing(TestV3DocumentsBase):
def get_r... | 139 | 5,805 |
black | profiling/mix_small.py | .py | config = some.Structure(
globalMap = {
103310322020340: [100000031211103,101042000320420,100100001202021,112320301100420,110101024402203,112001202000203,112101112010031,102130400200010,100401014300441,103000401422033],
110040120003212: [114413100031332,102101001412002,100210000032130,214000110100040... | 103 | 18,306 |
metrics | tests/unittests/segmentation/test_hausdorff_distance.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... | 144 | 6,022 |
beam | sdks/python/apache_beam/examples/cookbook/ordered_window_elements/streaming_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 | 14,699 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.