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 |
|---|---|---|---|---|---|
biopython | Tests/test_Align_bigbed.py | .py | # Copyright 2022 by Michiel de Hoon. 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 Align.bigbed module."""
import os
import sys
import tempfile
import unittest
fro... | 8,016 | 322,340 |
confluent-kafka-python | src/confluent_kafka/schema_registry/common/_oauthbearer.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2026 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 247 | 9,774 |
omegaconf | tests/test_compare_dictconfig_vs_dict.py | .py | """
This file compares DictConfig methods with the corresponding
methods of standard python's dict.
The following methods are compared:
__contains__
__delitem__
__eq__
__getitem__
__setitem__
get
pop
keys
values
items
We have separate test classes for the following cases:
Te... | 657 | 22,483 |
black | tests/data/cases/fmtskip8.py | .py | # Make sure a leading comment is not removed.
def some_func( unformatted, args ): # fmt: skip
print("I am some_func")
return 0
# Make sure this comment is not removed.
# Make sure a leading comment is not removed.
async def some_async_func( unformatted, args): # fmt: skip
print("I am some_asyn... | 63 | 1,705 |
wandb | tests/system_tests/test_core/test_wandb_save.py | .py | import wandb
def test_uploads_at_end(wandb_backend_spy, tmp_path):
file = tmp_path / "my_test_dir" / "my_test_file.txt"
file.parent.mkdir()
file.write_text("testing testing")
with wandb.init() as run:
run.save(file, policy="end")
with wandb_backend_spy.freeze() as snapshot:
asser... | 16 | 418 |
astropy | astropy/io/fits/hdu/hdulist.py | .py | # Licensed under a 3-clause BSD style license - see PYFITS.rst
import gzip
import itertools
import os
import re
import shutil
import sys
import warnings
from textwrap import indent
import numpy as np
from astropy.io.fits.file import FILE_MODES, _File
from astropy.io.fits.header import _pad_length
from astropy.io.fit... | 1,631 | 60,364 |
confluent-kafka-python | examples/protobuf_consumer_encryption.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... | 109 | 4,327 |
probability | spinoffs/inference_gym/inference_gym/backends/jax_integration_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... | 31 | 1,111 |
wandb | wandb/sdk/verify/verify.py | .py | """Utilities for wandb verify."""
from __future__ import annotations
import contextlib
import getpass
import io
import os
import time
from collections.abc import Callable
from functools import partial
from http import HTTPStatus
from pathlib import Path
from typing import Any
import click
import requests
import wan... | 554 | 18,372 |
coremltools | coremltools/test/sklearn_tests/test_normalizer.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import unittest
import numpy as _np
from ..utils import load_boston
from coremltools._deps import _HAS... | 60 | 1,912 |
saleor | saleor/tests/e2e/product/utils/product_channel_listing.py | .py | import datetime
from ...utils import get_graphql_content
PRODUCT_CHANNEL_LISTING_UPDATE_MUTATION = """
mutation UpdateProductChannelListing(
$productId: ID!, $input: ProductChannelListingUpdateInput!
) {
productChannelListingUpdate(id: $productId, input: $input) {
errors {
field
message
co... | 108 | 2,926 |
onnx | tests/python/backend_reference_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import os
import platform
import sys
from typing import Any
import numpy
import version_utils
import onnx.backend.base
import onnx.backend.test
from onnx import ModelProto
from onnx.backend.base import... | 185 | 7,031 |
gunicorn | examples/frameworks/flaskapp_aiohttp_wsgi.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# Example command to run the example:
#
# $ gunicorn flaskapp_aiohttp_wsgi:aioapp -k aiohttp.worker.GunicornWebWorker
#
from aiohttp import web
from aiohttp_wsgi import WSGIHandler
from flask import Flask
app =... | 29 | 607 |
probability | tensorflow_probability/python/bijectors/chain_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... | 463 | 17,870 |
lemur | lemur/deployment/service.py | .py | import logging
from lemur import database
logger = logging.getLogger(__name__)
def rotate_certificate(endpoint, new_cert):
"""
Rotates a certificate on a given endpoint.
:param endpoint:
:param new_cert:
:return:
"""
old_cert = endpoint.certificate
# ensure that certificate is avai... | 33 | 876 |
openvino | tools/ovc/unit_tests/ovc/utils/cli_parser_test.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import argparse
import os
import shutil
import tempfile
import unittest
import openvino as ov
from openvino import PartialShape
from openvino.tools.ovc.cli_parser import _InputCutInfo
from openvino.tools.ovc.cli_parser import input_to_... | 582 | 26,512 |
pyomo | pyomo/contrib/piecewise/transform/factorable.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... | 496 | 16,351 |
textual | tests/snapshot_tests/snapshot_apps/dev_previews_easing.py | .py | from textual_dev.previews import EasingApp
app = EasingApp()
if __name__ == "__main__":
app.run()
| 6 | 103 |
hydra | plugins/hydra_ray_launcher/integration_test_tools/setup_integration_test_ami.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import subprocess
import sys
from datetime import datetime
dependencies = [
"boto3==1.22.6",
"hydra-core>=1.1.2",
"ray[default]==1.12.0",
# https://github.com/aio-libs/aiohttp/issues/6203
"aiohttp==3.8.1",
"cloudpickle==2.0.... | 35 | 959 |
hatch | tests/backend/builders/test_sdist.py | .py | import os
import tarfile
import pytest
from hatchling.builders.plugin.interface import BuilderInterface
from hatchling.builders.sdist import SdistBuilder
from hatchling.builders.utils import get_reproducible_timestamp
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION, get_core_metadata_constructors
from ha... | 1,545 | 55,800 |
sqlmap | plugins/dbms/mimersql/takeover.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.exception import SqlmapUnsupportedFeatureException
from plugins.generic.takeover import Takeover as GenericTakeover
class Takeover(GenericTakeover):
def osCmd(s... | 29 | 978 |
beam | sdks/python/apache_beam/ml/inference/vertex_ai_inference_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... | 118 | 4,527 |
textual | tests/test_filters.py | .py | from rich.color import Color as RichColor
from rich.color import ColorType
from rich.segment import Segment
from rich.style import Style
from rich.terminal_theme import MONOKAI
from textual.color import Color
from textual.filter import ANSIToTruecolor
def test_ansi_to_truecolor_8_bit_dim():
"""Test that converti... | 30 | 906 |
probability | tensorflow_probability/python/internal/backend/numpy/config.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... | 38 | 1,175 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/notebook_with_complex_metadata.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: '{{{,}}}'
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
| 12 | 157 |
wandb | tests/unit_tests/test_launch/test_runner/test_sagemaker.py | .py | """Tests for the sagemaker runner."""
from unittest.mock import MagicMock
import pytest
from wandb.sdk.launch.runner.sagemaker_runner import launch_sagemaker_job
@pytest.fixture
def mock_launch_project():
return MagicMock()
@pytest.fixture
def mock_sagemaker_client():
mock_client = MagicMock()
mock_cl... | 67 | 1,803 |
onnxruntime | onnxruntime/python/tools/quantization/quantize.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from __fut... | 1,077 | 60,301 |
mlflow | tests/utils/test_provider_filter.py | .py | import pytest
from mlflow.utils.provider_filter import (
_parse_provider_list,
filter_providers,
is_provider_allowed,
)
@pytest.mark.parametrize(
("input_value", "expected"),
[
(None, frozenset()),
("", frozenset()),
("openai", frozenset({"openai"})),
("openai,anth... | 78 | 2,947 |
openvino | tests/layer_tests/pytorch_tests/test_reflection_pad.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestReflectionPad(PytorchLayerTest):
def _prepare_input(self, n):
return (self.random.randn(*(2, 5, 6, 7, 8)[:n+2]),)
def create_model(self, pa... | 55 | 1,658 |
mlflow | tests/llama_index/test_llama_index_model_export.py | .py | import json
import os
from pathlib import Path
from typing import Any
from unittest import mock
import llama_index.core
import numpy as np
import pandas as pd
import pytest
from llama_index.core import QueryBundle, Settings, VectorStoreIndex
from llama_index.core.base.base_query_engine import BaseQueryEngine
from llam... | 603 | 21,559 |
mlflow | mlflow/tracing/utils/__init__.py | .py | # TODO: Split this file into multiple files and move under utils directory.
from __future__ import annotations
import inspect
import json
import logging
import uuid
from collections import defaultdict
from contextlib import contextmanager
from dataclasses import dataclass, fields, is_dataclass
from functools import lr... | 953 | 35,005 |
astropy | astropy/wcs/tests/test_pickle.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
import pickle
import numpy as np
import pytest
from numpy.testing import assert_array_almost_equal
from astropy import wcs
from astropy.io import fits
from astropy.utils.data import (
get_pkg_data_contents,
get_pkg_data_filename,
g... | 205 | 6,073 |
textual | src/textual/widgets/_rich_log.py | .py | """Provides a scrollable text-logging widget."""
from __future__ import annotations
from collections import deque
from typing import TYPE_CHECKING, NamedTuple, Optional, cast
from rich.console import RenderableType
from rich.highlighter import Highlighter, ReprHighlighter
from rich.measure import measure_renderables... | 321 | 12,192 |
textual | docs/examples/guide/screens/modal02.py | .py | from textual.app import App, ComposeResult
from textual.containers import Grid
from textual.screen import ModalScreen
from textual.widgets import Button, Footer, Header, Label
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit... | 52 | 1,482 |
probability | spinoffs/fun_mc/fun_mc/dynamic/backend_jax/util.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... | 471 | 12,642 |
pyomo | examples/gdp/eight_process/eight_proc_model.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... | 236 | 7,366 |
luigi | test/worker_task_process_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... | 71 | 2,775 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Range.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
class TestRange(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
inputs_data = {}
if self.n... | 57 | 2,243 |
coremltools | coremltools/converters/mil/mil/program.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 collections import defaultdict
from typing import Dict, List, Optional, Union
import numpy as _... | 466 | 18,651 |
pyro | pyro/distributions/transforms/permute.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.distributions.transforms import Transform
from torch.distributions.utils import lazy_property
from pyro.distributions import constraints
from ..util import copy_docs_from
@copy_docs_from(Transform)
class... | 143 | 5,300 |
biopython | Bio/Phylo/PAML/__init__.py | .py | # Copyright (C) 2011 by Brandon Invergo (b.invergo@gmail.com)
#
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been included as part of this
# package.
"""Support for PAML... | 9 | 325 |
pyomo | pyomo/contrib/incidence_analysis/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... | 1,055 | 42,795 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/runinference_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");... | 125 | 6,434 |
probability | tensorflow_probability/python/internal/backend/jax/rewrite.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... | 68 | 2,724 |
returns | returns/interfaces/specific/io.py | .py | from __future__ import annotations
from abc import abstractmethod
from collections.abc import Callable
from typing import TYPE_CHECKING, Never, TypeVar
from returns.interfaces import container, equable
from returns.primitives.hkt import KindN
if TYPE_CHECKING:
from returns.io import IO # noqa: WPS433
_FirstTyp... | 86 | 2,584 |
wandb | tests/unit_tests/test_lib/test_auth_prompt.py | .py | from unittest.mock import MagicMock
import pytest
from wandb.errors import links, term
from wandb.sdk.lib.wbauth import host_url, prompt, saas, validation, wbnetrc
from tests.fixtures.emulated_terminal import EmulatedTerminal
pytestmark = pytest.mark.usefixtures("skip_verify_login")
@pytest.fixture(autouse=True)
d... | 264 | 8,969 |
sqlmap | plugins/dbms/mysql/connector.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
try:
import pymysql
except:
pass
import logging
import struct
from lib.core.common import getSafeExString
from lib.core.data import conf
from lib.core.data import logger... | 72 | 2,094 |
black | tests/data/cases/pep_570.py | .py | def positional_only_arg(a, /):
pass
def all_markers(a, b, /, c, d, *, e, f):
pass
def all_markers_with_args_and_kwargs(
a_long_one,
b_long_one,
/,
c_long_one,
d_long_one,
*args,
e_long_one,
f_long_one,
**kwargs,
):
pass
def all_markers_with_defaults(a, b=1, /, c=2, ... | 45 | 680 |
mlflow | mlflow/demo/generators/traces.py | .py | from __future__ import annotations
import copy
import hashlib
import json
import logging
import random
import re
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from typing import Any, Literal
import mlflow
from mlflow.demo.base import (
DEMO_EXPERIMENT_NAME,
DEMO_PROMPT_P... | 894 | 33,742 |
astropy | astropy/extern/configobj/validate.py | .py | # validate.py
# A Validator object
# Copyright (C) 2005-2014:
# (name) : (email)
# Michael Foord: fuzzyman AT voidspace DOT org DOT uk
# Mark Andrews: mark AT la-la DOT com
# Nicola Larosa: nico AT tekNico DOT net
# Rob Dennis: rdennis AT gmail DOT com
# Eli Courtwright: eli AT courtwright DOT org
# This software is l... | 1,473 | 46,678 |
black | tests/data/cases/comment_after_escaped_newline.py | .py | def bob(): \
# pylint: disable=W9016
pass
def bobtwo(): \
\
# some comment here
pass
# output
def bob(): # pylint: disable=W9016
pass
def bobtwo():
# some comment here
pass
| 21 | 216 |
returns | returns/contrib/mypy/_typeops/transform_callable.py | .py | from types import MappingProxyType
from typing import ClassVar, Final, final
from mypy.nodes import (
ARG_NAMED,
ARG_NAMED_OPT,
ARG_OPT,
ARG_POS,
ARG_STAR,
ARG_STAR2,
ArgKind,
)
from mypy.typeops import get_type_vars
from mypy.types import (
AnyType,
CallableType,
FunctionLike,
... | 279 | 9,476 |
onnxruntime | onnxruntime/test/testdata/test_shape_data_propagation_with_shape_related_nodes_v3.py | .py | import onnx
from onnx import TensorProto, helper
# === Graph input/output ===
input_tensor = helper.make_tensor_value_info("input", TensorProto.FLOAT, ["batch", 3, "width", "height"])
output_tensor = helper.make_tensor_value_info("output", TensorProto.FLOAT, ["batch", 3, "width*height"])
# === Initializers ===
B = he... | 110 | 3,774 |
pyomo | pyomo/contrib/pynumero/interfaces/nlp_projections.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... | 409 | 15,298 |
saleor | saleor/graphql/payment/tests/mutations/test_transaction_event_report.py | .py | import datetime
from decimal import Decimal
from unittest.mock import patch
from uuid import uuid4
import graphene
import pytest
from django.utils import timezone
from freezegun import freeze_time
from .....checkout import CheckoutAuthorizeStatus, CheckoutChargeStatus
from .....checkout.calculations import fetch_chec... | 4,160 | 127,703 |
textual | tests/snapshot_tests/snapshot_apps/hot_reloading_app_with_screen_css.py | .py | from pathlib import Path
from textual.app import App, ComposeResult
from textual.containers import Container
from textual.screen import Screen
from textual.widgets import Label
SCREEN_CSS_PATH = (Path(__file__) / "../hot_reloading_app_with_screen_css.tcss").resolve()
# Write some CSS to the file before the app load... | 42 | 889 |
coremltools | coremltools/converters/mil/frontend/tensorflow2/test/test_v2_load.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 os
import shutil
import tempfile
import pytest
import coremltools.converters as converter
fr... | 285 | 9,970 |
saleor | saleor/order/calculations.py | .py | import logging
from collections.abc import Iterable
from decimal import Decimal
from typing import TYPE_CHECKING, Union
from uuid import UUID
from django.conf import settings
from django.db import transaction
from django.utils import timezone
from prices import Money, TaxedMoney
from promise import Promise
from ..cor... | 1,164 | 40,002 |
coremltools | scripts/build_tag.py | .py | #!/usr/bin/env python
#
# 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
# Construct a valid wheel build tag with ``git describe``.
#
# We do this with p... | 30 | 891 |
probability | discussion/robust_inverse_graphics/util/tree2.py | .py | # Copyright 2024 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 1,105 | 35,550 |
probability | tensorflow_probability/python/bijectors/absolute_value_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... | 71 | 2,931 |
textual | tests/snapshot_tests/snapshot_apps/programmatic_disable_button.py | .py | from textual.app import App, ComposeResult
from textual.containers import Center
from textual.widgets import Button, Footer, Label
class ExampleApp(App):
CSS = """
Screen {
align: center middle;
}
"""
BINDINGS = [("space", "toggle_button", "Toggle Button")]
def compose(self) -> Compo... | 36 | 900 |
onnxruntime | orttraining/orttraining/test/python/_orttraining_ortmodule_models.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# orttraining_test_ortmodule_api.py
import torch
class MyCustomClassInputNet(torch.nn.Module):
def forward(self, x, custom_class_obj):
if custom_class_obj.x == 1:
return x + 1
return x
clas... | 57 | 1,842 |
openvino | tests/layer_tests/onnx_tests/test_neg.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
pytest.importorskip("openvino.tools.mo", reason="Ticket - 157136")
from common.layer_test_class import check_ir_version
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
from unit_tests.utils.... | 96 | 3,225 |
textual | docs/examples/guide/workers/weather05.py | .py | from urllib.parse import quote
from urllib.request import Request, urlopen
from rich.text import Text
from textual import work
from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widgets import Input, Static
from textual.worker import Worker, get_current_worker
clas... | 54 | 1,807 |
astropy | astropy/io/ascii/html.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""An extensible HTML table reader and writer.
html.py:
Classes to read and write HTML tables
`BeautifulSoup <https://www.crummy.com/software/BeautifulSoup/>`_
must be installed to read HTML tables.
"""
import warnings
from copy import deepcopy
from ... | 504 | 18,567 |
astropy | astropy/io/ascii/tests/common.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
from pathlib import Path
__all__ = [
"setup_function",
"teardown_function",
]
CWD = Path.cwd()
TEST_DIR = Path(__file__).parent
def setup_function(function):
os.chdir(TEST_DIR)
def teardown_function(function):
os.chdir(CWD)... | 26 | 443 |
readthedocs.org | readthedocs/proxito/middleware.py | .py | """
Middleware for Proxito.
This is used to take the request and map the host to the proper project slug.
Additional processing is done to get the project from the URL in the ``views.py`` as well.
"""
import re
from urllib.parse import urlparse
import structlog
from corsheaders.middleware import ACCESS_CONTROL_ALLO... | 383 | 16,052 |
mkdocs-material | material/__init__.py | .py | # Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, c... | 22 | 1,148 |
onnxruntime | onnxruntime/test/python/test_pytorch_export_contrib_ops.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# pylint: disable=W0622
"""Test export of PyTorch operators using ONNX Runtime contrib ops."""
import copy
import io
import unittest
import numpy as np
import onnx
import parameterized
import torch
import onnxruntime
from ... | 245 | 8,582 |
rq | rq/utils.py | .py | """
Miscellaneous helper functions.
The formatter for ANSI colored console output is heavily based on Pygments
terminal colorizing code, originally by Georg Brandl.
"""
from __future__ import annotations
import calendar
import datetime
import importlib
import inspect
import json
import logging
import numbers
import ... | 599 | 18,526 |
cvxpy | cvxpy/reductions/solvers/nlp_solvers/diff_engine/registry.py | .py | """
Copyright 2025, 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, s... | 320 | 12,377 |
beam | sdks/python/apache_beam/ml/inference/gemini_inference_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... | 84 | 2,937 |
pyomo | pyomo/contrib/trustregion/TRF.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... | 669 | 23,026 |
astropy | astropy/wcs/wcsapi/fitswcs.py | .py | # This file includes the definition of a mix-in class that provides the low-
# and high-level WCS API to the astropy.wcs.WCS object. We keep this code
# isolated in this mix-in class to avoid making the main wcs.py file too
# long.
import warnings
import numpy as np
import astropy.constants
from astropy import units... | 834 | 32,077 |
astropy | astropy/config/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains configuration and setup utilities for the
Astropy project.
"""
from .configuration import *
from .paths import *
| 10 | 204 |
returns | tests/test_converters/test_flatten.py | .py | import pytest
from returns.context import (
RequiresContext,
RequiresContextFutureResult,
RequiresContextIOResult,
RequiresContextResult,
)
from returns.converters import flatten
from returns.future import Future, FutureResult
from returns.io import IO, IOFailure, IOSuccess
from returns.maybe import No... | 138 | 4,216 |
saleor | saleor/graphql/product/types/collections.py | .py | from collections import defaultdict
import graphene
from graphene import relay
from promise import Promise
from ....core.search import prefix_search
from ....permission.enums import ProductPermissions
from ....product import models
from ....thumbnail.utils import (
get_image_or_proxy_url,
get_thumbnail_format... | 215 | 7,978 |
sphinx | sphinx/pycode/__init__.py | .py | """Utilities parsing and analyzing Python code."""
from __future__ import annotations
import tokenize
from importlib import import_module
from typing import TYPE_CHECKING
from sphinx.errors import PycodeError
from sphinx.pycode.parser import Parser
from sphinx.util._pathlib import _StrPath
if TYPE_CHECKING:
imp... | 171 | 6,156 |
readthedocs.org | readthedocs/projects/exceptions.py | .py | """Project exceptions."""
from readthedocs.doc_builder.exceptions import BuildAppError
from readthedocs.doc_builder.exceptions import BuildUserError
class ProjectConfigurationError(BuildUserError):
"""Error raised trying to configure a project for build."""
NOT_FOUND = "project:sphinx:conf-py-not-found"
... | 34 | 1,247 |
mamba | libmambapy-stubs/setup.py | .py | import os
import sys
import libmambapy
import mypy.stubgen
import setuptools
import setuptools.command.build_py
class build_py(setuptools.command.build_py.build_py):
def run(self):
"""Generate stub files."""
options = mypy.stubgen.Options(
pyversion=sys.version_info[:2],
n... | 49 | 1,314 |
onnxruntime | onnxruntime/test/python/transformers/parity_utilities.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 ar... | 240 | 7,804 |
pyomo | pyomo/contrib/preprocessing/tests/test_deactivate_trivial_constraints.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... | 141 | 5,087 |
mlflow | tests/test_skinny_client_omits_sql_libs.py | .py | import os
import sys
import pytest
@pytest.mark.skipif(
"MLFLOW_SKINNY" not in os.environ, reason="This test is only valid for the skinny client"
)
def test_fails_import_sqlalchemy():
import mlflow # noqa: F401
with pytest.raises(ImportError, match="sqlalchemy"):
import sqlalchemy # noqa: F401... | 30 | 776 |
saleor | saleor/graphql/order/bulk_mutations/order_bulk_cancel.py | .py | from collections.abc import Iterable
from uuid import UUID
import graphene
from ....order import models
from ....order.actions import WEBHOOK_EVENTS_FOR_ORDER_CANCELED, cancel_order
from ....permission.enums import OrderPermissions
from ....webhook.utils import get_webhooks_for_multiple_events
from ...app.dataloaders... | 59 | 2,149 |
probability | tensorflow_probability/python/internal/backend/numpy/_utils.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... | 128 | 4,078 |
beam | learning/tour-of-beam/learning-content/introduction/introduction-concepts/pipeline-concepts/setting-pipeline/python-example/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"); y... | 84 | 2,857 |
mlflow | dev/clint/src/clint/rules/prefer_os_environ.py | .py | import ast
from typing import Literal
from typing_extensions import Self
from clint.resolver import Resolver
from clint.rules.base import Rule
# See https://github.com/astral-sh/ruff/issues/3608
class PreferOsEnviron(Rule):
def __init__(self, func: Literal["getenv", "putenv"]) -> None:
self.func = func
... | 26 | 770 |
mlflow | mlflow/bedrock/_autolog.py | .py | import io
import json
import logging
from typing import Any
from botocore.client import BaseClient
from botocore.response import StreamingBody
import mlflow
from mlflow.bedrock import FLAVOR_NAME
from mlflow.bedrock.chat import convert_tool_to_mlflow_chat_tool
from mlflow.bedrock.stream import ConverseStreamWrapper, ... | 240 | 9,147 |
textual | tests/test_paste.py | .py | from textual import events
from textual.app import App
from textual.widgets import Input
async def test_paste_app():
paste_events = []
class PasteApp(App):
def on_paste(self, event):
paste_events.append(event)
app = PasteApp()
async with app.run_test() as pilot:
app.post_... | 46 | 1,162 |
mlflow | mlflow/models/dependencies_schemas.py | .py | import json
import logging
import warnings
from abc import ABC, abstractmethod
from contextlib import contextmanager
from dataclasses import dataclass, field
from enum import Enum
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from mlflow.models.model import Model
_logger = logging.getLogger(__name__)
... | 298 | 10,208 |
mlflow | mlflow/runs.py | .py | """
CLI for runs
"""
import json
import click
import mlflow
from mlflow import MlflowClient
from mlflow.entities import RunStatus, ViewType
from mlflow.environment_variables import MLFLOW_EXPERIMENT_ID, MLFLOW_EXPERIMENT_NAME
from mlflow.exceptions import MlflowException
from mlflow.mcp.decorator import mlflow_mcp
f... | 253 | 8,060 |
beam | playground/infrastructure/test_ci_cd.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 ... | 54 | 1,854 |
python-prompt-toolkit | src/prompt_toolkit/eventloop/__init__.py | .py | from __future__ import annotations
from .async_generator import aclosing, generator_to_async_generator
from .inputhook import (
InputHook,
InputHookContext,
InputHookSelector,
new_eventloop_with_inputhook,
set_eventloop_with_inputhook,
)
from .utils import (
call_soon_threadsafe,
get_traceb... | 32 | 730 |
openvino | docs/articles_en/assets/snippets/ov_multi.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import openvino as ov
import openvino.properties as properties
import openvino.properties.device as device
import openvino.properties.streams as streams
from utils import get_model
model = get_model()
def MULTI_0():
#! [MULTI_0]
... | 129 | 3,663 |
hydra | tests/test_apps/schema_overrides_hydra/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from typing import Dict
from omegaconf import MISSING
import hydra
from hydra.core.config_store import ConfigStore
from hydra.core.hydra_config import HydraConfig
@dataclass
class Config:
age: int = MISSING
... | 32 | 717 |
saleor | saleor/tests/e2e/orders/discounts/test_order_voucher_specific_product_and_manual_line_discount.py | .py | import pytest
from .....product.tasks import recalculate_discounted_price_for_products_task
from ... import DEFAULT_ADDRESS
from ...product.utils.preparing_product import prepare_product
from ...shop.utils.preparing_shop import prepare_shop
from ...taxes.utils import update_country_tax_rates
from ...utils import assig... | 332 | 12,272 |
coremltools | docs/examples/optimize/torch/pruning/magnitude_pruning.py | .py | # -*- coding: utf-8 -*-
"""
.. _magnitude_pruning_tutorial:
Magnitude Pruning
=================
"""
########################################################################
# In this tutorial, you learn how to train a simple convolutional neural network on
# `MNIST <http://yann.lecun.com/exdb/mnist/>`_ using :py:cla... | 258 | 9,911 |
beam | learning/katas/python/Core Transforms/Combine/CombineFn/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... | 34 | 1,186 |
openvino | tests/e2e_tests/common/postprocessors/semantic_segmentation.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Semantic segmentation postprocessor"""
from .provider import ClassProvider
import numpy as np
import logging as log
class ParseSemanticSegmentation(ClassProvider):
"""Semantic segmentation parser"""
__action_name__ = "parse_... | 32 | 1,128 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.