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 |
|---|---|---|---|---|---|
wandb | tests/unit_tests/test_filters/_strategies.py | .py | """Example generation strategies for generic MongoDB filter tests that rely on `hypothesis`."""
from __future__ import annotations
from string import ascii_letters, digits, punctuation
from typing import Any
from hypothesis.strategies import (
DrawFn,
booleans,
composite,
dictionaries,
fixed_dict... | 130 | 4,309 |
pyomo | doc/OnlineDocs/src/strip_examples.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... | 79 | 2,528 |
astropy | astropy/table/tests/test_pickle.py | .py | import pickle
import numpy as np
from astropy.coordinates import Angle, SkyCoord
from astropy.table import Column, MaskedColumn, QTable, Table
from astropy.table.table_helpers import simple_table
from astropy.time import Time
from astropy.units import Quantity, deg
def test_pickle_column(protocol):
c = Column(
... | 181 | 4,924 |
mlflow | tests/genai/scorers/phoenix/test_models.py | .py | from unittest.mock import Mock, patch
import pytest
from mlflow.exceptions import MlflowException
from mlflow.genai.scorers.phoenix.models import (
MlflowPhoenixModel,
create_phoenix_model,
)
@pytest.fixture
def mock_call_chat_completions():
with patch(
"mlflow.genai.judges.adapters.databricks_m... | 161 | 5,261 |
astropy | astropy/cosmology/_src/funcs/optimize.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Convenience functions for `astropy.cosmology`."""
__all__ = ("z_at_value",)
import warnings
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, NotRequired, Protocol, TypeAlias, TypedDict
import numpy as np
import numpy.typing... | 483 | 19,648 |
python-prompt-toolkit | examples/progress-bar/styled-1.py | .py | #!/usr/bin/env python
"""
A very simple progress bar which keep track of the progress as we consume an
iterator.
"""
import time
from prompt_toolkit.shortcuts import ProgressBar
from prompt_toolkit.styles import Style
style = Style.from_dict(
{
"title": "#4444ff underline",
"label": "#ff4400 bold... | 38 | 863 |
pyro | pyro/contrib/gp/kernels/brownian.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.distributions import constraints
from pyro.contrib.gp.kernels.kernel import Kernel
from pyro.nn.module import PyroParam
class Brownian(Kernel):
r"""
This kernel correponds to a two-sided Brownion ... | 51 | 1,577 |
black | tests/data/cases/type_ignore_with_other_comment.py | .py | import pandas as pd
interval_td = pd.Interval(
pd.Timedelta("1 days"), pd.Timedelta("2 days"), closed="neither"
)
_td = ( # pyright: ignore[reportOperatorIssue,reportUnknownVariableType]
interval_td
- pd.Interval( # type: ignore[operator]
pd.Timedelta(1, "ns"), pd.Timedelta(2, "ns")
)
)
# o... | 28 | 643 |
probability | tensorflow_probability/python/bijectors/iterated_sigmoid_centered_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... | 137 | 5,608 |
loguru | loguru/_datetime.py | .py | import re
from calendar import day_abbr, day_name, month_abbr, month_name
from datetime import datetime as datetime_
from datetime import timedelta, timezone
from functools import lru_cache, partial
from time import localtime, strftime
tokens = r"H{1,2}|h{1,2}|m{1,2}|s{1,2}|S+|YYYY|YY|M{1,4}|D{1,4}|Z{1,2}|zz|A|X|x|E|Q... | 180 | 6,136 |
coremltools | coremltools/converters/mil/backend/mil/test_load.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 itertools
import math
import os
import platform
import shutil
import tempfile
from typing impo... | 1,240 | 49,715 |
openvino | src/bindings/python/tests/test_graph/test_dft.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino import Type
import openvino.opset10 as ov
import numpy as np
import pytest
def build_fft_input_data():
np.random.seed(202104)
return np.random.uniform(0, 1, (2, 10, 10, 2)).astype(np.float3... | 46 | 1,598 |
coremltools | coremltools/optimize/torch/_utils/python_utils.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 logging as _logging
from collections import OrderedDict as _OrderedDict
from typing import IO ... | 122 | 3,781 |
textual | src/textual/widgets/button.py | .py | from textual.widgets._button import ButtonVariant
__all__ = ["ButtonVariant"]
| 4 | 79 |
beam | sdks/python/apache_beam/utils/processes.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... | 108 | 3,973 |
probability | tensorflow_probability/python/distributions/multivariate_student_t.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... | 418 | 15,185 |
readthedocs.org | readthedocs/core/utils/objects.py | .py | # Sentinel value to check if a default value was provided,
# so we can differentiate when None is provided as a default value
# and when it was not provided at all.
_DEFAULT = object()
def get_dotted_attribute(obj, attribute, default=_DEFAULT):
"""
Allow to get nested attributes from an object using a dot not... | 23 | 827 |
black | src/black/cache.py | .py | """Caching of formatted files with feature-based invalidation."""
import hashlib
import os
import pickle
import sys
import tempfile
from collections.abc import Iterable
from dataclasses import dataclass, field
from pathlib import Path
from typing import NamedTuple
from platformdirs import user_cache_dir
from _black_... | 157 | 4,876 |
openvino | tests/layer_tests/pytorch_tests/test_fork_wait.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 TestForkWait(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(10, 20),)
def create_model(self):
cl... | 38 | 1,077 |
openvino | tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import itertools
import warnings
from copy import deepcopy
import os
import torch
import pytest
import logging
import numpy as np
from common.constants import test_device, test_precision
from openvino.frontend.pytorch.ts_decoder import ... | 616 | 25,743 |
sphinx | sphinx/search/_stopwords/sv.py | .py | # automatically generated by utils/generate-snowball.py
# from https://github.com/snowballstem/snowball-website/raw/efb4ae4d65769fb1652acbe608c0c817e746c730/algorithms/swedish/stop.txt
from __future__ import annotations
SWEDISH_STOPWORDS = frozenset({
'alla',
'allt',
'att',
'av',
'blev',
'bli'... | 122 | 1,614 |
biopython | Tests/test_PDB_Exposure.py | .py | # Copyright 2009-2011 by Eric Talevich. All rights reserved.
# Revisions copyright 2009-2013 by Peter Cock. All rights reserved.
# Revisions copyright 2013 Lenna X. Peterson. All rights reserved.
#
# Converted by Eric Talevich from an older unit test copyright 2002
# by Thomas Hamelryck.
#
# Merged related test files... | 128 | 5,228 |
wandb | tests/system_tests/test_functional/asyncio_manager_run/does_not_block_exit.py | .py | """Tests that the asyncio thread is daemon."""
import asyncio
import threading
import time
from wandb.sdk.lib import asyncio_manager
def _avoid_hanging_ci(asyncer: asyncio_manager.AsyncioManager) -> None:
"""Join the asyncio thread if the test takes too long."""
def _join_manager():
# If the test f... | 29 | 717 |
wandb | tests/system_tests/test_artifacts/test_data_types.py | .py | from __future__ import annotations
import time
from collections.abc import Callable
from typing import TYPE_CHECKING, TypeAlias
import matplotlib
import numpy as np
import wandb
from pytest import MonkeyPatch, fixture, mark, raises
from wandb import Api
from wandb.data_types import Table, WBValue
from wandb.sdk.data_... | 570 | 18,850 |
sphinx | sphinx/ext/autodoc/_legacy_class_based/_directive_options.py | .py | from __future__ import annotations
from typing import Any
from sphinx.ext.autodoc._legacy_class_based._sentinels import ALL, EMPTY, SUPPRESS
from sphinx.locale import __
def identity(x: Any) -> Any:
return x
def members_option(arg: Any) -> object | list[str]:
"""Used to convert the :members: option to aut... | 101 | 2,938 |
cvxpy | cvxpy/tests/test_fuzz_reshape.py | .py | """
Copyright, the CVXPY authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
... | 255 | 10,703 |
hydra | tests/test_apps/hydra_verbose/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig
import hydra
@hydra.main(config_path=".", config_name="config")
def my_app(_: DictConfig) -> None:
pass
if __name__ == "__main__":
my_app()
| 14 | 257 |
hydra | examples/plugins/example_configsource_plugin/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from setuptools import find_namespace_packages, setup
with open("README.md") as fh:
LONG_DESC = fh.read()
setup(
name="hydra-example-configsource",
version="1.0.0",
author="Omry Yadan",
author_... | 40 | 1,721 |
mlflow | tests/evaluate/logging/test_evaluation_tag.py | .py | import pytest
from mlflow.evaluation.evaluation_tag import EvaluationTag
def test_evaluation_tag_equality():
tag1 = EvaluationTag(key="tag1", value="value1")
tag2 = EvaluationTag(key="tag1", value="value1")
tag3 = EvaluationTag(key="tag1", value="value2")
tag4 = EvaluationTag(key="tag2", value="value... | 50 | 1,392 |
onnxruntime | orttraining/tools/ci_test/compare_results.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse # noqa: F401
import collections
import csv
import re # noqa: F401
import sys
Comparison = collections.namedtuple("Comparison", ["name", "fn"])
class Comparisons:
@staticmethod
def eq():
re... | 77 | 2,740 |
cvxpy | cvxpy/reductions/solvers/utilities.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... | 88 | 2,824 |
pyro | pyro/infer/reparam/stable.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import torch
import pyro
import pyro.distributions as dist
from pyro.distributions.stable import _standard_stable, _unsafe_standard_stable
from pyro.infer.util import is_validation_enabled
from .reparam import Repara... | 270 | 10,548 |
onnxruntime | onnxruntime/test/testdata/transform/fusion/bias_softmax_gen.py | .py | import onnx
from onnx import OperatorSetIdProto, TensorProto, helper
add = helper.make_node("Add", ["input", "bias"], ["add_out"], "add")
reverseadd = helper.make_node("Add", ["bias", "input"], ["add_out"], "add")
softmax1 = helper.make_node("Softmax", ["add_out"], ["output"], "softmax", axis=1)
softmax3 = helper.make... | 245 | 7,755 |
astropy | astropy/io/fits/hdu/compressed/section.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
from astropy.io.fits.hdu.base import BITPIX2DTYPE
from astropy.io.fits.hdu.compressed._tiled_compression import (
decompress_image_data_section,
)
from astropy.io.fits.hdu.compressed.utils import _n_tiles
from astropy.utils.shapes ... | 132 | 4,598 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_meshgrid.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import numpy as np
import paddle
from save_model import exportModel
def meshgrid():
paddle.disable_static()
@paddle.jit.to_static
def test_model(x, y, z):
return paddle.meshgrid(x, y, z)
... | 26 | 594 |
mlflow | mlflow/metrics/genai/prompt_template.py | .py | import string
from typing import Any
class PromptTemplate:
"""A prompt template for a language model.
A prompt template consists of an array of strings that will be concatenated together. It accepts
a set of parameters from the user that can be used to generate a prompt for a language model.
The tem... | 69 | 2,441 |
saleor | saleor/graphql/order/tests/queries/test_order_tax.py | .py | from decimal import Decimal
from functools import reduce
from operator import getitem
from unittest.mock import patch
import graphene
import pytest
from prices import TaxedMoney
from .....core.prices import quantize_price
from .....core.taxes import zero_taxed_money
from .....order import OrderStatus
from .....order.... | 242 | 6,741 |
conda | conda/models/enums.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Collection of enums used throughout conda."""
import sys
import sysconfig
from enum import Enum
from platform import machine
from ..auxlib.decorators import classproperty
from ..auxlib.ish import dals
from ..auxlib.type_coercion import Type... | 197 | 5,380 |
openvino | tests/e2e_tests/common/preprocessors/provider.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import inspect
import numpy as np
import torch
from e2e_tests.common.common.base_provider import BaseProvider, BaseStepProvider
class ClassProvider(BaseProvider):
registry = {}
@classmethod
def validate(cls):
met... | 51 | 1,644 |
mlflow | examples/tracing/langchain_auto.py | .py | """
This example demonstrates how to enable automatic tracing for LangChain.
Note: this example requires the `langchain` and `langchain-openai` package to be installed.
"""
import json
import os
from langchain.prompts import PromptTemplate
from langchain.schema.output_parser import StrOutputParser
from langchain_ope... | 51 | 1,810 |
sqlmap | plugins/dbms/h2/connector.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.connector import Connector as GenericConnector
class Connector(GenericConnector):
def co... | 16 | 499 |
coremltools | coremltools/converters/mil/mil/passes/defs/optimize_quantization.py | .py | # Copyright (c) 2023, 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 typing import List, Set, Tuple
import numpy as np
from coremltools.converters.mil._deployment_... | 1,246 | 48,006 |
sqlmap | extra/cloak/cloak.py | .py | #!/usr/bin/env python
"""
cloak.py - Simple file encryption/compression utility
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from __future__ import print_function
import os
import struct
import sys
import zlib
from optparse import OptionError
from... | 87 | 2,254 |
confluent-kafka-python | tests/avro/test_message_serializer.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... | 102 | 3,694 |
beam | sdks/python/apache_beam/utils/windowed_value.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... | 459 | 14,551 |
onnxruntime | csharp/tools/MauiModelTester/create_test_data.py | .py | import argparse
import shutil
import sys
from pathlib import Path
import numpy as np
# set to the directory the ONNX Runtime repo is in
# `git checkout https://github.com/microsoft/onnxruntime.git` if needed.
ORT_ROOT_DIR = Path(__file__).parents[3]
SOLUTION_DIR = Path(__file__).parent
# add path for test data/dir g... | 159 | 5,034 |
onnx | onnx/backend/test/case/node/affinegrid.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
from onnx.reference.ops.op_affine_grid import (
apply_affine_transform,
... | 209 | 6,084 |
pyro | pyro/distributions/testing/rejection_gamma.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from pyro.distributions.rejector import Rejector
from pyro.distributions.score_parts import ScoreParts
from pyro.distributions.torch import Beta, Dirichlet, Gamma, Normal
from pyro.distributions.util import copy_docs_... | 234 | 8,842 |
saleor | saleor/webhook/response_schemas/transaction.py | .py | import logging
from datetime import datetime
from decimal import Decimal
from enum import Enum
from typing import Annotated, Any, Literal
from django.conf import settings
from django.utils import timezone
from pydantic import BaseModel, Field, HttpUrl, field_validator
from ...graphql.core.utils import str_to_enum
fro... | 464 | 14,366 |
metrics | src/torchmetrics/segmentation/__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... | 20 | 918 |
pyro | tests/distributions/test_coalescent.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import io
import re
import pytest
import torch
import pyro
from pyro.distributions import CoalescentTimes, CoalescentTimesWithRate
from pyro.distributions.coalescent import (
CoalescentRateLikelihood,
CoalescentTimesConstrain... | 278 | 11,355 |
pyomo | examples/performance/jump/opf_662bus.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... | 350 | 9,655 |
saleor | saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_fully_refunded.py | .py | import json
from unittest.mock import patch
import graphene
from django.test import override_settings
from ......core.models import EventDelivery
from ......graphql.webhook.subscription_query import SubscriptionQuery
from ......webhook.event_types import WebhookEventAsyncType
from .....manager import get_plugins_mana... | 232 | 7,092 |
biopython | Bio/Graphics/__init__.py | .py | # Copyright 2008 by Brad Chapman. All rights reserved.
# Copyright 2008 by Michiel de Hoon. All rights reserved.
# Copyright 2009-2017 by Peter Cock. 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... | 93 | 3,300 |
wandb | tests/unit_tests/test_lib/test_auth_netrc.py | .py | import netrc
import pathlib
import textwrap
import pytest
from wandb.sdk.lib.wbauth import wbnetrc
from tests.fixtures.mock_wandb_log import MockWandbLog
@pytest.fixture
def fake_netrc_path(
monkeypatch: pytest.MonkeyPatch,
tmp_path: pathlib.Path,
) -> pathlib.Path:
path = tmp_path / "test-netrc"
mo... | 230 | 6,530 |
probability | tensorflow_probability/python/distributions/platform_compatibility_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... | 561 | 21,677 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_share_data.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# share_data paddle model generator
#
import numpy as np
import sys
from save_model import saveModel
def share_data(name : str, x, axis=None, keepdim=False):
import paddle
paddle.enable_static()
with paddle.static.progr... | 42 | 1,072 |
mlflow | mlflow/store/artifact/azure_blob_artifact_repo.py | .py | import base64
import datetime
import os
import posixpath
import re
import urllib.parse
from datetime import timezone
from mlflow.entities import FileInfo
from mlflow.entities.multipart_upload import (
CreateMultipartUploadResponse,
MultipartUploadCredential,
)
from mlflow.environment_variables import MLFLOW_AR... | 297 | 13,214 |
hydra | tests/test_apps/app_with_cfg_groups/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any
from omegaconf import DictConfig
import hydra
@hydra.main(config_path="conf", config_name="config")
def my_app(cfg: DictConfig) -> Any:
return cfg
if __name__ == "__main__":
my_app()
| 16 | 291 |
mlflow | mlflow/store/tracking/_secret_cache.py | .py | """
Server-side encrypted cache for secrets management.
Implements time-bucketed ephemeral encryption for cached secrets to provide defense-in-depth
and satisfy CWE-316 (https://cwe.mitre.org/data/definitions/316.html).
Security Model and Limitations:
This cache protects against accidental exposure of secrets in log... | 291 | 11,589 |
sqlmap | plugins/dbms/postgresql/takeover.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import os
from lib.core.common import Backend
from lib.core.common import checkFile
from lib.core.common import decloakToTemp
from lib.core.common import flattenValue
from lib.co... | 177 | 7,486 |
wandb | tools/local_wandb_server.py | .py | """Commands for using a local-testcontainer for testing."""
from __future__ import annotations
import contextlib
import dataclasses
import json
import pathlib
import pprint
import re
import shlex
import subprocess
import sys
import time
import traceback
from collections.abc import Generator
import click
import filel... | 480 | 13,372 |
black | tests/data/cases/remove_parens_from_lhs.py | .py | # Remove unnecessary parentheses from LHS of assignments
def a():
return [1, 2, 3]
# Single variable with unnecessary parentheses
(b) = a()[0]
# Tuple unpacking with unnecessary parentheses
(c, *_) = a()
# These should not be changed - parentheses are necessary
(d,) = a() # single-element tuple
e = (1 + 2) *... | 36 | 709 |
ipython | IPython/terminal/pt_inputhooks/gtk4.py | .py | """
prompt_toolkit input hook for GTK 4.
"""
from gi.repository import GLib
class _InputHook:
def __init__(self, context):
self._quit = False
GLib.io_add_watch(
context.fileno(), GLib.PRIORITY_DEFAULT, GLib.IO_IN, self.quit
)
def quit(self, *args, **kwargs):
self.... | 28 | 557 |
httpie | httpie/cli/exceptions.py | .py | class ParseError(Exception):
pass
| 3 | 38 |
slimit | src/slimit/tests/test_nodevisitor.py | .py | ###############################################################################
#
# Copyright (c) 2011 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, inc... | 38 | 1,564 |
conda | tests/cli/test_main_remove.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import json
from importlib.metadata import version
from logging import getLogger
from typing import TYPE_CHECKING
import pytest
from conda.base.context import context, reset_context
from conda.common.io impo... | 170 | 5,362 |
wagtail | wagtail/contrib/settings/models.py | .py | from django.db import models
from django.utils.functional import cached_property
from django.utils.translation import gettext as _
from wagtail.coreutils import InvokeViaAttributeShortcut
from wagtail.models import Site
from wagtail.permission_policies import ModelPermissionPolicy
from wagtail.permission_policies.site... | 221 | 6,867 |
pyomo | examples/pyomobook/overview-ch/wl_concrete_script.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... | 50 | 1,613 |
wagtail | wagtail/admin/forms/auth.py | .py | from django import forms
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.forms import PasswordChangeForm as DjangoPasswordChangeForm
from django.contrib.auth.forms import PasswordResetForm as DjangoPasswordResetForm
from django.utils.translation import gettext_lazy
class LoginForm(Au... | 82 | 2,758 |
mlflow | mlflow/models/evaluation/utils/metric.py | .py | import logging
from dataclasses import dataclass
from typing import Any, Callable
import numpy as np
from mlflow.metrics.base import MetricValue
from mlflow.models.evaluation.base import EvaluationMetric
_logger = logging.getLogger(__name__)
@dataclass
class MetricDefinition:
"""
A dataclass representing a... | 129 | 4,532 |
hypercorn | src/hypercorn/config.py | .py | from __future__ import annotations
import importlib
import importlib.util
import logging
import os
import socket
import stat
import sys
import types
import warnings
from collections.abc import Mapping
from dataclasses import dataclass
from ssl import (
create_default_context,
OP_NO_COMPRESSION,
Purpose,
... | 411 | 13,419 |
probability | discussion/robust_inverse_graphics/util/math_util_test.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... | 58 | 1,930 |
saleor | saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_checkout_fully_authorized.py | .py | import json
from unittest.mock import patch
import graphene
from django.test import override_settings
from ......core.models import EventDelivery
from ......graphql.webhook.subscription_query import SubscriptionQuery
from ......webhook.event_types import WebhookEventAsyncType
from .....manager import get_plugins_mana... | 248 | 7,550 |
hatch | src/hatch/template/__init__.py | .py | from __future__ import annotations
from contextlib import suppress
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from hatch.utils.fs import Path
class File:
def __init__(self, path: Path | None, contents: str = ""):
self.path = path
self.contents = contents
self.feature = None
... | 34 | 780 |
probability | tensorflow_probability/python/distributions/joint_distribution_coroutine.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... | 373 | 15,971 |
coremltools | coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/functionalize_loops.py | .py | # Copyright (c) 2020, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from coremltools import _logger as logger
from ..basic_graph_ops import (connect_dests, connect_edge... | 470 | 19,047 |
scikit-bio | skbio/diversity/_driver.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.
# --------------------------------------------... | 461 | 16,590 |
pyfilesystem2 | fs/filesize.py | .py | # coding: utf-8
"""Functions for reporting filesizes.
The functions declared in this module should cover the different
usecases needed to generate a string representation of a file size
using several different units. Since there are many standards regarding
file size units, three different functions have been implemen... | 119 | 3,495 |
wagtail | wagtail/images/tests/urls.py | .py | from django.urls import re_path
from wagtail.images.views.serve import SendFileView, ServeView
from wagtail.test import dummy_sendfile_backend
urlpatterns = [
# Format: signature, image_id, filter_spec, filename=None
re_path(
r"^actions/serve/(.*)/(\d*)/(.*)/[^/]*",
ServeView.as_view(action="s... | 39 | 1,182 |
conda | tests/plugins/subcommands/doctor/health_checks/test_environment_txt.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Tests for the environment.txt health check.
Note: env_ok fixture is defined in tests/plugins/subcommands/conftest.py
and shared with health fix tests.
"""
from __future__ import annotations
from typing import TYPE_CHECKING
from conda.base... | 85 | 2,808 |
saleor | saleor/core/db/tests/test_connection.py | .py | from unittest.mock import patch
import pytest
from django.db import connections
from ....graphql.context import SaleorContext
from ....tests.models import Book
from ..connection import (
UnsafeWriterAccessError,
allow_writer,
allow_writer_in_context,
log_writer_usage,
restrict_writer,
)
def test... | 89 | 2,651 |
scikit-bio | skbio/binaries/tests/test_util.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.
# --------------------------------------------... | 67 | 2,430 |
metrics | src/torchmetrics/classification/exact_match.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... | 463 | 20,293 |
sqlmap | lib/request/http2.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
# Native, dependency-free HTTP/2 client (RFC 9113) with HPACK (RFC 7541). Runtime code uses only
# the standard library. The accompanying tests optionally use python-hyper/hpack a... | 1,629 | 64,464 |
onnx | onnx/backend/test/case/node/hardsigmoid.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 HardSigmoid(Base):
@staticmethod
def export() -> None:
... | 40 | 1,256 |
cvxpy | cvxpy/reductions/solvers/conic_solvers/cbc_conif.py | .py | """
Copyright 2016 Sascha-Dominic Schnug
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... | 236 | 8,527 |
cvxpy | cvxpy/tests/nlp_tests/stress_tests_diff_engine/test_normal_cdf.py | .py | """
Copyright, the CVXPY authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
... | 49 | 1,657 |
saleor | saleor/graphql/checkout/tests/mutations/test_checkout_add_promo_code.py | .py | import datetime
from decimal import Decimal
from unittest.mock import ANY, patch
import graphene
import pytest
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from prices import Money
from .....checkout import base_calculations, calculations
from .....chec... | 1,467 | 48,955 |
saleor | saleor/tests/e2e/shop/utils/__init__.py | .py | from .preparing_shop import prepare_default_shop, prepare_shop
from .shop_update_settings import update_shop_settings
__all__ = [
"prepare_shop",
"prepare_default_shop",
"update_shop_settings",
]
| 9 | 209 |
scikit-bio | skbio/sequence/tests/test_alphabet.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.
# --------------------------------------------... | 266 | 11,057 |
black | tests/data/cases/remove_redundant_parens_in_case_guard.py | .py | # flags: --minimum-version=3.10 --line-length=79
match 1:
case _ if (True):
pass
match 1:
case _ if (
True
):
pass
match 1:
case _ if (
# this is a comment
True
):
pass
match 1:
case _ if (
True
# this is a comment
):
... | 115 | 1,486 |
beam | sdks/python/apache_beam/testing/metric_result_matchers.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... | 198 | 6,940 |
kafka | tests/kafkatest/services/streams.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 ... | 811 | 35,786 |
probability | tensorflow_probability/python/experimental/stats/sample_stats_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... | 352 | 14,023 |
probability | tensorflow_probability/python/distributions/truncated_normal.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... | 401 | 16,095 |
sphinx | sphinx/domains/changeset.py | .py | """The changeset domain."""
from __future__ import annotations
from typing import TYPE_CHECKING, NamedTuple
from docutils import nodes
from sphinx import addnodes
from sphinx.domains import Domain
from sphinx.locale import _
from sphinx.util.docutils import SphinxDirective
if TYPE_CHECKING:
from collections.ab... | 193 | 6,295 |
gunicorn | tests/requests/invalid/rfc9110_trailer_forbidden_cl_01.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# RFC 9110 section 6.5.1: Content-Length in trailers is a classic
# smuggling vector; origin must reject.
from gunicorn.http.errors import InvalidHeaderName
request = InvalidHeaderName
| 9 | 291 |
textual | docs/examples/widgets/sparkline_colors.py | .py | from math import sin
from textual.app import App, ComposeResult
from textual.widgets import Sparkline
class SparklineColorsApp(App[None]):
CSS_PATH = "sparkline_colors.tcss"
def compose(self) -> ComposeResult:
nums = [abs(sin(x / 3.14)) for x in range(0, 360 * 6, 20)]
yield Sparkline(nums, s... | 27 | 979 |
kafka | tests/kafkatest/tests/streams/utils/util.py | .py | # 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
# distributed under the Li... | 44 | 2,097 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.