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 |
|---|---|---|---|---|---|
pyro | tests/ops/test_jit.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
import pyro.ops.jit
from tests.common import assert_equal
def test_varying_len_args():
def fn(*args):
return sum(args)
jit_fn = pyro.ops.jit.trace(fn)
examples = [
[torch.tensor(1.0)],
... | 43 | 1,077 |
saleor | saleor/graphql/product/tests/benchmark/test_category.py | .py | import graphene
import pytest
from .....product.models import Category
from ....tests.utils import get_graphql_content
@pytest.mark.django_db
@pytest.mark.count_queries(autouse=False)
def test_category_view(api_client, category_with_products, count_queries, channel_USD):
query = """
fragment BasicProduct... | 270 | 6,873 |
coremltools | coremltools/optimize/torch/quantization/modules/fused_modules.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
from collections import OrderedDict as _OrderedDict
from typing import Union as _Union
import torch ... | 122 | 2,418 |
onnxruntime | onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/NodeEdge.py | .py | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: fbs
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class NodeEdge(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuf... | 127 | 4,057 |
beam | sdks/python/apache_beam/io/mongodbio_test.py | .py | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | 747 | 26,041 |
flit | tests/test_command.py | .py | from subprocess import Popen, PIPE, STDOUT
import sys
def test_flit_help():
p = Popen([sys.executable, '-m', 'flit', '--help'], stdout=PIPE, stderr=STDOUT)
out, _ = p.communicate()
assert 'Build wheel' in out.decode('utf-8', 'replace')
def test_flit_usage():
p = Popen([sys.executable, '-m', 'flit'], s... | 14 | 460 |
lemur | lemur/__about__.py | .py | __all__ = [
"__title__",
"__summary__",
"__uri__",
"__version__",
"__author__",
"__email__",
"__license__",
"__copyright__",
]
__title__ = "lemur"
__summary__ = "Certificate management and orchestration service"
__uri__ = "https://github.com/Netflix/lemur"
__version__ = "1.9.0"
__auth... | 23 | 477 |
pyomo | pyomo/core/expr/boolean_value.py | .py | # -*- coding: utf-8 -*-
# ____________________________________________________________________________________
#
# 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 En... | 333 | 10,299 |
mlflow | mlflow/cli/datasets.py | .py | import json
from typing import Any, Literal
import click
from mlflow import MlflowClient
from mlflow.environment_variables import MLFLOW_EXPERIMENT_ID
from mlflow.utils.string_utils import _create_table
from mlflow.utils.time import conv_longdate_to_str
EXPERIMENT_ID = click.option(
"--experiment-id",
"-x",
... | 139 | 3,906 |
saleor | saleor/graphql/page/tests/queries/pages_with_where/test_with_where_references_variants.py | .py | import graphene
import pytest
from ......attribute import AttributeEntityType, AttributeInputType, AttributeType
from ......attribute.models import Attribute, AttributeValue
from ......attribute.utils import associate_attribute_values_to_instance
from .....core.utils import to_global_id_or_none
from .....tests.utils i... | 317 | 9,982 |
openvino | src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/op_support.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# mypy: ignore-errors
import logging
from collections.abc import Mapping
from torch.nn import Module
from torch._ops import OpOverload
from torch.fx.node import Node, _get_qualified_name
from torch.fx.passes.op... | 315 | 15,459 |
probability | tensorflow_probability/python/distributions/loglogistic.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... | 172 | 6,616 |
slimit | src/slimit/visitors/minvisitor.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... | 438 | 14,179 |
mkdocs-material | material/plugins/social/config.py | .py | # Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, c... | 69 | 2,845 |
pymc | tests/step_methods/__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... | 14 | 613 |
beam | sdks/python/apache_beam/testing/benchmarks/nexmark/nexmark_perf.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... | 53 | 1,912 |
beam | sdks/python/apache_beam/ml/transforms/tft_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... | 1,112 | 37,267 |
ipython | tests/test_shellapp.py | .py | # -*- coding: utf-8 -*-
"""Tests for shellapp module.
Authors
-------
* Bradley Froehle
"""
# -----------------------------------------------------------------------------
# Copyright (C) 2012 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYIN... | 144 | 4,316 |
textual | src/textual/signal.py | .py | """
Signals are a simple pub-sub mechanism.
DOMNodes can subscribe to a signal, which will invoke a callback when the signal is published.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Generic, TypeVar, Union
from weakref import WeakKeyDictionary, ref
import ric... | 138 | 4,296 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_logical_and.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# logical_and paddle model generator
#
import numpy as np
from save_model import saveModel
import sys
def equal_logical_and(name : str, x, y, z):
import paddle
paddle.enable_static()
with paddle.static.program_guard(paddl... | 51 | 1,610 |
mlflow | mlflow/store/workspace_aware_mixin.py | .py | """
Mixin class providing common workspace functionality for stores.
"""
from __future__ import annotations
from mlflow.environment_variables import MLFLOW_ENABLE_WORKSPACES
from mlflow.exceptions import MlflowException
from mlflow.utils.workspace_context import get_request_workspace
from mlflow.utils.workspace_utils... | 64 | 2,174 |
wagtail | wagtail/admin/urls/editing_sessions.py | .py | from django.urls import path
from wagtail.admin.views.editing_sessions import ping, release
app_name = "wagtailadmin_editing_sessions"
urlpatterns = [
path(
"ping/<str:app_label>/<str:model_name>/<str:object_id>/<int:session_id>/",
ping,
name="ping",
),
path(
"release/<int:... | 18 | 385 |
httpie | httpie/internal/daemon_runner.py | .py | import argparse
from contextlib import redirect_stderr, redirect_stdout
from typing import List
from httpie.context import Environment
from httpie.internal.update_warnings import _fetch_updates, _get_suppress_context
from httpie.status import ExitStatus
STATUS_FILE = '.httpie-test-daemon-status'
def _check_status(e... | 51 | 1,521 |
textual | src/textual/widgets/_static.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from textual.app import RenderResult
from textual.visual import Visual, VisualType, visualize
from textual.widget import Widget
class Static(Widget, inherit_bindings=False):
"""A widget to display simple static content, o... | 96 | 3,220 |
sqlmap | plugins/dbms/cubrid/syntax.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.convert import getOrds
from plugins.generic.syntax import Syntax as GenericSyntax
class Syntax(GenericSyntax):
@staticmethod
def escape(expression, quote=Tr... | 24 | 725 |
returns | returns/contrib/mypy/_features/pipe.py | .py | """
Typing ``pipe`` functions requires several phases.
It is pretty obvious from its usage:
1. When we pass a sequence of functions we have to reduce
the final callable type, it is require to match the ``callable`` protocol.
And at this point we also kinda try
to check that all pipeline functions do match,
... | 137 | 4,576 |
beam | sdks/python/apache_beam/runners/direct/direct_metrics_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... | 257 | 9,444 |
pyomo | pyomo/contrib/doe/examples/reactor_compute_factorial_FIM.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... | 96 | 3,298 |
textual | tests/toggles/test_radiobutton.py | .py | from __future__ import annotations
from textual.app import App, ComposeResult
from textual.widgets import RadioButton
class RadioButtonApp(App[None]):
def __init__(self):
super().__init__()
self.events_received = []
def compose(self) -> ComposeResult:
yield RadioButton("Test", id="rb... | 64 | 1,955 |
saleor | saleor/graphql/checkout/tests/mutations/test_checkout_delete.py | .py | import graphene
import pytest
from .....checkout.error_codes import CheckoutErrorCode
from .....checkout.models import Checkout
from .....payment.models import TransactionItem
from ....core.utils import to_global_id_or_none
from ....tests.utils import assert_no_permission, get_graphql_content
MUTATION_CHECKOUT_DELETE... | 200 | 5,868 |
ipython | IPython/terminal/pt_inputhooks/pyglet.py | .py | """Enable pyglet to be used interactively with prompt_toolkit"""
import sys
import time
from timeit import default_timer as clock
import pyglet
# On linux only, window.flip() has a bug that causes an AttributeError on
# window close. For details, see:
# http://groups.google.com/group/pyglet-users/browse_thread/threa... | 68 | 2,371 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Rint.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
class TestRint(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
assert 'input:0' in... | 45 | 1,878 |
sqlmap | extra/dbwire/monetdb.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
"""
Minimal pure-python MonetDB MAPI client (stdlib only, no pymonetdb).
MAPI is a block-framed text protocol: a 2-byte little-endian header (length << 1 | last-flag) wraps each
... | 241 | 9,264 |
openvino | tests/layer_tests/onnx_tests/test_sign.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
pytest.importorskip("openvino.tools.mo", reason="Ticket - 157136")
from common.layer_test_class import check_ir_version
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
from unit_tests.utils.... | 181 | 6,024 |
saleor | saleor/tests/e2e/account/account/test_login_throttling.py | .py | import datetime
from unittest.mock import patch
import pytest
from django.utils import timezone
from freezegun import freeze_time
from .....account.error_codes import AccountErrorCode
from .....account.models import User
from .....account.throttling import (
get_cache_key_blocked_ip,
get_cache_key_failed_ip,
... | 161 | 5,860 |
lemur | lemur/tests/test_dns_providers.py | .py | import json
import unittest
from lemur.dns_providers import util as dnsutil
from lemur.dns_providers.schemas import dns_provider_output_schema
class TestDNSProvider(unittest.TestCase):
def test_is_valid_domain(self):
self.assertTrue(dnsutil.is_valid_domain('example.com'))
self.assertTrue(dnsutil.... | 41 | 1,904 |
coremltools | coremltools/converters/mil/mil/__init__.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
SPACES = " "
from .block import Block, Function, curr_block
from .builder import Builder
from .inpu... | 34 | 822 |
probability | tensorflow_probability/python/experimental/util/deferred_module.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... | 164 | 6,806 |
gunicorn | tests/requests/valid/013.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
request = {
"method": "POST",
"uri": uri("/chunked_w_extensions"),
"version": (1, 1),
"headers": [
("TRANSFER-ENCODING", "chunked")
],
"body": b"hello world"
}
| 14 | 298 |
sphinx | tests/roots/test-ext-autodoc/target/inherited_annotations.py | .py | """Test case for https://github.com/sphinx-doc/sphinx/issues/11387,
corner case involving inherited members with type annotations
on python 3.9 and earlier
"""
class HasTypeAnnotatedMember:
inherit_me: int
"""Inherited"""
class NoTypeAnnotation(HasTypeAnnotatedMember):
a = 1
"""Local"""
class NoTy... | 20 | 385 |
pyro | tests/contrib/funsor/test_vectorized_markov.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pyroapi import pyro_backend
from torch.distributions import constraints
from pyro.ops.indexing import Vindex
# put all funsor-related imports here, so test collection works without funsor
try:
impo... | 850 | 30,783 |
saleor | saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_checkout_updated.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... | 243 | 7,319 |
pyomo | pyomo/common/tests/deps.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... | 42 | 1,502 |
probability | testing/virtualenv_is_active.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... | 26 | 1,090 |
qutip | qutip/solver/heom/bofin_solvers.py | .py | """
This module provides solvers for system-bath evoluation using the
HEOM (hierarchy equations of motion).
See https://en.wikipedia.org/wiki/Hierarchical_equations_of_motion for a very
basic introduction to the technique.
The implementation is derived from the BoFiN library (see
https://github.com/tehruhn/bofin) whi... | 1,411 | 52,376 |
saleor | saleor/core/db_routers.py | .py | from django.conf import settings
class PrimaryReplicaRouter:
def db_for_write(self, model, **hints):
"""Write only to primary."""
return settings.DATABASE_CONNECTION_DEFAULT_NAME
def allow_relation(self, obj1, obj2, **hints):
"""All relations are allowed as we don't have pool separati... | 12 | 347 |
coremltools | coremltools/test/optimize/torch/conversion/joint/test_joint_compression_conversion.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 pytest
ct = pytest.importorskip("coremltools")
import coremltools.test.optimize.torch.convers... | 98 | 3,376 |
python-prompt-toolkit | examples/dialogs/input_dialog.py | .py | #!/usr/bin/env python
"""
Example of an input box dialog.
"""
from prompt_toolkit.shortcuts import input_dialog
def main():
result = input_dialog(
title="Input dialog example", text="Please type your name:"
).run()
print(f"Result = {result}")
if __name__ == "__main__":
main()
| 19 | 307 |
saleor | saleor/core/tests/test_dataloaders.py | .py | from django.core.handlers.base import BaseHandler
from ...graphql.plugins.dataloaders import get_plugin_manager_promise
def test_plugins_manager_loader_loads_requestor_in_plugin(rf, customer_user, settings):
settings.PLUGINS = ["saleor.plugins.tests.sample_plugins.ActivePlugin"]
request = rf.request()
re... | 39 | 1,213 |
metrics | src/torchmetrics/classification/precision_fixed_recall.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... | 516 | 25,300 |
httpie | docs/installation/generate.py | .py | import re
import sys
from pathlib import Path
from typing import Dict
import yaml
from jinja2 import Template
Database = Dict[str, dict]
# Files
HERE = Path(__file__).parent
DB_FILE = HERE / 'methods.yml'
DOC_FILE = HERE.parent / 'README.md'
TPL_FILE = HERE / 'installation.jinja2'
# Database keys
KEY_DOC_STRUCTURE ... | 86 | 2,390 |
sqlmap | plugins/dbms/monetdb/__init__.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 DBMS
from lib.core.settings import MONETDB_SYSTEM_DBS
from lib.core.unescaper import unescaper
from plugins.dbms.monetdb.enumeration import Enumeration... | 31 | 919 |
onnxruntime | tools/ci_build/github/windows/sign_java_artifacts.py | .py | import argparse
import hashlib
import os
import platform
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
def clean_gpg_trustdb() -> None:
if platform.system() == "Windows":
# Clean up GPG trust database if it exists
appdata = os.environ.get("APPDATA")
if... | 168 | 6,368 |
beam | learning/katas/python/Streaming/Triggers/Window Accumulation Modes/task.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not... | 64 | 2,408 |
scikit-bio | skbio/diversity/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.
# --------------------------------------------... | 172 | 6,582 |
saleor | saleor/webhook/tests/fixtures/subscription_webhooks.py | .py | import pytest
from ...event_types import WebhookEventAsyncType, WebhookEventSyncType
from ...models import Webhook
from ..subscription_webhooks import subscription_queries as queries
@pytest.fixture
def subscription_webhook(webhook_app):
def fun(query, event_type, name="Subscription", app=webhook_app):
w... | 1,392 | 39,531 |
sphinx | sphinx/ext/inheritance_diagram.py | .py | r"""Defines a docutils directive for inserting inheritance diagrams.
Provide the directive with one or more classes or modules (separated
by whitespace). For modules, all of the classes in that module will
be used.
Example::
Given the following classes:
class A: pass
class B(A): pass
class C(A): pass
... | 570 | 19,094 |
python-prompt-toolkit | examples/prompts/get-password-with-toggle-display-shortcut.py | .py | #!/usr/bin/env python
"""
get_password function that displays asterisks instead of the actual characters.
With the addition of a ControlT shortcut to hide/show the input.
"""
from prompt_toolkit import prompt
from prompt_toolkit.filters import Condition
from prompt_toolkit.key_binding import KeyBindings
def main():
... | 30 | 767 |
clearml | clearml/cli/task/__main__.py | .py | import sys
from argparse import ArgumentParser
from pathlib2 import Path
import clearml.backend_api.session
from clearml import Task, PipelineController
from clearml.backend_interface.task.populate import CreateAndPopulate
from clearml.version import __version__
clearml.backend_api.session.Session.add_client("clearm... | 355 | 13,252 |
omegaconf | tests/test_nested_containers.py | .py | import copy
import re
from typing import Any, Dict, List, Optional, Union
from pytest import mark, param, raises
from omegaconf import (
MISSING,
Container,
DictConfig,
IntegerNode,
KeyValidationError,
ListConfig,
Node,
OmegaConf,
ValidationError,
)
from omegaconf._utils import (
... | 1,444 | 43,731 |
flit | flit_core/tests_core/samples/constructed_version/module1.py | .py |
"""This module has a __version__ that requires runtime interpretation"""
__version__ = ".".join(["1", "2", "3"])
| 5 | 115 |
black | tests/data/cases/skip_magic_trailing_comma.py | .py | # flags: --skip-magic-trailing-comma
# We should not remove the trailing comma in a single-element subscript.
a: tuple[int,]
b = tuple[int,]
# But commas in multiple element subscripts should be removed.
c: tuple[int, int,]
d = tuple[int, int,]
# Remove commas for non-subscripts.
small_list = [1,]
list_of_types = [tu... | 112 | 2,505 |
mlflow | dev/clint/tests/rules/test_forbidden_trace_ui_in_notebook.py | .py | from pathlib import Path
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import lint_file
from clint.rules.forbidden_trace_ui_in_notebook import ForbiddenTraceUIInNotebook
def test_forbidden_trace_ui_in_notebook(index: SymbolIndex) -> None:
notebook_content = """
{
"cells":... | 68 | 1,487 |
pyro | pyro/distributions/transforms/matrix_exponential.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
from functools import partial
import torch
import torch.nn as nn
from torch.distributions import Transform, constraints
from pyro.nn import DenseNN
from ..conditional import ConditionalTransformModule
from ..torch_tr... | 335 | 13,724 |
coremltools | coremltools/converters/mil/mil/types/symbolic.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 numpy as np
import sympy as sm
k_used_symbols = {}
k_num_internal_syms = 0
_OBJECT_DTYPE = ... | 85 | 2,237 |
beam | sdks/python/apache_beam/runners/worker/sdk_worker_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... | 788 | 32,299 |
mlflow | mlflow/pyfunc/loaders/code_model.py | .py | from typing import Any
from mlflow.pyfunc.loaders.chat_agent import _ChatAgentPyfuncWrapper
from mlflow.pyfunc.loaders.chat_model import _ChatModelPyfuncWrapper
from mlflow.pyfunc.model import (
ChatAgent,
ChatModel,
_load_context_model_and_signature,
_PythonModelPyfuncWrapper,
)
try:
from mlflow.... | 32 | 1,121 |
wandb | wandb/sdk/artifacts/_generated/run_input_artifacts.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/artifacts/
from __future__ import annotations
from pydantic import Field
from wandb._pydantic import GQLResult
from .fragments import ArtifactFragment, PageInfoFragment
class RunInputArtifacts(GQLResult):
project: RunInputArtifactsProject | None
... | 40 | 1,066 |
saleor | saleor/csv/tests/test_tasks.py | .py | import datetime
from unittest.mock import ANY, MagicMock, Mock, patch
from django.core.files import File
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from ...core import JobStatus
from .. import ExportEvents, FileTypes
from ..models import ExportEvent, ... | 306 | 9,798 |
confluent-kafka-python | tests/ducktape/run_ducktape_test.py | .py | #!/usr/bin/env python3
"""
Unified test runner for Ducktape Producer and Consumer tests
"""
import argparse
import os
import subprocess
import sys
import tempfile
from datetime import datetime
import ducktape
def get_test_info(test_type):
"""Get test file and description based on test type"""
test_info = {
... | 185 | 5,594 |
mlflow | tests/server/test_otel_api.py | .py | from unittest import mock
from fastapi import FastAPI
from fastapi.testclient import TestClient
from opentelemetry.proto.collector.trace.v1.trace_service_pb2 import ExportTraceServiceRequest
from mlflow.entities import Workspace
from mlflow.environment_variables import MLFLOW_ENABLE_WORKSPACES
from mlflow.server.fast... | 393 | 11,930 |
mlflow | mlflow/server/graphql/graphql_errors.py | .py | import graphene
class ErrorDetail(graphene.ObjectType):
# NOTE: This is not an exhaustive list, might need to add more things in the future if needed.
field = graphene.String()
message = graphene.String()
class ApiError(graphene.ObjectType):
code = graphene.String()
message = graphene.String()
... | 16 | 432 |
ipython | tests/test_guarded_eval.py | .py | import sys
from contextlib import contextmanager
from importlib import import_module
from typing import (
Annotated,
AnyStr,
NamedTuple,
Literal,
NewType,
Optional,
Protocol,
TypeGuard,
Union,
TypedDict,
TypeVar,
List,
Callable,
Any,
Dict,
)
from functools imp... | 1,057 | 28,620 |
pyomo | pyomo/contrib/piecewise/transform/incremental.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... | 189 | 8,639 |
pyro | tests/ops/einsum/conftest.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
def pytest_collection_modifyitems(items):
for item in items:
if item.nodeid.startswith("tests/ops/einsum"):
if "stage" not in item.keywords:
item.add_marker(pytest.mark.stage(... | 14 | 437 |
textual | tests/layouts/test_factory.py | .py | import pytest
from textual.layouts.factory import MissingLayout, get_layout
from textual.layouts.vertical import VerticalLayout
def test_get_layout_valid_layout():
layout = get_layout("vertical")
assert type(layout) is VerticalLayout
def test_get_layout_invalid_layout():
with pytest.raises(MissingLayou... | 15 | 354 |
astropy | astropy/nddata/compat.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module contains a class equivalent to pre-1.0 NDData.
import numpy as np
from astropy import log
from astropy.units import Unit, UnitConversionError, UnitsError # noqa: F401
from .flag_collection import FlagCollection
from .mixins.ndarithmetic ... | 305 | 10,196 |
pymc | tests/logprob/test_linalg.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... | 86 | 2,852 |
sphinx | tests/roots/test-root/special/code.py | .py | print('line 1')
print('line 2')
| 3 | 32 |
saleor | saleor/graphql/menu/sorters.py | .py | import graphene
from django.db.models import Count, QuerySet
from ..core.types import SortInputObjectType
class MenuSortField(graphene.Enum):
NAME = ["name", "pk"]
ITEMS_COUNT = ["items_count", "name", "pk"]
@property
def description(self):
if self.name in MenuSortField.__enum__._member_name... | 44 | 1,286 |
cvxpy | cvxpy/reductions/solvers/qp_solvers/osqp_qpif.py | .py | import numpy as np
import scipy.sparse as sp
import cvxpy.interface as intf
import cvxpy.settings as s
from cvxpy.error import SolverError
from cvxpy.reductions.solution import Solution, failure_solution
from cvxpy.reductions.solvers import utilities
from cvxpy.reductions.solvers.qp_solvers.qp_solver import QpSolver
f... | 170 | 6,867 |
saleor | saleor/graphql/giftcard/tests/queries/test_gift_card_filtering.py | .py | import graphene
import pytest
from .....giftcard.models import GiftCard
from ....tests.utils import get_graphql_content, get_graphql_content_from_response
QUERY_GIFT_CARDS = """
query giftCards($filter: GiftCardFilterInput){
giftCards(first: 10, filter: $filter) {
edges {
node ... | 552 | 14,149 |
textual | tests/snapshot_tests/snapshot_apps/data_table_auto_height.py | .py | from textual.app import App, ComposeResult
from textual.widgets import DataTable, Label
LORUM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
class ExampleApp(App):
CSS = """
Screen {
DataTable {
... | 39 | 1,014 |
pyomo | pyomo/common/dependencies.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 1,161 | 43,380 |
pyomo | examples/pyomobook/intro-ch/concrete1_generic.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... | 30 | 958 |
wandb | wandb/sdk/data_types/helper_types/image_mask.py | .py | from __future__ import annotations
import numbers
import os
from typing import TYPE_CHECKING
import wandb
from wandb import util
from wandb.sdk.lib import runid
from .._private import MEDIA_TMP
from ..base_types.media import Media
if TYPE_CHECKING: # pragma: no cover
from wandb.sdk.artifacts.artifact import Ar... | 254 | 8,845 |
clearml | clearml/backend_api/session/jsonmodels/validators.py | .py | """Predefined validators."""
import re
from typing import Any
from six.moves import reduce
from .errors import ValidationError
from . import utilities
class Min:
"""Validator for minimum value."""
def __init__(self, minimum_value: Any, exclusive: bool = False) -> None:
"""Init.
:param mini... | 180 | 6,023 |
mlflow | examples/tracing/client.py | .py | """
This example demonstrates how to create a trace with multiple spans using the low-level MLflow client APIs.
"""
import mlflow
exp = mlflow.set_experiment("mlflow-tracing-example")
exp_id = exp.experiment_id
# Initialize MLflow client.
client = mlflow.MlflowClient()
def run(x: int, y: int) -> int:
# Create ... | 102 | 2,995 |
onnxruntime | onnxruntime/test/python/transformers/gpt2_model_generator.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 ... | 1,333 | 48,614 |
jupyterlab | binder/jupyter_config.py | .py | """An INSECURE configuration for Jupyter Server, intended only for mybinder.org."""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import logging
common = [
"--no-browser",
"--debug",
"--port={port}",
"--ServerApp.ip=127.0.0.1",
'--IdentityProv... | 54 | 1,265 |
astropy | astropy/constants/codata2010.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Astronomical and physics constants in SI units. See :mod:`astropy.constants`
for a complete listing of constants defined in Astropy.
"""
import numpy as np
from .constant import Constant, EMConstant
# PHYSICAL CONSTANTS
class CODATA2010(Constant)... | 173 | 3,814 |
wagtail | wagtail/admin/panels/title_field_panel.py | .py | from django.utils.text import format_lazy
from django.utils.translation import gettext_lazy
from wagtail.models import AbstractPage
from .field_panel import FieldPanel
class TitleFieldPanel(FieldPanel):
"""
Prepares the default widget attributes that are used on Page title fields.
Can be used outside of... | 133 | 4,846 |
mamba | micromamba/tests/test_activation.py | .py | import os
import pathlib
import platform
import re
import shutil
import subprocess
import tempfile
from pathlib import Path, PurePosixPath, PureWindowsPath
import pytest
from . import helpers
plat, running_os = None, None
if platform.system() == "Linux":
plat = "linux"
running_os = "unix"
elif platform.syst... | 1,074 | 35,417 |
astropy | astropy/version.py | .py | from packaging.version import Version
# NOTE: First try _dev.scm_version if it exists and setuptools_scm is installed
# This file is not included in astropy wheels/tarballs, so otherwise it will
# fall back on the generated _version module.
try:
try:
from ._dev.scm_version import version
except ImportE... | 42 | 976 |
pyfilesystem2 | tests/test_bulk.py | .py | from __future__ import unicode_literals
import unittest
from fs._bulk import Copier, _Task
from fs.errors import BulkCopyFailed
class BrokenTask(_Task):
def __call__(self):
1 / 0
class TestBulk(unittest.TestCase):
def test_worker_error(self):
with self.assertRaises(BulkCopyFailed):
... | 19 | 410 |
pymc | pymc/sampling/deterministic.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... | 192 | 7,254 |
coremltools | coremltools/proto/SoundAnalysisPreprocessing_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: SoundAnalysisPreprocessing.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import message as... | 47 | 2,227 |
mlflow | mlflow/types/utils.py | .py | import logging
import warnings
from collections import defaultdict
from copy import deepcopy
from typing import Any, Dict, List
import numpy as np
import pandas as pd
import pydantic
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
from mlflow.types import... | 742 | 27,468 |
wagtail | wagtail/snippets/tests/test_chooser_widget.py | .py | from django.test import TestCase
from wagtail.snippets.widgets import (
AdminSnippetChooser,
SnippetChooserAdapter,
)
from wagtail.test.testapp.models import Advert
from wagtail.test.utils import WagtailTestUtils
class TestAdminSnippetChooserWidget(WagtailTestUtils, TestCase):
def test_adapt(self):
... | 23 | 673 |
hatch | tests/helpers/templates/wheel/standard_default_sbom.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.default import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
metadata_direc... | 55 | 1,492 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.