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 |
|---|---|---|---|---|---|
beam | sdks/python/apache_beam/runners/worker/operation_specs.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,731 |
mlflow | mlflow/store/db_migrations/versions/770bee3ae1dd_add_assessments_table.py | .py | """add assessments table
Create Date: 2025-06-23 11:26:19.855639
"""
import sqlalchemy as sa
from alembic import op
from mlflow.store.tracking.dbmodels.models import SqlAssessments
# revision identifiers, used by Alembic.
revision = "770bee3ae1dd"
down_revision = "cbc13b556ace"
branch_labels = None
depends_on = No... | 72 | 2,640 |
sphinx | sphinx/domains/rst.py | .py | """The reStructuredText domain."""
from __future__ import annotations
import re
from typing import TYPE_CHECKING
from docutils.parsers.rst import directives
from sphinx import addnodes
from sphinx.directives import ObjectDescription
from sphinx.domains import Domain, ObjType
from sphinx.locale import _, __
from sph... | 350 | 11,280 |
mlflow | mlflow/store/artifact/runs_artifact_repo.py | .py | import logging
import os
import urllib.parse
from typing import Iterator
import mlflow
from mlflow.entities.file_info import FileInfo
from mlflow.entities.logged_model import LoggedModel
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import RESOURCE_DOES_NOT_EXIST
from mlflow.store.art... | 272 | 11,633 |
onnxruntime | tools/python/util/__init__.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from .get_azcopy import get_azcopy # noqa: F401
from .logger import get_logger
from .platform_helpers import is_linux, is_macOS, is_windows # noqa: F401
from .qnn_helpers import parse_qnn_version_from_sdk_yaml # noqa: F401... | 30 | 1,027 |
openvino | tests/samples_tests/smoke_tests/test_hello_classification.py | .py | """
Copyright (C) 2018-2026 Intel Corporation
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 w... | 149 | 6,544 |
wandb | wandb/sdk/artifacts/_generated/delete_registry_members.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/artifacts/
from __future__ import annotations
from wandb._pydantic import GQLResult
class DeleteRegistryMembers(GQLResult):
result: DeleteRegistryMembersResult | None
class DeleteRegistryMembersResult(GQLResult):
success: bool
DeleteRegistry... | 18 | 344 |
saleor | saleor/graphql/account/mutations/staff/staff_create.py | .py | from collections import defaultdict
from typing import cast
from urllib.parse import urlencode
import graphene
from django.core.exceptions import ValidationError
from .....account import models
from .....account.error_codes import AccountErrorCode
from .....account.notifications import send_set_password_notification
... | 255 | 9,388 |
pyomo | pyomo/repn/tests/gams/test_gams.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... | 521 | 17,002 |
hatch | src/hatch/project/frontend/scripts/core_metadata.py | .py | from __future__ import annotations
import json
import os
from hatchling.metadata.core import ProjectMetadata
from hatchling.metadata.utils import resolve_metadata_fields
from hatchling.plugin.manager import PluginManager
RUNNER: dict = {}
def main() -> None:
project_root: str = RUNNER["project_root"]
outpu... | 30 | 783 |
kafka | tests/kafkatest/tests/client/compression_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 ... | 89 | 4,480 |
onnxruntime | orttraining/orttraining/python/training/ortmodule/_torch_module_interface.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# _torch_module_interface.py
from collections import OrderedDict
from collections.abc import Callable, Iterator
from typing import Optional, TypeVar
import torch
from typing_extensions import Self
T = TypeVar("T", bound="to... | 106 | 4,556 |
saleor | saleor/graphql/page/tests/deprecated/test_page_sorting.py | .py | import pytest
from django.utils import timezone
from freezegun import freeze_time
from .....page.models import Page
from .....tests.utils import dummy_editorjs
from ....tests.utils import get_graphql_content
QUERY_PAGE_WITH_SORT = """
query ($sort_by: PageSortingInput!) {
pages(first:5, sortBy: $sort_by) ... | 80 | 2,832 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_FullyConnected.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shape_x': [40, 37], 'shape_y': [37, 37]},
{'shape_x': [5, 5], 'shape_y': [4, 5]},
{'shape_x': [1, 5, 5], 'shape_y': [4, 5]},
]
class TestTFLiteFullyConnectedLayerTest(TFLiteLayerTest):
... | 35 | 1,305 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_ExpandDims.py | .py | import pytest
import tensorflow as tf
import numpy as np
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shape': [2], 'axis': [0]},
{'shape': [2, 2], 'axis': [2]},
{'shape': [2, 2], 'axis': [0, 2]},
{'shape': [5, 2, 2, 2], 'axis': [1]},
{'shape': [5, 2, 2, 2], 'axis': ... | 47 | 1,644 |
voila | tests/app/preheat_default_kernel_env_test.py | .py | import asyncio
import os
import pytest
@pytest.fixture()
def voila_args_extra():
return ['--VoilaKernelManager.default_env_variables={"FOO": "BAR"}']
@pytest.fixture
def preheat_mode():
return True
@pytest.fixture
def voila_notebook(notebook_directory):
return os.path.join(notebook_directory, "prehea... | 36 | 760 |
clearml | examples/storage/upload_and_stream.py | .py | """
Example of uploading files to remote storage and streaming them back to memory
Uploads two small sample files to the given storage location, then reads their contents
back with StorageManager.get_stream() - the content is streamed directly to memory as
bytes chunks, without being written to disk or stored in the l... | 61 | 2,264 |
pyomo | pyomo/core/tests/unit/uninstantiated_model_linear.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... | 26 | 901 |
wagtail | wagtail/admin/telepath/widgets.py | .py | """
Register Telepath adapters for core Django form widgets, so that they can
have corresponding Javascript objects with the ability to render new instances
and extract field values.
"""
from django import forms
from django.core.exceptions import ValidationError
from django.utils.functional import cached_property
fro... | 79 | 1,885 |
biopython | Bio/Entrez/Parser.py | .py | # Copyright 2008-2014 by Michiel de Hoon. All rights reserved.
# Revisions copyright 2008-2015 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 sho... | 1,166 | 46,942 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_gru.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.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasGru(CommonTF2LayerTest):
def _prepare_input(self, inputs_info):
assert 'x' in inputs_info, "... | 60 | 2,916 |
mlflow | tests/entities/test_mcp_server_entities.py | .py | import pytest
from mlflow.entities.mcp_access_endpoint import MCPAccessEndpoint
from mlflow.entities.mcp_server import (
VALID_STATUS_TRANSITIONS,
MCPRemoteTransportType,
MCPServer,
MCPStatus,
MCPTool,
)
from mlflow.entities.mcp_server_version import MCPServerVersion
from mlflow.exceptions import M... | 155 | 4,811 |
beam | sdks/python/apache_beam/utils/multi_process_shared_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... | 499 | 15,788 |
cvxpy | cvxpy/tests/test_perspective.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
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | 479 | 13,345 |
wagtail | wagtail/admin/menu.py | .py | from django.core.exceptions import ImproperlyConfigured
from django.forms import Media, MediaDefiningClass
from django.utils.functional import cached_property
from wagtail import hooks
from wagtail.admin.ui.sidebar import LinkMenuItem as LinkMenuItemComponent
from wagtail.admin.ui.sidebar import SubMenuItem as SubMenu... | 310 | 10,728 |
openvino | samples/python/hello_query_device/hello_query_device.py | .py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
import sys
import openvino as ov
def param_to_string(parameters) -> str:
"""Convert a list / tuple of parameters returned from OV to a string."""
if isinstanc... | 45 | 1,581 |
openvino | src/bindings/python/src/openvino/opset4/ops.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Factory functions for all openvino ops."""
from typing import Optional, Union
import numpy as np
from functools import partial
from openvino import Node, Shape
from openvino.op import Constant, Parameter
from... | 463 | 18,101 |
onnx | onnx/backend/test/case/node/__init__.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import sys
from copy import deepcopy
from typing import TYPE_CHECKING, Any
import onnx
from onnx.backend.test.case.test_case import TestCase
from onnx.backend.test.case.utils import import_recursive
fr... | 412 | 16,598 |
onnx | tests/python/utils_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import io
import os
import shutil
import tarfile
import tempfile
import pytest
import onnx
from onnx import TensorProto, helper
class TestUtilityFunctions:
def test_extract_model(self) -> None:
... | 80 | 2,830 |
astropy | astropy/cosmology/_src/tests/io/test_connect.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import inspect
import sys
import pytest
from astropy import cosmology
from astropy.cosmology import Cosmology, w0wzCDM
from astropy.cosmology._src.tests.io import (
test_cosmology,
test_ecsv,
test_html,
test_json,
test_latex,
tes... | 304 | 10,624 |
hydra | hydra/test_utils/launcher_common_tests.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Common test functions testing launchers
"""
import copy
import os
import re
from pathlib import Path
from typing import Any, Callable, List, Optional, Set
from omegaconf import DictConfig, OmegaConf
from pytest import mark, param, raises
from... | 688 | 23,749 |
bazel | src/test/py/bazel/windows_remote_test.py | .py | # pylint: disable=g-bad-file-header
# pylint: disable=superfluous-parens
# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:/... | 259 | 8,459 |
sqlmap | tests/test_openapi.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Unit coverage for the OpenAPI/Swagger target extractor (lib/parse/openapi.py): schema example
synthesis, $ref resolution (incl. cycles), base-URL resolution (v2 + v3, relative/templat... | 484 | 30,177 |
luigi | luigi/contrib/external_daily_snapshot.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2017 Spotify AB.
#
# 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... | 79 | 2,380 |
mlflow | mlflow/tracking/_workspace/fluent.py | .py | from __future__ import annotations
import threading
from typing import Callable, TypeVar
from mlflow.entities.workspace import (
TraceArchivalConfig,
Workspace,
WorkspaceDeletionMode,
)
from mlflow.exceptions import MlflowException, RestException
from mlflow.protos import databricks_pb2
from mlflow.protos... | 162 | 5,224 |
pyro | tests/ops/gamma_gaussian.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
import pyro.distributions as dist
from pyro.ops.gamma_gaussian import GammaGaussian
from tests.common import assert_close
def random_gamma_gaussian(batch_shape, dim, rank=None):
"""
Generate a random Gaussia... | 52 | 1,763 |
onnx | onnx/reference/ops/aionnxml/op_svm_regressor.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from onnx.reference.ops.aionnxml._op_run_aionnxml import OpRunAiOnnxMl
from onnx.reference.ops.aionnxml.op_svm_helper import SVMCommon
class SVMRegressor(OpRunAiOnnxMl):
"""The class only implement... | 44 | 1,256 |
omegaconf | tests/interpolation/test_interpolation.py | .py | import copy
import re
from pathlib import Path
from textwrap import dedent
from typing import Any, Tuple, Union
from pytest import mark, param, raises
from omegaconf import (
II,
SI,
AnyNode,
Container,
DictConfig,
IntegerNode,
ListConfig,
Node,
OmegaConf,
StringNode,
Valid... | 576 | 17,297 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/withtimestamps.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");... | 42 | 1,300 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_bart_attention.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import logging
import numpy as np
from fusion_attention import Attentio... | 507 | 23,420 |
biopython | Bio/PDB/PDBExceptions.py | .py | # Copyright (C) 2002, Thomas Hamelryck (thamelry@binf.ku.dk)
#
# 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.
"""Some Bio.PDB-spec... | 35 | 934 |
lemur | lemur/sources/service.py | .py | """
.. module: lemur.sources.service
: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 arrow
from datetime import timedelta
import copy
from flask import current_app
fr... | 467 | 16,929 |
saleor | saleor/graphql/checkout/tests/deprecated/test_checkout_lines_add.py | .py | from unittest import mock
import graphene
from .....checkout.error_codes import CheckoutErrorCode
from .....checkout.fetch import fetch_checkout_info, fetch_checkout_lines
from .....checkout.utils import calculate_checkout_quantity
from .....plugins.manager import get_plugins_manager
from ....tests.utils import get_g... | 156 | 5,507 |
biopython | Tests/test_SeqIO_PdbIO.py | .py | # Copyright 2012 by Eric Talevich. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Tests for SeqIO PdbIO module."""
import unittest
import warnings
try:
import numpy as ... | 204 | 7,625 |
metrics | src/torchmetrics/wrappers/running.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... | 184 | 8,362 |
luigi | examples/pyspark_wc.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# 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... | 108 | 3,360 |
pyomo | pyomo/core/base/set_types.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... | 31 | 927 |
kombu | kombu/compression.py | .py | """Compression utilities."""
from __future__ import annotations
import sys
import zlib
from kombu.utils.encoding import ensure_bytes
_aliases = {}
_encoders = {}
_decoders = {}
__all__ = ('register', 'encoders', 'get_encoder',
'get_decoder', 'compress', 'decompress')
def register(encoder, decoder, con... | 118 | 2,905 |
saleor | saleor/graphql/account/mutations/authentication/__init__.py | .py | from .create_token import CreateToken
from .deactivate_all_user_tokens import DeactivateAllUserTokens
from .external_authentication_url import ExternalAuthenticationUrl
from .external_logout import ExternalLogout
from .external_obtain_access_tokens import ExternalObtainAccessTokens
from .external_refresh import Externa... | 28 | 897 |
returns | tests/test_functions/test_raise_exception.py | .py | import pytest
from returns.functions import raise_exception
from returns.result import Failure, Success
class _CustomError(Exception):
"""Just for the test."""
@pytest.mark.parametrize(
'exception_type',
[
TypeError,
ValueError,
_CustomError,
],
)
def test_raise_regular_exce... | 35 | 877 |
saleor | saleor/graphql/menu/tests/queries/test_menu_items.py | .py | import pytest
from .....menu.models import Menu, MenuItem
from ....tests.utils import get_graphql_content
@pytest.fixture
def menu_items_for_pagination(db):
menu = Menu.objects.get(name="navbar")
items = MenuItem.tree.build_tree_nodes(
{
"name": "Item1",
"menu": menu,
... | 113 | 3,069 |
scikit-bio | skbio/workflow.py | .py | r"""Workflow Construction (:mod:`skbio.workflow`)
=============================================
.. currentmodule:: skbio.workflow
Construct arbitrarily complex workflows in which the specific methods run are
determined at runtime. This module supports short circuiting a workflow if an
item fails, supports ordering me... | 568 | 19,012 |
pyomo | examples/pyomo/connectors/network_flow.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... | 80 | 2,558 |
gunicorn | examples/dirty_example/wsgi_app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Example WSGI Application that uses Dirty Workers
This demonstrates how HTTP workers can call dirty workers
for heavy operations like ML inference.
Run with:
cd examples/dirty_example
gunicorn wsgi_app... | 226 | 7,988 |
probability | tensorflow_probability/python/experimental/bayesopt/acquisition/expected_improvement.py | .py | # Copyright 2023 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... | 400 | 14,022 |
wagtail | wagtail/tests/test_revision_model.py | .py | import datetime
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied
from django.test import TestCase
from freezegun import freeze_time
from wagtail.models import ModelLogEntry, Revision, get_default_page_content_type
from wagtail.test.testapp.models import (
... | 385 | 16,985 |
onnxruntime | plugin-ep-cuda/python/onnxruntime_ep_cuda/__init__.py | .py | """ONNX Runtime CUDA Plugin Execution Provider Python package."""
from __future__ import annotations
import pathlib
__all__ = [
"get_ep_name",
"get_ep_names",
"get_library_path",
]
_module_dir = pathlib.Path(__file__).parent
def get_library_path() -> str:
"""Return the path to the CUDA plugin EP s... | 39 | 1,008 |
wagtail | wagtail/embeds/finders/embedly.py | .py | from django.utils.html import format_html
from wagtail.embeds.exceptions import EmbedException, EmbedNotFoundException
from .base import EmbedFinder
class EmbedlyException(EmbedException):
pass
class AccessDeniedEmbedlyException(EmbedlyException):
pass
class EmbedlyFinder(EmbedFinder):
key = None
... | 77 | 2,085 |
saleor | saleor/graphql/core/types/context.py | .py | from typing import Generic, TypeVar, cast
from django.db.models import Model
from graphene.types.resolver import get_default_resolver
from ...translations.resolvers import resolve_translation
from .. import ResolveInfo
from ..context import ChannelContext
from .base import BaseObjectType
from .model import ModelObjec... | 63 | 1,947 |
saleor | saleor/tests/e2e/orders/utils/draft_order_bulk_delete.py | .py | from saleor.graphql.tests.utils import get_graphql_content
DRAFT_ORDER_BULK_DELETE_MUTATION = """
mutation DraftBulkDelete($ids: [ID!]!) {
draftOrderBulkDelete(ids: $ids) {
errors {
field
code
message
}
count
}
}
"""
def draft_order_bulk_delete(api_client, ids_list):
variables =... | 29 | 570 |
probability | tensorflow_probability/python/distributions/inverse_gamma_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... | 373 | 15,124 |
saleor | saleor/core/tests/test_sqs.py | .py | from datetime import timedelta
from unittest.mock import MagicMock, Mock, patch
import pytest
from django.utils import timezone
from freezegun import freeze_time
from ..sqs import Channel
@pytest.mark.parametrize(
("eta_offset", "expected_delay"),
[
(timedelta(seconds=359, microseconds=84649), 359),... | 86 | 2,657 |
onnxruntime | orttraining/tools/ci_test/download_azure_blob_archive.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import hashlib
import os
import shutil
import subprocess
import sys
import tempfile
import urllib.request # noqa: F401
import zipfile # noqa: F401
SCRIPT_DIR = os.path.dirname(os.path... | 76 | 2,550 |
saleor | saleor/graphql/channel/mutations/channel_deactivate.py | .py | import graphene
from django.core.exceptions import ValidationError
from ....channel.error_codes import ChannelErrorCode
from ....permission.enums import ChannelPermissions
from ....webhook.event_types import WebhookEventAsyncType
from ...core import ResolveInfo
from ...core.doc_category import DOC_CATEGORY_CHANNELS
fr... | 56 | 2,078 |
metrics | src/torchmetrics/functional/detection/_panoptic_quality_common.py | .py | # Copyright The PyTorch 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 i... | 476 | 20,147 |
pyro | pyro/infer/reparam/split.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import torch
import pyro
import pyro.distributions as dist
import pyro.poutine as poutine
from pyro.distributions.torch_distribution import TorchDistributionMixin
from pyro.ops.tensor_utils import broadcast_tensors_without_dim
from .... | 141 | 5,504 |
mlflow | mlflow/keras/utils.py | .py | import numpy as np
from mlflow.models import ModelSignature
from mlflow.types import Schema, TensorSpec
def get_model_signature(model):
def replace_none_in_shape(shape):
return [-1 if dim_size is None else dim_size for dim_size in shape]
input_shape = model.input_shape
input_dtype = model.input_... | 34 | 1,127 |
conda | conda/cli/main_commands.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Mock CLI implementation for `conda activate`.
A mock implementation of the activate shell command for better UX.
"""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from argparse import ArgumentPa... | 39 | 981 |
metrics | tests/unittests/regression/test_explained_variance.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... | 112 | 4,400 |
conda | conda/__main__.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Conda as a module entry point."""
import sys
from .cli import main
sys.exit(main())
| 10 | 165 |
metrics | src/torchmetrics/utilities/checks.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... | 336 | 12,885 |
saleor | saleor/graphql/page/tests/queries/test_page_type.py | .py | import graphene
import pytest
from ....tests.utils import (
assert_no_permission,
get_graphql_content,
get_graphql_content_from_response,
)
PAGE_TYPE_QUERY = """
query PageType(
$id: ID!, $filters: AttributeFilterInput, $where: AttributeWhereInput,
$search: String
) {
pageT... | 436 | 13,112 |
saleor | saleor/graphql/page/mutations/page_reorder_attribute_values.py | .py | import graphene
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from ....core.tracing import traced_atomic_transaction
from ....page import models as page_models
from ....page.error_codes import PageErrorCode
from ....permission.enums import PagePermissions
from ...attribute.mutations import Bas... | 120 | 4,152 |
openvino | tests/layer_tests/pytorch_tests/test_where.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from packaging import version
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
# torch.where with a uint8 condition tensor is deprecated in PyTorch 2.9.
_WHERE_UINT8_DE... | 184 | 8,293 |
pyro | examples/mixed_hmm/model.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.distributions import constraints
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer import config_enumerate
from pyro.ops.indexing import Vindex
def guide_generic(confi... | 273 | 9,884 |
pymc | pymc/step_methods/hmc/integration.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... | 146 | 4,701 |
coremltools | coremltools/converters/mil/mil/passes/tests/test_gelu_sigmoid_pass.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 numpy as np
from coremltools.converters.mil.mil import Builder as mb
from coremltools.convert... | 161 | 5,675 |
saleor | saleor/core/payments.py | .py | from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from ..checkout.fetch import CheckoutInfo, CheckoutLineInfo
from ..payment.interface import (
CustomerSource,
GatewayResponse,
PaymentData,
PaymentGateway,
TokenConfig,
)... | 80 | 2,156 |
biopython | Tests/test_GraphicsBitmaps.py | .py | # Copyright 2001 by Brad Chapman. All rights reserved.
# Copyright 2009 by Peter Cock. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Test for bitmap output via ReportLab (... | 138 | 4,440 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Bitwise.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import platform
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng(21097)
op_type_to_tf = {
'BitwiseAnd': tf.raw_ops.BitwiseAnd,
'Bitwis... | 74 | 2,959 |
gunicorn | gunicorn/dirty/app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Dirty Application Base Class
Provides the DirtyApp base class that all dirty applications must inherit from,
and utilities for loading dirty apps from import paths.
"""
import importlib
import sys
from .erro... | 351 | 10,716 |
beam | sdks/python/apache_beam/transforms/window_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... | 391 | 16,063 |
coremltools | coremltools/models/ml_program/experimental/remote_device.py | .py | # Copyright (c) 2025, 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 asyncio as _asyncio
import json as _json
import os as _os
import shutil as _shutil
import subproc... | 2,576 | 83,221 |
gunicorn | examples/frameworks/flaskapp.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# Run with:
#
# $ gunicorn flaskapp:app
#
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
| 16 | 253 |
sphinx | sphinx/ext/apidoc/__init__.py | .py | """Creates reST files corresponding to Python modules for code documentation.
Parses a directory tree looking for Python modules and packages and creates
ReST files appropriately to create code documentation with Sphinx. It also
creates a modules index (named modules.<suffix>).
This is derived from the "sphinx-autop... | 67 | 2,227 |
coremltools | coremltools/converters/mil/mil/ops/tests/iOS14/test_elementwise_binary.py | .py | # Copyright (c) 2020, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import itertools
import numpy as np
import pytest
from coremltools.converters.mil.mil import Builder... | 589 | 21,150 |
sphinx | sphinx/domains/citation.py | .py | """The citation domain."""
from __future__ import annotations
from typing import TYPE_CHECKING, cast
from docutils import nodes
from sphinx.addnodes import pending_xref
from sphinx.domains import Domain
from sphinx.locale import __
from sphinx.transforms import SphinxTransform
from sphinx.util import logging
from s... | 190 | 6,054 |
sphinx | tests/test_markup/test_parser.py | .py | """Tests parsers module."""
from __future__ import annotations
from typing import TYPE_CHECKING
from unittest.mock import Mock, patch
import pytest
from sphinx.parsers import RSTParser
from sphinx.util.docutils import new_document
if TYPE_CHECKING:
from sphinx.testing.util import SphinxTestApp
@pytest.mark.s... | 71 | 2,374 |
conda | conda/plugins/virtual_packages/windows.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Detect whether this is Windows."""
from __future__ import annotations
from typing import TYPE_CHECKING
from ...base.context import context
from .. import hookimpl
from ..types import CondaVirtualPackage
if TYPE_CHECKING:
from collecti... | 39 | 1,048 |
lemur | lemur/endpoints/views.py | .py | """
.. module: lemur.endpoints.views
: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>
"""
from flask import Blueprint, g
from flask_restful import reqparse, Api
from lemur.common... | 109 | 2,991 |
wagtail | wagtail/jinja2tags.py | .py | import jinja2
import jinja2.nodes
from jinja2.ext import Extension
from markupsafe import Markup, escape
from .templatetags.wagtailcore_tags import (
fullpageurl,
pageurl,
richtext,
slugurl,
wagtail_site,
wagtail_version,
)
class WagtailCoreExtension(Extension):
tags = {"include_block"}
... | 86 | 2,600 |
saleor | saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_not_started_voucher.py | .py | import datetime
import pytest
from django.utils import timezone
from ....product.utils.preparing_product import prepare_product
from ....shop.utils import prepare_default_shop
from ....utils import assign_permissions
from ....vouchers.utils import (
create_voucher,
create_voucher_channel_listing,
get_vouc... | 165 | 4,828 |
sqlmap | tests/test_compat.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Tests for lib/core/compat.py -- cross-version compatibility utilities,
including WichmannHill RNG, patchHeaders, cmp_to_key, LooseVersion,
MixedWriteTextIO, and _codecs_open.
"""
imp... | 290 | 10,214 |
mlflow | tests/server/auth/test_read_write_routing.py | .py | import shutil
from pathlib import Path
from unittest import mock
import pytest
from mlflow.server.auth.config import AuthConfig, read_auth_config
from mlflow.server.auth.sqlalchemy_store import SqlAlchemyStore
@pytest.fixture
def write_db_uri(tmp_path: Path) -> str:
return f"sqlite:///{tmp_path / 'auth_write.db... | 182 | 5,783 |
jupytext | tests/data/notebooks/outputs/ipynb_to_marimo/cat_variable.py | .py | import marimo
__generated_with = "0.17.8"
app = marimo.App()
@app.cell
def _():
cat = 42
return
if __name__ == "__main__":
app.run()
| 15 | 150 |
pdm | src/pdm/cli/commands/list.py | .py | from __future__ import annotations
import argparse
import csv
import importlib.metadata as im
import io
import json
from collections import defaultdict
from collections.abc import Iterable, Mapping, Sequence
from fnmatch import fnmatch
from pdm.cli.commands.base import BaseCommand
from pdm.cli.options import venv_opt... | 429 | 17,034 |
saleor | saleor/order/tests/test_tasks.py | .py | import datetime
from unittest import mock
from unittest.mock import ANY, patch
import pytest
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from ...account.models import User
from ...core.models import EventDelivery
from ...discount.models import VoucherC... | 821 | 24,218 |
wandb | tests/system_tests/test_core/test_resume_auto.py | .py | import json
import pathlib
import pytest
import wandb
class AutoResumeTestError(Exception):
"""Raised in auto-resume tests to leave behind an auto-resume file."""
def test_autoresume_first_run_saves():
with pytest.raises(AutoResumeTestError):
with wandb.init(mode="offline", resume="auto") as run:
... | 69 | 2,149 |
cvxpy | cvxpy/reductions/dcp2cone/canonicalizers/quad/__init__.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... | 35 | 1,381 |
mlflow | mlflow/entities/logged_model_output.py | .py | from mlflow.entities._mlflow_object import _MlflowObject
from mlflow.protos.service_pb2 import ModelOutput
class LoggedModelOutput(_MlflowObject):
"""ModelOutput object associated with a Run."""
def __init__(self, model_id: str, step: int) -> None:
self._model_id = model_id
self._step = step
... | 36 | 1,004 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.