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 |
|---|---|---|---|---|---|
saleor | saleor/graphql/order/tests/queries/test_orders_search.py | .py | from decimal import Decimal
import graphene
import pytest
from prices import Money, TaxedMoney
from .....core.postgres import FlatConcatSearchVector
from .....discount.models import OrderDiscount
from .....invoice.models import Invoice
from .....order import OrderEvents
from .....order.models import Order, Payment
fr... | 577 | 16,707 |
pyomo | pyomo/contrib/preprocessing/plugins/zero_sum_propagator.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 | 4,221 |
openvino | src/frontends/onnx/tests/tests_python/test_frontend_lib_close.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import onnx
import pytest
from onnx.helper import make_graph, make_model, make_tensor_value_info
from openvino.frontend import FrontEndManager
def make_onnx_model(model_name: str) -> None:
"""Make ... | 82 | 2,428 |
structlog | tests/test_config.py | .py | # SPDX-License-Identifier: MIT OR Apache-2.0
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the MIT License. See the LICENSE file in the root of this
# repository for complete details.
import abc
import pickle
import warnings
from unittest.mock import call
import pytest
impo... | 469 | 13,276 |
wandb | wandb/_strutils.py | .py | from __future__ import annotations
from base64 import b64decode, b64encode
from collections.abc import Iterable
from typing import Any
def ensureprefix(s: str, prefix: str) -> str:
"""Ensures the string has the given prefix prepended."""
return s if s.startswith(prefix) else f"{prefix}{s}"
def nameof(obj: ... | 41 | 1,279 |
wagtail | wagtail/admin/tests/test_userbar.py | .py | import json
from django.contrib.auth.models import AnonymousUser, Permission
from django.template import Context, Template
from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils import translation
from django.utils.translation import gettext
from wagtail import hooks
fro... | 977 | 37,609 |
mlflow | tests/genai/judges/test_judge_tool_search_traces.py | .py | from unittest import mock
import pytest
from mlflow.entities.assessment import Expectation, Feedback
from mlflow.entities.assessment_error import AssessmentError
from mlflow.entities.assessment_source import AssessmentSource, AssessmentSourceType
from mlflow.entities.span import Span
from mlflow.entities.trace import... | 452 | 14,984 |
pdm | tests/test_signals.py | .py | from itertools import chain
from unittest import mock
import pytest
from pdm import signals
from pdm.models.candidates import Candidate
from pdm.models.repositories import Package
from pdm.models.requirements import Requirement
def test_post_init_signal(project_no_init, pdm):
mock_handler = mock.Mock()
with... | 112 | 5,313 |
coremltools | coremltools/test/sklearn_tests/test_linear_regression.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import unittest
import pandas as pd
from ..utils import load_boston
from coremltools._deps import _HAS... | 137 | 4,962 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_spatialdropout2d.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasSpatialDropout2D(CommonTF2LayerTest):
def create_keras_spatialdropout2d_net(self, input_names, input_shapes, input_typ... | 58 | 2,757 |
sphinx | sphinx/search/_stopwords/no.py | .py | # automatically generated by utils/generate-snowball.py
# from https://github.com/snowballstem/snowball-website/raw/efb4ae4d65769fb1652acbe608c0c817e746c730/algorithms/norwegian/stop.txt
from __future__ import annotations
NORWEGIAN_STOPWORDS = frozenset({
'alle',
'at',
'av',
'bare',
'begge',
'... | 180 | 2,297 |
openvino | tools/ovc/unit_tests/moc_tf_fe/test_models/model_switch_merge.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import tensorflow.compat.v1 as tf
tf.reset_default_graph()
with tf.Session() as sess:
x = tf.placeholder(tf.float32, [2, 3], 'x')
y = tf.placeholder(tf.float32, [2, 3], 'y')
is_training = tf.placeholder(tf.bool, [], 'is_trai... | 21 | 702 |
metrics | docs/source/pyplots/collection_binary.py | .py | import matplotlib.pyplot as plt
import torch
import torchmetrics
N = 10
num_updates = 10
num_steps = 5
w = torch.tensor([0.2, 0.8])
target = lambda it: torch.multinomial((it * w).softmax(dim=-1), 100, replacement=True)
preds = lambda it: torch.multinomial((it * w).softmax(dim=-1), 100, replacement=True)
collection ... | 30 | 797 |
coremltools | coremltools/converters/sklearn/_ridge_regression.py | .py | # Copyright (c) 2017, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from ..._deps import _HAS_SKLEARN
from ...models import MLModel as _MLModel
if _HAS_SKLEARN:
import... | 54 | 1,422 |
probability | tensorflow_probability/python/math/gradient_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... | 324 | 12,753 |
mlflow | dev/clint/src/clint/builtin.py | .py | # https://github.com/PyCQA/isort/blob/b818cec889657cb786beafe94a6641f8fc0f0e64/isort/stdlibs/py311.py
BUILTIN_MODULES = {
"_ast",
"_thread",
"abc",
"aifc",
"argparse",
"array",
"ast",
"asynchat",
"asyncio",
"asyncore",
"atexit",
"audioop",
"base64",
"bdb",
"bi... | 217 | 3,223 |
astropy | astropy/io/fits/hdu/compressed/_codecs.py | .py | """
This module contains the FITS compression algorithms in numcodecs style Codecs.
"""
from gzip import compress as gzip_compress
from gzip import decompress as gzip_decompress
import numpy as np
from astropy.io.fits.hdu.compressed._compression import (
compress_hcompress_1_c,
compress_plio_1_c,
compres... | 454 | 13,838 |
biopython | Bio/bgzf.py | .py | #!/usr/bin/env python
# Copyright 2010-2018 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".
# Please see the LICENSE file that should have been included as part of this
# package.
... | 961 | 39,777 |
pymc | pymc/tuning/starting.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... | 270 | 9,802 |
mlflow | dev/clint/src/clint/rules/use_walrus_operator.py | .py | import ast
from clint.rules.base import Rule
class UseWalrusOperator(Rule):
def _message(self) -> str:
return (
"Use the walrus operator `:=` when a variable is assigned and only used "
"within an `if` block that tests its truthiness. "
"For example, replace `a = ...; ... | 190 | 6,365 |
pyro | pyro/infer/mcmc/mcmc_kernel.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from abc import ABCMeta, abstractmethod
class MCMCKernel(object, metaclass=ABCMeta):
def setup(self, warmup_steps, *args, **kwargs):
r"""
Optional method to set up any state required at the start of the
... | 81 | 2,347 |
kombu | examples/hello_publisher.py | .py | from __future__ import annotations
import datetime
from kombu import Connection
with Connection('amqp://guest:guest@localhost:5672//') as conn:
simple_queue = conn.SimpleQueue('simple_queue')
message = f'helloworld, sent at {datetime.datetime.today()}'
simple_queue.put(message)
print(f'Sent: {message... | 13 | 349 |
saleor | saleor/checkout/tests/test_search_indexing.py | .py | from decimal import Decimal
from unittest.mock import patch
import graphene
import pytest
from ...payment.models import Payment, TransactionEvent, TransactionItem
from ...plugins.manager import get_plugins_manager
from ...tests import race_condition
from ..fetch import fetch_checkout_info
from ..models import Checkou... | 730 | 20,995 |
metrics | src/torchmetrics/multimodal/__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... | 24 | 974 |
beam | sdks/python/apache_beam/ml/inference/agent_development_kit.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... | 309 | 11,404 |
mlflow | dev/clint/tests/rules/test_os_chdir_in_test.py | .py | from pathlib import Path
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import Position, Range, lint_file
from clint.rules.os_chdir_in_test import OsChdirInTest
def test_os_chdir_in_test(index: SymbolIndex) -> None:
code = """
import os
# Bad
def test_func():
os.chdir(... | 107 | 2,913 |
pyfilesystem2 | tests/test_zipfs.py | .py | # -*- encoding: UTF-8
from __future__ import unicode_literals
import sys
import os
import six
import tempfile
import unittest
import zipfile
from fs import zipfs
from fs.compress import write_zip
from fs.enums import Seek
from fs.errors import NoURL
from fs.opener import open_fs
from fs.opener.errors import NotWrite... | 227 | 7,792 |
pyomo | doc/OnlineDocs/src/data/set5.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... | 23 | 789 |
scikit-bio | skbio/io/tests/test_descriptors.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.
# --------------------------------------------... | 669 | 25,411 |
wandb | wandb/integration/keras/callbacks/model_checkpoint.py | .py | from __future__ import annotations
import os
import string
from typing import Any, Literal
import tensorflow as tf # type: ignore
from tensorflow.keras import callbacks # type: ignore
import wandb
from wandb.sdk.lib import telemetry
from wandb.sdk.lib.paths import StrPath
from ..keras import patch_tf_keras
Mode ... | 191 | 8,512 |
coremltools | deps/protobuf/python/google/protobuf/internal/reflection_test.py | .py | # -*- coding: utf-8 -*-
# Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions a... | 3,380 | 139,465 |
sqlmap | plugins/dbms/maxdb/fingerprint.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.agent import agent
from lib.core.common import Backend
from lib.core.common import Format
from lib.core.compat import xrange
from lib.core.data import conf
from lib.... | 138 | 3,791 |
coremltools | coremltools/converters/mil/mil/passes/defs/quantization.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 abc import abstractmethod
from enum import Enum as _Enum
from typing import Dict, Set, Text, Tup... | 653 | 26,940 |
black | src/black/trans.py | .py | """
String transformers that can split and merge strings.
"""
import re
from abc import ABC, abstractmethod
from collections import defaultdict
from collections.abc import Callable, Collection, Iterable, Iterator, Sequence
from dataclasses import dataclass
from typing import Any, ClassVar, Final, Literal, TypeVar, Uni... | 2,617 | 100,252 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Squeeze.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
class TestSqueeze(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
assert 'input:0' in inputs_info
... | 149 | 6,282 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_ConjugateTranspose.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
# Testing operation ConjugateTranspose
# Documentation: https://www.tensorflow.org/api_docs/python/tf/raw_ops/ConjugateTr... | 117 | 4,113 |
pyro | examples/hmm.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
This example shows how to marginalize out discrete model variables in Pyro.
This combines Stochastic Variational Inference (SVI) with a
variable elimination algorithm, where we use enumeration to exactly
marginalize out some v... | 776 | 32,365 |
beam | sdks/python/apache_beam/runners/interactive/interactive_environment.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... | 751 | 32,171 |
readthedocs.org | readthedocs/search/tests/utils.py | .py | import random
from readthedocs.projects.models import HTMLFile
SECTION_FIELDS = ["section.title", "section.content"]
DATA_TYPES_VALUES = ["title"] + SECTION_FIELDS
def get_search_query_from_project_file(
project_slug, page_num=0, field="title", type=None
):
"""
Return search query from the project's pag... | 55 | 1,539 |
pymc | tests/distributions/test_simulator.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... | 384 | 14,059 |
cvxpy | cvxpy/tests/nlp_tests/test_entropy_related.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
... | 188 | 6,905 |
metrics | src/torchmetrics/functional/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... | 349 | 18,024 |
beam | sdks/python/apache_beam/runners/sdf_utils.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... | 242 | 9,138 |
saleor | saleor/plugins/views.py | .py | from django.http import HttpResponse
from ..core.db.connection import allow_writer
from ..graphql.core import SaleorContext
from .manager import get_plugins_manager
@allow_writer()
def handle_plugin_webhook(request: SaleorContext, plugin_id: str) -> HttpResponse:
manager = get_plugins_manager(allow_replica=False... | 28 | 896 |
saleor | saleor/csv/tests/test_notifications.py | .py | from unittest import mock
from django.core.files import File
from freezegun import freeze_time
from ...core.notification.utils import get_site_context
from ...core.notify import AdminNotifyEvent
from ...core.utils import build_absolute_uri
from .. import notifications
from ..notifications import get_default_export_pa... | 100 | 3,263 |
readthedocs.org | readthedocs/audit/signals.py | .py | """Audit signals."""
from django.contrib.auth.models import User
from django.contrib.auth.signals import user_logged_in
from django.contrib.auth.signals import user_logged_out
from django.contrib.auth.signals import user_login_failed
from django.db.models import Q
from django.dispatch import receiver
from readthedocs... | 50 | 1,411 |
coremltools | docs/examples/optimize/torch/palettization/dkm_palettization.py | .py | # -*- coding: utf-8 -*-
"""
.. _palettization_tutorial:
Palettization Using Differentiable K-Means
==========================================
"""
########################################################################
# In this tutorial, you learn how to palettize a
# network trained on `MNIST <http://yann.lecun.co... | 226 | 8,142 |
confluent-kafka-python | src/confluent_kafka/schema_registry/common/serde.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2024 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 586 | 17,109 |
kafka | docker/docker_official_image_build_test.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... | 88 | 4,385 |
onnxruntime | onnxruntime/contrib_ops/cuda/sparse/sparse_attention_v1/compile_sparse_attention.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# Use triton AoT compiler to convert sparse_attention_triton.py to C sou... | 136 | 7,211 |
coremltools | coremltools/converters/mil/mil/passes/graph_pass.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 abc import ABC, abstractmethod
from typing import Callable, List, Optional, Text, Union
from co... | 75 | 2,756 |
clearml | clearml/debugging/__init__.py | .py | """ Debugging module """
from .log import (
get_logger,
get_null_logger,
TqdmLog,
add_options as add_log_options,
apply_logging_args as parse_log_args,
add_rotating_file_handler,
add_time_rotating_file_handler,
)
from .timer import Timer
__all__ = [
"Timer",
"get_logger",
"get_n... | 23 | 466 |
onnx | tests/python/function_test.py | .py | # SPDX-License-Identifier: Apache-2.0
# Copyright (c) ONNX Project Contributors
from __future__ import annotations
import onnx
from onnx import checker, utils
class TestFunction:
def _verify_function_set(self, extracted_model, function_set, func_domain):
checker.check_model(extracted_model)
asse... | 222 | 8,523 |
beam | sdks/python/apache_beam/runners/interactive/dataproc/dataproc_cluster_manager_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... | 360 | 14,881 |
probability | tensorflow_probability/python/layers/util.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... | 360 | 14,450 |
readthedocs.org | readthedocs/oauth/admin.py | .py | """Admin configuration for the OAuth app."""
from django.contrib import admin
from .models import GitHubAppInstallation
from .models import RemoteOrganization
from .models import RemoteOrganizationRelation
from .models import RemoteRepository
from .models import RemoteRepositoryRelation
@admin.register(GitHubAppIns... | 135 | 3,092 |
mlflow | tests/tracking/integration_test_utils.py | .py | import contextlib
import logging
import os
import socket
import sys
import time
from subprocess import Popen
from threading import Thread
from typing import Any, Generator, Literal
import requests
import uvicorn
from fastapi import FastAPI
import mlflow
from mlflow.server import ARTIFACT_ROOT_ENV_VAR, BACKEND_STORE_U... | 165 | 5,170 |
scikit-bio | skbio/metadata/_testing.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.
# --------------------------------------------... | 1,374 | 52,348 |
lemur | lemur/plugins/lemur_azure_dest/tests/test_azure_dest.py | .py | import unittest
from unittest.mock import patch, Mock
from flask import Flask
from lemur.plugins.lemur_azure_dest import plugin
import json
# mock certificate to test the upload function code
test_server_cert = '''-----BEGIN CERTIFICATE-----
MIIDsDCCApigAwIBAgIJAIezI4YBdaH5MA0GCSqGSIb3DQEBCwUAMGYxCzAJBgNV
BAYTAkFUMQ8... | 140 | 6,947 |
voila | tests/app/page_config_hook_test.py | .py | import os
import pytest
BASE_DIR = os.path.dirname(__file__)
@pytest.fixture
def voila_notebook(notebook_directory):
return os.path.join(notebook_directory, "print.ipynb")
@pytest.fixture
def voila_config():
def foo(current_page_config, **kwargs):
current_page_config["foo"] = "my custom config"
... | 30 | 664 |
textual | tests/selection_list/test_selection_values.py | .py | """Unit tests dealing with the tracking of selection list values."""
from __future__ import annotations
from textual.app import App, ComposeResult
from textual.widgets import SelectionList
class SelectionListApp(App[None]):
def __init__(self, default_state: bool = False) -> None:
super().__init__()
... | 83 | 3,216 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/Line_breaks_in_LateX_305.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: region,endregion
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# This cell uses no particular cell marker
#
# $$
# \begin{align}
# \dot{x} & = \sigma(y-x)\\
# \dot{y} & = \rho x - y - xz \\
# \dot{z} & = -\beta z + xy
# ... | 44 | 818 |
saleor | saleor/graphql/attribute/tests/mutations/test_attribute_bulk_create.py | .py | from unittest.mock import patch
import graphene
from .....attribute import AttributeType
from .....attribute.error_codes import AttributeBulkCreateErrorCode
from .....attribute.models import Attribute, AttributeValue
from ....core.enums import ErrorPolicyEnum
from ....tests.utils import get_graphql_content
from ...en... | 915 | 28,810 |
onnxruntime | orttraining/orttraining/python/training/ortmodule/_fallback_exceptions.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# _fallback_exceptions.py
class ORTModuleFallbackException(Exception): # noqa: N818
"""Base exception class for fallback
Although it must be specialized for specific scenarios,
it can also be used for generic e... | 66 | 2,349 |
coremltools | coremltools/converters/mil/frontend/torch/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 pytest
import torch
import torch.nn as nn
from coremltools.converters.mil.frontend.torch.ops ... | 145 | 5,640 |
wagtail | wagtail/project_template/home/tests.py | .py | from home.models import HomePage
from wagtail.models import Page, Site
from wagtail.test.utils import WagtailPageTestCase
class HomeSetUpTests(WagtailPageTestCase):
"""
Tests for basic page structure setup and HomePage creation.
"""
def test_root_create(self):
root_page = Page.objects.get(pk... | 43 | 1,303 |
probability | tensorflow_probability/python/distributions/chi.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... | 171 | 6,413 |
sphinx | sphinx/util/_pathlib.py | .py | """What follows is awful and will be gone in Sphinx 10.
Instances of _StrPath should not be constructed except in Sphinx itself.
Consumers of Sphinx APIs should prefer using ``pathlib.Path`` objects
where possible. _StrPath objects can be treated as equivalent to ``Path``,
save that ``_StrPath.replace`` is overridden ... | 182 | 6,711 |
openvino | docs/articles_en/assets/snippets/ov_infer_request.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from utils import get_model
#! [import]
import openvino as ov
#! [import]
core = ov.Core()
model = get_model()
compiled_model = core.compile_model(model, "AUTO")
#! [create_infer_request]
infer_request = compiled_model.create_infer_re... | 98 | 2,398 |
pyomo | pyomo/dataportal/DataPortal.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... | 441 | 14,915 |
cvxpy | cvxpy/tests/test_python_backends.py | .py | from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass
import numpy as np
import pytest
import scipy.sparse as sp
import cvxpy as cp
import cvxpy.settings as s
from cvxpy.lin_ops.backends import (
CooCanonBackend,
CooTensor,
PythonCanonBackend,
SciPy... | 3,562 | 132,597 |
coremltools | coremltools/converters/mil/mil/ops/tests/iOS14/__init__.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
import coremltools as ct
from coremltools.converters.mil.testing_reqs import backends_internal, clean... | 10 | 430 |
flit | flit/wheel.py | .py | import logging
import flit_core.wheel as core_wheel
log = logging.getLogger(__name__)
def make_wheel_in(ini_path, wheel_directory, editable=False):
return core_wheel.make_wheel_in(ini_path, wheel_directory, editable)
class WheelBuilder(core_wheel.WheelBuilder):
pass
| 12 | 279 |
eve | eve/methods/__init__.py | .py | # -*- coding: utf-8 -*-
"""
eve.methods
~~~~~~~~~~~
This package implements the HTTP methods supported by Eve.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
from eve.methods.delete import delete, deleteitem
# flake8: noqa
from eve.methods.get import get... | 19 | 432 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/Notebook with html and latex cells.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: '{{{,}}}'
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# {{{ language="html"
# <p><a href="https://github.com/mwouts/jupytext", style="color: rgb(0,0,255)">Jupytext</a> on GitHub</p>
# }}}
# {{{ language="latex"
# $\fr... | 29 | 591 |
textual | docs/examples/styles/outline_vs_border.py | .py | from textual.app import App
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, I will turn the inner eye to see its path.
Where th... | 25 | 690 |
omegaconf | tests/structured_conf/data/dataclasses_pre_311.py | .py | import dataclasses
import sys
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Dict, List, Literal, Optional, Tuple, Union, cast
from pytest import importorskip
from omegaconf import II, MISSING, SI
from tests import Color, Enum1
if sys.version_info >= (3, 8): # pragma: no c... | 942 | 23,434 |
pyro | examples/smcfilter.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import argparse
import logging
import torch
import pyro
import pyro.distributions as dist
from pyro.infer import SMCFilter
logging.basicConfig(format="%(relativeCreated) 9d %(message)s", level=logging.INFO)
"""
This file demons... | 119 | 3,358 |
probability | tensorflow_probability/python/internal/backend/numpy/numpy_math.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... | 1,081 | 31,860 |
mamba | libmambapy/src/libmambapy/specs.py | .py | # This file exists on its own rather than in `__init__.py` to make `import libmambapy.specs` work.
from libmambapy.bindings.specs import * # noqa: F403
| 3 | 153 |
openvino | tests/layer_tests/jax_tests/test_square.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(34455)
class TestSquare(JaxLayerTest):
def _prepare_input(self):
if np.iss... | 45 | 1,571 |
saleor | saleor/webhook/tests/response_schemas/test_shipping.py | .py | import base64
from decimal import Decimal
from unittest.mock import patch
import graphene
import pytest
from pydantic import ValidationError
from ...response_schemas.shipping import (
ExcludedShippingMethodSchema,
FilterShippingMethodsSchema,
ListShippingMethodsSchema,
ShippingMethodSchema,
logger... | 488 | 14,814 |
mlflow | mlflow/protos/model_registry_pb2.py | .py |
import google.protobuf
from packaging.version import Version
if Version(google.protobuf.__version__).major >= 5:
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: model_registry.proto
# Protobuf Python Version: 5.26.0
"""Generated protocol buffer code."""
from goo... | 1,074 | 103,633 |
mlflow | mlflow/store/model_registry/databricks_workspace_model_registry_rest_store.py | .py | import logging
from functools import partial
from urllib.parse import parse_qs, urlparse
import mlflow
from mlflow.environment_variables import MLFLOW_SKIP_SIGNATURE_CHECK_FOR_UC_REGISTRY_MIGRATION
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import (
RESOURCE_ALREADY_EXISTS,
... | 164 | 7,180 |
mlflow | mlflow/deployments/interface.py | .py | import inspect
from logging import Logger
from mlflow.deployments.base import BaseDeploymentClient
from mlflow.deployments.plugin_manager import DeploymentPlugins
from mlflow.deployments.utils import get_deployments_target, parse_target_uri
from mlflow.exceptions import MlflowException
plugin_store = DeploymentPlugin... | 103 | 4,624 |
probability | tensorflow_probability/python/vi/mutual_information.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... | 573 | 24,144 |
wagtail | wagtail/models/panels.py | .py | # Placeholder for panel types defined in wagtail.admin.panels.
# These are needed because we wish to define properties such as `content_panels` on core models
# such as Page, but importing from wagtail.admin would create a circular import. We therefore use a
# placeholder object, and swap it out for the real panel clas... | 38 | 1,239 |
onnxruntime | onnxruntime/test/testdata/make_transpose_optimizer_per_axis_qdq_models.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import numpy as np
import onnx
def subgraph_1d_const_input_dq(inputs, initializers, nodes) -> str:
"""
Creates mul_weight -> DQ. mul_weight is a constant of rank 1.
"""
mul_weight_i8_data = np.array([1, 2, 3... | 208 | 6,871 |
pyomo | pyomo/contrib/gdpopt/cut_generation.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... | 99 | 4,101 |
sqlmap | plugins/dbms/db2/fingerprint.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.common import Backend
from lib.core.common import Format
from lib.core.compat import xrange
from lib.core.data import conf
from lib.core.data import kb
from lib.core... | 181 | 5,870 |
saleor | saleor/graphql/translations/tests/mutations/test_product_translate.py | .py | import graphene
from .....product.models import ProductTranslation
from ....core.enums import LanguageCodeEnum
from ....tests.utils import get_graphql_content
PRODUCT_TRANSLATE_MUTATION = """
mutation (
$id: ID!,
$languageCode: LanguageCodeEnum!,
$input: TranslationInput!
) {
pr... | 189 | 4,874 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/partition_lambda.py | .py | # coding=utf-8
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License");... | 72 | 2,488 |
mlflow | tests/gateway/schemas/test_chat.py | .py | import pydantic
import pytest
from mlflow.gateway.schemas import chat
def test_chat_request():
chat.RequestPayload(**{
"messages": [{"role": "user", "content": "content"}],
})
chat.RequestPayload(**{
"messages": [
{
"role": "user",
"content": [
... | 277 | 8,754 |
saleor | saleor/graphql/product/mutations/__init__.py | .py | from .category import CategoryCreate, CategoryDelete, CategoryUpdate
from .collection import (
CollectionAddProducts,
CollectionCreate,
CollectionDelete,
CollectionRemoveProducts,
CollectionReorderProducts,
CollectionUpdate,
)
from .product import (
ProductCreate,
ProductDelete,
Prod... | 60 | 1,497 |
mlflow | examples/databricks/log_runs.py | .py | """
Logs MLflow runs in Databricks from an external host.
How to run:
$ python examples/databricks/log_runs.py --host <host> --token <token> --user <user> [--experiment-id 123]
See also:
https://docs.databricks.com/dev-tools/api/latest/authentication.html#generate-a-personal-access-token
"""
import argparse
import o... | 57 | 1,756 |
sqlmap | tests/test_charset.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Response charset / meta detection and parameter parsing.
checkCharEncoding canonicalizes the encoding sqlmap will decode a page with;
META_CHARSET_REGEX / HTML_TITLE_REGEX / META_REF... | 105 | 4,730 |
wandb | wandb/automations/_generated/update_automation.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/automations/
from __future__ import annotations
from wandb._pydantic import GQLResult
from .fragments import TriggerFields
class UpdateAutomation(GQLResult):
result: UpdateAutomationResult | None
class UpdateAutomationResult(GQLResult):
trigg... | 21 | 419 |
onnxruntime | plugin-ep-webgpu/python/setup.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Minimal setup.py to produce a platform-specific wheel.
The package contains pre-built native libraries (not CPython extension modules),
so the wheel tag should be py3-none-{platform} rather than cp3XX-cp3XX-{platform}.
Th... | 30 | 888 |
jupytext | tests/external/test_marimo.py | .py | from jupytext.marimo import marimo_py_to_notebook, notebook_to_marimo_py, marimo_version
import pytest
from nbformat.v4.nbbase import new_notebook, new_code_cell
from jupytext.compare import compare, compare_notebooks
from jupytext.formats import guess_format
@pytest.fixture
def py_marimo() -> str:
return f"""imp... | 45 | 995 |
beam | sdks/python/apache_beam/typehints/decorators.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,124 | 39,793 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.