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 |
|---|---|---|---|---|---|
metrics | src/torchmetrics/functional/retrieval/precision_recall_curve.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... | 101 | 4,037 |
onnx | onnx/reference/ops/op_conv_transpose.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
from onnx.reference.ops.op_col2im import col2im_naive_implementation
class ConvTranspose(OpRun):
def _run(
self,
X,
... | 140 | 5,166 |
sphinx | sphinx/ext/githubpages.py | .py | """To publish HTML docs at GitHub Pages, create .nojekyll file."""
from __future__ import annotations
import urllib.parse
from typing import TYPE_CHECKING
import sphinx
if TYPE_CHECKING:
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
from sphinx.util.typing import ... | 59 | 1,983 |
metrics | src/torchmetrics/functional/classification/logauc.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... | 357 | 17,864 |
coveragepy | lab/pick.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""
Pick lines from the standard input. Blank or commented lines are ignored.
Used to subset lists of tests to run. Use with the --select-cmd pytest plugin
opt... | 73 | 1,799 |
openvino | src/frontends/tensorflow/tests/test_models/gen_scripts/generate_saved_model_with_gather.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import tensorflow as tf
# This test model aims to cover conversion of SavedModel with integer input types
class ModelWithGather(tf.Module):
def __init__(self):
super(ModelWithGather, self).__init__()
... | 24 | 743 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_ReverseV2.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shape': [1], 'axis': [-1]},
{'shape': [1], 'axis': [0]},
{'shape': [2, 6], 'axis': [-1, -2]},
{'shape': [2, 6], 'axis': [1]},
{'shape': [2, 4, 6], 'axis': [0, -2]},
{'shape': [2, ... | 44 | 1,671 |
sphinx | sphinx/ext/autodoc/_directive.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from docutils import nodes
from sphinx.ext.autodoc._directive_options import _process_documenter_options
from sphinx.ext.autodoc._generate import _auto_document_object
from sphinx.ext.autodoc._shared import LOGGER, _AutodocAttrGetter, _AutodocConfig... | 119 | 4,317 |
beam | sdks/python/apache_beam/io/filesystem_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 "L... | 591 | 21,336 |
pyomo | examples/dae/run_distill.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... | 60 | 2,005 |
beam | sdks/python/apache_beam/runners/interactive/dataproc/dataproc_cluster_manager.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... | 367 | 14,573 |
returns | tests/test_unsafe/test_unsafe_perform_io.py | .py | from returns.io import IO
from returns.unsafe import unsafe_perform_io
def test_unsafe_perform_io():
"""Ensures that unsafe_perform_io returns the object itself."""
id_object = object()
assert unsafe_perform_io(IO(id_object)) is id_object
| 9 | 253 |
lemur | lemur/roles/service.py | .py | """
.. module: service
:platform: Unix
:synopsis: This module contains all of the services level functions used to
administer roles in Lemur
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.... | 163 | 3,772 |
python-dotenv | tests/test_zip_imports.py | .py | import os
import posixpath
import subprocess
import sys
import textwrap
from typing import List
from unittest import mock
from zipfile import ZipFile
def walk_to_root(path: str):
last_dir = None
current_dir = path
while last_dir != current_dir:
yield current_dir
parent_dir = posixpath.dirn... | 110 | 2,864 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_MatrixDiag.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shape': [3]},
{'shape': [1, 22]},
{'shape': [1, 1, 8]},
{'shape': [1, 22, 22, 8]},
{'shape': [1, 22, 22, 8, 3]},
]
class TestTFLiteMatrixDiagLayerTest(TFLiteLayerTest):
inputs =... | 35 | 1,160 |
openvino | tests/e2e_tests/common/env_utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Utility module with config environment utilities."""
import os
def fix_path(path, root_path=None):
"""
Fix path: expand environment variables if any, make absolute path from
root_path/path if path is relative, resolve s... | 32 | 1,088 |
mlflow | mlflow/pydantic_ai/utils.py | .py | import logging
from dataclasses import asdict, is_dataclass
from typing import Any
from mlflow.tracing.constant import TokenUsageKey
_logger = logging.getLogger(__name__)
_SAFE_PRIMITIVE_TYPES = (str, int, float, bool)
def is_safe_for_serialization(value: Any) -> bool:
if value is None:
return False
... | 115 | 4,364 |
lemur | lemur/plugins/lemur_acme/route53.py | .py | import time
from lemur.plugins.lemur_aws.sts import sts_client
@sts_client("route53")
def wait_for_dns_change(change_id, client=None):
_, change_id = change_id
while True:
response = client.get_change(Id=change_id)
if response["ChangeInfo"]["Status"] == "INSYNC":
return
t... | 136 | 4,462 |
astropy | astropy/nddata/mixins/ndslicing.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module implements the Slicing mixin to the NDData class.
from astropy import log
from astropy.wcs.wcsapi import (
BaseHighLevelWCS, # noqa: F401
BaseLowLevelWCS, # noqa: F401
HighLevelWCSWrapper,
SlicedLowLevelWCS,
)
__all__ = [... | 141 | 4,498 |
conda | conda/testing/integration.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
These helpers were originally defined in tests/test_create.py,
but were refactored here so downstream projects can benefit from
them too.
"""
from __future__ import annotations
import os
import sys
from logging import getLogger
from os.pat... | 133 | 4,037 |
luigi | examples/foo.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... | 60 | 1,463 |
pdm | tests/fixtures/projects/demo_extras/setup.py | .py | from setuptools import setup
setup(
name="demo-extras",
version="0.0.1",
description="test demo",
py_modules=["demo"],
install_requires=[],
extras_require={"extra1": ["requests[security]"], "extra2": ["requests[socks]"]},
)
| 12 | 250 |
omegaconf | tests/interpolation/built_in_resolvers/test_oc_select.py | .py | from dataclasses import dataclass
from typing import Any
from pytest import mark, raises
from omegaconf import SI, OmegaConf
from omegaconf.errors import InterpolationKeyError
def test_oc_select_abs() -> None:
cfg = OmegaConf.create(
{
"a0": "${k}",
"a1": "${oc.select:k}",
... | 155 | 3,527 |
openvino | tests/layer_tests/pytorch_tests/test_mean.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestMean(PytorchLayerTest):
def _prepare_input(self, use_out, keep_dim, axis, dtype):
import numpy as np
if keep_dim is None:
ke... | 103 | 4,538 |
lemur | lemur/destinations/views.py | .py | """
.. module: lemur.destinations.views
:platform: Unix
:synopsis: This module contains all of the accounts view code.
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
from flask import B... | 451 | 15,141 |
openvino | tests/model_hub_tests/tensorflow/conftest.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import inspect
from models_hub_common.utils import get_params
def pytest_generate_tests(metafunc):
test_gen_attrs_names = list(inspect.signature(get_params).parameters)
params = get_params()
metafunc.parametrize(test_gen_a... | 12 | 357 |
pyomo | pyomo/repn/tests/ampl/test_suffixes.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... | 223 | 8,194 |
openvino | tests/layer_tests/pytorch_tests/test_fp16.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestBF16(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(10),)
def create_model(self):
class aten_... | 58 | 1,828 |
lemur | lemur/plugins/lemur_aws/elb.py | .py | """
.. module: lemur.plugins.lemur_aws.elb
:synopsis: Module contains some often used and helpful classes that
are used to deal with ELBs
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
import botocore
from celery.exceptions import SoftTimeLimitExceeded
from flask import current_app
from retrying im... | 492 | 15,207 |
readthedocs.org | readthedocs/config/tests/test_validation.py | .py | from pytest import raises
from readthedocs.config.exceptions import ConfigValidationError
from readthedocs.config.validation import (
validate_bool,
validate_choice,
validate_list,
validate_path,
validate_string,
)
class TestValidateBool:
def test_it_accepts_true(self):
assert validat... | 113 | 3,758 |
beam | sdks/python/apache_beam/ml/rag/chunking/base_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... | 139 | 4,569 |
mlflow | tests/genai/judges/optimizers/test_simba.py | .py | from importlib import reload
from unittest.mock import MagicMock, patch
import dspy
import pytest
from mlflow.exceptions import MlflowException
from mlflow.genai.judges.optimizers import SIMBAAlignmentOptimizer
def test_dspy_optimize_no_dspy():
# Since dspy import is now at module level, we need to test this di... | 113 | 4,620 |
coremltools | coremltools/test/ml_program/__init__.py | .py | # Copyright (c) 2022, 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 | 4 | 214 |
sqlmap | tamper/plus2fnconcat.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import os
import re
from lib.core.common import singleTimeWarnMessage
from lib.core.common import zeroDepthSearch
from lib.core.compat import xrange
from lib.core.enums import DB... | 65 | 2,249 |
coremltools | coremltools/optimize/torch/_utils/transforms.py | .py | # Copyright (c) 2024, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import operator as _operator
from abc import ABC as _ABC
from abc import abstractmethod as _abstractm... | 1,189 | 38,536 |
probability | tensorflow_probability/python/distributions/multinomial.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... | 448 | 17,690 |
textual | src/textual/_cells.py | .py | from typing import Callable
from textual.expand_tabs import get_tab_widths
__all__ = ["cell_len", "cell_width_to_column_index"]
cell_len: Callable[[str], int]
try:
from rich.cells import cached_cell_len as cell_len
except ImportError:
from rich.cells import cell_len
def cell_width_to_column_index(line: st... | 45 | 1,416 |
black | tests/data/cases/preview_hug_parens_with_type_ignore.py | .py | # flags: --unstable
# A `type: ignore` is recorded per line by the AST, so hugging must not join two
# of them onto one line.
foo( # type:ignore
[ # type:ignore
a
]
)
items = [ # type: ignore
( # type: ignore
{"key1": "val1", "key2": "val2", "key3": "val3"}
if some_var == "longs... | 59 | 1,235 |
saleor | saleor/graphql/plugins/tests/conftest.py | .py | import pytest
@pytest.fixture
def staff_api_client_can_manage_plugins(staff_api_client, permission_manage_plugins):
staff_api_client.user.user_permissions.add(permission_manage_plugins)
return staff_api_client
| 8 | 220 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_UnaryOps.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import platform
import pytest
import sys
from common.tf_layer_test_class import CommonTFLayerTest
class TestUnaryOps(CommonTFLayerTest):
current_op_type = None
def _prepare_input(self, inputs_dict):
... | 198 | 8,056 |
pymc | pymc/distributions/moments/__init__.py | .py | # Copyright 2024 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 20 | 738 |
coremltools | coremltools/converters/mil/mil/ops/defs/iOS16/tensor_transformation.py | .py | # Copyright (c) 2022, 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-Clausefrom coremltools.converters.mil.mil import types
import numpy as np
from coremltools.converters.mil.m... | 187 | 6,965 |
metrics | tests/unittests/_helpers/__init__.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... | 43 | 1,585 |
readthedocs.org | readthedocs/search/api/v3/tests/test_api.py | .py | import itertools
from unittest import mock
import pytest
from django.contrib.auth.models import User
from django.core.management import call_command
from django.test import TestCase, override_settings
from django.urls import reverse
from django_dynamic_fixture import get
from readthedocs.builds.models import Version
... | 951 | 36,314 |
mlflow | mlflow/utils/warnings_utils.py | .py | import warnings
# ANSI escape code
ANSI_BASE = "\033["
COLORS = {
"default_bold": f"{ANSI_BASE}1m",
"red": f"{ANSI_BASE}31m",
"red_bold": f"{ANSI_BASE}1;31m",
"yellow": f"{ANSI_BASE}33m",
"yellow_bold": f"{ANSI_BASE}1;33m",
"blue": f"{ANSI_BASE}34m",
"blue_bold": f"{ANSI_BASE}1;34m",
}
RESE... | 26 | 627 |
pyomo | pyomo/contrib/observer/component_collector.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... | 121 | 4,080 |
metrics | src/torchmetrics/functional/image/ssim.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... | 530 | 21,695 |
luigi | test/contrib/s3_test.py | .py | # -*- coding: utf-8 -*-
#
# Copyright (c) 2013 Mortar Data
#
# 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... | 644 | 25,981 |
wandb | wandb/apis/_generated/get_sweep_legacy.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/api/
from __future__ import annotations
from wandb._pydantic import GQLResult
from .fragments import LegacySweepFragment
class GetSweepLegacy(GQLResult):
project: GetSweepLegacyProject | None
class GetSweepLegacyProject(GQLResult):
sweep: Leg... | 21 | 415 |
textual | docs/examples/guide/actions/actions03.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Static
TEXT = """
[b]Set your background[/b]
[@click=app.set_background('red')]Red[/]
[@click=app.set_background('green')]Green[/]
[@click=app.set_background('blue')]Blue[/]
"""
class ActionsApp(App):
def compose(self) -> ComposeResult:
... | 23 | 512 |
saleor | saleor/graphql/discount/types/discounts.py | .py | from typing import TypeVar
import graphene
from django.db.models.base import Model
from graphene import relay
from ....core.prices import quantize_price
from ....discount import models
from ....permission.enums import OrderPermissions
from ...core import ResolveInfo
from ...core.doc_category import DOC_CATEGORY_ORDER... | 114 | 3,455 |
deap | doc/code/tutorials/part_3/3_6_2_tool_decoration.py | .py | from deap import base
from deap import creator
from deap import tools
toolbox = base.Toolbox()
MIN, MAX = -5, 5
def checkBounds(min, max):
def decorator(func):
def wrapper(*args, **kargs):
offspring = func(*args, **kargs)
for child in offspring:
for i in range(len(c... | 27 | 771 |
returns | tests/test_context/test_requires_context_ioresult/test_requires_context_ioresult_bind.py | .py | from returns.context import RequiresContext, RequiresContextResult
from returns.context import RequiresContextIOResult as RCR # noqa: N814
from returns.io import IOFailure, IOResult, IOSuccess
from returns.result import Failure, Result, Success
def test_bind():
"""Ensures that bind works."""
def factory(inn... | 123 | 3,869 |
probability | tensorflow_probability/python/mcmc/eight_schools_hmc_graph_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... | 27 | 1,029 |
onnxruntime | onnxruntime/test/python/transformers/test_mha_flash_attn.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 o... | 447 | 14,874 |
saleor | saleor/graphql/checkout/tests/benchmark/test_homepage.py | .py | from decimal import Decimal
from unittest.mock import patch
import pytest
from django.utils import timezone
from .....checkout.delivery_context import assign_shipping_method_to_checkout
from .....checkout.models import CheckoutDelivery
from .....webhook.transport.shipping_helpers import to_shipping_app_id
from ....te... | 291 | 6,780 |
python-prompt-toolkit | examples/print-text/print-frame.py | .py | #!/usr/bin/env python
"""
Example usage of 'print_container', a tool to print
any layout in a non-interactive way.
"""
from prompt_toolkit.shortcuts import print_container
from prompt_toolkit.widgets import Frame, TextArea
print_container(
Frame(
TextArea(text="Hello world!\n"),
title="Stage: pars... | 16 | 332 |
onnxruntime | onnxruntime/python/tools/microbench/softmax.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 59 | 1,756 |
slimit | src/slimit/tests/test_parser.py | .py | ###############################################################################
#
# Copyright (c) 2011-2012 Ruslan Spivak
#
# 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... | 244 | 5,995 |
wagtail | wagtail/api/v2/views.py | .py | from collections import OrderedDict
import swapper
from django.apps import apps
from django.conf import settings
from django.core.exceptions import FieldDoesNotExist
from django.http import Http404
from django.shortcuts import redirect
from django.urls import path, reverse
from django.utils.functional import classprop... | 615 | 20,535 |
wandb | wandb/apis/_generated/__init__.py | .py | # Generated by ariadne-codegen
__all__ = [
"CREATE_INVITE_GQL",
"CREATE_PROJECT_GQL",
"CREATE_SERVICE_ACCOUNT_GQL",
"CREATE_TEAM_GQL",
"CREATE_USER_FROM_ADMIN_GQL",
"DELETE_API_KEY_GQL",
"DELETE_INVITE_GQL",
"GENERATE_API_KEY_GQL",
"GET_AGENT_RUNS_GQL",
"GET_DEFAULT_ENTITY_GQL",... | 123 | 3,170 |
probability | tensorflow_probability/python/distributions/batch_reshape.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... | 631 | 25,490 |
luigi | test/local_target_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... | 358 | 11,343 |
jupytext | tests/functional/docs/test_changelog.py | .py | import re
import sys
from pathlib import Path
import pytest
from jupytext.version import __version__
def replace_issue_number_with_links(text):
return re.sub(
r"([^\[-])#([0-9]+)",
r"\1[#\2](https://github.com/mwouts/jupytext/issues/\2)",
text,
)
@pytest.mark.parametrize(
"input... | 75 | 2,371 |
openvino | tests/layer_tests/pytorch_tests/test_data.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 Model(torch.nn.Module):
def forward(self, x):
return x.data
class ModelGrad(torch.nn.Module):
def forward(self... | 67 | 2,483 |
saleor | saleor/graphql/product/bulk_mutations/product_variant_stocks_update.py | .py | from collections import defaultdict
import graphene
from django.core.exceptions import ValidationError
from ....core.tracing import traced_atomic_transaction
from ....core.utils.events import call_event
from ....permission.enums import ProductPermissions
from ....product import models
from ....warehouse import models... | 238 | 9,547 |
conda | tests/plugins/subcommands/doctor/test_cli.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from typing import TYPE_CHECKING
from conda.base.context import context
from conda.exceptions import EnvironmentLocationNotFound
if TYPE_CHECKING:
from pytest_mock import MockerFixture
from conda.te... | 166 | 5,218 |
readthedocs.org | readthedocs/builds/constants_docker.py | .py | """
Define constants here to allow import them without any external dependency.
There are situations where we want to have access to these values without Django installed
(e.g. common/dockerfiles/tasks.py)
Note these constants where previously defined as Django settings in ``readthedocs/settings/base.py``.
"""
DOCKE... | 111 | 4,097 |
wagtail | wagtail/documents/views/bulk_actions/add_tags.py | .py | from django import forms
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ngettext
from wagtail.admin import widgets
from wagtail.documents.views.bulk_actions.document_bulk_action import DocumentBulkAction
class TagForm(forms.Form):
tags = forms.Field(label=_("Tags"), w... | 45 | 1,546 |
saleor | saleor/product/tests/test_product_availability.py | .py | import datetime
from decimal import Decimal
import pytest
from django.utils import timezone
from freezegun import freeze_time
from prices import Money, TaxedMoney, TaxedMoneyRange
from ...tax import TaxCalculationStrategy
from .. import models
from ..utils.availability import get_product_availability
def test_avail... | 504 | 17,183 |
textual | docs/examples/app/widgets02.py | .py | from textual.app import App
from textual.widgets import Welcome
class WelcomeApp(App):
def on_key(self) -> None:
self.mount(Welcome())
def on_button_pressed(self) -> None:
self.exit()
if __name__ == "__main__":
app = WelcomeApp()
app.run()
| 16 | 277 |
conda | tests/cli/test_main_env_update.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from conda.exceptions import InvalidInstaller
from .test_main_env_create import DummyExternalPackagesEnvSpecPlugin
if TYPE_CHECKING:
from pathlib import P... | 32 | 991 |
wandb | wandb/sdk/data_types/helper_types/classes.py | .py | from __future__ import annotations
import os
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any
from .. import _dtypes
from ..base_types.media import Media
if TYPE_CHECKING: # pragma: no cover
from wandb.sdk.artifacts.artifact import Artifact
from ...wandb_run import Run as LocalRun... | 163 | 5,496 |
saleor | saleor/graphql/attribute/tests/mutations/test_attribute_value_update.py | .py | import json
from unittest import mock
import graphene
import pytest
from django.utils.functional import SimpleLazyObject
from django.utils.text import slugify
from freezegun import freeze_time
from .....attribute.error_codes import AttributeErrorCode
from .....attribute.tests.model_helpers import (
get_product_at... | 794 | 25,194 |
ipython | IPython/utils/coloransi.py | .py | # Deprecated/should be removed, but we break older version of ipyparallel
# https://github.com/ipython/ipyparallel/pull/924
# minimal subset of TermColors, removed from IPython
# not for public consumption, beyond ipyparallel.
class TermColors:
Normal = "\033[0m"
Red = "\033[0;31m"
| 10 | 293 |
onnx | onnx/reference/ops/op_random_normal.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from onnx.reference.ops._op_common_random import _CommonRandom
class RandomNormal(_CommonRandom):
def _run(self, dtype=None, mean=None, scale=None, seed=None, shape=None):
state = self._get... | 17 | 512 |
conda | tests/common/test_yaml_deferred_imports.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Verify that importing conda.common.serialize.yaml does not eagerly load ruamel.yaml."""
from __future__ import annotations
import subprocess
import sys
import textwrap
import pytest
from conda.common.serialize import yaml
def test_yaml_... | 82 | 2,469 |
probability | discussion/robust_inverse_graphics/probnerf.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... | 382 | 10,873 |
mlflow | dev/clint/tests/rules/test_unnamed_thread.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 UnnamedThread
def test_unnamed_thread(index: SymbolIndex) -> None:
code = """
import threading
# Bad
threading.Thread(target=lambda: None)
# G... | 24 | 630 |
coremltools | deps/pybind11/tests/test_buffers.py | .py | from __future__ import annotations
import ctypes
import io
import struct
import pytest
import env
from pybind11_tests import ConstructorStats
from pybind11_tests import buffers as m
np = pytest.importorskip("numpy")
if m.long_double_and_double_have_same_size:
# Determined by the compiler used to build the pybi... | 231 | 7,160 |
wagtail | wagtail/admin/views/generic/history.py | .py | from collections import defaultdict
from datetime import timedelta
import django_filters
from django.contrib.admin.utils import quote
from django.forms import CheckboxSelectMultiple
from django.shortcuts import get_object_or_404
from django.urls import reverse
from django.utils.functional import cached_property
from d... | 624 | 21,523 |
wandb | wandb/proto/wandb_sync_pb2.py | .py | import google.protobuf
protobuf_version = google.protobuf.__version__[0]
if protobuf_version == "5":
from wandb.proto.v5.wandb_sync_pb2 import *
elif protobuf_version == "6":
from wandb.proto.v6.wandb_sync_pb2 import *
elif protobuf_version == "7":
from wandb.proto.v7.wandb_sync_pb2 import *
| 11 | 307 |
sqlmap | plugins/dbms/sqlite/filesystem.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.filesystem import Filesystem as GenericFilesystem
class Filesystem(GenericFilesystem):
d... | 19 | 670 |
pyomo | pyomo/contrib/pynumero/linalg/tests/test_mumps_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... | 75 | 2,748 |
scikit-bio | skbio/stats/composition/_utils.py | .py | # ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# --------------------------------------------... | 310 | 9,028 |
openvino | src/bindings/python/tests/test_graph/test_sparse_fill_empty_rows.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino import Type
from openvino.opset15 import parameter
import openvino.opset16 as ov
import pytest
@pytest.mark.parametrize("values_dtype", [
Type.f32,
Type.f16,
Type.i32
])
@pytest.mark.pa... | 43 | 1,583 |
coveragepy | lab/show_pyc.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""
Dump the contents of a .pyc file.
The output will only be correct if run with the same version of Python that
produced the .pyc.
"""
import binascii
import... | 218 | 6,827 |
sqlmap | plugins/dbms/cache/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 jaydebeapi
import jpype
except:
pass
import logging
from lib.core.common import checkFile
from lib.core.common import getSafeExString
from lib.core.commo... | 79 | 2,447 |
hydra | plugins/hydra_optuna_sweeper/example/sphere.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import hydra
from omegaconf import DictConfig
@hydra.main(config_path="conf", config_name="config")
def sphere(cfg: DictConfig) -> float:
x: float = cfg.x
y: float = cfg.y
if cfg.get("error", False):
raise RuntimeError("cfg.er... | 19 | 400 |
onnx | onnx/backend/test/case/node/scatter.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import Any
import numpy as np
import onnx
from onnx import helper
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
# The below Scatter's numpy ... | 110 | 3,398 |
openvino | tests/layer_tests/ovc_python_api_tests/telemetry/test_pytorch_telemetry.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import unittest
from unittest.mock import MagicMock, patch
import openvino_telemetry as tm
import torch
from openvino.tools.ovc import convert_model
def arange_pt_model():
class aten_arange_end_dtype(torch.nn.Module):
def... | 48 | 1,513 |
mlflow | tests/server/jobs/test_utils.py | .py | import os
import pytest
from mlflow.exceptions import MlflowException
from mlflow.server.jobs.utils import _load_function, _validate_function_parameters
pytestmark = pytest.mark.skipif(
os.name == "nt", reason="MLflow job execution is not supported on Windows"
)
def test_validate_function_parameters():
def... | 137 | 4,882 |
clearml | clearml/backend_api/services/v2_20/tasks.py | .py | """
tasks service
Provides a management API for tasks in the system.
"""
from typing import List, Optional, Any
import six
from datetime import datetime
import enum
from dateutil.parser import parse as parse_datetime
from clearml.backend_api.session import (
Request,
BatchRequest,
Response,
NonStrictDa... | 12,747 | 446,657 |
qutip | qutip/core/properties.py | .py | from . import Qobj, QobjEvo
__all__ = [
'isbra', 'isket', 'isoper', 'issuper', 'isoperbra', 'isoperket', 'isherm'
]
def isbra(x: Qobj | QobjEvo) -> bool:
return isinstance(x, (Qobj, QobjEvo)) and x.type in ['bra', 'scalar']
def isket(x: Qobj | QobjEvo) -> bool:
return isinstance(x, (Qobj, QobjEvo)) and... | 36 | 966 |
clearml | clearml/binding/jsonargs_bind.py | .py | import copy
import json
import logging
from typing import Optional, Callable, Tuple, Union, List, Dict, TYPE_CHECKING, Any
try:
# public import capabilities of namespace, util, actions will be deprecated
# import from "protected" instead
from jsonargparse._namespace import Namespace
# noinspection Py... | 318 | 14,095 |
coremltools | coremltools/test/sklearn_tests/test_glm_classifier.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 itertools
import random
import unittest
import pandas as pd
from coremltools._deps import _HAS_... | 113 | 4,400 |
mlflow | mlflow/demo/base.py | .py | import logging
from abc import ABC, abstractmethod
from dataclasses import dataclass
from enum import Enum
from mlflow.tracking._tracking_service.utils import _get_store
_logger = logging.getLogger(__name__)
DEMO_EXPERIMENT_NAME = "MLflow Demo"
DEMO_PROMPT_PREFIX = "mlflow-demo"
class DemoFeature(str, Enum):
"... | 136 | 4,746 |
wagtail | wagtail/tests/test_page_model.py | .py | import datetime
import json
import unittest
from unittest.mock import Mock
import swapper
from asgiref.sync import async_to_sync
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import AnonymousUser, Group
from django.contrib.contenttypes.models import Con... | 4,423 | 180,529 |
black | tests/data/cases/type_params.py | .py | # flags: --minimum-version=3.12
def func [T ](): pass
async def func [ T ] (): pass
class C[ T ] : pass
def all_in[T : int,U : (bytes, str),* Ts,**P](): pass
def really_long[WhatIsTheLongestTypeVarNameYouCanThinkOfEnoughToMakeBlackSplitThisLine](): pass
def even_longer[WhatIsTheLongestTypeVarNameYouCanThinkOf... | 102 | 1,763 |
saleor | saleor/graphql/order/mutations/fulfillment_cancel.py | .py | from typing import cast
import graphene
from django.core.exceptions import ValidationError
from ....account.models import User
from ....giftcard.utils import order_has_gift_card_lines
from ....order import FulfillmentStatus
from ....order.actions import cancel_fulfillment
from ....order.error_codes import OrderErrorC... | 133 | 4,918 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.