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/contrib/interior_point/linalg/scipy_interface.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 | 2,146 |
sqlmap | plugins/dbms/hana/fingerprint.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.common import Backend
from lib.core.common import Format
from lib.core.data import conf
from lib.core.data import kb
from lib.core.data import logger
from lib.core.e... | 95 | 2,574 |
conda | tests/cli/test_main_info.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import json
import re
from collections.abc import Iterable
from os.path import isdir
from pathlib import Path
from types import SimpleNamespace
from typing import TYPE_CHECKING
import pytest
from conda.base... | 368 | 10,806 |
django-cms | cms/admin/permissionadmin.py | .py | from copy import deepcopy
from django.contrib import admin
from django.contrib.admin import site
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin
from django.contrib.sites.models import Site
from django.db import OperationalError, ProgrammingError
from django.utils.transla... | 185 | 6,956 |
django-cms | cms/utils/permissions.py | .py | from collections import defaultdict
from contextlib import contextmanager
from contextvars import ContextVar
from functools import lru_cache, wraps
from django.contrib.auth import get_permission_codename, get_user_model
from django.contrib.auth.models import Group
from django.db.models import Q
from cms.constants imp... | 383 | 12,201 |
biopython | Bio/SearchIO/FastaIO.py | .py | # Adapted from Bio.AlignIO.FastaIO copyright 2008-2011 by Peter Cock.
# Copyright 2012 by Wibowo Arindrarto.
# 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 shoul... | 603 | 25,993 |
mlflow | mlflow/sentence_transformers/__init__.py | .py | import json
import logging
import pathlib
import re
from typing import Any
import numpy as np
import pandas as pd
import yaml
from packaging.version import Version
import mlflow
from mlflow import pyfunc
from mlflow.entities.model_registry.prompt import Prompt
from mlflow.exceptions import MlflowException
from mlflow... | 566 | 22,418 |
openvino | tests/layer_tests/pytorch_tests/test_grid_sampler.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 TestGridSampler(PytorchLayerTest):
def _prepare_input(self, h_in, w_in, h_out, w_out):
return (self.random.randn(1, 3, h_in, w_in)... | 46 | 1,944 |
sphinx | sphinx/util/requests.py | .py | """Simple requests package loader"""
from __future__ import annotations
import warnings
from typing import TYPE_CHECKING
from urllib.parse import urljoin, urlsplit
import requests
from urllib3.exceptions import InsecureRequestWarning
import sphinx
if TYPE_CHECKING:
import re
from collections.abc import Seq... | 112 | 3,655 |
beam | sdks/python/apache_beam/coders/coders_test_common.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,115 | 40,468 |
astropy | astropy/cosmology/_src/io/builtin/mrt.py | .py | r"""|Cosmology| <-> MRT I/O, using |Cosmology.read| and |Cosmology.write|.
We assume the following setup:
>>> from pathlib import Path
>>> from tempfile import TemporaryDirectory
>>> temp_dir = TemporaryDirectory()
Writing a cosmology to a mrt file will produce a table with the cosmology's type,
name, an... | 325 | 12,789 |
sphinx | tests/roots/test-ext-autodoc/target/preserve_defaults.py | .py | from __future__ import annotations
from datetime import datetime
from typing import Any # NoQA: TC003
CONSTANT = 'foo'
SENTINEL = object()
def foo(
name: str = CONSTANT,
sentinel: Any = SENTINEL,
now: datetime = datetime.now(), # NoQA: B008,DTZ005
color: int = 0xFFFFFF,
*,
kwarg1,
kwar... | 79 | 1,701 |
coremltools | coremltools/converters/mil/frontend/tensorflow/ssa_passes/expand_tf_lstm.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 numpy as np
from coremltools import _logger as logger
from coremltools.converters.mil.mil imp... | 225 | 7,187 |
textual | tests/snapshot_tests/snapshot_apps/scroll_to.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Checkbox, Footer
class ScrollOffByOne(App):
"""Scroll to item 50."""
AUTO_FOCUS = None
def compose(self) -> ComposeResult:
for number in range(1, 100):
yield Checkbox(str(number), id=f"number-{number}")
yi... | 22 | 486 |
sphinx | sphinx/builders/singlehtml.py | .py | """Single HTML builders."""
from __future__ import annotations
import warnings
from typing import TYPE_CHECKING
from docutils import nodes
from sphinx._cli.util.colour import darkgreen
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.deprecation import RemovedInSphinx10Warning
from sphinx.environm... | 224 | 8,250 |
saleor | saleor/graphql/account/mutations/staff/__init__.py | .py | from .address_create import AddressCreate
from .address_delete import AddressDelete
from .address_set_default import AddressSetDefault
from .address_update import AddressUpdate
from .customer_create import CustomerCreate
from .customer_delete import CustomerDelete
from .customer_update import CustomerUpdate
from .staff... | 28 | 795 |
probability | tensorflow_probability/python/stats/kendalls_tau_test.py | .py | # Copyright 2020 The TensorFlow Probability Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless require... | 76 | 2,825 |
saleor | saleor/graphql/order/mutations/order_note_common.py | .py | import graphene
from django.core.exceptions import ValidationError
from ....order.error_codes import OrderNoteAddErrorCode
from ...core.doc_category import DOC_CATEGORY_ORDERS
from ...core.mutations import BaseMutation
from ...core.types import BaseInputObjectType
from ...core.validators import validate_required_strin... | 43 | 1,272 |
mlflow | tests/conftest.py | .py | import cProfile
import inspect
import io
import json
import logging
import os
import posixpath
import pstats
import re
import shutil
import sqlite3
import subprocess
import sys
import tempfile
import threading
import time
import uuid
from collections import defaultdict
from contextlib import nullcontext
from dataclasse... | 1,405 | 50,338 |
coremltools | deps/pybind11/tests/test_unnamed_namespace_a.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import unnamed_namespace_a as m
from pybind11_tests import unnamed_namespace_b as mb
XFAIL_CONDITION = (
"(m.PYBIND11_INTERNALS_VERSION <= 4 and (m.defined___clang__ or not m.defined___GLIBCXX__))"
" or "
"(m.PYBIND11_INTERNALS_VERSION ... | 37 | 1,177 |
beam | sdks/python/apache_beam/typehints/testing/__init__.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 19 | 836 |
mlflow | mlflow/gateway/providers/mistral.py | .py | import json
import time
from collections.abc import AsyncIterable
from typing import Any
from mlflow.gateway.config import EndpointConfig, MistralConfig
from mlflow.gateway.providers.base import BaseProvider, ProviderAdapter
from mlflow.gateway.providers.utils import send_request, send_stream_request
from mlflow.gatew... | 299 | 10,553 |
mlflow | mlflow/gateway/schemas/embeddings.py | .py | from pydantic import ConfigDict
from mlflow.gateway.base_models import RequestModel, ResponseModel
_REQUEST_PAYLOAD_EXTRA_SCHEMA = {
"example": {
"input": ["hello", "world"],
}
}
class RequestPayload(RequestModel):
input: str | list[str] | list[int] | list[list[int]]
model_config = ConfigDi... | 89 | 2,199 |
mlflow | dev/clint/tests/rules/test_multi_assign.py | .py | from pathlib import Path
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import Position, Range, lint_file
from clint.rules import MultiAssign
def test_multi_assign(index: SymbolIndex) -> None:
code = """
# Bad - non-constant values
x, y = func1(), func2()
# Good - unpackin... | 27 | 696 |
confluent-kafka-python | tests/integration/cluster_fixture.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... | 497 | 16,587 |
beam | sdks/python/apache_beam/examples/inference/sklearn_mnist_classification.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... | 139 | 5,031 |
openvino | src/bindings/python/src/openvino/op/__init__.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""
Package: openvino.op
Low level wrappers for the c++ api in ov::op.
"""
# flake8: noqa
from openvino._pyopenvino.op import Constant
from openvino._pyopenvino.op import assign
from openvino._pyopenvino.op import _PagedAttentionExtens... | 21 | 661 |
mlflow | tests/genai/judges/utils/test_prompt_utils.py | .py | import pytest
from mlflow.genai.judges.base import Judge
from mlflow.genai.judges.utils.prompt_utils import add_output_format_instructions
from mlflow.genai.prompts.utils import format_prompt
def test_add_output_format_instructions():
output_fields = Judge.get_output_fields()
simple_prompt = "Evaluate this ... | 63 | 2,226 |
pyomo | pyomo/contrib/gdpopt/algorithm_base_class.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... | 529 | 20,520 |
kombu | t/unit/transport/test_filesystem.py | .py | from __future__ import annotations
import contextlib
import shutil
import tempfile
from queue import Empty
from typing import Generator
from unittest.mock import call, patch
import pytest
import t.skip
from kombu import Connection, Consumer, Exchange, Producer, Queue
from kombu.transport.virtual import Channel
cla... | 363 | 13,408 |
saleor | saleor/schedulers/customschedule.py | .py | from celery import schedules
class CustomSchedule(schedules.BaseSchedule):
def __init__(
self,
import_path: str,
schedule: schedules.BaseSchedule,
nowfun=None,
app=None,
):
super().__init__(nowfun=nowfun, app=app)
self.schedule = schedule
self.im... | 23 | 618 |
metrics | src/torchmetrics/__about__.py | .py | __version__ = "1.9.0"
__author__ = "Lightning-AI et al."
__author_email__ = "name@pytorchlightning.ai"
__license__ = "Apache-2.0"
__copyright__ = f"Copyright (c) 2020-2024, {__author__}."
__homepage__ = "https://github.com/Lightning-AI/torchmetrics"
__docs__ = "PyTorch native Metrics"
__docs_url__ = "https://lightning.... | 29 | 1,239 |
probability | tensorflow_probability/python/experimental/sts_gibbs/spike_and_slab_test.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... | 379 | 16,391 |
pyomo | pyomo/contrib/appsi/base.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,721 | 63,570 |
probability | tensorflow_probability/python/bijectors/scale.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... | 154 | 4,619 |
onnxruntime | onnxruntime/test/testdata/transform/transform_nested_ifs_toplogical_sorted_nodes.py | .py | import google.protobuf.text_format
import onnx
from numpy import array, float16
import onnxruntime as ort
# Run n times
N = 1
onnx_model_text = """
ir_version: 8
producer_name: "pytorch"
producer_version: "2.2.0"
graph {
node {
output: "_val_1"
name: "Constant_0"
op_type: "Constant"
attribute {
... | 860 | 21,546 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_gpt_attention_megatron.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
import numpy as np
from fusion_gpt_attent... | 356 | 13,284 |
scikit-optimize | skopt/learning/gaussian_process/tests/test_kernels.py | .py | import numpy as np
from scipy import optimize
from scipy.spatial.distance import pdist, squareform
try:
from sklearn.preprocessing import OrdinalEncoder
UseOrdinalEncoder = True
except ImportError:
UseOrdinalEncoder = False
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert... | 213 | 7,406 |
jupytext | tests/external/rst2md/test_rst2md.py | .py | import os
import pytest
from nbformat.v4.nbbase import new_markdown_cell, new_notebook
from jupytext import TextFileContentsManager, read, write
from jupytext.cli import jupytext
@pytest.mark.requires_sphinx_gallery
def test_rst2md(tmpdir, cwd_tmpdir):
tmp_py = "notebook.py"
tmp_ipynb = "notebook.ipynb"
... | 70 | 1,723 |
pyomo | pyomo/solvers/tests/piecewise_linear/__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... | 12 | 588 |
qutip | qutip/solver/mesolve.py | .py | """
This module provides solvers for the Lindblad master equation and von Neumann
equation.
"""
# Required for Sphinx to follow autodoc_type_aliases
from __future__ import annotations
__all__ = ['mesolve', 'MESolver']
from numpy.typing import ArrayLike
from typing import Any
from time import time
from .. import Qobj... | 306 | 11,773 |
saleor | saleor/core/tests/test_search_tasks.py | .py | from ...account.search import update_user_search_vector
from ...core.postgres import FlatConcatSearchVector
from ...core.search_tasks import (
set_order_search_document_values,
set_user_search_document_values,
)
def test_set_user_search_document_values(customer_user, customer_user2):
# given
assert no... | 56 | 1,483 |
pyomo | examples/gdp/circles/circles.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... | 263 | 8,293 |
beam | sdks/python/apache_beam/examples/wordcount_debugging.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... | 192 | 6,990 |
mlflow | tests/genai/discovery/test_job.py | .py | from unittest import mock
import pytest
from mlflow.entities.run_status import RunStatus
from mlflow.exceptions import MlflowException
from mlflow.genai.discovery.job import (
_fetch_provider_credentials,
invoke_issue_detection_job,
)
@pytest.mark.parametrize(
("provider", "secret_value", "auth_config",... | 260 | 10,318 |
kafka | tests/kafkatest/services/verifiable_share_consumer.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 ... | 353 | 16,146 |
probability | tensorflow_probability/python/distributions/dpp_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... | 367 | 13,748 |
onnx | onnx/reference/ops/op_rnn.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 CommonRNN(OpRun):
def __init__(self, onnx_node, run_params):
OpRun.__init__(self, onnx_node, run_params)
if self.d... | 203 | 6,149 |
mlflow | tests/utils/test_uv_utils.py | .py | import subprocess
from unittest import mock
import pytest
from packaging.version import Version
from mlflow.environment_variables import MLFLOW_UV_AUTO_DETECT
from mlflow.utils.environment import infer_pip_requirements
from mlflow.utils.uv_utils import (
_PYPROJECT_FILE,
_UV_LOCK_FILE,
copy_uv_project_fil... | 868 | 28,171 |
biopython | Scripts/Restriction/ranacompiler.py | .py | #!/usr/bin/env python
#
# Restriction Analysis Libraries.
# Copyright (C) 2004. Frederic Sohm.
#
# 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.
# This script is used to produce the dictiona... | 1,077 | 39,653 |
saleor | saleor/discount/tests/test_rounding_issue.py | .py | from decimal import Decimal
import pytest
from ...checkout.fetch import fetch_checkout_info, fetch_checkout_lines
from ...checkout.tests.utils import add_variant_to_checkout
from ...discount.models import PromotionRule
from ...plugins.manager import get_plugins_manager
from ...product.models import Product, ProductVa... | 114 | 4,246 |
clearml | clearml/binding/frameworks/base_bind.py | .py | from abc import ABC, abstractmethod
from typing import Callable, Union, IO, TYPE_CHECKING, Any
if TYPE_CHECKING:
from clearml import Task
class PatchBaseModelIO(ABC):
"""
Base class for patched models
:param __main_task: Task to run (Experiment)
:type __main_task: Task
:param __patched: True... | 55 | 1,238 |
pyomo | pyomo/core/kernel/constraint.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 859 | 30,116 |
hypercorn | src/hypercorn/asyncio/run.py | .py | from __future__ import annotations
import asyncio
import platform
import signal
import ssl
import sys
from collections.abc import Awaitable, Callable
from functools import partial
from multiprocessing.synchronize import Event as EventType
from os import getpid
from random import randint
from socket import socket
from ... | 242 | 8,085 |
pyomo | pyomo/solvers/tests/models/LP_infeasible1.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... | 71 | 2,365 |
astropy | astropy/coordinates/builtin_frames/hadec.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from astropy import units as u
from astropy.coordinates import representation as r
from astropy.coordinates.attributes import (
EarthLocationAttribute,
QuantityAttribute,
TimeAttribute,
)
from astropy.coordinates.baseframe import (
BaseCoo... | 143 | 5,830 |
qutip | qutip/core/data/_scipy_sparse.py | .py | """
Helper module for the use of ``scipy.sparse`` backing containers in the
data layer.
In the light of SciPy's migration plans, ``spmatrix`` types (``csr_matrix``,
``dia_matrix``, ...) will be replaced by ``sparray`` types.
We respond to this by ensuring that qutip's data layer always uses ``sparray``
containers inte... | 102 | 3,229 |
pyomo | pyomo/contrib/mindtpy/plugins.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 | 820 |
saleor | saleor/graphql/translations/tests/mutations/test_category_translate.py | .py | import graphene
from ....core.enums import LanguageCodeEnum
from ....tests.utils import get_graphql_content
CATEGORY_TRANSLATE_MUTATION = """
mutation (
$id: ID!,
$languageCode: LanguageCodeEnum!,
$input: TranslationInput!
) {
categoryTranslate(
id: $id,
... | 113 | 2,844 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_full.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# fill_const paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle
import sys
def full(name : str, shape : list, dtype, value):
paddle.enable_static()
with paddle.static.program_guard(padd... | 119 | 5,257 |
pyomo | pyomo/core/tests/unit/test_mutable.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... | 131 | 3,840 |
pyomo | pyomo/core/tests/unit/test_numeric_expr.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... | 5,736 | 190,515 |
astropy | astropy/coordinates/calculation.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# Standard library
import re
import textwrap
import warnings
from datetime import datetime
from typing import Final
from urllib.request import Request, urlopen
# Third-party
from astropy import time as atime
from astropy.utils.console import _color_text... | 237 | 7,181 |
mlflow | mlflow/tracing/processor/mlflow_v3.py | .py | import logging
from opentelemetry.sdk.trace import Span as OTelSpan
from opentelemetry.sdk.trace.export import SpanExporter
from mlflow.entities.trace_info import TraceInfo
from mlflow.entities.trace_location import TraceLocation
from mlflow.entities.trace_state import TraceState
from mlflow.tracing.processor.base_ml... | 54 | 2,042 |
pyomo | examples/pyomobook/blocks-ch/blocks_intro.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... | 114 | 2,909 |
saleor | saleor/graphql/account/tests/queries/test_address.py | .py | import graphene
from ....tests.utils import (
assert_no_permission,
get_graphql_content,
get_graphql_content_from_response,
)
ADDRESS_QUERY = """
query address($id: ID!) {
address(id: $id) {
postalCode
lastName
firstName
city
country {
code
}
... | 253 | 7,340 |
readthedocs.org | readthedocs/search/tests/conftest.py | .py | import json
import os
from random import shuffle
import pytest
from django.core.management import call_command
from django_dynamic_fixture import get
from readthedocs.builds.constants import STABLE
from readthedocs.builds.models import Version
from readthedocs.projects.constants import PUBLIC
from readthedocs.project... | 100 | 2,816 |
astropy | astropy/constants/cgs.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Astronomical and physics constants in cgs units. See :mod:`astropy.constants`
for a complete listing of constants defined in Astropy.
"""
from .config import codata, iaudata
from .constant import Constant
for _nm, _c in (*sorted(vars(codata).items()... | 17 | 525 |
onnxruntime | onnxruntime/test/testdata/test_dangling_input_segment_ids.py | .py | """
Run this script to recreate the original onnx model.
Example usage:
python test_dangling_input_segment_ids.py test_dangling_input_segment_ids.onnx
"""
import sys
import numpy as np
import onnx
def order_repeated_field(repeated_proto, key_name, order):
order = list(order)
repeated_proto.sort(key=lambda x... | 137 | 7,173 |
attrs | tests/test_abc.py | .py | # SPDX-License-Identifier: MIT
import abc
import inspect
import pytest
import attrs
from attr._compat import PY_3_12_PLUS
class TestUpdateAbstractMethods:
def test_abc_implementation(self, slots):
"""
If an attrs class implements an abstract method, it stops being
abstract.
"""... | 60 | 1,534 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_SparseTensorDenseAdd.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 TestSparseTensorDenseAdd(CommonTFLayerTest):
def _prepare_... | 83 | 3,447 |
mlflow | examples/spark_udf/spark_udf_with_prebuilt_env.py | .py | """
This example code shows how to use `mlflow.pyfunc.spark_udf` with Databricks Connect
outside Databricks runtime.
"""
import os
from databricks.connect import DatabricksSession
from databricks.sdk import WorkspaceClient
from sklearn import datasets
from sklearn.neighbors import KNeighborsClassifier
import mlflow
... | 45 | 1,465 |
mlflow | tests/pyfunc/test_pyfunc_model_config.py | .py | import os
import pytest
import yaml
import mlflow
from mlflow.models import Model
@pytest.fixture
def model_path(tmp_path):
return os.path.join(tmp_path, "model")
@pytest.fixture
def model_config():
return {
"use_gpu": True,
"temperature": 0.9,
"timeout": 300,
}
def _load_pyf... | 155 | 5,259 |
gunicorn | tests/docker/http2/app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Test WSGI application for HTTP/2 Docker integration tests."""
import json
def app(environ, start_response):
"""Simple WSGI app for testing HTTP/2 functionality."""
path = environ.get('PATH_INFO', '/')... | 160 | 5,192 |
textual | tests/animations/test_environment_variable.py | .py | import pytest
from textual import constants
from textual.app import App
from textual.constants import _get_textual_animations
@pytest.mark.parametrize(
["env_variable", "value"],
[
("", "full"), # default
("FULL", "full"),
("BASIC", "basic"),
("NONE", "none"),
("garba... | 33 | 968 |
onnx | onnx/defs/gen_doc.py | .py | #!/usr/bin/env python
# Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import os
from collections import defaultdict
from typing import TYPE_CHECKING, Any, NamedTuple
import numpy as np
from onnx import defs, helper
from onnx.backend.sample.ops impo... | 441 | 17,078 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_ortmodule_autograd.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# pylint: disable=missing-docstring
# pylint: disable=C0103
# pylint: disable=W0212
import copy
import os
import onnx
import pytest
import torch
from _test_helpers import (
assert_gradients_match_and_reset_gradient,
... | 1,858 | 66,611 |
attrs | tests/utils.py | .py | # SPDX-License-Identifier: MIT
"""
Common helper functions for tests.
"""
from attr import Attribute
from attr._make import NOTHING, _default_init_alias_for, make_class
def simple_class(
eq=False,
order=False,
repr=False,
unsafe_hash=False,
str=False,
slots=False,
frozen=False,
cache... | 70 | 1,294 |
mlflow | mlflow/protos/databricks_managed_catalog_messages_pb2.py | .py |
import google.protobuf
from packaging.version import Version
if Version(google.protobuf.__version__).major >= 5:
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: databricks_managed_catalog_messages.proto
# Protobuf Python Version: 5.26.0
"""Generated protocol buffe... | 96 | 5,275 |
astropy | astropy/constants/constant.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import functools
import types
import warnings
import numpy as np
from astropy.units.core import Unit
from astropy.units.errors import UnitsError
from astropy.units.quantity import Quantity
from astropy.utils import lazyproperty
from astropy.utils.except... | 281 | 9,417 |
jupytext | tools/absolute_links_in_readme.py | .py | import re
from pathlib import Path
from hatchling.metadata.plugin.interface import MetadataHookInterface
class AbsoluteLinksInReadme(MetadataHookInterface):
"""Hook that processes README.md to make relative links absolute."""
def update(self, metadata):
"""Process README.md when metadata is being pr... | 42 | 1,627 |
flit | flit_core/tests_core/test_buildapi.py | .py | from contextlib import contextmanager
import os
import os.path as osp
import tarfile
from testpath import assert_isfile, assert_isdir
from testpath.tempdir import TemporaryDirectory
import zipfile
from flit_core import buildapi
samples_dir = osp.join(osp.dirname(__file__), 'samples')
@contextmanager
def cwd(director... | 94 | 3,934 |
wandb | tests/system_tests/test_functional/terminput/terminput_tester.py | .py | import argparse
import fcntl
import os
import sys
import termios
from wandb.errors.term import terminput
if __name__ == "__main__":
# Tell the pseudoterminal to which stdin is attached to control
# this process, so that it can implement Ctrl+C and so on.
os.setsid()
fcntl.ioctl(sys.stdin, termios.TIOC... | 35 | 933 |
openvino | tests/layer_tests/pytorch_tests/test_stack.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestStack2D(PytorchLayerTest):
def _prepare_input(self):
return self.input_tensors
def create_model(self, dim=None):
import torch
... | 92 | 2,532 |
pyro | pyro/distributions/sine_skewed.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import warnings
from math import pi
import torch
from torch import broadcast_shapes
from torch.distributions import Uniform
from pyro.distributions import constraints
from .torch_distribution import TorchDistribution
class SineSke... | 172 | 7,374 |
saleor | saleor/graphql/order/tests/test_homepage.py | .py | import datetime
import pytest
from prices import Money
from ....order import OrderEvents
from ....order.models import Order, OrderEvent
from ...core.enums import ReportingPeriod
from ...tests.utils import assert_no_permission, get_graphql_content
QUERY_HOMEPAGE_EVENTS = """
{
homepageEvents(first: 20) {
... | 531 | 14,145 |
saleor | saleor/graphql/account/tests/queries/test_permission_groups_sorting.py | .py | import pytest
from .....account.models import Group
from ....tests.utils import get_graphql_content
QUERY_PERMISSION_GROUP_WITH_SORT = """
query ($sort_by: PermissionGroupSortingInput!) {
permissionGroups(first:5, sortBy: $sort_by) {
edges{
node{
name
}
}
... | 52 | 1,347 |
openvino | src/bindings/python/tests/test_graph/test_col2im.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino import Type
import openvino.opset15 as ov
import numpy as np
import pytest
@pytest.mark.parametrize(("input_shape", "output_size", "kernel_size", "expected_shape", "params"), [
((3, 4), [2, 2],... | 28 | 1,191 |
wagtail | wagtail/admin/tests/test_telepath.py | .py | import itertools
from django.test import TestCase
from wagtail.admin.telepath import Adapter, JSContext, register
class Artist:
def __init__(self, name):
self.name = name
class Album:
def __init__(self, title, artists):
self.title = title
self.artists = artists
class ArtistAdapte... | 354 | 10,380 |
saleor | saleor/webhook/tests/test_payment_webhook_utils.py | .py | import pytest
from ...core import EventDeliveryStatus, private_storage
from ...core.models import EventDelivery, EventPayload
from ...payment import TransactionKind
from ..const import APP_ID_PREFIX
from ..transport.payment import (
parse_list_payment_gateways_response,
parse_payment_action_response,
)
from ..... | 296 | 9,867 |
hatch | src/hatch/cli/new/__init__.py | .py | import click
@click.command(short_help="Create or initialize a project")
@click.argument("name", required=False)
@click.argument("location", required=False)
@click.option("--interactive", "-i", "interactive", is_flag=True, help="Interactively choose details about the project")
@click.option("--cli", "feature_cli", is... | 163 | 6,063 |
black | tests/data/cases/pep_572_py310.py | .py | # flags: --minimum-version=3.10
# Unparenthesized walruses are now allowed in indices since Python 3.10.
x[a := 0]
x[a := 0, b := 1]
x[5, b := 0]
# Walruses are allowed inside generator expressions on function calls since 3.10.
if any(match := pattern_error.match(s) for s in buffer):
if match.group(2) == data_not_... | 22 | 643 |
beam | learning/katas/python/Core Transforms/Tee/Tee/tests/test_task.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not... | 36 | 1,243 |
cvxpy | cvxpy/tests/test_solver_data_validation.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
... | 60 | 2,265 |
sqlmap | plugins/dbms/mckoi/enumeration.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.data import logger
from plugins.generic.enumeration import Enumeration as GenericEnumeration
class Enumeration(GenericEnumeration):
def getBanner(self):
... | 85 | 2,370 |
textual | src/textual/_color_constants.py | .py | from __future__ import annotations
ANSI_COLORS = [
"black",
"red",
"green",
"yellow",
"blue",
"magenta",
"cyan",
"white",
"bright_black",
"bright_red",
"bright_green",
"bright_yellow",
"bright_blue",
"bright_magenta",
"bright_cyan",
"bright_white",
]
"""T... | 193 | 6,099 |
wandb | tests/unit_tests/test_lib/test_auth.py | .py | import pathlib
import textwrap
from unittest.mock import MagicMock
import pytest
from wandb.errors import AuthenticationError
from wandb.sdk.lib.wbauth import (
AuthApiKey,
AuthIdentityTokenFile,
authenticate_session,
session_credentials,
use_explicit_auth,
validation,
)
from tests.fixtures.mo... | 213 | 6,581 |
deap | tests/test_operators.py | .py | import unittest
from unittest import mock
import random
from deap.tools import crossover
class TestCxOrdered(unittest.TestCase):
def setUp(self):
pass
def test_crossover(self):
a = [8, 7, 3, 4, 5, 6, 0, 2, 1, 9]
b = [7, 6, 0, 1, 2, 9, 8, 4, 3, 5]
expected_ap = [4, 5, 6, 1, 2,... | 37 | 1,069 |
openvino | tests/layer_tests/pytorch_tests/test_argsort.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
class TestArgSort(PytorchLayerTest):
def _prepare_input(self):
return (self.input_tensor,)
def create_model(self, dim... | 85 | 3,431 |
readthedocs.org | readthedocs/subscriptions/apps.py | .py | """Subscriptions app."""
from django.apps import AppConfig
class SubscriptionsConfig(AppConfig):
"""App configuration."""
name = "readthedocs.subscriptions"
label = "subscriptions"
def ready(self):
import readthedocs.subscriptions.event_handlers # noqa
import readthedocs.subscripti... | 37 | 1,166 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.