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
beam
sdks/python/apache_beam/io/gcp/datastore/v1new/rampup_throttling_fn_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...
79
3,002
pyro
pyro/infer/reparam/transform.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import torch import pyro import pyro.distributions as dist from .reparam import Reparam class TransformReparam(Reparam): """ Reparameterizer for :class:`pyro.distributions.torch.TransformedDistribution` latent varia...
59
1,789
readthedocs.org
readthedocs/gold/tests/test_views.py
.py
import re from django.contrib.auth.models import User from django.test import TestCase from django.urls import reverse from django_dynamic_fixture import get from readthedocs.payments.tests.utils import PaymentMixin class TestViews(PaymentMixin, TestCase): def setUp(self): super().setUp() self.us...
32
1,110
mlflow
tests/server/jobs/test_jobs.py
.py
import concurrent.futures import json import multiprocessing import os import time from pathlib import Path from unittest import mock import pytest import mlflow.store.jobs.sqlalchemy_store from mlflow.entities._job_status import JobStatus from mlflow.environment_variables import MLFLOW_ENABLE_WORKSPACES, MLFLOW_WORK...
1,091
39,000
probability
tensorflow_probability/python/experimental/vi/__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...
51
2,839
coremltools
coremltools/converters/mil/experimental/passes/generic_linear_bias_fusion.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import os import numpy as np from coremltools.converters.mil import Builder as mb from coremltools....
134
4,994
beam
sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupby_two_exprs.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");...
58
1,692
onnx
onnx/backend/test/case/node/reducemax.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 ReduceMax(Base): @staticmethod def export_do_not_keepdims() ->...
232
6,721
astropy
astropy/stats/tests/test_biweight.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import numpy as np import pytest from numpy.testing import assert_allclose, assert_array_almost_equal_nulp, assert_equal import astropy.units as u from astropy.stats.biweight import ( biweight_location, biweight_midcorrelation, biweight_midco...
589
19,405
mlflow
tests/langchain/test_chat_utils.py
.py
from unittest.mock import MagicMock, patch import pytest from langchain_core.language_models.chat_models import SimpleChatModel from langchain_core.messages import ( AIMessage, AIMessageChunk, HumanMessage, SystemMessage, ToolMessage, ) from langchain_core.outputs import ChatGenerationChunk from la...
550
19,093
pyomo
pyomo/opt/tests/base/test_sol.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...
159
6,052
sphinx
tests/test_writers/test_writer_text.py
.py
"""Test the LaTeX writer""" from __future__ import annotations import pytest from docutils.utils import column_width from sphinx.writers.text import TextWrapper find_break_end = TextWrapper._find_break_end @pytest.mark.parametrize( # glyph of column width 0 'glyph', ['', '\N{COMBINING TILDE}'], ) def ...
184
6,216
beam
sdks/python/apache_beam/examples/snippets/transforms/elementwise/keys.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");...
59
1,618
confluent-kafka-python
tests/integration/schema_registry/_sync/test_proto_serializers.py
.py
#!/usr/bin/env python # # Copyright 2016 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...
169
6,117
confluent-kafka-python
tests/schema_registry/test_azure_client.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2024 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...
100
4,043
hypercorn
tests/protocol/test_http_stream.py
.py
from __future__ import annotations from typing import Any, cast from unittest.mock import AsyncMock, call import pytest import pytest_asyncio from hypercorn.asyncio.statsd import StatsdLogger from hypercorn.asyncio.worker_context import WorkerContext from hypercorn.config import Config from hypercorn.logging import ...
430
13,134
pyomo
pyomo/dae/contset.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...
305
11,274
metrics
tests/unittests/classification/test_calibration_error.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...
291
11,933
astropy
astropy/io/fits/tests/test_tilde_path.py
.py
# Licensed under a 3-clause BSD style license - see PYFITS.rst import os import numpy as np import pytest from astropy.io import fits from astropy.io.fits.scripts import fitsheader from astropy.utils.misc import _NOT_OVERWRITING_MSG_MATCH from .conftest import FitsTestCase class TestTildePaths(FitsTestCase): ...
175
6,151
saleor
saleor/graphql/meta/mutations/delete_private_metadata.py
.py
import graphene from ...core import ResolveInfo from ...core.types import MetadataError, NonNullList from ..permissions import PRIVATE_META_PERMISSION_MAP from .base import BaseMetadataMutation from .utils import delete_private_metadata_keys, get_valid_metadata_instance class DeletePrivateMetadata(BaseMetadataMutati...
41
1,392
sqlmap
extra/esperanto/run.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission Standalone launcher for the DBMS-agnostic Esperanto engine. Run it straight from this directory - no sqlmap, no PYTHONPATH, no `-m` incantation: python run.py -u 'http://host/vul...
32
1,245
saleor
saleor/tests/e2e/__init__.py
.py
DEFAULT_ADDRESS = { "firstName": "John Saleor", "lastName": "Doe Mirumee", "companyName": "Saleor Commerce", "streetAddress1": "14208 Hawthorne Blvd", "streetAddress2": "", "postalCode": "90250", "country": "US", "city": "Hawthorne", "countryArea": "CA", "phone": "+12025550163", ...
39
953
probability
tensorflow_probability/python/internal/backend/numpy/gen/linear_operator_toeplitz.py
.py
# Copyright 2020 The TensorFlow Probability Authors. All Rights Reserved. # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ # THIS FILE IS AUTO-GENERATED BY `gen_linear_operators.py`. # DO NOT MODIFY DIRECTLY. # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...
329
13,498
saleor
saleor/tests/e2e/checkout/test_checkout_with_shipping_method_with_min_order_value.py
.py
import pytest from ..product.utils import ( create_product_variant, create_product_variant_channel_listing, ) from ..product.utils.preparing_product import prepare_product from ..shop.utils import prepare_shop from ..utils import assign_permissions from .utils import checkout_create, checkout_delivery_method_u...
127
3,509
textual
src/textual/widgets/_selection_list.py
.py
"""Provides a selection list widget, allowing one or more items to be selected.""" from __future__ import annotations from dataclasses import dataclass from typing import Callable, ClassVar, Generic, Iterable, TypeVar, cast from rich.repr import Result from rich.segment import Segment from rich.style import Style fr...
716
25,078
openvino
tests/layer_tests/pytorch_tests/test_index_add.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 TestIndexAdd(PytorchLayerTest): def _prepare_input(self, dtype, out): if not out: return (np.ones((3, 3))...
67
2,528
conda
conda/notices/views.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Handles all display/view logic.""" from collections.abc import Sequence from ..base.context import context from ..common.serialize import json from .types import ChannelNotice def print_notices(channel_notices: Sequence[ChannelNotice]): ...
62
2,040
bazel
tools/ctexplain/analyses/summary_test.py
.py
# Copyright 2020 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
45
1,658
clearml
clearml/backend_api/services/v2_9/projects.py
.py
""" projects service Provides support for defining Projects containing Tasks, Models and Dataset Versions. """ from typing import List, Optional, Any from datetime import datetime import six from dateutil.parser import parse as parse_datetime from ....backend_api.session import ( NonStrictDataModel, Request, ...
2,610
90,634
cvxpy
cvxpy/atoms/elementwise/abs.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...
105
2,949
coveragepy
tests/modules/pkg1/sub/__main__.py
.py
# Used in the tests for PyRunner import sys print("pkg1.sub.__main__: passed %s" % sys.argv[1])
5
97
pyomo
pyomo/contrib/incidence_analysis/tests/test_triangularize.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...
502
15,896
probability
spinoffs/inference_gym/inference_gym/internal/datasets/brownian_motion_missing_middle_observations.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...
68
2,098
mlflow
tests/genai/scorers/online/test_trace_loader.py
.py
from unittest.mock import MagicMock, patch import pytest from mlflow.entities import Trace, TraceInfo from mlflow.genai.scorers.online.trace_loader import OnlineTraceLoader from mlflow.tracing.constant import SpansLocation, TraceTagKey @pytest.fixture def mock_store(): return MagicMock() @pytest.fixture def t...
249
8,414
pdm
tasks/render_reference_docs.py
.py
from __future__ import annotations import argparse import re from os import PathLike from pathlib import Path from pdm.core import Core from pdm.project.config import Config ROOT = Path(__file__).resolve().parent.parent REFERENCE_DIR = ROOT / "docs" / "reference" TEMPLATE_DIR = ROOT / "tasks" / "doc_templates" CLI_T...
165
6,329
onnxruntime
onnxruntime/python/tools/transformers/models/stable_diffusion/optimize_pipeline.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # # This script converts stable diffusion onnx models from float to half...
591
21,648
pyomo
pyomo/gdp/tests/test_mbigm.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,229
48,572
jupytext
src/jupytext_config/jupytext_config.py
.py
""" the code for jupytext-config set-default-viewer and related subcommands """ import sys from argparse import ArgumentParser from pathlib import Path import jupyter_core.paths as jupyter_core_paths from .labconfig import LabConfig class SubCommand: """ a subcommand for jupytext-config """ def __...
97
2,660
pyro
pyro/infer/mcmc/hmc.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import math from collections import OrderedDict import torch import pyro import pyro.distributions as dist from pyro.distributions.testing.fakes import NonreparameterizedNormal from pyro.distributions.util import scalar_like from...
453
18,825
readthedocs.org
readthedocs/rtd_tests/tests/test_project_views.py
.py
from unittest import mock from allauth.socialaccount.models import SocialAccount from django.contrib.auth.models import User from django.http.response import HttpResponseRedirect from django.test import TestCase, override_settings from django.urls import reverse from django.views.generic.base import ContextMixin from ...
833
30,820
pyomo
examples/pyomobook/abstract-ch/set2a.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...
21
737
kafka
tests/kafkatest/tests/core/delegation_token_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 use ...
128
6,093
sqlmap
tamper/binary.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import re from lib.core.enums import PRIORITY __priority__ = PRIORITY.HIGHEST def dependencies(): pass def tamper(payload, **kwargs): """ Injects the keyword binar...
44
1,300
conda
tests/cli/test_subcommands.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from __future__ import annotations import json from typing import TYPE_CHECKING import pytest from conda.common.compat import on_win if TYPE_CHECKING: from pathlib import Path from pytest_benchmark.fixture import BenchmarkFixture ...
340
8,669
clearml
clearml/binding/frameworks/pytorch_bind.py
.py
import importlib import sys import threading from typing import Callable, Optional, Any from pathlib2 import Path from ..frameworks import ( _patched_call, _patched_call_no_recursion_guard, WeightsFileHandler, _Empty, ) from ..import_bind import PostImportHookPatching from ...binding.frameworks.base_b...
356
13,137
openvino
src/plugins/intel_gpu/src/graph/common_utils/test_kernels_db_gen.py
.py
#!/usr/bin/python3 # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import unittest import os, sys import argparse from kernels_db_gen import Code2CHeaders class TestOpenCLCodePreprocessing(unittest.TestCase): def setUp(self): self.kernels_folder = 'test_kernels' s...
197
6,453
conda
conda/cli/main_create.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """CLI implementation for `conda create`. Creates new conda environments with the specified packages. """ from __future__ import annotations from logging import getLogger from typing import TYPE_CHECKING from ..notices import notices if TYP...
221
7,743
onnxruntime
onnxruntime/core/mlas/lib/sve/gen_sve_asm.py
.py
#!/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """Freeze SVE intrinsics translation units into KleidiAI-style machine code. Compiles an SVE intrinsics reference TU with gcc, extracts the requested extern "C" functions from the object file, and emits...
205
7,665
hydra
examples/plugins/example_registered_plugin/setup.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved # type: ignore from setuptools import setup with open("README.md") as fh: LONG_DESC = fh.read() setup( name="hydra-example-registered-plugin", version="1.0.0", author="Jasha Sommer-Simpson", description="Example of Hydra Plugin ...
35
1,273
onnxruntime
onnxruntime/test/python/transformers/profile_matmul_nbits.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- """ Profiling script for the CUDA MatMulNBits (4-bit / 8-bit weight-onl...
207
7,337
python-prompt-toolkit
src/prompt_toolkit/input/win32.py
.py
from __future__ import annotations import os import sys from abc import abstractmethod from asyncio import get_running_loop from contextlib import AbstractContextManager, contextmanager from ..utils import SPHINX_AUTODOC_RUNNING assert sys.platform == "win32" # Do not import win32-specific stuff when generating doc...
908
31,491
probability
tensorflow_probability/python/bijectors/cholesky_to_inv_cholesky_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...
141
6,089
astropy
astropy/extern/ply/ygen.py
.py
# ply: ygen.py # # This is a support program that auto-generates different versions of the YACC parsing # function with different features removed for the purposes of performance. # # Users should edit the method LRParser.parsedebug() in yacc.py. The source code # for that method is then used to create the other meth...
70
2,246
wagtail
wagtail/documents/tests/test_bulk_actions/test_bulk_add_tags.py
.py
from django.contrib.auth.models import Permission from django.test import TestCase from django.urls import reverse from wagtail.documents import get_document_model from wagtail.test.utils import WagtailTestUtils Document = get_document_model() def get_tag_list(document): return [tag.name for tag in document.tag...
84
2,647
python-prompt-toolkit
src/prompt_toolkit/shortcuts/__init__.py
.py
from __future__ import annotations from .choice_input import choice from .dialogs import ( button_dialog, checkboxlist_dialog, input_dialog, message_dialog, progress_dialog, radiolist_dialog, yes_no_dialog, ) from .progress_bar import ProgressBar, ProgressBarCounter from .prompt import ( ...
50
1,020
pyomo
pyomo/repn/tests/cpxlp/test_lpv2.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...
346
6,910
textual
tests/layouts/test_grid.py
.py
from textual import containers, widgets from textual.app import App, ComposeResult from textual.layouts.grid import GridLayout async def test_grid_size(): """Test the `grid_size` property on GridLayout.""" class GridApp(App): CSS = """ Grid { grid-size: 3; grid-columns...
35
985
wagtail
wagtail/contrib/typed_table_block/tests.py
.py
from django.core.exceptions import ValidationError from django.forms.utils import ErrorList from django.test import TestCase from wagtail import blocks from wagtail.blocks.base import get_error_json_data from wagtail.blocks.definition_lookup import BlockDefinitionLookup from wagtail.blocks.struct_block import StructBl...
568
22,716
saleor
saleor/graphql/core/enums.py
.py
from typing import Final import graphene from django.conf import settings from ...account import error_codes as account_error_codes from ...app import error_codes as app_error_codes from ...attribute import error_codes as attribute_error_codes from ...channel import error_codes as channel_error_codes from ...checkout...
517
18,401
pyro
pyro/contrib/gp/kernels/kernel.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import numbers from pyro.contrib.gp.parameterized import Parameterized class Kernel(Parameterized): """ Base class for kernels used in this Gaussian Process module. Every inherited class should implement a :meth:`fo...
260
8,446
jupytext
tests/functional/simple_notebooks/test_read_simple_julia.py
.py
import jupytext from jupytext.compare import compare def test_read_simple_file( julia='''""" cube(x) Compute the cube of `x`, ``x^3``. # Examples ```jldoctest julia> cube(2) 8 ``` """ function cube(x) x^3 end cube(x) # And a markdown comment ''', ): nb = jupytext.reads(julia, "jl") assert nb.met...
54
888
mlflow
mlflow/utils/plugins.py
.py
import importlib.metadata def _get_entry_points(group: str) -> list[importlib.metadata.EntryPoint]: return importlib.metadata.entry_points(group=group) def get_entry_points(group: str) -> list[importlib.metadata.EntryPoint]: return _get_entry_points(group)
10
269
pyomo
pyomo/contrib/community_detection/community_graph.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...
227
9,984
textual
docs/examples/widgets/header_app_title.py
.py
from textual.app import App, ComposeResult from textual.widgets import Header class HeaderApp(App): def compose(self) -> ComposeResult: yield Header() def on_mount(self) -> None: self.title = "Header Application" self.sub_title = "With title and sub-title" if __name__ == "__main__":...
17
357
pyomo
pyomo/util/model_size.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...
181
6,953
openvino
src/frontends/tensorflow/tests/test_models/gen_scripts/generate_saved_model_program-only.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os import sys import tensorflow as tf # Create the graph and model tf.compat.v1.reset_default_graph() with tf.compat.v1.Session() as sess: x_value = [[1.,2.,3.],[3.,2.,1.]] tf_x = tf.constant(x_value) tf_y = tf.compa...
17
578
wandb
wandb/integration/sagemaker/__init__.py
.py
"""wandb integration sagemaker module.""" from .auth import sagemaker_auth from .config import is_using_sagemaker, parse_sm_config from .resources import parse_sm_secrets, set_global_settings, set_run_id __all__ = [ "sagemaker_auth", "is_using_sagemaker", "parse_sm_config", "parse_sm_secrets", "se...
15
360
django-cms
cms/tests/test_placeholder_admin.py
.py
from unittest.mock import patch from django.contrib.contenttypes.models import ContentType from django.db import connection from django.forms.models import model_to_dict from django.test.utils import CaptureQueriesContext, override_settings from cms.api import add_plugin, create_page from cms.models import CMSPlugin,...
916
52,944
cvxpy
cvxpy/reductions/inverse_data.py
.py
""" Copyright 2016 Jaehyun Park, 2017 Robin Verschueren 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 t...
57
1,944
mlflow
mlflow/utils/uv_utils.py
.py
""" Utilities for uv package manager integration. This module provides functions for detecting uv projects and exporting dependencies via ``uv export`` for automatic dependency inference during model logging. """ import logging import os import re import shutil import subprocess from pathlib import Path from typing i...
470
15,222
confluent-kafka-python
tests/test_message.py
.py
import pickle import pytest from confluent_kafka.cimpl import Message def empty_message_1(): return Message() def empty_message_2(): return Message(None, -2, -2, None, None, None, None, None, -2.0, -2) def empty_message_3(): msg = Message() msg.set_topic(None) msg.set_value(None) msg.set...
311
9,498
hatch
src/hatch/env/collectors/default.py
.py
from hatch.env.collectors.plugin.interface import EnvironmentCollectorInterface from hatch.env.internal import get_internal_env_config from hatch.env.utils import ensure_valid_environment class DefaultEnvironmentCollector(EnvironmentCollectorInterface): PLUGIN_NAME = "default" def get_initial_config(self): ...
14
486
sphinx
tests/test_domains/test_domain_rst.py
.py
"""Tests the reStructuredText domain.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx import addnodes from sphinx.addnodes import ( desc, desc_addname, desc_annotation, desc_content, desc_name, desc_signature, ) from sphinx.domains.rst import ...
290
7,497
sphinx
tests/test_ext_autodoc/conftest.py
.py
from __future__ import annotations import sys import pytest from tests.utils import TEST_ROOTS_DIR TYPE_CHECKING = False if TYPE_CHECKING: from collections.abc import Iterator @pytest.fixture(scope='module') def inject_autodoc_root_into_sys_path() -> Iterator[None]: autodoc_root_path = str(TEST_ROOTS_DIR ...
21
461
saleor
saleor/discount/tests/test_utils/test_create_or_update_discount_objects_from_promotion_for_order.py
.py
from decimal import Decimal import graphene from ....order.fetch import fetch_draft_order_lines_info from ....product.models import ( ProductVariantChannelListing, VariantChannelListingPromotionRule, ) from ....warehouse.models import Stock from ... import DiscountType, DiscountValueType, RewardType, RewardVa...
545
19,752
wandb
tools/perf/scripts/push_perf_results_helper.py
.py
import argparse import json import logging import os import re import wandb logger = logging.getLogger(__name__) def log_to_wandb(args: argparse.Namespace) -> None: # Initialize a W&B run with wandb.init( project=args.project, name=args.run_name, job_type="performance_test" ) as run: # L...
76
2,126
lemur
lemur/reporting/service.py
.py
import arrow from datetime import timedelta from sqlalchemy import cast, not_ from sqlalchemy_utils import ArrowType from lemur import database from lemur.certificates.models import Certificate def filter_by_validity(query, validity=None): if validity == "expired": query = query.filter(Certificate.expir...
78
1,918
saleor
saleor/tests/e2e/checkout/utils/checkout_add_promo_code.py
.py
from ...utils import get_graphql_content CHECKOUT_ADD_PROMO_CODE_MUTATION = """ mutation AddCheckoutPromoCode($checkoutId: ID!, $promoCode: String!) { checkoutAddPromoCode(id: $checkoutId, promoCode: $promoCode) { checkout { id totalPrice { gross { amount } } sub...
107
1,859
readthedocs.org
readthedocs/rtd_tests/tests/test_builds.py
.py
import datetime from django.contrib.auth.models import User from django.test import TestCase from django.utils import timezone from django_dynamic_fixture import get from readthedocs.builds.constants import ( BRANCH, EXTERNAL, GENERIC_EXTERNAL_VERSION_NAME, GITHUB_EXTERNAL_VERSION_NAME, GITLAB_EXT...
314
9,281
hydra
tests/defaults_list/test_slash_normalization.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from pytest import raises from hydra import compose, initialize from hydra._internal.defaults_list import create_defaults_list from hydra.core.plugins import Plugins from hydra.errors import ConfigCompositionException from tests.defaults_list impor...
114
4,643
attrs
src/attrs/exceptions.py
.py
# SPDX-License-Identifier: MIT from attr.exceptions import * # noqa: F403
4
76
astropy
astropy/coordinates/builtin_frames/icrs.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from astropy.coordinates.baseframe import base_doc from astropy.utils.decorators import format_doc from .baseradec import BaseRADecFrame, doc_components __all__ = ["ICRS"] @format_doc(base_doc, components=doc_components, footer="") class ICRS(BaseRADe...
25
892
mlflow
mlflow/server/assistant/session.py
.py
import json import os import signal import tempfile import uuid from dataclasses import dataclass, field from pathlib import Path from typing import Any, Literal from mlflow.assistant.types import Message SESSION_DIR = Path(tempfile.gettempdir()) / "mlflow-assistant-sessions" @dataclass class Session: """Sessio...
250
8,294
astropy
astropy/wcs/tests/test_tab.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from copy import deepcopy import numpy as np import pytest from packaging.version import Version from astropy import wcs from astropy.io import fits from astropy.utils.data import get_pkg_data_filename from astropy.wcs.wcs import WCSLIB_VERSION from .he...
107
3,499
luigi
test/contrib/sge_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...
101
3,428
black
tests/data/cases/pattern_matching_extras.py
.py
# flags: --minimum-version=3.10 import match match something: case [a as b]: print(b) case [a as b, c, d, e as f]: print(f) case Point(a as b): print(b) case Point(int() as x, int() as y): print(x, y) match = 1 case: int = re.match(something) match re.match(case): ...
103
1,796
wandb
tests/system_tests/test_core/test_wandb_init_reinit.py
.py
"""Tests for the `reinit` setting.""" import pytest import wandb def test_reinit_create_new__does_not_modify_wandb_run(): with wandb.init(mode="offline", reinit="create_new"): assert wandb.run is None def test_reinit_create_new__fails_on_id_conflict(): with wandb.init(mode="offline") as run1: ...
57
1,699
saleor
saleor/tests/e2e/pages/utils/page_type_create.py
.py
from ...utils import get_graphql_content PAGE_TYPE_CREATE_MUTATION = """ mutation PageTypeCreate($input: PageTypeCreateInput!) { pageTypeCreate(input: $input) { errors { field message code } pageType { id name slug attributes{ id } } } } """ ...
46
825
mlflow
examples/evaluation/evaluate_on_regressor.py
.py
from sklearn.datasets import load_diabetes from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split import mlflow diabetes_dataset = load_diabetes() X_train, X_test, y_train, y_test = train_test_split( diabetes_dataset.data, diabetes_dataset.target, test_size=0.33, r...
29
848
onnx
onnx/backend/test/case/model/expand.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from typing import TYPE_CHECKING import numpy as np import onnx from onnx.backend.test.case.base import Base from onnx.backend.test.case.model import expect if TYPE_CHECKING: from collections.abc ...
92
3,300
biopython
Bio/PDB/PICIO.py
.py
# Copyright 2019-2022 by Robert T. Miller. 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. """PICIO: read and...
1,120
41,280
deap
tests/test_pickle.py
.py
import sys import unittest import array import pickle import operator import functools import numpy from deap import creator from deap import base from deap import gp from deap import tools def func(): return "True" class Pickling(unittest.TestCase): def setUp(self): creator.create("FitnessMax",...
171
7,281
mlflow
tests/pyfunc/test_model_export_with_loader_module_and_data_path.py
.py
import os import pickle import types from unittest import mock import cloudpickle import numpy as np import pytest import sklearn.datasets import sklearn.neighbors import yaml import mlflow import mlflow.pyfunc from mlflow.exceptions import MlflowException from mlflow.models import Model, infer_signature from mlflow....
369
12,659
astropy
astropy/modeling/polynomial.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This module contains models representing polynomials and polynomial series. """ # pylint: disable=invalid-name from math import comb from textwrap import indent import numpy as np from .core import FittableModel, Model from .functional_models impor...
1,956
56,834
saleor
saleor/graphql/shipping/mutations/shipping_price_update.py
.py
import graphene from ....permission.enums import ShippingPermissions from ....shipping import models from ...core import ResolveInfo from ...core.context import ChannelContext from ...core.mutations import DeprecatedModelMutation from ...core.types import ShippingError from ...plugins.dataloaders import get_plugin_man...
55
2,005
cvxpy
cvxpy/reductions/dgp2dcp/canonicalizers/cumprod_canon.py
.py
""" Copyright 2024 the CVXPY 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 law or agreed to in writing, so...
21
694
mlflow
mlflow/genai/judges/tools/get_span.py
.py
""" Get span tool for MLflow GenAI judges. This module provides a tool for retrieving a specific span by ID. """ import json from mlflow.entities.trace import Trace from mlflow.genai.judges.tools.base import JudgeTool from mlflow.genai.judges.tools.constants import ToolNames from mlflow.genai.judges.tools.types impo...
133
5,306
sphinx
tests/roots/test-ext-autosummary/autosummary_dummy_inherited_module.py
.py
from autosummary_dummy_module import Foo class InheritedAttrClass(Foo): def __init__(self): #: other docstring self.subclassattr = 'subclassattr' super().__init__() __all__ = ['InheritedAttrClass']
13
231
mlflow
tests/autologging/test_autologging_client.py
.py
import time from unittest import mock import pytest import mlflow from mlflow import MlflowClient from mlflow.exceptions import MlflowException from mlflow.utils import _truncate_dict from mlflow.utils.autologging_utils import MlflowAutologgingQueueingClient from mlflow.utils.validation import ( MAX_ENTITY_KEY_LE...
272
10,603
pyomo
pyomo/solvers/plugins/solvers/mosek_persistent.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...
264
10,610