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 |
|---|---|---|---|---|---|
cvxpy | cvxpy/atoms/affine/promote.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... | 121 | 3,484 |
pyomo | pyomo/repn/tests/diffutils.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... | 54 | 1,750 |
ipython | IPython/core/debugger.py | .py | """
Pdb debugger class.
This is an extension to PDB which adds a number of new features.
Note that there is also the `IPython.terminal.debugger` class which provides UI
improvements.
We also strongly recommend to use this via the `ipdb` package, which provides
extra configuration options.
Among other things, this s... | 1,473 | 50,999 |
onnxruntime | onnxruntime/python/tools/transformers/large_model_exporter.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
"""
Export LLM to onnx
"""
import argparse
import inspect
import math
... | 397 | 14,927 |
pdm | tests/models/test_setup_parsing_extra.py | .py | import logging
import textwrap
import pytest
from pdm.exceptions import ProjectError
from pdm.formats import MetaConvertError
from pdm.models.setup import Setup
def test_setup_update_truthiness_semantics():
base = Setup(name="foo", install_requires=["a"], summary=None)
other = Setup(name=None, install_requi... | 419 | 12,846 |
confluent-kafka-python | src/confluent_kafka/aio/producer/_message_batch.py | .py | # Copyright 2025 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... | 71 | 2,654 |
openvino | docs/articles_en/assets/snippets/ov_model_snippets.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
#! [import]
import openvino as ov
#! [import]
import openvino.opset12 as ops
#! [import]
import openvino.passes as passes
# ! [ov:create_simple_model]
def create_simple_model():
# This example shows how to create... | 91 | 2,971 |
pyro | pyro/distributions/spanning_tree.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import itertools
import math
import torch
from torch.distributions import constraints
from torch.distributions.utils import lazy_property
from pyro.distributions.torch_distribution import TorchDistribution
class SpanningTree(To... | 618 | 22,113 |
mlflow | tests/pydantic_ai/test_pydanticai_tracing.py | .py | import importlib.metadata
import sys
import types
from unittest.mock import patch
import pytest
from packaging.version import Version
PYDANTIC_AI_VERSION = Version(importlib.metadata.version("pydantic_ai"))
if PYDANTIC_AI_VERSION.major >= 2:
pytest.skip("Pydantic AI 1.x tracing tests", allow_module_level=True)
f... | 587 | 20,989 |
mlflow | tests/evaluate/test_validation.py | .py | import random
from unittest import mock
import pytest
import mlflow
from mlflow.exceptions import MlflowException
from mlflow.models.evaluation import (
EvaluationResult,
MetricThreshold,
ModelEvaluator,
evaluate,
)
from mlflow.models.evaluation.evaluator_registry import _model_evaluation_registry
fro... | 966 | 37,112 |
mamba | micromamba/tests/test_completer.py | .py | import pytest
from . import helpers
def test_completer_lists_top_level_commands(tmp_home, tmp_root_prefix):
"""Regression: duplicate deactivate must not abort completer (CLI::OptionAlreadyAdded)."""
umamba = helpers.get_umamba()
out = helpers.subprocess_run(umamba, "completer", "").decode()
for comm... | 60 | 1,763 |
luigi | luigi/contrib/gcp.py | .py | """
Common code for GCP (google cloud services) integration
"""
import logging
logger = logging.getLogger("luigi-interface")
try:
import google.auth
import httplib2
except ImportError:
logger.warning(
"Loading GCP module without the python packages httplib2, google-auth. \
This *could* cr... | 43 | 1,410 |
biopython | Bio/SeqIO/GfaIO.py | .py | """Bio.SeqIO support for the Graphical Fragment Assembly format.
This format is output by many assemblers and includes linkage information for
how the different sequences fit together, however, we just care about the
segment (sequence) information.
Documentation:
- Version 1.x: https://gfa-spec.github.io/GFA-spec/GFA... | 216 | 7,221 |
onnx | onnx/backend/test/case/node/shrink.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 Shrink(Base):
@staticmethod
def export_hard_shrink() -> None:
... | 38 | 1,053 |
saleor | saleor/graphql/channel/mutations/channel_create.py | .py | import graphene
from django.conf import settings
from django.utils.text import slugify
from ....channel import models
from ....core.tracing import traced_atomic_transaction
from ....permission.enums import ChannelPermissions
from ....tax.models import TaxConfiguration
from ....webhook.event_types import WebhookEventAs... | 399 | 15,247 |
wagtail | wagtail/admin/auth.py | .py | from functools import wraps
import swapper
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.translation import gettext as _
from wagtail.admin import messages
from wagtail.admin.localization imp... | 155 | 4,813 |
kombu | t/unit/transport/test_etcd.py | .py | from __future__ import annotations
from array import array
from queue import Empty
from unittest.mock import Mock, patch
import pytest
from kombu.transport.etcd import Channel, Transport
pytest.importorskip('etcd')
class test_Etcd:
def setup_method(self):
self.connection = Mock()
self.connect... | 71 | 2,345 |
onnx | onnx/backend/test/case/node/pow.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
def pow(x: np.ndarray, y: np.ndarray) -> np.ndarray: # noqa: A001
retur... | 107 | 3,900 |
textual | docs/examples/guide/reactivity/validate01.py | .py | from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.reactive import reactive
from textual.widgets import Button, RichLog
class ValidateApp(App):
CSS_PATH = "validate01.tcss"
count = reactive(0)
def validate_count(self, count: int) -> int:
"""Validate... | 39 | 999 |
wandb | tests/system_tests/test_functional/test_tensorboard/conftest.py | .py | import pytest
import wandb
@pytest.fixture(autouse=True)
def unpatch_tensorboard():
yield
# Undo any TensorBoard patching after every test in this directory
# to prevent order dependence.
wandb.tensorboard.unpatch()
| 12 | 235 |
clearml | examples/pipeline/pipeline_from_tasks.py | .py | from clearml import Task
from clearml.automation import PipelineController
def pre_execute_callback_example(a_pipeline, a_node, current_param_override):
# type (PipelineController, PipelineController.Node, dict) -> bool
print(
f"Cloning Task id={a_node.base_task_id} with parameters: {current_param_ove... | 70 | 2,221 |
saleor | saleor/graphql/shop/mutations/shop_settings_update.py | .py | import graphene
from django.core.exceptions import ValidationError
from ....core.error_codes import ShopErrorCode
from ....core.jwt import JWT_SALEOR_OWNER_NAME
from ....core.utils.url import validate_storefront_url
from ....permission.enums import SitePermissions
from ....site import PasswordLoginMode
from ....site.m... | 308 | 12,798 |
python-prompt-toolkit | tests/test_print_formatted_text.py | .py | """
Test the `print` function.
"""
from __future__ import annotations
import pytest
from prompt_toolkit import print_formatted_text as pt_print
from prompt_toolkit.formatted_text import HTML, FormattedText, to_formatted_text
from prompt_toolkit.output import ColorDepth
from prompt_toolkit.styles import Style
from pr... | 113 | 3,039 |
biopython | Tests/test_SearchIO_hmmer3_text_index.py | .py | # Copyright 2012 by Wibowo Arindrarto. 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 SearchIO hmmer3-text indexing."""
import unittest
from search_tests_common ... | 340 | 18,801 |
beam | sdks/python/apache_beam/examples/complete/game/user_score_it_test.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 117 | 4,281 |
eve | eve/render.py | .py | # -*- coding: utf-8 -*-
"""
eve.render
~~~~~~~~~~
Implements proper, automated rendering for Eve responses.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
import datetime
import re
import time
from collections import OrderedDict # noqa
from functools im... | 566 | 18,530 |
openvino | tools/ovc/unit_tests/moc_tf_fe/test_models/model_bool.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import tensorflow.compat.v1 as tf
tf.reset_default_graph()
with tf.Session() as sess:
x = tf.placeholder(tf.bool, [2, 3], 'in1')
y = tf.placeholder(tf.bool, [2, 3], 'in2')
tf.math.logical_and(x, y)
tf.global_variables_i... | 16 | 420 |
onnx | onnx/reference/ops/op_constant.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, RefAttrName
def _check_dtype(val):
dtype = val.dtype
if not isinstance(dtype, np.dtype):
raise TypeError(
f"Type... | 120 | 4,332 |
gunicorn | tests/test_invalid_requests.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import glob
import os
import pytest
from gunicorn.http.errors import (
InvalidRequestLine,
InvalidRequestMethod,
InvalidSchemeHeaders,
ObsoleteFolding,
)
import treq
dirname = os.path.dirname(__f... | 69 | 2,317 |
sphinx | tests/roots/test-ext-autodoc/target/bound_method.py | .py | class Cls:
def method(self):
"""Method docstring"""
pass
bound_method = Cls().method
| 8 | 107 |
probability | discussion/adaptive_malt/trial_runner.py | .py | # Copyright 2022 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... | 64 | 1,796 |
readthedocs.org | readthedocs/core/utils/contact.py | .py | import markdown
import structlog
from django.conf import settings
from django.core.mail import send_mail
from django.template import Context
from django.template import Engine
log = structlog.get_logger(__name__)
# TODO: re-implement sending notifications to users.
# This needs more thinking because the notificatio... | 103 | 3,502 |
probability | tensorflow_probability/substrates/__init__.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... | 35 | 1,210 |
pyomo | pyomo/common/tests/config_plugin.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... | 17 | 801 |
pyomo | pyomo/dae/set_utils.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... | 304 | 11,421 |
mlflow | tests/demo/test_review_queues_generator.py | .py | import pytest
import mlflow
from mlflow.demo.base import DEMO_EXPERIMENT_NAME, DemoFeature, DemoResult
from mlflow.demo.generators.review_queues import (
DEMO_DEFAULT_REVIEWER,
DEMO_LABEL_SCHEMAS,
DEMO_REVIEW_QUEUE_NAME,
DEMO_REVIEWERS,
ReviewQueuesDemoGenerator,
)
from mlflow.tracking._tracking_se... | 149 | 4,872 |
cvxpy | cvxpy/reductions/solvers/bisection.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
... | 223 | 8,387 |
mlflow | tests/genai/judges/test_judge_tool_get_span.py | .py | import pytest
from mlflow.entities.span import Span
from mlflow.entities.trace import Trace
from mlflow.entities.trace_data import TraceData
from mlflow.entities.trace_info import TraceInfo
from mlflow.entities.trace_location import TraceLocation
from mlflow.entities.trace_state import TraceState
from mlflow.genai.jud... | 234 | 6,967 |
textual | tests/test_duration.py | .py | import pytest
from textual._duration import DurationParseError, _duration_as_seconds
def test_parse() -> None:
assert _duration_as_seconds("30") == 30.0
assert _duration_as_seconds("30s") == 30.0
assert _duration_as_seconds("30000ms") == 30.0
assert _duration_as_seconds("0.5") == 0.5
assert _dura... | 16 | 481 |
saleor | saleor/graphql/checkout/tests/test_checkout_filters.py | .py | import datetime
import uuid
from decimal import Decimal
import graphene
import pytest
from django.core.exceptions import ValidationError
from freezegun import freeze_time
from prices import Money
from ....account.models import User
from ....checkout.models import Checkout
from ....checkout.payment_utils import update... | 1,040 | 29,291 |
textual | tests/snapshot_tests/snapshot_apps/listview_index.py | .py | from textual.app import App, ComposeResult
from textual.reactive import reactive
from textual.widgets import Label, ListItem, ListView
class ListViewIndexApp(App):
CSS = """
ListView {
height: 10;
}
"""
data = reactive(list(range(6)))
def __init__(self) -> None:
super().__ini... | 36 | 831 |
beam | sdks/python/apache_beam/io/gcp/bigquery_tools.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 1,925 | 67,765 |
astropy | astropy/time/setup_package.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# Copied from astropy/convolution/setup_package.py
import os
from numpy import get_include as get_numpy_include
from setuptools import Extension
C_TIME_PKGDIR = os.path.relpath(os.path.dirname(__file__))
SRC_FILES = [
os.path.join(C_TIME_PKGDIR, f... | 28 | 703 |
wandb | wandb/_pydantic/__init__.py | .py | """Internal utilities for working with pydantic."""
__all__ = [
"CompatBaseModel",
"JsonableModel",
"GQLBase",
"GQLInput",
"GQLResult",
"Connection",
"ConnectionWithTotal",
"Edge",
"FilterDict",
"PageInfo",
"OrderValidator",
"PaginatorVars",
"Typename",
"GQLId",
... | 58 | 1,109 |
funcy | tests/test_types.py | .py | from funcy.types import *
def test_iterable():
assert iterable([])
assert iterable({})
assert iterable('abc')
assert iterable(iter([]))
assert iterable(x for x in range(10))
assert iterable(range(10))
assert not iterable(1)
def test_is_iter():
assert is_iter(iter([]))
assert is_... | 21 | 409 |
pyomo | pyomo/contrib/community_detection/detection.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... | 862 | 41,405 |
pyomo | pyomo/solvers/tests/models/LP_constant_objective1.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... | 53 | 1,844 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_SparseTensorDenseMatMul.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import platform
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng(475912)
class TestSparseTensorDenseMatMul(CommonTFLayerTest):
def _prepa... | 97 | 4,052 |
conda | conda/cli/condarc.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Configuration file manipulation utilities for conda.
This module provides classes and functions for working with conda configuration
files (.condarc), including reading, writing, and validating configuration keys.
"""
from __future__ impor... | 691 | 22,600 |
hatch | src/hatch/env/internal/static_analysis.py | .py | from __future__ import annotations
from typing import Any
def get_default_config() -> dict[str, Any]:
return {
"skip-install": True,
"installer": "uv",
"dependencies": [f"ruff=={RUFF_DEFAULT_VERSION}"],
"scripts": {
"format-check": "ruff format{env:HATCH_FMT_ARGS:}{env... | 45 | 1,484 |
pyro | pyro/infer/reparam/conjugate.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from .reparam import Reparam
class ConjugateReparam(Reparam):
"""
EXPERIMENTAL Reparameterize to a conjugate updated distribution.
This update... | 109 | 4,315 |
readthedocs.org | readthedocs/payments/mixins.py | .py | """Payment view mixin classes."""
from djstripe.enums import APIKeyType
from djstripe.models import APIKey
class StripeMixin:
"""Adds Stripe publishable key to the context data."""
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["stripe_publishable"... | 16 | 437 |
mlflow | tests/genai/conftest.py | .py | import functools
import os
from unittest import mock
import pytest
import mlflow
import mlflow.telemetry.utils
from mlflow.entities.assessment import Expectation
from mlflow.entities.document import Document
from mlflow.entities.span import SpanType
from mlflow.genai.scorers.validation import IS_DBX_AGENTS_INSTALLED
... | 116 | 3,732 |
onnx | onnx/backend/test/case/node/reversesequence.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 ReverseSequence(Base):
@staticmethod
def export_reversesequenc... | 87 | 2,240 |
mlflow | tests/utils/test_promptlab_utils.py | .py | import json
import os
import pytest
from mlflow.entities.param import Param
from mlflow.entities.run_status import RunStatus
from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository
from mlflow.tracking._tracking_service.utils import _get_store
from mlflow.utils.promptlab_utils import (
... | 104 | 3,581 |
pyomo | pyomo/contrib/doe/examples/update_suffix_doe_example.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 73 | 2,657 |
pyomo | pyomo/contrib/appsi/solvers/highs.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... | 834 | 31,337 |
beam | sdks/python/apache_beam/runners/worker/worker_status_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... | 238 | 9,709 |
mlflow | mlflow/server/fastapi_security.py | .py | import logging
from http import HTTPStatus
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from starlette.types import ASGIApp
from mlflow.environment_variables import (
MLFLOW_SERVER_DISABLE_SECURITY_MIDDLEWARE,
MLFLOW_SERVER_X_FRAME_OPTIONS,
)
from mlflow.server.security_utils... | 202 | 7,301 |
astropy | astropy/io/ascii/tests/test_html.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module tests some of the methods related to the ``HTML``
reader/writer and aims to document its functionality.
Requires `BeautifulSoup <http://www.crummy.com/software/BeautifulSoup/>`_
to be installed.
"""
import os
from io import StringIO
from... | 840 | 23,882 |
saleor | saleor/graphql/order/tests/queries/test_draft_order_with_sort.py | .py | import pytest
from freezegun import freeze_time
from prices import Money, TaxedMoney
from .....order import OrderStatus
from .....order.models import Order
from ....tests.utils import get_graphql_content
QUERY_DRAFT_ORDER_WITH_SORT = """
query ($sort_by: OrderSortingInput!) {
draftOrders(first:5, sortBy: ... | 87 | 2,793 |
python-prompt-toolkit | examples/progress-bar/a-lot-of-parallel-tasks.py | .py | #!/usr/bin/env python
"""
More complex demonstration of what's possible with the progress bar.
"""
import random
import threading
import time
from prompt_toolkit import HTML
from prompt_toolkit.shortcuts import ProgressBar
def main():
with ProgressBar(
title=HTML("<b>Example of many parallel tasks.</b>"... | 67 | 1,902 |
coremltools | coremltools/converters/mil/mil/ops/defs/iOS16/scatter_gather.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 Operation, types
from coremltools.converters.mil.mil.input... | 216 | 7,219 |
onnxruntime | onnxruntime/test/python/transformers/conformer_model_generator.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... | 964 | 42,653 |
python-prompt-toolkit | src/prompt_toolkit/contrib/telnet/log.py | .py | """
Python logger for the telnet server.
"""
from __future__ import annotations
import logging
logger = logging.getLogger(__package__)
__all__ = [
"logger",
]
| 14 | 167 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_index_select.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# index_select paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle
import sys
data_type = "float32"
def index_select(name: str, x, index, axis):
paddle.enable_static()
with paddle.stat... | 60 | 1,659 |
pyro | tests/infer/mcmc/test_nuts.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import os
from collections import namedtuple
import pytest
import torch
import pyro
import pyro.distributions as dist
import pyro.optim as optim
import pyro.poutine as poutine
from pyro.contrib.conjugate.infer impo... | 566 | 20,409 |
astropy | astropy/io/fits/hdu/groups.py | .py | # Licensed under a 3-clause BSD style license - see PYFITS.rst
import math
import sys
import numpy as np
from astropy.io.fits.column import FITS2NUMPY, ColDefs, Column
from astropy.io.fits.fitsrec import FITS_rec, FITS_record
from astropy.io.fits.util import _is_int, _is_pseudo_integer, _pseudo_zero
from astropy.uti... | 621 | 21,191 |
mlflow | mlflow/store/_unity_catalog/registry/uc_oss_rest_store.py | .py | import functools
import os
import shutil
from contextlib import contextmanager
import mlflow
from mlflow.exceptions import MlflowException
from mlflow.protos.unity_catalog_messages_pb2 import (
READ_WRITE_MODEL_VERSION,
CreateModelVersion,
CreateRegisteredModel,
DeleteModelVersion,
DeleteRegistered... | 505 | 20,110 |
astropy | astropy/coordinates/tests/test_angle_generators.py | .py | """Unit tests for the :mod:`astropy.coordinates.angles.utils` module."""
import pytest
import astropy.units as u
from astropy.coordinates import (
golden_spiral_grid,
uniform_spherical_random_surface,
uniform_spherical_random_volume,
)
from astropy.utils import NumpyRNGContext
def test_golden_spiral_gri... | 38 | 1,086 |
clearml | examples/frameworks/fire/fire_object_cmd.py | .py | # ClearML - Example of Python Fire integration, with commands derived from an object
#
from clearml import Task
import fire
class Calculator:
def add(self, x, y):
return x + y
def multiply(self, x, y):
return x * y
if __name__ == "__main__":
Task.init(project_name="examples", task_name... | 20 | 400 |
kafka | tests/kafkatest/services/security/security_config.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 ... | 434 | 21,477 |
readthedocs.org | readthedocs/proxito/tests/handler_404_urls.py | .py | """
This URL file is to be used in tests to emulate NGINX 404 internal redirects.
Instead of using ``fast_404`` to just return a 404, we use ``ServeError404`` and
force passing ``request.full_path()`` as ``proxito_path`` argument to the view.
``proxito_path`` is everything coming after ``_proxito_404_`` in the URL
ge... | 41 | 1,387 |
textual | tests/snapshot_tests/snapshot_apps/focus_component_class.py | .py | from rich.text import Text
from textual.app import App, ComposeResult, RenderResult
from textual.containers import VerticalScroll
from textual.widgets import Header, Footer
from textual.widget import Widget
class Tester(Widget, can_focus=True):
COMPONENT_CLASSES = {"tester--text"}
DEFAULT_CSS = """
Test... | 43 | 944 |
mlflow | mlflow/evaluation/evaluation.py | .py | """
THE 'mlflow.evaluation` MODULE IS LEGACY AND WILL BE REMOVED IN MLFLOW 3.0.
For assessment functionality, use `mlflow.entities.assessment` for assessment classes and
`mlflow.tracing.assessments` for assessment APIs. There are no alternatives for Evaluation and
EvaluationEntity objects and related APIs.
"""
import ... | 412 | 14,499 |
pyomo | examples/pyomo/amplbook2/econmin.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... | 56 | 1,418 |
conda | tests/gateways/disk/test_link.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import os
from os.path import exists, isfile, join, lexists
from pathlib import Path
import pytest
from conda.common.compat import on_win
from conda.gateways.disk.link import islink, link, readlink, symlink
from conda.gateways.disk.test import... | 69 | 2,304 |
mlflow | tests/entities/test_run_inputs.py | .py | from mlflow.entities import RunInputs
from mlflow.entities.dataset_input import DatasetInput
def _check_inputs(run_datasets, datasets):
for d1, d2 in zip(run_datasets, datasets):
assert d1.dataset.digest == d2.dataset.digest
assert d1.dataset.name == d2.dataset.name
assert d1.dataset.sourc... | 45 | 1,451 |
lemur | lemur/tests/test_defaults.py | .py | from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from .vectors import SAN_CERT, WILDCARD_CERT, INTERMEDIATE_CERT
def test_cert_get_cn(client):
from lemur.common.defaults import common_name
assert common_name(SAN_CERT) ==... | 185 | 5,509 |
openvino | tests/layer_tests/pytorch_tests/test_tensor_split.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from collections.abc import Collection
from numbers import Number
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestTensorSplit(PytorchLayerTest):
def _prepare_input(self):
return (... | 67 | 2,223 |
saleor | saleor/core/sqs.py | .py | import uuid
from datetime import datetime
from typing import Any
from django.utils import timezone
from kombu.asynchronous.aws.sqs.message import AsyncMessage
from kombu.transport.SQS import Channel as SqsChannel
from kombu.transport.SQS import Transport as SqsTransport
from kombu.utils.json import dumps
class Chann... | 67 | 2,590 |
pyomo | examples/pyomobook/intro-ch/mydata.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... | 15 | 652 |
astropy | astropy/modeling/tests/test_models_quantities.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# pylint: disable=invalid-name, no-member
import numpy as np
import pytest
from astropy import units as u
from astropy.modeling.bounding_box import ModelBoundingBox
from astropy.modeling.core import fix_inputs
from astropy.modeling.fitting import (
D... | 1,171 | 35,032 |
scikit-optimize | examples/sampler/initial-sampling-method-integer.py | .py | """
===================================================
Comparing initial sampling methods on integer space
===================================================
Holger Nahrstaedt 2020 Sigurd Carlsen October 2019
.. currentmodule:: skopt
When doing baysian optimization we often want to reserve some of the
early part o... | 179 | 6,096 |
mlflow | tests/server/auth/test_dataset_authorization.py | .py | # Unit tests for the evaluation-dataset authorization validators and route routing.
from types import SimpleNamespace
import flask
import mlflow.server.auth as a
class _Req:
def __init__(self, path, method):
self.path = path
self.method = method
def _perm(read=False, update=False, delete=Fals... | 96 | 3,805 |
marshmallow | tests/mypy_test_cases/test_schema.py | .py | import json
from marshmallow import EXCLUDE, Schema
from marshmallow.fields import Integer, String
# Test that valid `Meta` class attributes pass type checking
class MySchema(Schema):
foo = String()
bar = Integer()
class Meta(Schema.Meta):
fields = ("foo", "bar")
additional = ("baz", "qu... | 30 | 748 |
saleor | saleor/plugins/user_email/plugin.py | .py | import logging
from collections.abc import Callable
from dataclasses import asdict
from typing import TYPE_CHECKING
from django.conf import settings
from promise.promise import Promise
from ...core.notify import NotifyEventType, UserNotifyEvent
from ...graphql.plugins.dataloaders import EmailTemplatesByPluginConfigur... | 488 | 19,466 |
astropy | astropy/visualization/tests/test_basic_rgb.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
import sys
import tempfile
import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.utils.compat.optional_deps import HAS_MATPLOTLIB, HAS_PLT
from astropy.visualization import basic_rgb
from astropy.visualization... | 377 | 11,760 |
mlflow | mlflow/gateway/providers/gemini.py | .py | import hashlib
import json
import time
from typing import Any, AsyncIterable
from mlflow.gateway.config import EndpointConfig, GeminiConfig
from mlflow.gateway.exceptions import AIGatewayException
from mlflow.gateway.providers.base import (
BaseProvider,
PassthroughAction,
ProviderAdapter,
_client_prov... | 981 | 35,829 |
jupyterlab | jupyterlab/handlers/build_handler.py | .py | """Tornado handlers for frontend config storage."""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import json
import logging
from asyncio import Future
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor
from threading import Ev... | 199 | 6,353 |
hatch | src/hatch/cli/env/find.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="Locate environments")
@click.argument("env_name", default="default")
@click.pass_obj
def find(app: Application, env_name: str):
"""Loca... | 25 | 681 |
saleor | saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_fixed_voucher_should_not_result_in_negative_variant_price.py | .py | import pytest
from ....product.utils.preparing_product import prepare_product
from ....shop.utils import prepare_default_shop
from ....utils import assign_permissions
from ....vouchers.utils import create_voucher, create_voucher_channel_listing
from ...utils import (
checkout_add_promo_code,
checkout_complete,... | 167 | 5,146 |
probability | tensorflow_probability/python/optimizer/variational_sgd_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... | 348 | 15,016 |
onnx | onnx/reference/ops/op_space_to_depth.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
class SpaceToDepth(OpRun):
def _run(self, data, blocksize=None):
if len(data.shape) != 4:
raise RuntimeError(f"Unexpe... | 34 | 883 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/sum_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");... | 63 | 1,885 |
pyomo | doc/OnlineDocs/src/data/table3.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... | 24 | 836 |
mlflow | mlflow/store/db_migrations/versions/b7c8d9e0f1a2_add_trace_metrics_table.py | .py | """add trace metrics table
Create Date: 2025-12-04 12:00:00.000000
"""
import sqlalchemy as sa
from alembic import op
from mlflow.store.tracking.dbmodels.models import SqlTraceMetrics
# revision identifiers, used by Alembic.
revision = "b7c8d9e0f1a2"
down_revision = "1bd49d398cd23"
branch_labels = None
depends_on ... | 45 | 1,248 |
openvino | src/plugins/intel_gpu/src/graph/common_utils/kernels_db_gen.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import argparse
import glob
import ntpath
import re
def detect_guard_patterns(content):
# Detect include guard macros (#ifndef X paired with bodyless #define X for the
# same name) to avoid adding #undef for them. With... | 286 | 12,385 |
astropy | astropy/io/fits/tests/test_logical_helpers.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_array_equal
from astropy.io.fits._logical_helpers import (
_detect_legacy_logical_vla_heap,
_logical_to_fits_bytes,
_logical_vla_heap_has_null,
_validate_logical_input,
)
f... | 143 | 5,121 |
django-cms | cms/test_utils/project/app_using_non_feature/cms_config.py | .py | from cms.app_base import CMSAppConfig
class NonFeatureCMSConfig(CMSAppConfig):
# Attempting to use features from a cms app that doesn't define a
# configure_app method
app_with_feature_not_implemented_enabled = True
| 8 | 230 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.