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 |
|---|---|---|---|---|---|
pymc | tests/test_testing.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... | 119 | 3,679 |
wandb | wandb/sdk/artifacts/_generated/registry_collections.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/artifacts/
from __future__ import annotations
from pydantic import Field
from wandb._pydantic import GQLResult
from .fragments import PageInfoFragment, RegistryCollectionFragment
class RegistryCollections(GQLResult):
organization: RegistryCollecti... | 45 | 1,419 |
wagtail | wagtail/models/i18n.py | .py | import uuid
from django.apps import apps
from django.conf import settings
from django.core import checks
from django.db import migrations, models, transaction
from django.db.models.signals import pre_save
from django.dispatch import receiver
from django.utils import translation
from django.utils.encoding import force_... | 525 | 17,403 |
sphinx | tests/roots/test-ext-autodoc/target/annotated.py | .py | # from __future__ import annotations
import dataclasses
import types
from typing import Annotated
@dataclasses.dataclass(frozen=True)
class FuncValidator:
func: types.FunctionType
@dataclasses.dataclass(frozen=True)
class MaxLen:
max_length: int
whitelisted_words: list[str]
def validate(value: str) -... | 43 | 869 |
mlflow | mlflow/models/evaluation/utils/trace.py | .py | import contextlib
import inspect
import logging
from typing import Any, Callable
from mlflow.ml_package_versions import FLAVOR_TO_MODULE_NAME
from mlflow.utils.autologging_utils import (
AUTOLOGGING_INTEGRATIONS,
autologging_conf_lock,
get_autolog_function,
is_autolog_supported,
)
from mlflow.utils.aut... | 180 | 8,278 |
saleor | saleor/graphql/account/bulk_mutations/__init__.py | .py | from .customer_bulk_delete import CustomerBulkDelete
from .customer_bulk_update import CustomerBulkUpdate
from .staff_bulk_delete import StaffBulkDelete
from .user_bulk_set_active import UserBulkSetActive
__all__ = [
"CustomerBulkDelete",
"CustomerBulkUpdate",
"StaffBulkDelete",
"UserBulkSetActive",
]
| 12 | 320 |
mlflow | mlflow/genai/scorers/validation.py | .py | import importlib
import logging
from collections import defaultdict
from typing import Any, Callable
from mlflow.exceptions import MlflowException
from mlflow.genai.scorers.base import AggregationFunc, Scorer
from mlflow.genai.scorers.builtin_scorers import (
BuiltInScorer,
MissingColumnsException,
get_all... | 204 | 7,694 |
openvino | tests/layer_tests/pytorch_tests/test_scatter.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
class TestScatter(PytorchLayerTest):
def _prepare_input(self, dtype, out=False):
inp = self.random.randn(6,... | 275 | 11,252 |
mlflow | examples/pydanticai/tracing.py | .py | """
This is an example for leveraging MLflow's auto tracing capabilities for Pydantic AI.
Most codes are from https://ai.pydantic.dev/examples/bank-support/.
"""
import mlflow
import mlflow.pydantic_ai
mlflow.set_tracking_uri("http://localhost:5000")
mlflow.set_experiment("Pydantic AI Example")
mlflow.pydantic_ai.aut... | 87 | 2,551 |
saleor | saleor/graphql/utils/__init__.py | .py | import hashlib
import logging
import traceback
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any
from uuid import UUID
import graphene
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db.models import Q, Value
from django.db.models.functions impor... | 329 | 10,530 |
coremltools | coremltools/converters/sklearn/_linear_regression.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 numpy as _np
from coremltools import proto
from ... import SPECIFICATION_VERSION
from ..._deps ... | 83 | 2,367 |
hydra | plugins/hydra_joblib_launcher/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from pathlib import Path
from read_version import read_version
from setuptools import find_namespace_packages, setup
setup(
name="hydra-joblib-launcher",
version=read_version("hydra_plugins/hydra_joblib_launcher", "__init__.... | 36 | 1,316 |
saleor | saleor/graphql/core/dataloaders.py | .py | import threading
from collections import defaultdict
from collections.abc import Iterable
from typing import TypeVar
from promise import Promise
from promise.dataloader import DataLoader as BaseLoader
from ...core.db.connection import allow_writer_in_context
from ...core.telemetry import saleor_attributes, tracer
fro... | 109 | 3,859 |
probability | spinoffs/inference_gym/inference_gym/targets/model.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... | 321 | 11,735 |
hatch | tests/backend/metadata/test_core.py | .py | import pytest
from hatchling.metadata.core import BuildMetadata, CoreMetadata, HatchMetadata, ProjectMetadata
from hatchling.metadata.spec import (
LATEST_METADATA_VERSION,
get_core_metadata_constructors,
project_metadata_from_core_metadata,
)
from hatchling.plugin.manager import PluginManager
from hatchli... | 1,888 | 75,981 |
biopython | Tests/test_PDB_SASA.py | .py | # Copyright 2020 Joao Rodrigues. All rights reserved.
#
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been included as part of this
# package.
"""Unit tests for the Bio.P... | 160 | 5,587 |
onnx | onnx/backend/test/case/node/flexattention.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 import TensorProto, helper
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.defs import AI_ONNX_PREVIEW_DOM... | 584 | 20,278 |
beam | infra/keys/test_service_account.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 t... | 602 | 30,126 |
mlflow | tests/tracing/export/test_mlflow_v3_attachments.py | .py | from unittest.mock import MagicMock, patch
from mlflow.tracing.attachments import Attachment
from mlflow.tracing.constant import SpansLocation, TraceTagKey
from mlflow.tracing.export.mlflow_v3 import MlflowV3SpanExporter
def _make_trace_info_mock():
info = MagicMock()
info.trace_id = "tr-test123"
info.ta... | 126 | 4,421 |
hydra | hydra/core/object_type.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from enum import Enum
class ObjectType(Enum):
NOT_FOUND = 0
CONFIG = 1
GROUP = 2
| 9 | 166 |
metrics | tests/unittests/classification/test_hamming_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... | 534 | 23,167 |
pyro | pyro/distributions/transforms/sylvester.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
import torch.nn as nn
from .. import constraints
from ..torch_transform import TransformModule
from ..util import copy_docs_from
from .householder import Householder
@copy_docs_from(TransformModule)
class Sylvester(... | 175 | 6,317 |
saleor | saleor/graphql/order/tests/mutations/test_order_line_update.py | .py | from decimal import Decimal
from unittest.mock import ANY, patch
import graphene
import pytest
from django.test import override_settings
from .....core.models import EventDelivery
from .....core.prices import quantize_price
from .....core.taxes import zero_money
from .....discount import DiscountType, DiscountValueTy... | 1,489 | 56,091 |
mlflow | tests/claude_code/test_config.py | .py | import json
import pytest
from mlflow.claude_code.config import (
MLFLOW_TRACING_ENABLED,
get_env_var,
get_tracing_status,
load_claude_config,
save_claude_config,
setup_environment_config,
)
@pytest.fixture
def temp_settings_path(tmp_path):
"""Provide a temporary settings.json path for t... | 334 | 11,671 |
coremltools | coremltools/converters/mil/mil/ops/defs/coreml_dialect/__init__.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
from .ops import coreml_update_state
| 7 | 256 |
metrics | src/torchmetrics/classification/eer.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... | 452 | 21,210 |
onnx | onnx/backend/test/case/node/spacetodepth.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 SpaceToDepth(Base):
@staticmethod
def export() -> None:
... | 67 | 1,939 |
sphinx | sphinx/ext/autosectionlabel.py | .py | """Allow reference sections by :ref: role using its title."""
from __future__ import annotations
from types import NoneType
from typing import TYPE_CHECKING, cast
from docutils import nodes
import sphinx
from sphinx.locale import __
from sphinx.util import logging
from sphinx.util.nodes import clean_astext
if TYPE... | 87 | 2,573 |
textual | tests/snapshot_tests/snapshot_apps/richlog_width.py | .py | from textual.app import App, ComposeResult
from textual.events import Resize
from textual.widgets import RichLog
from rich.text import Text
class RichLogWidth(App[None]):
def compose(self) -> ComposeResult:
rich_log = RichLog(min_width=20)
rich_log.display = False
rich_log.write(
... | 34 | 1,120 |
saleor | saleor/graphql/attribute/dataloaders/reference_types.py | .py | from collections import defaultdict
from collections.abc import Iterable
from ....attribute.models import Attribute
from ....page.models import PageType
from ....product.models import ProductType
from ...core.dataloaders import DataLoader
from ...page.dataloaders import PageTypeByIdLoader
from ...product.dataloaders i... | 106 | 4,200 |
openvino | tests/layer_tests/jax_tests/test_transpose.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from jax import lax
from jax import numpy as jnp
from jax_layer_test_class import JaxLayerTest
class TestTranspose(JaxLayerTest):
def _prepare_input(self):
inp = jnp.array(np.random.rand(*s... | 47 | 1,592 |
probability | tensorflow_probability/python/experimental/tangent_spaces/__init__.py | .py | # Copyright 2021 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... | 40 | 2,002 |
scikit-bio | skbio/stats/composition/tests/test_dirmult.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.
# --------------------------------------------... | 505 | 23,818 |
openvino | src/frontends/tensorflow_lite/tests/test_models/gen_scripts/generate_malformed_indices.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# Generate crafted .tflite model files with out-of-bounds tensor/buffer/opcode indices.
# These models test that the TFLite frontend properly validates all FlatBuffer
# vector indices before use, preventing CWE-125 (Out-of-bounds Read).
... | 205 | 8,397 |
openvino | src/bindings/python/src/openvino/opset15/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 opset15."""
from functools import partial
from typing import Literal, Optional
import numpy as np
from openvino import Node, Type
from openvino.opset1 import convert... | 394 | 14,693 |
confluent-kafka-python | tests/integration/conftest.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2020 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 126 | 3,602 |
mlflow | mlflow/store/workspace/abstract_store.py | .py | from __future__ import annotations
import re
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Iterable
from mlflow.entities import Workspace
from mlflow.entities.workspace import TraceArchivalConfig, WorkspaceDeletionMode
from mlflow.exceptions import MlflowException
@datacla... | 181 | 6,732 |
onnx | onnx/reference/ops/op_less_or_equal.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 OpRunBinaryComparison
class LessOrEqual(OpRunBinaryComparison):
def _run(self, a, b):
return (np.less_equal(a, b),)
| 14 | 302 |
pyomo | pyomo/repn/plugins/mps.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... | 790 | 32,948 |
metrics | examples/audio/pesq.py | .py | """
Evaluating Speech Quality with PESQ metric
==============================================
This notebook will guide you through calculating the Perceptual Evaluation of Speech Quality (PESQ) score,
a key metric in assessing how effective noise reduction and enhancement techniques are in improving speech quality.
... | 119 | 4,598 |
lemur | lemur/tests/test_notifications.py | .py | import pytest
from lemur.notifications.views import * # noqa
from .vectors import (
VALID_ADMIN_API_TOKEN,
VALID_ADMIN_HEADER_TOKEN,
VALID_READ_ONLY_HEADER_TOKEN,
VALID_USER_HEADER_TOKEN,
)
def test_notification_input_schema(client, notification_plugin, notification):
from lemur.notifications.... | 205 | 4,945 |
metrics | src/torchmetrics/text/mer.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... | 142 | 5,250 |
wagtail | wagtail/admin/modal_workflow.py | .py | from django.http import JsonResponse
from django.template.loader import render_to_string
def render_modal_workflow(
request, html_template, js_template=None, template_vars=None, json_data=None
):
""" "
Render a response consisting of an HTML chunk and a JS onload chunk
in the format required by the mo... | 29 | 783 |
luigi | test/contrib/scalding_test.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... | 66 | 2,084 |
jupytext | tests/data/notebooks/outputs/ipynb_to_marimo/plotly_graphs.py | .py | import marimo
__generated_with = "0.17.8"
app = marimo.App()
@app.cell(hide_code=True)
def _(mo):
mo.md(r"""
This notebook contains complex outputs, including plotly javascript graphs.
""")
return
@app.cell(hide_code=True)
def _(mo):
mo.md(r"""
# Interactive plots
""")
return
@app... | 58 | 992 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex_test.py | .py | # coding=utf-8
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License");... | 189 | 5,785 |
probability | spinoffs/inference_gym/inference_gym/targets/sparse_logistic_regression_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... | 157 | 5,455 |
astropy | astropy/units/quantity_helper/converters.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Converters for Quantity."""
import threading
import numpy as np
from astropy.units.core import dimensionless_unscaled
from astropy.units.errors import UnitConversionError, UnitsError, UnitTypeError
__all__ = [
"UFUNC_HELPERS",
"UNSUPPORTED_U... | 395 | 15,899 |
onnxruntime | onnxruntime/python/tools/transformers/models/whisper/whisper_decoder.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 ... | 466 | 21,428 |
wagtail | wagtail/search/models.py | .py | from django.db import models
from django.db.models import OneToOneField
from modelsearch.abstract_models import AbstractIndexEntry, AbstractSQLiteFTSIndexEntry
# We import abstract models from the modelsearch app and define concrete implementations here in the
# wagtail.search app. This preserves backwards compatibili... | 47 | 1,699 |
probability | tensorflow_probability/python/layers/weight_norm_test.py | .py | # Copyright 2019 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 326 | 13,444 |
openvino | src/frontends/onnx/tests/tests_python/test_ops_random.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import onnx
from tests.tests_python.utils import run_node
def test_random_uniform():
low = 90.0
high = 100.0
node = onnx.helper.make_node(
"RandomUniform",
inputs... | 54 | 1,173 |
lemur | lemur/plugins/lemur_statsd/lemur_statsd/__init__.py | .py | try:
from importlib.metadata import version
VERSION = version(__name__)
except Exception as e:
VERSION = "Unknown"
| 6 | 127 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_place_test_model.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import paddle
import numpy as np
from save_model import saveModel
import sys
import os
def paddle_rnn_lstm(input_size, hidden_size, layers, direction):
import paddle
paddle.enable_static()
main_program = paddle.static.Progra... | 94 | 4,031 |
mlflow | tests/entities/test_link.py | .py | from mlflow.entities.link import Link
TRACE_ID = "tr-abc123"
SPAN_ID = "aabbccddeeff0011"
def test_link_to_dict():
link = Link(trace_id=TRACE_ID, span_id=SPAN_ID, attributes={"type": "causality"})
assert link.to_dict() == {
"trace_id": TRACE_ID,
"span_id": SPAN_ID,
"attributes": {"typ... | 30 | 851 |
returns | tests/test_maybe/test_maybe_equality.py | .py | from copy import copy, deepcopy
import pytest
from returns.maybe import Nothing, Some, _Nothing # noqa: PLC2701
from returns.primitives.exceptions import ImmutableStateError
def test_equals():
"""Ensures that ``.equals`` method works correctly."""
inner_value = 1
assert Some(inner_value).equals(Some(i... | 102 | 3,017 |
pyomo | pyomo/contrib/pynumero/interfaces/pyomo_grey_box_nlp.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... | 929 | 36,878 |
pyomo | pyomo/contrib/solver/tests/unit/test_solution.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... | 431 | 15,453 |
pyomo | pyomo/opt/base/results.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 35 | 1,209 |
beam | sdks/python/apache_beam/ml/rag/enrichment/milvus_search_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... | 343 | 14,212 |
mlflow | tests/tracing/utils/test_warning.py | .py | import logging
import warnings
import pytest
import mlflow
from mlflow.tracing.utils.warning import suppress_warning
from tests.tracing.helper import skip_when_testing_trace_sdk
def test_suppress_token_detach_warning(caplog):
logger = logging.getLogger("opentelemetry.context")
logger.setLevel(logging.INFO)... | 104 | 3,448 |
pyomo | pyomo/core/plugins/transform/radix_linearization.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... | 292 | 11,622 |
textual | src/textual/_ansi_theme.py | .py | from __future__ import annotations
from rich.terminal_theme import TerminalTheme
def rgb(red: int, green: int, blue: int) -> tuple[int, int, int]:
"""Define an RGB color.
This exists mainly so that a VSCode extension can render the colors inline.
Args:
red: Red component.
green: Green c... | 73 | 1,509 |
pyomo | pyomo/contrib/pynumero/interfaces/tests/test_pyomo_grey_box_nlp.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... | 2,628 | 101,823 |
jupytext | tests/integration/contents_manager/test_contentsmanager.py | .py | import inspect
import os
import re
import shutil
import time
import pytest
from jupyter_server.utils import ensure_async
from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook
from tornado.web import HTTPError
import jupytext
from jupytext.cli import jupytext as jupytext_cli
from jupytext.compa... | 2,058 | 68,078 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_LinSpace.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
class TestLinSpace(CommonTFLayerTest):
def _prepare_input(self, _):
inputs_data = {}
inputs_data['sta... | 49 | 2,088 |
python-prompt-toolkit | src/prompt_toolkit/patch_stdout.py | .py | """
patch_stdout
============
This implements a context manager that ensures that print statements within
it won't destroy the user interface. The context manager will replace
`sys.stdout` by something that draws the output above the current prompt,
rather than overwriting the UI.
Usage::
with patch_stdout(appli... | 302 | 9,646 |
pyro | examples/eight_schools/mcmc.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import argparse
import logging
import data
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.infer import MCMC, NUTS
logging.basicConfig(format="%(message)s", level=logging.INFO)... | 70 | 1,818 |
sqlmap | lib/parse/headers.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import os
from lib.core.common import parseXmlFile
from lib.core.common import singleTimeWarnMessage
from lib.core.data import kb
from lib.core.data import paths
from lib.parse.h... | 42 | 1,738 |
returns | tests/test_io/test_ioresult_container/test_ioresult_bind.py | .py | from returns.io import IOFailure, IOResult, IOSuccess
from returns.result import Failure, Result, Success
def test_bind():
"""Ensures that bind works."""
def factory(inner_value: int) -> IOResult[int, str]:
if inner_value > 0:
return IOSuccess(inner_value * 2)
return IOFailure(str... | 86 | 2,510 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_thresholdedrelu.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 TestKerasThresholdedReLU(CommonTF2LayerTest):
def create_keras_thresholdedrelu_net(self, input_names, input_shapes, input_type,... | 48 | 2,179 |
httpie | httpie/cli/nested_json/__init__.py | .py | """
A library for parsing the HTTPie nested JSON key syntax and constructing the resulting objects.
<https://httpie.io/docs/cli/nested-json>
It has no dependencies.
"""
from .interpret import interpret_nested_json, unwrap_top_level_list_if_needed
from .errors import NestedJSONSyntaxError
from .tokens import EMPTY_ST... | 21 | 497 |
onnxruntime | tools/python/util/test/test_pytorch_export_helpers.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import unittest
import torch
from ..pytorch_export_helpers import infer_input_info
# example usage from <ort root>/tools/python
# python -m unittest util/test/test_pytorch_export_helpers.py
# NOTE: at least on Windows you ... | 43 | 1,520 |
metrics | src/torchmetrics/image/psnrb.py | .py | # Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to i... | 153 | 6,181 |
textual | tests/snapshot_tests/snapshot_apps/border_alpha.py | .py | from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import Label
class BorderAlphaApp(App[None]):
CSS = """
.boxes {
height: 3;
width: 100%;
}
#box0 {
border: heavy green 0%;
}
#box1 {
border: heavy gre... | 41 | 771 |
gunicorn | tests/dirty/test_arbiter_streaming.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for dirty arbiter streaming functionality."""
import asyncio
import struct
from unittest import mock
import pytest
from gunicorn.dirty.protocol import (
DirtyProtocol,
BinaryProtocol,
make_r... | 328 | 11,210 |
sphinx | tests/test_domains/test_domain_c.py | .py | """Tests the C Domain"""
from __future__ import annotations
import itertools
import xml.etree.ElementTree as ET
import zlib
from typing import TYPE_CHECKING
import pytest
from sphinx import addnodes
from sphinx.addnodes import (
desc,
desc_content,
desc_name,
desc_parameter,
desc_parameterlist,
... | 1,423 | 43,714 |
gunicorn | tests/test_dirty_stash.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for dirty stash (shared state) functionality."""
import pytest
from gunicorn.dirty.stash import (
StashClient,
StashTable,
StashError,
StashTableNotFoundError,
StashKeyNotFoundError,
... | 207 | 6,800 |
jupytext | tests/data/notebooks/outputs/ipynb_to_percent/jupyter_again.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %%
c = '''
title: "Quick test"
output:
ioslides_presentation:
widescreen: true
smaller: true
editor_options:
chunk_output_type console
'''
# %%
import yaml
print(yaml.dump(yaml.load(c)))
# ... | 26 | 331 |
django-cms | cms/sitemaps/cms_sitemap.py | .py | from django.contrib.sitemaps import Sitemap
from django.contrib.sites.models import Site
from django.db.models import OuterRef, Q, QuerySet, Subquery
from cms.models import PageContent, PageUrl
from cms.utils.i18n import get_public_languages
def from_iterable(iterables):
"""
Backport of itertools.chain.from_... | 120 | 4,276 |
saleor | saleor/graphql/warehouse/tests/mutations/test_warehouse_shipping_zone_unassign.py | .py | import graphene
MUTATION_UNASSIGN_SHIPPING_ZONE_WAREHOUSE = """
mutation unassignWarehouseShippingZone($id: ID!, $shippingZoneIds: [ID!]!) {
unassignWarehouseShippingZone(id: $id, shippingZoneIds: $shippingZoneIds) {
errors {
field
message
code
}
}
}
"""
def test_shipping_zone_unassign... | 39 | 1,025 |
pdm | src/pdm/cli/actions.py | .py | from __future__ import annotations
import contextlib
import datetime
import hashlib
import inspect
import json
import os
import sys
import textwrap
from collections.abc import Collection, Iterable
from typing import TYPE_CHECKING, cast
from resolvelib.resolvers import ResolutionImpossible, ResolutionTooDeep
from pdm... | 465 | 20,360 |
wagtail | wagtail/project_template/project_name/settings/dev.py | .py | from .base import *
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "{{ secret_key }}"
# SECURITY WARNING: define the correct hosts in production!
ALLOWED_HOSTS = ["*"]
EMAIL_BACKEND = "django.core.mail.ba... | 19 | 410 |
beam | sdks/python/apache_beam/examples/inference/multi_language_inference/multi_language_custom_transform/multi_language_custom_transform/composite_transform.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 ... | 122 | 5,041 |
sqlmap | plugins/dbms/informix/filesystem.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from plugins.generic.filesystem import Filesystem as GenericFilesystem
class Filesystem(GenericFilesystem):
pass
| 12 | 259 |
jupyterlab | scripts/watch_packages.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from jupyterlab.commands import watch_packages
if __name__ == "__main__":
procs = watch_packages()
procs[0].wait()
| 9 | 226 |
pyro | tests/infer/autoguide/test_inference.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
from functools import partial
import numpy as np
import pytest
import torch
from torch.distributions import biject_to, constraints
import pyro
import pyro.distributions as dist
import pyro.optim as optim
from pyro.... | 256 | 8,100 |
pyomo | pyomo/core/base/expression.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 503 | 17,067 |
textual | tests/snapshot_tests/snapshot_apps/bind_override.py | .py | from textual.app import App, ComposeResult
from textual.widget import Widget
from textual.widgets import Footer, Switch
from textual.binding import Binding
class MyWidget(Widget, can_focus=True):
BINDINGS = [
Binding("space", "app.bell", "Bell (Widget)"),
Binding("a", "app.notify('a widget')", "wi... | 42 | 985 |
openvino | src/bindings/python/src/openvino/_op_base.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from typing import Union, Optional
from openvino._pyopenvino import Op as OpBase
from openvino._pyopenvino import Node, Output
class Op(OpBase):
def __init__(
self,
py_obj: "Op",
inp... | 29 | 896 |
conda | conda/misc.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Miscellaneous utility functions."""
from __future__ import annotations
import os
import re
import shutil
from logging import getLogger
from os.path import abspath, dirname, isdir, isfile, join, relpath
from typing import TYPE_CHECKING
from... | 389 | 12,509 |
openvino | tests/layer_tests/pytorch_tests/test_istft.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestISTFT(PytorchLayerTest):
def _prepare_input(self, n_fft, hop_length, win_length, center, normalized, signal_shape, rand_data=False, out_dty... | 247 | 10,059 |
clearml | examples/frameworks/jsonargparse/jsonargparse_command.py | .py | from jsonargparse import CLI
from clearml import Task
class Main:
def __init__(self, prize: int = 100):
self.prize = prize
def person(self, name: str):
return f"{name} won {self.prize}!"
if __name__ == "__main__":
Task.init(
project_name="examples",
task_name="jsonargpar... | 19 | 360 |
pyro | pyro/contrib/mue/models.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
"""
Example MuE observation models.
"""
import datetime
import numpy as np
import torch
import torch.nn as nn
from torch.nn.functional import softplus
from torch.optim import Adam
from torch.utils.data import DataLoader
import pyro
... | 873 | 34,329 |
mlflow | tests/deployments/databricks/test_databricks.py | .py | import os
import warnings
from unittest import mock
import pytest
from mlflow.deployments import get_deploy_client
from mlflow.exceptions import MlflowException
@pytest.fixture(autouse=True)
def mock_databricks_credentials(monkeypatch):
monkeypatch.setenv("DATABRICKS_HOST", "https://test.cloud.databricks.com")
... | 606 | 22,900 |
wagtail | wagtail/tests/actions/test_delete.py | .py | from django.contrib.auth.models import Permission
from django.test import TestCase
from wagtail.actions.delete import DeleteAction, DeletePermissionError
from wagtail.log_actions import registry as log_registry
from wagtail.permission_policies import ModelPermissionPolicy
from wagtail.test.testapp.models import Advert... | 94 | 4,179 |
pymc | pymc/model_graph.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... | 909 | 29,616 |
gunicorn | tests/test_asgi_valid_requests.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Test valid HTTP requests against ASGI callback parser.
Runs the same .http test files as test_valid_requests.py but using
the ASGI PythonProtocol callback parser.
"""
import glob
import os
import pytest
impo... | 53 | 1,728 |
confluent-kafka-python | src/confluent_kafka/_oauthbearer/aws/sasl_extensions_parser.py | .py | # Copyright 2026 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 51 | 1,714 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_StableHLOComposite.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import numpy as np
import pytest
from flatbuffers import flexbuffers
from tensorflow.lite.python import schema_py_generated as schema_fb
from tensorflow.lite.tools import flatbuffer_utils as fb_utils
import openvino as ov
te... | 331 | 13,875 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.