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/sentence_transformers/simple.py | .py | from sentence_transformers import SentenceTransformer
import mlflow
import mlflow.sentence_transformers
model = SentenceTransformer("all-MiniLM-L6-v2")
example_sentences = ["This is a sentence.", "This is another sentence."]
# Define the signature
signature = mlflow.models.infer_signature(
model_input=example_s... | 43 | 1,360 |
coremltools | coremltools/converters/mil/frontend/tensorflow/tf_op_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
from coremltools import _logger as logger
_TF_OPS_REGISTRY = {}
def register_tf_op(_func=None, tf... | 59 | 2,039 |
pyomo | pyomo/contrib/iis/tests/trivial_mis.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... | 28 | 1,263 |
saleor | saleor/tests/e2e/promotions/utils/promotion_query.py | .py | from ...utils import get_graphql_content
PROMOTION_QUERY = """
query PromotionQuery($id:ID!) {
promotion(id:$id) {
id
}
}
"""
def promotion_query(
staff_api_client,
promotion_id,
):
variables = {"id": promotion_id}
response = staff_api_client.post_graphql(
PROMOTION_QUERY,
va... | 28 | 425 |
saleor | saleor/graphql/checkout/mutations/checkout_email_update.py | .py | import graphene
from django.core.exceptions import ValidationError
from ....checkout.actions import call_checkout_event
from ....checkout.error_codes import CheckoutErrorCode
from ....webhook.event_types import WebhookEventAsyncType
from ...core import ResolveInfo
from ...core.context import SyncWebhookControlContext
... | 91 | 3,007 |
astropy | astropy/nddata/tests/test_compat.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module contains tests of a class equivalent to pre-1.0 NDData.
import numpy as np
import pytest
from astropy import units as u
from astropy.nddata.compat import NDDataArray
from astropy.nddata.nddata import NDData
from astropy.nddata.nduncertaint... | 158 | 4,855 |
saleor | saleor/graphql/product/tests/queries/test_categories_query_with_filter.py | .py | import graphene
import pytest
from freezegun import freeze_time
from .....product.models import (
Category,
Product,
ProductChannelListing,
ProductVariantChannelListing,
)
from .....tests.utils import dummy_editorjs
from .....warehouse.models import Stock, Warehouse
from ....tests.utils import get_grap... | 950 | 24,985 |
saleor | saleor/asgi/tests/test_telemetry.py | .py | from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from asgiref.typing import ASGIReceiveCallable, ASGISendCallable
from ...asgi.telemetry import get_hostname, telemetry_middleware
from ...core.telemetry.saleor_attributes import SALEOR_ENVIRONMENT_DOMAIN
@pytest.mark.parametrize(
("scope", "exp... | 91 | 2,366 |
onnx | tests/python/basic_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import io
import os
import pathlib
import tempfile
import google.protobuf.message
import google.protobuf.text_format
import pytest
import onnx
from onnx import serialization
def _simple_model() -> on... | 294 | 11,626 |
saleor | saleor/graphql/app/tests/queries/test_apps.py | .py | import graphene
import pytest
from freezegun import freeze_time
from .....app.models import App
from .....app.types import AppType
from .....core.jwt import create_access_token_for_app
from .....webhook.models import Webhook
from ....tests.utils import (
assert_no_permission,
get_graphql_content,
get_graph... | 527 | 13,690 |
conda | tests/_private/test_extract.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Verify the extraction worker module stays import-light."""
from __future__ import annotations
import subprocess
import sys
def test_extract_module_does_not_import_runtime_state() -> None:
script = """\
import sys
import conda._private... | 37 | 935 |
saleor | saleor/graphql/product/tests/test_product_prior_price.py | .py | import graphene
from ...tests.utils import get_graphql_content
def test_product_prior_price(api_client, product, channel_USD):
# given
query = """
query ProductWithPriorPrice($id: ID!, $channel: String!) {
product(id: $id, channel: $channel) {
pricing {
... | 42 | 1,161 |
astropy | astropy/io/votable/dataorigin.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Extract Data Origin in VOTable.
References
----------
DataOrigin is a vocabulary described in the IVOA note: https://www.ivoa.net/documents/DataOrigin/
Notes
-----
This API retrieve Metadata from INFO in VOTable.
The information can be found at diffe... | 638 | 18,828 |
sqlmap | thirdparty/chardet/cp949prober.py | .py | ######################## BEGIN LICENSE BLOCK ########################
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Con... | 50 | 1,855 |
mlflow | mlflow/server/auth/__init__.py | .py | """
Usage
-----
.. code-block:: bash
mlflow server --app-name basic-auth
"""
from __future__ import annotations
import asyncio
import base64
import functools
import hmac
import importlib
import json
import logging
import os
import re
import secrets
import threading
from dataclasses import asdict, dataclass
from... | 5,774 | 220,958 |
scikit-bio | skbio/util/_plotting.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.
# --------------------------------------------... | 69 | 2,018 |
astropy | astropy/coordinates/tests/test_name_resolve.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains tests for the name resolve convenience module.
"""
import time
import urllib.request
import numpy as np
import pytest
from pytest_remotedata.disable_internet import no_internet
from astropy import units as u
from astropy.config... | 198 | 6,129 |
saleor | saleor/graphql/product/tests/queries/test_category_query.py | .py | import logging
from unittest.mock import MagicMock
import graphene
from django.core.files import File
from .....product.models import Category, Product
from .....product.utils.costs import get_product_costs_data
from .....tests.utils import dummy_editorjs
from .....thumbnail.models import Thumbnail
from ....core.enum... | 770 | 25,107 |
saleor | saleor/graphql/account/tests/mutations/staff/test_customer_update.py | .py | from unittest.mock import patch
import graphene
import pytest
from ......account import events as account_events
from ......account import models
from ......account.error_codes import AccountErrorCode
from ......attribute.models import AssignedUserAttributeValue
from ......giftcard.models import GiftCard
from ......g... | 1,172 | 38,527 |
coremltools | coremltools/proto/TreeEnsemble_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: TreeEnsemble.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_po... | 96 | 6,947 |
astropy | astropy/io/fits/hdu/compressed/tests/test_checksum.py | .py | # Licensed under a 3-clause BSD style license - see PYFITS.rst
import numpy as np
from astropy.io import fits
from astropy.io.fits.tests.test_checksum import BaseChecksumTests
class TestChecksumFunctions(BaseChecksumTests):
# All checksums have been verified against CFITSIO
def test_compressed_image_data(s... | 148 | 6,795 |
mlflow | tests/gateway/providers/test_openai.py | .py | from unittest import mock
import pytest
from aiohttp import ClientTimeout
from fastapi.encoders import jsonable_encoder
from pydantic import ValidationError
from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS
from mlflow.exceptions import MlflowException
from mlflow.gateway.config import End... | 1,498 | 53,664 |
onnxruntime | setup.py | .py | # ------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# ------------------------------------------------------------------------
# pylint: disable=C0103
import datetime
import json
import logging
import p... | 922 | 38,301 |
cvxpy | cvxpy/reductions/solvers/kktsolver.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... | 125 | 4,372 |
eve | eve/validation.py | .py | # -*- coding: utf-8 -*-
"""
eve.validation
~~~~~~~~~~~~~~
Helper module. Allows eve submodules (methods.patch/post) to be fully
datalayer-agnostic. Specialized Validator classes are implemented in the
datalayer submodules.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE... | 178 | 6,430 |
saleor | saleor/graphql/payment/mutations/stored_payment_methods/utils.py | .py | from django.core.exceptions import ValidationError
from .....channel.models import Channel
from .....payment.interface import (
PaymentMethodTokenizationBaseRequestData,
PaymentMethodTokenizationResponseData,
)
from ....core import ResolveInfo
from ....plugins.dataloaders import get_plugin_manager_promise
from... | 49 | 1,569 |
mlflow | examples/openai/embeddings.py | .py | import os
import numpy as np
import openai
import mlflow
from mlflow.models.signature import ModelSignature
from mlflow.types.schema import ColSpec, ParamSchema, ParamSpec, Schema, TensorSpec
assert "OPENAI_API_KEY" in os.environ, " OPENAI_API_KEY environment variable must be set"
print(
"""
# ****************... | 54 | 1,543 |
wandb | wandb/sdk/wandb_init.py | .py | """Defines wandb.init() and associated classes and methods.
`wandb.init()` indicates the beginning of a new run. In an ML training pipeline,
you could add `wandb.init()` to the beginning of your training script as well as
your evaluation script, and each step would be tracked as a run in W&B.
For more on using `wandb... | 1,558 | 60,248 |
pyomo | pyomo/contrib/solver/tests/solvers/test_asl_sol_reader.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... | 707 | 24,591 |
mlflow | mlflow/store/tracking/mcp_server_registry/__init__.py | .py | from mlflow.store.tracking.mcp_server_registry.abstract_mixin import MCPServerRegistryMixin
__all__ = ["MCPServerRegistryMixin"]
| 4 | 130 |
toolz | toolz/tests/test_compatibility.py | .py | import pytest
import importlib
def test_compat_warn():
with pytest.warns(DeprecationWarning):
# something else is importing this,
import toolz.compatibility
# reload to be sure we warn
importlib.reload(toolz.compatibility)
| 10 | 260 |
onnxruntime | orttraining/orttraining/test/python/qat_poc_example/model.py | .py | import io
import logging
import os
import onnx
import torch
from onnxruntime.training import artifacts
class MNIST(torch.nn.Module):
"""MNIST PyTorch model"""
def __init__(self, input_size, hidden_size, num_classes):
super().__init__()
self.fc1 = torch.nn.Linear(input_size, hidden_size)
... | 122 | 4,135 |
saleor | saleor/payment/models.py | .py | from decimal import Decimal
from operator import attrgetter
from uuid import uuid4
from django.conf import settings
from django.contrib.postgres.fields import ArrayField
from django.contrib.postgres.indexes import BTreeIndex, GinIndex
from django.core.serializers.json import DjangoJSONEncoder
from django.core.validato... | 510 | 18,312 |
ipython | IPython/terminal/prompts.py | .py | """Terminal input and output prompts."""
from __future__ import annotations
from pygments.token import _TokenType, Token
import sys
from IPython.core.displayhook import DisplayHook
from prompt_toolkit.formatted_text import fragment_list_width, PygmentsTokens
from prompt_toolkit.shortcuts import print_formatted_text... | 147 | 4,821 |
textual | docs/examples/widgets/radio_set_changed.py | .py | from rich.text import Text
from textual.app import App, ComposeResult
from textual.containers import Horizontal, VerticalScroll
from textual.widgets import Label, RadioButton, RadioSet
class RadioSetChangedApp(App[None]):
CSS_PATH = "radio_set_changed.tcss"
def compose(self) -> ComposeResult:
with V... | 47 | 1,703 |
beam | sdks/python/apache_beam/runners/worker/sdk_worker.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,485 | 55,117 |
wagtail | wagtail/embeds/urls.py | .py | from django.urls import path
from wagtail.embeds.views import chooser
app_name = "wagtailembeds"
urlpatterns = [
path("chooser/", chooser.chooser, name="chooser"),
path("chooser/upload/", chooser.chooser_upload, name="chooser_upload"),
]
| 10 | 248 |
cvxpy | cvxpy/utilities/replace_quad_forms.py | .py | """
Copyright 2017 Robin Verschueren
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, softw... | 58 | 2,378 |
ipython | IPython/core/history.py | .py | """History related magics and functionality"""
from __future__ import annotations
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import atexit
import datetime
import os
import re
import weakref
import threading
from pathlib import Path
import functools
from c... | 1,398 | 47,475 |
beam | sdks/python/apache_beam/runners/direct/direct_metrics.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... | 254 | 7,948 |
colorama | colorama/initialise.py | .py | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
import atexit
import contextlib
import sys
from .ansitowin32 import AnsiToWin32
def _wipe_internal_state_for_tests():
global orig_stdout, orig_stderr
orig_stdout = None
orig_stderr = None
global wrapped_stdout, wrapped_stderr... | 118 | 3,200 |
pynacl | src/nacl/hashlib.py | .py | # Copyright 2016-2019 Donald Stufft and individual contributors
#
# 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 applicabl... | 142 | 4,366 |
mkdocs-material | material/plugins/projects/builder/__init__.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... | 321 | 13,007 |
mlflow | dev/update_mlflow_versions.py | .py | import argparse
import logging
import re
from pathlib import Path
from packaging.version import Version
_logger = logging.getLogger(__name__)
_PYTHON_VERSION_FILES = [
Path("mlflow", "version.py"),
]
_PYPROJECT_TOML_FILES = [
Path("pyproject.toml"),
Path("pyproject.release.toml"),
Path("libs/skinny/... | 274 | 9,183 |
voila | setup.py | .py | # setup.py shim for use with applications that require it.
__import__("setuptools").setup()
| 3 | 92 |
scikit-bio | skbio/sequence/_genetic_code.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.
# --------------------------------------------... | 863 | 30,993 |
readthedocs.org | readthedocs/embed/v3/tests/utils.py | .py | import os
import sphinx
srcdir = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"examples",
"default",
)
def get_anchor_link_title(thing):
# https://github.com/sphinx-doc/sphinx/commit/bc635627d32b52e8e1381f23cddecf26429db1ae
if sphinx.version_info < (5, 0, 0):
if thing == "he... | 39 | 1,037 |
probability | tensorflow_probability/python/internal/backend/numpy/gen/__init__.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... | 16 | 728 |
pyfilesystem2 | tests/test_url_tools.py | .py | # coding: utf-8
"""Test url tools. """
from __future__ import unicode_literals
import platform
import unittest
from fs._url_tools import url_quote
class TestBase(unittest.TestCase):
def test_quote(self):
test_fixtures = [
# test_snippet, expected
["foo/bar/egg/foofoo", "foo/bar/e... | 40 | 1,370 |
pyomo | pyomo/mpec/__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... | 11 | 636 |
qutip | qutip/tests/test_utilities.py | .py | import numpy as np
from qutip import convert_unit, clebsch, n_thermal
import qutip.utilities as utils
from functools import partial
import pytest
@pytest.mark.parametrize(['w', 'w_th', 'expected'], [
pytest.param(np.log(2), 1, 1, id='log(2)'),
pytest.param(np.log(2)*5, 5, 1, id='5*log(2)'),
pytest.param(0... | 269 | 10,187 |
pdm | tests/cli/test_completion.py | .py | """Tests for the completion command"""
import io
import os
import shutil
import subprocess
import sys
from pathlib import Path
from unittest.mock import patch
import pytest
from argcomplete import CompletionFinder
from argcomplete.completers import SuppressCompleter
from argcomplete.shell_integration import shellcode... | 236 | 7,965 |
probability | spinoffs/inference_gym/inference_gym/targets/ground_truth/brownian_motion_unknown_scales_missing_middle_observations.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... | 150 | 4,047 |
onnxruntime | onnxruntime/test/python/transformers/bart_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.
# --------------------------------------------------------------------------
"""Gene... | 280 | 13,360 |
clearml | clearml/utilities/plotlympl/mplexporter/_py3k_compat.py | .py | """
Simple fixes for Python 2/3 compatibility
"""
import sys
PY3K = sys.version_info[0] >= 3
if PY3K:
import builtins
import functools
reduce = functools.reduce
zip = builtins.zip
xrange = builtins.range
map = builtins.map
else:
import __builtin__
import itertools
builtins = __bu... | 25 | 442 |
coveragepy | coverage/debug.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Control of and utilities for debugging."""
from __future__ import annotations
import _thread
import atexit
import contextlib
import datetime
import functools... | 668 | 21,791 |
lemur | lemur/plugins/base/v1.py | .py | """
.. module: lemur.plugins.base.v1
:platform: Unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
import re
from threading import local
from typing import Optional, Dict, List, Any
from... | 170 | 5,370 |
sqlmap | lib/techniques/union/use.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import json
import re
import time
from lib.core.agent import agent
from lib.core.bigarray import BigArray
from lib.core.common import arrayizeValue
from lib.core.common import Ba... | 567 | 30,694 |
saleor | saleor/giftcard/tests/test_notifications.py | .py | from unittest import mock
from ...account.notifications import get_default_user_payload
from ...core.notify import NotifyEventType
from ...core.tests.utils import get_site_context_payload
from ...graphql.core.utils import to_global_id_or_none
from ...plugins.manager import get_plugins_manager
from ..notifications impo... | 65 | 2,167 |
scikit-optimize | doc/sphinxext/github_link.py | .py | from operator import attrgetter
import inspect
import subprocess
import os
import sys
from functools import partial
REVISION_CMD = 'git rev-parse --short HEAD'
def _get_git_revision():
try:
revision = subprocess.check_output(REVISION_CMD.split()).strip()
except (subprocess.CalledProcessError, OSError... | 85 | 2,672 |
ipython | tools/toollib.py | .py | """Various utilities common to IPython release and maintenance tools.
"""
# Library imports
import os
import sys
from pathlib import Path
# Useful shorthands
cd = os.chdir
# Build commands
# Source dists
build_command = "{python} -m build".format(python=sys.executable)
# Utility functions
def sh(cmd):
"""Run ... | 38 | 982 |
mlflow | mlflow/gateway/schemas/__init__.py | .py | from mlflow.gateway.schemas import chat, completions, embeddings
__all__ = ["chat", "completions", "embeddings"]
| 4 | 114 |
openvino | tests/model_hub_tests/pytorch/test_detectron2.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import subprocess
import platform
import pytest
import torch
from models_hub_common.utils import get_models_list, compare_two_tensors, retry
from torch_utils import TestTorchConvertModel, process_pytest_marks, skip_... | 140 | 6,566 |
mkdocs | mkdocs/config/config_options.py | .py | from __future__ import annotations
import functools
import ipaddress
import logging
import os
import string
import sys
import traceback
import types
import warnings
from collections import Counter, UserString
from types import SimpleNamespace
from typing import (
Any,
Callable,
Collection,
Dict,
Ge... | 1,227 | 44,182 |
black | tests/data/cases/pattern_matching_complex.py | .py | # flags: --minimum-version=3.10
# Cases sampled from Lib/test/test_patma.py
# case black_test_patma_098
match x:
case -0j:
y = 0
# case black_test_patma_142
match x:
case bytes(z):
y = 0
# case black_test_patma_073
match x:
case 0 if 0:
y = 0
case 0 if 1:
y = 1
# case bl... | 156 | 2,965 |
probability | tensorflow_probability/python/experimental/stats/sample_stats.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... | 899 | 36,423 |
hydra | plugins/hydra_optuna_sweeper/example/custom-search-space-objective.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import hydra
from omegaconf import DictConfig
from optuna.trial import Trial
@hydra.main(config_path="custom-search-space", config_name="config")
def multi_dimensional_sphere(cfg: DictConfig) -> float:
w: float = cfg.w
x: float = cfg.x
... | 28 | 769 |
onnxruntime | onnxruntime/test/testdata/nn/deform_conv_test_gen.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Generate DeformConv ONNX model and test data for cross-platform validation.
Based on ONNX DeformConv spec (opset 19+): https://onnx.ai/onnx/operators/onnx__DeformConv.html
Uses a moderately complex config: groups=2, offs... | 195 | 6,638 |
cvxpy | cvxpy/reductions/eliminate_pwl/canonicalizers/max_canon.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... | 45 | 1,538 |
openvino | tests/model_hub_tests/transformation_tests/test_gptq_torchfx_transformations.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from huggingface_hub import snapshot_download
from transformers import AutoConfig, AutoTokenizer, AutoModelForCausalLM, pipeline
import torch
import hashlib
from openvino.frontend.pytorch.torchdynamo.execute import compiled_cache
import ... | 111 | 4,537 |
onnx | onnx/backend/test/case/node/reducemean.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class ReduceMean(Base):
@staticmethod
def export_do_not_keepdims() -... | 175 | 4,806 |
saleor | saleor/checkout/tests/test_associate_checkout_with_account.py | .py | import pytest
from saleor.channel import MarkAsPaidStrategy
from saleor.checkout.complete_checkout import complete_checkout
from ...plugins.manager import get_plugins_manager
from ..fetch import fetch_checkout_info, fetch_checkout_lines
@pytest.mark.django_db
@pytest.mark.parametrize(
"paid_strategy",
[
... | 119 | 3,316 |
mlflow | mlflow/gateway/tracing_utils.py | .py | import dataclasses
import functools
import inspect
import json
import logging
from collections.abc import Callable
from typing import Any
import pydantic
import mlflow
from mlflow.entities import SpanStatus, SpanType
from mlflow.entities.trace_location import MlflowExperimentLocation
from mlflow.gateway.config import... | 659 | 25,110 |
probability | tensorflow_probability/python/bijectors/real_nvp.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... | 428 | 17,886 |
saleor | saleor/page/models.py | .py | from typing import TYPE_CHECKING, Union
from django.contrib.postgres.indexes import BTreeIndex, GinIndex
from django.contrib.postgres.search import SearchVectorField
from django.db import models
from ..core.db.fields import SanitizedJSONField
from ..core.editorjs import clean_editorjs
from ..core.models import ModelW... | 108 | 3,682 |
textual | tests/animations/test_loading_indicator_animation.py | .py | """
Tests for the loading indicator animation, which is considered a basic animation.
(An animation that also plays on the level BASIC.)
"""
from textual.app import App
async def test_loading_indicator_is_not_static_on_full() -> None:
"""The loading indicator doesn't fall back to the static render on FULL."""
... | 43 | 1,362 |
onnxruntime | tools/python/util/vcpkg_helpers.py | .py | import os
from pathlib import Path
# Compile-time options that shrink the sqlite3 build used by 1DS as its offline-event store.
# The SDK uses a single event table with parameter-bound INSERT/SELECT/DELETE, a small set of
# PRAGMAs, and VACUUM. It does not use the omitted APIs or features.
_SQLITE_TELEMETRY_MINIMAL_DE... | 882 | 41,866 |
textual | docs/examples/guide/widgets/tooltip01.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Button
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear."""
class TooltipApp(App):
CSS = """
Screen {
align: center middle;
}
"""
def com... | 27 | 546 |
returns | returns/functions.py | .py | from collections.abc import Callable
from functools import wraps
from typing import Any, Never, TypeVar
from typing_extensions import ParamSpec
_FirstType = TypeVar('_FirstType')
_SecondType = TypeVar('_SecondType')
_ThirdType = TypeVar('_ThirdType')
_FuncParams = ParamSpec('_FuncParams')
def identity(instance: _F... | 163 | 4,009 |
saleor | saleor/core/tests/test_jwt.py | .py | import graphene
import jwt
from cryptography.hazmat.primitives import serialization
from django.urls import reverse
from ..jwt import (
JWT_ACCESS_TYPE,
create_access_token_for_app,
create_access_token_for_app_extension,
get_user_from_access_payload,
jwt_decode,
jwt_encode,
jwt_user_payload... | 225 | 6,550 |
onnxruntime | onnxruntime/python/tools/transformers/quantize_helper.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 ... | 81 | 2,931 |
astropy | astropy/coordinates/name_resolve.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains convenience functions for getting a coordinate object
for a named object by querying SESAME and getting the first returned result.
Note that this is intended to be a convenience, and is very simple. If you
need precise coordinates... | 216 | 7,217 |
onnxruntime | tools/python/wgsl_template/test/run_tests.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Test runner for the WGSL template Python port.
Discovers ``test_*.py`` siblings and aggregates them into one suite.
Invoked manually or via ``ctest`` (see CMake's ``add_test`` wiring).
"""
from __fu... | 35 | 978 |
mlflow | mlflow/haystack/autolog.py | .py | import json
import logging
import threading
from typing import Any
from haystack.tracing import enable_tracing
from opentelemetry import trace
from opentelemetry.context import Context
from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan
from opentelemetry.sdk.trace import Span as OTelSpan
from opentel... | 263 | 10,132 |
probability | tensorflow_probability/python/experimental/distribute/diagonal_mass_matrix_adaptation_test.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... | 161 | 6,910 |
pynacl | src/nacl/bindings/utils.py | .py | # Copyright 2013-2017 Donald Stufft and individual contributors
#
# 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 applicabl... | 142 | 4,298 |
mlflow | tests/gateway/providers/test_openai_compatible.py | .py | from unittest import mock
import pytest
from fastapi.encoders import jsonable_encoder
from mlflow.gateway.config import EndpointConfig, _OpenAICompatibleConfig
from mlflow.gateway.providers.base import PassthroughAction
from mlflow.gateway.providers.openai_compatible import (
OpenAICompatibleAdapter,
OpenAICo... | 504 | 16,117 |
onnxruntime | onnxruntime/test/python/quantization/test_op_gemm.py | .py | #!/usr/bin/env python
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# ---------------------------------------------------------------... | 846 | 32,702 |
saleor | saleor/tests/e2e/orders/utils/order_query.py | .py | from ...account.utils.fragments import ADDRESS_FRAGMENT
from ...utils import get_graphql_content
from .fragments import ORDER_LINE_FRAGMENT
ORDER_QUERY = (
"""
query OrderDetails($id: ID!) {
order(id: $id) {
paymentStatus
authorizeStatus
chargeStatus
isPaid
payments {
id
gateway
... | 113 | 1,626 |
onnxruntime | onnxruntime/test/testdata/transform/computation_reduction/gathernd/gathernd_matmul.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,
... | 53 | 1,769 |
astropy | astropy/utils/tests/test_data.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# NOTE: All the tests here might non-deterministically emit
# ResourceWarning about unclosed socket or SSLSocket,
# which we tell pytest to ignore. See GH Issue 9619.
import base64
import contextlib
import errno
import hashlib
import io
import... | 2,434 | 82,656 |
wagtail | wagtail/test/basepage/models.py | .py | from django.db import models
from wagtail.models import AbstractPage
class BasePage(AbstractPage):
importance = models.CharField(max_length=255, blank=True, null=True)
promote_panels = AbstractPage.promote_panels + ["importance"]
| 10 | 242 |
mlflow | mlflow/genai/judges/constants.py | .py | _DATABRICKS_DEFAULT_JUDGE_MODEL = "databricks"
_DATABRICKS_AGENTIC_JUDGE_MODEL = "gpt-oss-120b"
# Use case constants for chat completions
USE_CASE_BUILTIN_JUDGE = "builtin_judge"
USE_CASE_AGENTIC_JUDGE = "agentic_judge"
USE_CASE_CUSTOM_PROMPT_JUDGE = "custom_prompt_judge"
USE_CASE_JUDGE_ALIGNMENT = "judge_alignment"
... | 102 | 1,768 |
conda | conda/api.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Collection of conda's high-level APIs."""
from .base.constants import DepsModifier as _DepsModifier
from .base.constants import UpdateModifier as _UpdateModifier
from .base.context import context
from .common.constants import NULL
from .core... | 502 | 17,522 |
qutip | qutip/tests/test_subsys_apply.py | .py | from numpy.linalg import norm
from qutip import (
Qobj, tensor, vector_to_operator, operator_to_vector, kraus_to_super,
subsystem_apply, rand_dm, rand_unitary,
)
from qutip.random_objects import rand_kraus_map
class TestSubsysApply(object):
"""
A test class for the QuTiP function for applying superop... | 117 | 4,569 |
saleor | saleor/graphql/core/tests/garbage_collection/test_asgiref.py | .py | import gc
import pytest
from asgiref.local import Local
from .utils import (
clean_up_after_garbage_collection_test,
disable_gc_for_garbage_collection_test,
)
# Group all tests that require garbage collection so that they do not run concurrently.
# This is necessary to ensure that tests don't interfere with... | 40 | 1,478 |
readthedocs.org | readthedocs/oauth/services/github.py | .py | """OAuth utility functions."""
import json
import re
import structlog
from allauth.socialaccount.providers.github.provider import GitHubProvider
from django.conf import settings
from oauthlib.oauth2.rfc6749.errors import InvalidGrantError
from oauthlib.oauth2.rfc6749.errors import TokenExpiredError
from requests.exce... | 555 | 21,338 |
astropy | astropy/units/tests/test_physical.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Unit tests for the handling of physical types in `astropy.units`.
"""
import pickle
import pytest
from astropy import units as u
from astropy.constants import hbar
from astropy.units import physical
unit_physical_type_pairs = [
(u.m, "length")... | 530 | 19,101 |
cvxpy | cvxpy/reductions/matrix_stuffing.py | .py | """
Copyright 2017 Robin Verschueren, 2017 Akshay Agrawal
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... | 244 | 8,675 |
readthedocs.org | readthedocs/oauth/signals.py | .py | import structlog
from allauth.account.signals import user_logged_in
from allauth.socialaccount.models import SocialLogin
from allauth.socialaccount.signals import social_account_added
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from re... | 89 | 3,472 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.