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 |
|---|---|---|---|---|---|
mlflow | examples/gateway/uc_functions/run.py | .py | import argparse
import json
import openai
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--uc-function-name",
type=str,
required=True,
help="Name of the UC function to use",
)
return parser.parse_args()
def main():
args = parse_args()
... | 114 | 2,884 |
openvino | tests/layer_tests/jax_tests/test_logistic.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import jax
import numpy as np
import pytest
from jax import numpy as jnp
from jax_layer_test_class import JaxLayerTest
rng = np.random.default_rng(5402)
class TestLogistic(JaxLayerTest):
def _prepare_input(self):
input =... | 38 | 1,130 |
textual | docs/examples/guide/actions/actions07.py | .py | from textual.app import App, ComposeResult
from textual.containers import HorizontalScroll
from textual.reactive import reactive
from textual.widgets import Footer, Placeholder
PAGES_COUNT = 5
class PagesApp(App):
BINDINGS = [
("n", "next", "Next"),
("p", "previous", "Previous"),
]
CSS_P... | 45 | 1,288 |
onnxruntime | tools/python/wgsl_template/test/test_in_tree_smoke.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Golden tests against the real in-tree wgsl.template files.
These templates back shipped WebGPU operators (Pad, Transpose,
im2col-matmul, and others under core/providers/webgpu). The generated
C++ is compared against a comm... | 110 | 3,734 |
sqlmap | tamper/decentities.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.enums import PRIORITY
__priority__ = PRIORITY.LOWEST
def dependencies():
pass
def tamper(payload, **kwargs):
"""
HTML encode in decimal (using code po... | 34 | 682 |
pyro | examples/air/air.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
An implementation of the model described in [1].
[1] Eslami, SM Ali, et al. "Attend, infer, repeat: Fast scene
understanding with generative models." Advances in Neural Information
Processing Systems. 2016.
"""
from collectio... | 410 | 14,031 |
textual | tests/snapshot_tests/snapshot_apps/notification_with_inline_link.py | .py | from textual.app import App
class NotifyWithInlineLinkApp(App):
def on_mount(self) -> None:
self.notify("Click [@click=bell]here[/] for the bell sound.")
if __name__ == "__main__":
app = NotifyWithInlineLinkApp()
app.run()
| 12 | 247 |
mlflow | mlflow/store/db_migrations/versions/5b0e9adcef9c_add_cascade_deletion_to_trace_tables_fk.py | .py | """add cascade deletion to trace tables foreign keys
Create Date: 2024-05-22 17:44:24.597019
"""
from alembic import op
from mlflow.store.tracking.dbmodels.models import SqlTraceInfo, SqlTraceMetadata, SqlTraceTag
# revision identifiers, used by Alembic.
revision = "5b0e9adcef9c"
down_revision = "867495a8f9d4"
bra... | 39 | 1,191 |
wandb | wandb/sdk/launch/sweeps/scheduler.py | .py | """Abstract Scheduler class."""
from __future__ import annotations
import asyncio
import base64
import copy
import logging
import os
import socket
import threading
import time
import traceback
from abc import ABC, abstractmethod
from collections.abc import Iterator
from dataclasses import dataclass
from enum import E... | 737 | 26,692 |
onnxruntime | tools/python/util/make_dynamic_shape_fixed.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
import argparse
import os
import pathlib
import sys
import onnx
from .onnx_model_utils import fix_output_shapes, make_dim_param_fixed, make_input_shape_fixed
def m... | 74 | 2,569 |
wandb | wandb/integration/ultralytics/classification_utils.py | .py | from __future__ import annotations
from typing import Any
import numpy as np
from tqdm.auto import tqdm
from ultralytics.engine.results import Results
from ultralytics.models.yolo.classify import ClassificationPredictor
import wandb
def plot_classification_predictions(
result: Results,
model_name: str,
... | 86 | 3,185 |
probability | tensorflow_probability/python/sts/components/__init__.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... | 71 | 3,799 |
clearml | clearml/storage/util.py | .py | import fnmatch
import sys
from typing import Optional, Callable, Any
from six.moves.urllib.parse import quote
# Imports backwards compatibility
from .filepaths import get_common_path # noqa: F401
from .hashing import ( # noqa: F401
sha256sum,
md5text,
crc32text,
hash_text,
hash_dict,
)
from .url ... | 77 | 2,006 |
bazel | src/test/py/bazel/bazel_windows_test.py | .py | # Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 682 | 19,422 |
sqlmap | plugins/dbms/mckoi/syntax.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from plugins.generic.syntax import Syntax as GenericSyntax
class Syntax(GenericSyntax):
@staticmethod
def escape(expression, quote=True):
"""
>>> Syntax.e... | 19 | 446 |
deap | examples/pso/speciation.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 182 | 6,580 |
pyomo | examples/pyomobook/pyomo-components-ch/expr_declaration.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... | 81 | 1,750 |
sqlmap | tamper/hexentities.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.enums import PRIORITY
__priority__ = PRIORITY.LOWEST
def dependencies():
pass
def tamper(payload, **kwargs):
"""
HTML encode in hexadecimal (using cod... | 34 | 717 |
biopython | Doc/conf.py | .py | #!/usr/bin/env python3
"""Biopython Sphinx documentation build configuration file.
After generating ``*.rst`` files from the source code, this
file controls running ``sphinx-build`` to turn these into
human readable documentation.
"""
import os
import shutil
import sys
import tempfile
from Bio import __version__
# ... | 396 | 13,144 |
saleor | saleor/graphql/discount/tests/mutations/test_promotion_delete.py | .py | from unittest.mock import patch
import graphene
import pytest
from .....discount.models import PromotionRule
from .....product.models import ProductChannelListing
from ....tests.utils import assert_no_permission, get_graphql_content
from ...utils import get_products_for_promotion
PROMOTION_DELETE_MUTATION = """
... | 139 | 4,304 |
textual | tests/test_keys.py | .py | import pytest
from textual.app import App
from textual.binding import Binding
from textual.keys import _character_to_key, format_key, key_to_character
@pytest.mark.parametrize(
"character,key",
[
("1", "1"),
("2", "2"),
("a", "a"),
("z", "z"),
("_", "underscore"),
... | 79 | 2,171 |
pyro | examples/contrib/epidemiology/regional.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import argparse
import logging
import torch
import pyro
from pyro.contrib.epidemiology.models import RegionalSIRModel
logging.basicConfig(format="%(message)s", level=logging.INFO)
def Model(args, data):
assert 0 <= args.coupli... | 218 | 7,900 |
metrics | src/torchmetrics/functional/multimodal/lve.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... | 94 | 4,398 |
wagtail | wagtail/admin/panels/publishing_panel.py | .py | from wagtail.admin.widgets.datetime import AdminDateTimeInput
from wagtail.models import AbstractPage
from .field_panel import FieldPanel
from .group import MultiFieldPanel
# This allows users to include the publishing panel in their own per-model override
# without having to write these fields out by hand, potentia... | 63 | 2,468 |
textual | docs/examples/guide/styles/colors02.py | .py | from textual.app import App, ComposeResult
from textual.color import Color
from textual.widgets import Static
class ColorApp(App):
def compose(self) -> ComposeResult:
self.widgets = [Static("") for n in range(10)]
yield from self.widgets
def on_mount(self) -> None:
for index, widget i... | 21 | 561 |
sphinx | tests/test__cli/test__cli_util_errors.py | .py | from __future__ import annotations
import itertools
import operator
from typing import TYPE_CHECKING
from sphinx._cli.util.colour import blue, reset
from sphinx._cli.util.errors import strip_escape_sequences
if TYPE_CHECKING:
from collections.abc import Sequence
from typing import Final
CURSOR_UP: Final[str... | 82 | 2,877 |
beam | learning/katas/python/Introduction/Hello Beam/Hello Beam/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"); y... | 35 | 1,415 |
beam | learning/tour-of-beam/learning-content/core-transforms/motivating-challenge-4/python-solution/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... | 81 | 2,733 |
saleor | saleor/tests/e2e/test_utils.py | .py | import json
from unittest.mock import Mock
from .utils import request_matcher
def test_equal_dicts():
r1 = Mock(
body=Mock(
decode=Mock(return_value=json.dumps({"key1": "value1", "key2": "value2"}))
)
)
r2 = Mock(
body=Mock(
decode=Mock(return_value=json.du... | 125 | 2,974 |
coremltools | coremltools/converters/mil/frontend/tensorflow/test/test_custom_ops.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 itertools
import numpy as np
import pytest
from coremltools.converters.mil.frontend.tensorfl... | 289 | 11,065 |
onnx | onnx/reference/ops/aionnx_preview/__init__.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
__all__ = ["load_op"]
from onnx.reference.ops.aionnx_preview._op_list import load_op
| 9 | 203 |
hypercorn | tests/test_config.py | .py | from __future__ import annotations
import os
import socket
import ssl
import sys
from unittest.mock import Mock, NonCallableMock
import pytest
from _pytest.monkeypatch import MonkeyPatch
import hypercorn.config
from hypercorn.config import Config
access_log_format = "bob"
h11_max_incomplete_size = 4
def _check_st... | 155 | 5,507 |
ipython | IPython/core/completerlib.py | .py | """Implementations for various useful completers.
These are all loaded by default by IPython.
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2010-2011 The IPython Development Team.
#
# Distributed under the terms of the BSD License.
#
# The full license is in the ... | 380 | 12,626 |
pyro | pyro/infer/svi.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import warnings
import torch
import pyro
import pyro.optim
import pyro.poutine as poutine
from pyro.infer.abstract_infer import TracePosterior
from pyro.infer.elbo import ELBO
from pyro.infer.util import torch_item
class SVI(Tr... | 163 | 5,947 |
onnx | onnx/reference/ops/op_pad.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
def _pad_impl(data, raw_pads, mode, constant_values=0.0, axes=None):
input_rank = data.ndim
if axes is None:
axes = list(rang... | 66 | 2,004 |
onnxruntime | onnxruntime/test/testdata/transform/computation_reduction/gathernd/gathernd_div.py | .py | import numpy as np
import onnx
from onnx import OperatorSetIdProto, TensorProto, helper, numpy_helper
X = helper.make_tensor_value_info("input", TensorProto.FLOAT, ["batch", "seqlen", 128])
unsqueezed_masked_lm_positions = helper.make_tensor_value_info(
"unsqueezed_masked_lm_positions",
TensorProto.INT64,
... | 73 | 2,295 |
pymc | pymc/ode/ode.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... | 209 | 7,932 |
biopython | Bio/SearchIO/HmmerIO/_base.py | .py | # Copyright 2012 by Wibowo Arindrarto. All rights reserved.
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been included as part of this
# package.
"""Bio.SearchIO base cl... | 46 | 1,482 |
beam | sdks/python/apache_beam/ml/inference/onnx_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... | 96 | 3,204 |
clearml | clearml/automation/optuna/__init__.py | .py | from .optuna import OptimizerOptuna
__all__ = ["OptimizerOptuna"]
| 4 | 67 |
mlflow | tests/tracing/otel/test_livekit_translator.py | .py | import json
from unittest import mock
import pytest
from mlflow.entities.span import Span, SpanType
from mlflow.tracing.constant import SpanAttributeKey
from mlflow.tracing.otel.translation import (
translate_span_type_from_otel,
translate_span_when_storing,
)
from mlflow.tracing.otel.translation.livekit impo... | 321 | 10,123 |
pyomo | pyomo/core/plugins/transform/scaling.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... | 348 | 14,970 |
pyro | examples/rsa/schelling_false.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
Schelling coordination game with false belief:
Two spies, Alice and Bob, claim to want to meet.
Bob wants to meet Alice, but Alice actually wants to avoid Bob.
They must choose between two locations without communicating
by re... | 106 | 3,335 |
textual | docs/examples/styles/scrollbar_size.py | .py | from textual.app import App
from textual.containers import ScrollableContainer
from textual.widgets import 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 it to pass over me and through me.
And when it has gone past, ... | 25 | 658 |
clearml | clearml/backend_interface/task/repo/detectors.py | .py | from abc import ABC
import logging
import os
from subprocess import call, CalledProcessError
from typing import Any
import attr
from pathlib2 import Path
from ....config.defs import (
VCS_REPO_TYPE,
VCS_DIFF,
VCS_STATUS,
VCS_ROOT,
VCS_BRANCH,
VCS_COMMIT_ID,
VCS_REPOSITORY_URL,
)
from ....d... | 391 | 13,680 |
httpie | httpie/output/models.py | .py | import argparse
from typing import Any, Dict, Union, List, NamedTuple, Optional
from httpie.context import Environment
from httpie.cli.constants import PrettyOptions, PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY
from httpie.cli.argtypes import PARSED_DEFAULT_FORMAT_OPTIONS
from httpie.output.formatters.colors import AUTO_STYLE
... | 45 | 1,400 |
mlflow | tests/store/artifact/test_r2_artifact_repo.py | .py | import posixpath
from unittest import mock
from unittest.mock import ANY
import pytest
from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository
from mlflow.store.artifact.s3_artifact_repo import _cached_get_s3_client
from tests.helper_functions import set_boto_credentials # noqa: F401
... | 92 | 3,204 |
loguru | tests/exceptions/source/backtrace/nested.py | .py | import sys
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="", colorize=False, backtrace=True, diagnose=False)
def a(x):
@logger.catch
def nested(i):
1 / i
nested(x)
a(0)
def b(x):
def nested(i):
1 / i
with logger.catch():
nested(x)
b(0)
... | 42 | 457 |
returns | returns/_internal/futures/_future_result.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable
from typing import TYPE_CHECKING, Any, TypeVar
from returns.io import IO, IOResult
from returns.primitives.hkt import Kind2, dekind
from returns.result import Failure, Result, Success
if TYPE_CHECKING:
from returns.future import F... | 184 | 6,869 |
mlflow | mlflow/metrics/metric_definitions.py | .py | import functools
import logging
import subprocess
import tempfile
from pathlib import Path
import numpy as np
from mlflow.environment_variables import _MLFLOW_TESTING
from mlflow.metrics.base import MetricValue, standard_aggregations
_logger = logging.getLogger(__name__)
# used to silently fail with invalid metric... | 594 | 21,315 |
lemur | lemur/plugins/lemur_aws/tests/test_s3.py | .py | import boto3
from moto import mock_sts, mock_s3
@mock_sts()
@mock_s3()
def test_put_delete_s3_object(app):
from lemur.plugins.lemur_aws.s3 import put, delete, get
bucket = "public-bucket"
region = "us-east-1"
account = "123456789012"
path = "some-path/foo"
data = "dummy data"
s3_client =... | 42 | 1,143 |
pymc | tests/dims/distributions/test_core.py | .py | # Copyright 2025 - 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... | 287 | 10,255 |
beam | sdks/python/apache_beam/transforms/ptransform_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... | 3,093 | 113,511 |
kombu | kombu/asynchronous/aws/sqs/message.py | .py | """Amazon SQS message implementation."""
from __future__ import annotations
import base64
from kombu.message import Message
from kombu.utils.encoding import str_to_bytes
class BaseAsyncMessage(Message):
"""Base class for messages received on async client."""
class AsyncRawMessage(BaseAsyncMessage):
"""Ra... | 36 | 892 |
ipython | tests/test_exceptiongroup_tb.py | .py | import unittest
import re
from IPython.utils.capture import capture_output
import sys
import pytest
from tempfile import TemporaryDirectory
from IPython.testing import tools as tt
def _exceptiongroup_common(
outer_chain: str,
inner_chain: str,
native: bool,
) -> None:
pre_raise = "exceptiongroup." if ... | 109 | 3,410 |
metrics | src/torchmetrics/classification/calibration_error.py | .py | # Copyright The Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 393 | 17,288 |
astropy | astropy/io/votable/tests/test_tree.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import filecmp
import io
import numpy as np
import pytest
from astropy.io.votable import tree
from astropy.io.votable.exceptions import (
E26,
W07,
W08,
W15,
W21,
W27,
W37,
W41,
W47,
W54,
W57,
)
from astropy.io... | 711 | 22,634 |
beam | sdks/python/apache_beam/testing/synthetic_pipeline.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... | 967 | 35,000 |
sqlmap | lib/core/exception.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
class SqlmapBaseException(Exception):
pass
class SqlmapCompressionException(SqlmapBaseException):
pass
class SqlmapConnectionException(SqlmapBaseException):
pass
cl... | 79 | 1,645 |
black | tests/test_docs.py | .py | """
Test that the docs are up to date.
"""
import re
from collections.abc import Sequence
from itertools import islice
from pathlib import Path
import pytest
from black.mode import UNSTABLE_FEATURES, Preview
DOCS_PATH = Path("docs/the_black_code_style/future_style.md")
def check_feature_list(
lines: Sequenc... | 75 | 2,522 |
flit | flit_core/tests_core/test_common.py | .py | import email.parser
import email.policy
from io import StringIO
from pathlib import Path
import pytest
from unittest import TestCase
from flit_core import config
from flit_core.common import (
Module, get_info_from_module, InvalidVersion, NoVersionError, check_version,
normalize_file_permissions, Metadata, mak... | 243 | 8,951 |
pyomo | pyomo/core/tests/unit/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 12 | 569 |
pyro | pyro/distributions/avf_mvn.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.distributions import constraints
from pyro.distributions.torch import MultivariateNormal
from pyro.distributions.u... | 107 | 4,062 |
wagtail | wagtail/contrib/settings/tests/site_specific/test_admin.py | .py | from django.contrib.auth.models import Group, Permission
from django.http import HttpRequest, HttpResponse
from django.test import TestCase, override_settings
from django.urls import reverse
from wagtail import hooks
from wagtail.admin.admin_url_finder import AdminURLFinder
from wagtail.admin.panels import FieldPanel,... | 932 | 38,601 |
readthedocs.org | readthedocs/subscriptions/querysets.py | .py | """
Querysets for djstripe models.
Since djstripe is a third-party app,
these are injected at runtime at readthedocs/subscriptions/apps.py.
"""
from datetime import timedelta
from django.db import models
from django.utils import timezone
from djstripe.enums import SubscriptionStatus
from readthedocs.core.querysets ... | 34 | 1,034 |
pymc | pymc/distributions/multivariate.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... | 2,808 | 99,427 |
openvino | tests/layer_tests/pytorch_tests/test_isfinite.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
@pytest.mark.parametrize('input_tensor', (np.array([2, 0, 1, -2]),))
class TestIsFinite(PytorchLayerTest):
def _prepare_input(sel... | 31 | 926 |
probability | tensorflow_probability/python/optimizer/convergence_criteria/convergence_criterion.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... | 132 | 5,903 |
mlflow | mlflow/tracing/otel/translation/livekit.py | .py | """
Translation utilities for LiveKit Agents semantic conventions.
LiveKit Agents (Python SDK) provides real-time AI voice agents with built-in
OpenTelemetry support. This translator maps LiveKit's span attributes to MLflow's
semantic conventions for optimal visualization.
Reference:
- https://docs.livekit.io/agents/... | 117 | 3,770 |
coremltools | coremltools/converters/mil/backend/nn/mil_to_nn_mapping_registry.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
MIL_TO_NN_MAPPING_REGISTRY = {}
def register_mil_to_nn_mapping(func=None, override=False):
def f... | 19 | 739 |
readthedocs.org | readthedocs/telemetry/tasks.py | .py | """Tasks related to telemetry."""
from django.conf import settings
from django.utils import timezone
from readthedocs.builds.models import Build
from readthedocs.telemetry.models import BuildData
from readthedocs.worker import app
@app.task(queue="web")
def save_build_data(build_id, data):
"""
Save the buil... | 43 | 1,434 |
wandb | tests/unit_tests/test_sandbox/__init__.py | .py | from __future__ import annotations
import sys
import pytest
if sys.version_info < (3, 11):
pytest.skip("wandb.sandbox requires Python 3.11+", allow_module_level=True)
| 9 | 174 |
django-cms | cms/test_utils/project/pluginapp/plugins/multicolumn/forms.py | .py | from django import forms
from .models import MultiColumns
class MultiColumnForm(forms.ModelForm):
NUM_COLUMNS = (
(0, "0"),
(1, "1"),
(2, "2"),
(3, "3"),
(4, "4"),
(5, "5"),
(6, "6"),
(7, "7"),
(8, "8"),
(9, "9"),
(10, "10"),... | 30 | 604 |
wagtail | wagtail/snippets/tests/test_bulk_actions/test_bulk_delete.py | .py | from django.contrib.admin.utils import quote
from django.contrib.auth.models import Permission
from django.http import HttpRequest, HttpResponse
from django.test import TestCase
from django.urls import reverse
from django.utils.http import urlencode
from wagtail.snippets.bulk_actions.delete import DeleteBulkAction
fro... | 351 | 12,996 |
sphinx | tests/test_ext_intersphinx/test_ext_intersphinx_cache.py | .py | """Test the intersphinx extension."""
from __future__ import annotations
import posixpath
import re
import shutil
import zlib
from http.server import BaseHTTPRequestHandler
from io import BytesIO
from typing import TYPE_CHECKING
from sphinx.ext.intersphinx._shared import InventoryAdapter
from sphinx.testing.util imp... | 320 | 11,071 |
wandb | wandb/sdk/lib/wbauth/settings.py | .py | """Logic for setting auth-related parts of wandb.Settings."""
from wandb.sdk.wandb_settings import Settings
from .auth import Auth, AuthApiKey, AuthIdentityTokenFile
def set_auth_settings(settings: Settings, auth: Auth | None) -> None:
"""Set auth-related settings based on the given credentials.
Auth setti... | 66 | 2,109 |
onnx | onnx/reference/ops/op_tfidf_vectorizer.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import collections
from enum import IntEnum
import numpy as np
from onnx.reference.op_run import OpRun
class IntMap(collections.UserDict):
def __init__(self):
super().__init__()
s... | 381 | 12,527 |
deap | examples/gp/__init__.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 14 | 692 |
kafka | docker/generate_kafka_pr_template.py | .py | #!/usr/bin/env python
# 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 "Lice... | 93 | 3,649 |
lemur | lemur/tests/test_missing.py | .py | import arrow
from freezegun import freeze_time
def test_convert_validity_years(session):
from lemur.common.missing import convert_validity_years
with freeze_time("2016-01-01"):
data = convert_validity_years(dict(validity_years=2))
assert data["validity_start"] == arrow.utcnow().isoformat()
... | 21 | 628 |
mlflow | dev/clint/src/clint/rules/__init__.py | .py | from clint.rules.assign_before_append import AssignBeforeAppend
from clint.rules.base import Rule
from clint.rules.do_not_disable import DoNotDisable
from clint.rules.docstring_param_order import DocstringParamOrder
from clint.rules.empty_notebook_cell import EmptyNotebookCell
from clint.rules.example_syntax_error impo... | 125 | 5,227 |
mlflow | mlflow/utils/provider_filter.py | .py | import logging
import threading
from cachetools import LRUCache
from cachetools.func import cached
from mlflow.environment_variables import MLFLOW_GATEWAY_ALLOWED_PROVIDERS
_logger = logging.getLogger(__name__)
# Single source of truth for provider name aliases (string-level).
_PROVIDER_ALIASES: dict[str, str] = {
... | 63 | 1,804 |
coremltools | coremltools/converters/mil/frontend/torch/dialect_ops.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
from coremltools.converters.mil.mil import Operation, get_new_symbol, types
from coremltools.converte... | 217 | 7,912 |
saleor | saleor/tests/e2e/product/test_create_simple_product.py | .py | import pytest
from ..attributes.utils import attribute_create
from ..shop.utils.preparing_shop import prepare_default_shop
from ..utils import assign_permissions
from .utils import (
create_category,
create_product,
create_product_channel_listing,
create_product_type,
create_product_variant,
cr... | 110 | 3,297 |
tqdm | tqdm/dask.py | .py | from functools import partial
from dask.callbacks import Callback
from .auto import tqdm as tqdm_auto
__author__ = {"github.com/": ["casperdcl"]}
__all__ = ['TqdmCallback']
class TqdmCallback(Callback):
"""Dask callback for task progress."""
def __init__(self, start=None, pretask=None, tqdm_class=tqdm_auto... | 45 | 1,319 |
pyro | pyro/contrib/zuko.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
"""
This file contains helpers to use `Zuko <https://zuko.readthedocs.io/>`_-based
normalizing flows within Pyro piplines.
Accompanying tutorials can be found at `tutorial/svi_flow_guide.ipynb` and
`tutorial/vae_flow_prior.ipynb`.
"""... | 82 | 2,230 |
cvxpy | cvxpy/atoms/total_variation.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... | 64 | 2,220 |
kombu | setup.py | .py | #!/usr/bin/env python3
from __future__ import annotations
import os
import re
import sys
import setuptools
from setuptools import setup
# -- Parse meta
re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)')
re_doc = re.compile(r'^"""(.+?)"""')
def add_default(m):
attr_name, attr_value = m.groups()
return ((attr_na... | 138 | 3,932 |
pyomo | pyomo/network/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 13 | 681 |
metrics | src/torchmetrics/functional/retrieval/precision.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... | 72 | 2,847 |
openvino | src/frontends/tensorflow/tests/test_models/gen_scripts/generate_gather_with_string_table.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import tensorflow as tf
tf.compat.v1.reset_default_graph()
# Create the graph and model
with tf.compat.v1.Session() as sess:
params = tf.constant(["First sentence", "Second sentence sentence", "Third"], dtype=t... | 19 | 717 |
saleor | saleor/graphql/product/bulk_mutations/product_variant_stocks_delete.py | .py | 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 as warehouse_models
from ....warehou... | 140 | 5,587 |
onnx | onnx/reference/ops/op_squeeze.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
class Squeeze_1(OpRun):
def _run(self, data, axes=None):
if isinstance(axes, np.ndarray):
axes = tuple(axes)
... | 46 | 1,154 |
astropy | astropy/cosmology/_src/tests/flrw/test_base.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Testing :mod:`astropy.cosmology.flrw.base`.
This module sets up the tests for subclasses of :class:`astropy.cosmology.FLRW`. The
tests for the specific abstract class :class:`astropy.cosmology.FLRW` are in
``test_flrw``.
"""
import abc
from functool... | 569 | 20,866 |
astropy | astropy/visualization/tests/test_time.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from contextlib import nullcontext
import pytest
from erfa import ErfaWarning
from astropy.time import Time
from astropy.visualization.time import time_support
pytest.importorskip("matplotlib.pyplot")
from matplotlib.figure import Figure
# Since some ... | 269 | 8,620 |
hydra | tests/test_apps/multirun_structured_conflict/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from omegaconf import MISSING, DictConfig
import hydra
from hydra.core.config_store import ConfigStore
@dataclass
class TestConfig:
param: int = MISSING
config_store = ConfigStore.instance()
config_store.s... | 26 | 530 |
mlflow | tests/pmdarima/test_pmdarima_model_export.py | .py | import json
import os
from pathlib import Path
from unittest import mock
import numpy as np
import pandas as pd
import pmdarima
import pytest
import yaml
import mlflow.pmdarima
import mlflow.pyfunc.scoring_server as pyfunc_scoring_server
from mlflow import pyfunc
from mlflow.exceptions import MlflowException
from mlf... | 484 | 19,484 |
biopython | Bio/Graphics/GenomeDiagram/_Graph.py | .py | # Copyright 2003-2008 by Leighton Pritchard. All rights reserved.
# Revisions copyright 2008-2009 by Peter Cock.
#
# 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 incl... | 191 | 6,838 |
openvino | src/bindings/python/src/openvino/properties/intel_gpu/hint/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# Properties
import openvino._pyopenvino.properties.intel_gpu.hint as __hint
from openvino.properties._properties import __make_properties
__make_properties(__hint, __name__)
# Classes
from openvino._pyopenvino.p... | 12 | 366 |
clearml | clearml/utilities/gpu/pyrsmi.py | .py | # MIT License
#
# Copyright (c) 2023 Advanced Micro Devices, Inc.
#
# 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, copy... | 609 | 20,905 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.