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 |
|---|---|---|---|---|---|
clearml | clearml/hyperdatasets/data_entry_image.py | .py | from typing import Optional, Sequence, Tuple, List, Dict, Any, Union
import logging
from clearml.storage.manager import StorageManagerDiskSpaceFileSizeStrategy
from .data_entry import (
DataEntry,
DataSubEntry,
ENTRY_CLASS_KEY,
SUB_ENTRY_CLASS_KEY,
_copy_without_keys,
_get_class_identifier,
... | 811 | 32,087 |
probability | tensorflow_probability/python/sts/components/autoregressive_moving_average.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... | 273 | 12,327 |
pyomo | pyomo/repn/tests/gams/test_gams_comparison.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... | 108 | 3,806 |
django-cms | cms/test_utils/project/extensionapp/admin.py | .py | from django.contrib import admin
from cms.extensions import PageContentExtensionAdmin, PageExtensionAdmin
from cms.test_utils.project.extensionapp.models import (
MyPageContentExtension,
MyPageExtension,
)
class MyPageExtensionAdmin(PageExtensionAdmin):
pass
admin.site.register(MyPageExtension, MyPageE... | 22 | 483 |
black | tests/data/cases/nested_stub.py | .py | # flags: --pyi
import sys
class Outer:
class InnerStub: ...
outer_attr_after_inner_stub: int
class Inner:
inner_attr: int
outer_attr: int
if sys.version_info > (3, 7):
if sys.platform == "win32":
assignment = 1
def function_definition(self): ...
def f1(self) -> str: ...... | 70 | 1,243 |
mlflow | tests/helpers/db_mocks.py | .py | from __future__ import annotations
from contextlib import contextmanager
from unittest import mock
def mock_get_managed_session_maker(*args, **kwargs):
@contextmanager
def _manager():
session = mock.MagicMock()
def _mock_query(*q_args, **q_kwargs):
query = mock.MagicMock()
... | 25 | 661 |
beam | sdks/python/apache_beam/io/restriction_trackers_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... | 194 | 7,291 |
textual | src/textual/_wait.py | .py | from asyncio import sleep
from time import monotonic, process_time
SLEEP_GRANULARITY: float = 1 / 50
SLEEP_IDLE: float = SLEEP_GRANULARITY / 20.0
async def wait_for_idle(
min_sleep: float = SLEEP_GRANULARITY, max_sleep: float = 1
) -> None:
"""Wait until the process isn't working very hard.
This will co... | 42 | 1,446 |
pymc | pymc/stats/__init__.py | .py | # Copyright 2024 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 45 | 1,485 |
beam | examples/notebooks/beam-ml/rag_usecase/opensearch_connector.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... | 372 | 12,793 |
astropy | astropy/coordinates/tests/test_regression.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Regression tests for coordinates-related bugs that don't have an obvious other
place to live
"""
import copy
import io
from contextlib import nullcontext
import numpy as np
import pytest
from erfa import ErfaWarning
from astropy import units as u
f... | 758 | 27,470 |
mlflow | mlflow/store/db_migrations/versions/534353b11cbc_add_scorer_table.py | .py | """add scorer tables
Create Date: 2025-01-27 10:00:00.000000
"""
import sqlalchemy as sa
from alembic import op
from mlflow.store.tracking.dbmodels.models import SqlScorer, SqlScorerVersion
# revision identifiers, used by Alembic.
revision = "534353b11cbc"
down_revision = "1a0cddfcaa16"
branch_labels = None
depend... | 70 | 2,315 |
mlflow | mlflow/server/assistant/api.py | .py | import asyncio
import enum
import ipaddress
import uuid
from collections.abc import Awaitable, Callable
from pathlib import Path
from typing import Any, AsyncGenerator, Literal
from fastapi import APIRouter, Header, HTTPException, Request
from fastapi.responses import StreamingResponse
from fastapi.routing import APIR... | 828 | 30,925 |
probability | tensorflow_probability/python/distributions/dirichlet_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... | 415 | 16,042 |
luigi | luigi/tools/range.py | .py | # -*- coding: utf-8 -*-
# Copyright (c) 2014 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 or... | 790 | 33,551 |
saleor | saleor/graphql/meta/tests/mutations/test_page.py | .py | import graphene
from . import PRIVATE_KEY, PRIVATE_VALUE, PUBLIC_KEY, PUBLIC_VALUE
from .test_delete_metadata import (
execute_clear_public_metadata_for_item,
item_without_public_metadata,
)
from .test_delete_private_metadata import (
execute_clear_private_metadata_for_item,
item_without_private_metada... | 170 | 4,752 |
pyomo | pyomo/gdp/tests/test_hull.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... | 4,055 | 171,753 |
metrics | src/torchmetrics/regression/concordance.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... | 146 | 5,841 |
ipython | IPython/utils/_sysinfo.py | .py | # GENERATED BY setup.py
commit = ""
| 3 | 36 |
mlflow | mlflow/server/auth/sqlalchemy_store.py | .py | import logging
import re
from collections.abc import Iterable
from urllib.parse import quote, unquote
from sqlalchemy import and_, or_, select, text
from sqlalchemy.exc import IntegrityError, MultipleResultsFound, NoResultFound
from sqlalchemy.orm import selectinload, sessionmaker
from werkzeug.security import check_p... | 2,240 | 96,889 |
probability | tensorflow_probability/python/sts/components/sum.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... | 568 | 24,248 |
beam | sdks/python/apache_beam/runners/portability/fn_api_runner/watermark_manager.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... | 199 | 8,314 |
probability | spinoffs/fun_mc/fun_mc/dynamic/backend_jax/backend.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... | 33 | 1,085 |
beam | sdks/python/apache_beam/dataframe/io_it_test.py | .py | #!/usr/bin/env python
# -*- 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,... | 117 | 4,491 |
textual | src/textual/document/_wrapped_document.py | .py | from __future__ import annotations
from bisect import bisect_right
from rich.text import Text
from textual._cells import cell_len, cell_width_to_column_index
from textual._wrap import compute_wrap_offsets
from textual.document._document import DocumentBase, Location
from textual.expand_tabs import expand_tabs_inline... | 455 | 17,779 |
saleor | saleor/order/tests/fixtures/__init__.py | .py | from .benchmark import * # noqa: F403
from .draft_order import * # noqa: F403
from .fulfillment import * # noqa: F403
from .order import * # noqa: F403
from .order_line import * # noqa: F403
| 6 | 196 |
pyomo | pyomo/dae/tests/test_misc.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 1,075 | 35,446 |
pyomo | pyomo/contrib/mindtpy/outer_approximation.py | .py | # -*- coding: utf-8 -*-
# ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and E... | 161 | 8,017 |
saleor | saleor/core/exceptions.py | .py | from collections.abc import Iterable
from dataclasses import dataclass
from enum import Enum
from typing import TYPE_CHECKING, Optional
from uuid import UUID
from graphql import GraphQLError
from ..checkout.error_codes import CheckoutErrorCode
if TYPE_CHECKING:
from ..checkout.models import CheckoutLine
from... | 106 | 3,340 |
pyomo | pyomo/contrib/pynumero/linalg/__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 | 607 |
rq | rq/results.py | .py | from __future__ import annotations
import zlib
from base64 import b64decode, b64encode
from datetime import datetime, timezone
from enum import Enum
from typing import Any
from redis import Redis
from .defaults import UNSERIALIZABLE_RETURN_VALUE_PAYLOAD
from .job import Job
from .serializers import resolve_serialize... | 326 | 10,973 |
pdm | src/pdm/cli/commands/show.py | .py | from __future__ import annotations
import argparse
from typing import TYPE_CHECKING
from pdm.cli.commands.base import BaseCommand
from pdm.cli.options import venv_option
from pdm.exceptions import PdmUsageError
from pdm.models.candidates import Candidate
from pdm.models.project_info import ProjectInfo
from pdm.models... | 71 | 2,905 |
black | tests/data/miscellaneous/pattern_matching_invalid.py | .py | # First match, no errors
match something:
case bla():
pass
# Problem on line 10
match invalid_case:
case valid_case:
pass
case a := b:
pass
case valid_case:
pass
# No problems either
match something:
case bla():
pass
| 19 | 279 |
pdm | tests/cli/test_list.py | .py | import json
import os
import pathlib
from unittest import mock
import pytest
from rich.box import ASCII
from pdm.cli.commands.list import Command
from pdm.models.specifiers import PySpecSet
from pdm.pytest import Distribution
from tests import FIXTURES
def test_list_command(project, pdm, mocker):
# Calls the co... | 876 | 31,173 |
mlflow | tests/store/model_registry/test_rest_store_workspace.py | .py | from unittest import mock
import pytest
from mlflow.exceptions import MlflowException
from mlflow.store.model_registry.rest_store import RestStore
from mlflow.utils.rest_utils import MlflowHostCreds
ACTIVE_WORKSPACE = "team-a"
def test_model_registry_rest_store_workspace_guard():
creds = MlflowHostCreds("https... | 26 | 756 |
coremltools | coremltools/test/optimize/torch/conversion/quantization/test_quantization_conversion.py | .py | # Copyright (c) 2024, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import pytest
ct = pytest.importorskip("coremltools")
import coremltools.test.optimize.torch.convers... | 169 | 5,061 |
pyomo | examples/pyomobook/pyomo-components-ch/param_initialization.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... | 76 | 1,892 |
jupyterlab | examples/cell/main.py | .py | """
An example demonstrating a stand-alone "notebook".
Copyright (c) Jupyter Development Team.
Distributed under the terms of the Modified BSD License.
Example
-------
To run the example, see the instructions in the README to build it. Then
run ``python main.py``.
"""
import json
import os
from jupyter_server.bas... | 80 | 2,595 |
onnxruntime | onnxruntime/python/tools/symbolic_shape_infer.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# -*- coding: UTF-8 -*-
import argparse
import logging
import numpy as np
import onnx
try:
import sympy
except ImportError:
raise ImportError("sympy is required for symbolic shape inference. Install with: pip instal... | 3,145 | 145,403 |
saleor | saleor/warehouse/tests/test_stock_reservations_management.py | .py | import datetime
import pytest
from django.utils import timezone
from ...channel import AllocationStrategy
from ...checkout.models import Checkout
from ...core.exceptions import InsufficientStock
from ..models import ChannelWarehouse, Reservation, Stock, Warehouse
from ..reservations import reserve_stocks
COUNTRY_COD... | 370 | 11,677 |
pyomo | pyomo/contrib/pynumero/linalg/utils.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... | 36 | 1,370 |
metrics | src/torchmetrics/classification/confusion_matrix.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... | 544 | 23,841 |
biopython | Tests/test_PDB_PSEA.py | .py | # Copyright 2022 by Valentin Vareskic (valentin.vareskic@gmail.com).
# 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 PDB PSEA."""
import io
import os
import sys
imp... | 153 | 3,907 |
wandb | wandb/integration/metaflow/data_sklearn.py | .py | """Support for sklearn datatypes.
May raise MissingDependencyError on import.
"""
from __future__ import annotations
import pickle
from typing_extensions import Any, TypeIs
import wandb
from . import errors
try:
from sklearn.base import BaseEstimator
except ImportError as e:
warning = (
"`sklearn... | 77 | 1,753 |
metrics | src/torchmetrics/text/sacre_bleu.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... | 181 | 7,188 |
coremltools | coremltools/converters/mil/frontend/milproto/helper.py | .py | # Copyright (c) 2022, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from coremltools.converters.mil.mil import types
from coremltools.converters.mil.mil.program import ge... | 71 | 2,573 |
saleor | saleor/asgi/telemetry.py | .py | from asgiref.typing import (
ASGI3Application,
ASGIReceiveCallable,
ASGISendCallable,
Scope,
)
from ..core.telemetry import saleor_attributes, set_global_attributes
def get_hostname(scope: Scope) -> str:
if scope["type"] == "http":
for header, value in scope["headers"]:
if hea... | 29 | 836 |
pyomo | pyomo/version/tests/test_version.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... | 82 | 3,269 |
pyomo | pyomo/common/collections/bunch.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... | 163 | 6,080 |
onnx | onnx/backend/test/case/node/linear_attention.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
from onnx.reference.ops.op_linear_attention import (
LinearAttention as _R... | 542 | 18,779 |
saleor | saleor/graphql/plugins/tests/test_mutation_plugin_update.py | .py | import copy
from unittest import mock
import graphene
import pytest
from ....plugins.error_codes import PluginErrorCode
from ....plugins.manager import get_plugins_manager
from ....plugins.models import PluginConfiguration
from ....plugins.tests.sample_plugins import ChannelPluginSample, PluginSample
from ....plugins... | 408 | 14,575 |
scikit-optimize | skopt/benchmarks.py | .py | # -*- coding: utf-8 -*-
"""A collection of benchmark problems."""
import numpy as np
def bench1(x):
"""A benchmark function for test purposes.
f(x) = x ** 2
It has a single minima with f(x*) = 0 at x* = 0.
"""
return x[0] ** 2
def bench1_with_time(x):
"""Same as bench1 but returns the... | 101 | 2,931 |
saleor | saleor/graphql/discount/mutations/voucher/voucher_channel_listing_update.py | .py | from collections import defaultdict
import graphene
from django.core.exceptions import ValidationError
from .....core.tracing import traced_atomic_transaction
from .....discount import DiscountValueType, models
from .....discount.error_codes import DiscountErrorCode
from .....permission.enums import DiscountPermissio... | 227 | 9,284 |
saleor | saleor/attribute/models/__init__.py | .py | from .base import (
Attribute,
AttributeTranslation,
AttributeValue,
AttributeValueTranslation,
)
from .customer import AssignedUserAttributeValue, AttributeCustomerType
from .page import AssignedPageAttributeValue, AttributePage
from .product import AssignedProductAttributeValue, AttributeProduct
from ... | 31 | 822 |
wagtail | wagtail/test/emailuser/models.py | .py | import uuid
from django.contrib.auth.models import (
AbstractBaseUser,
BaseUserManager,
PermissionsMixin,
)
from django.db import models
class EmailUserManager(BaseUserManager):
def _create_user(self, email, password, is_staff, is_superuser, **extra_fields):
"""
Creates and saves a Us... | 54 | 1,652 |
tablib | src/tablib/formats/_jira.py | .py | """Tablib - Jira table export support.
Generates a Jira table from the dataset.
"""
class JIRAFormat:
title = 'jira'
@classmethod
def export_set(cls, dataset):
"""Formats the dataset according to the Jira table syntax:
||heading 1||heading 2||heading 3||
|col A1|col A2|col A3... | 41 | 1,087 |
textual | tests/snapshot_tests/snapshot_apps/text_selection.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Label
from textual.containers import VerticalGroup
from textual.content import Content
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... | 60 | 1,568 |
saleor | saleor/tests/e2e/gift_cards/test_gift_cards.py | .py | import pytest
from ....graphql.order.enums import OrderChargeStatusEnum
from ....tests import race_condition
from ...e2e.utils import assign_permissions
from ..checkout.utils.checkout_add_promo_code import checkout_add_promo_code
from ..checkout.utils.checkout_complete import checkout_complete
from ..checkout.utils.ch... | 408 | 13,238 |
wagtail | wagtail/images/tests/test_form_overrides.py | .py | from django import forms
from django.test import TestCase, override_settings
from taggit import models as taggit_models
from wagtail.admin import widgets
from wagtail.admin.widgets import AdminDateTimeInput
from wagtail.images import models
from wagtail.images.forms import BaseImageForm, get_image_base_form, get_image... | 84 | 3,406 |
jupyterlab | examples/filebrowser/main.py | .py | """
An example demonstrating a stand-alone "filebrowser".
Copyright (c) Jupyter Development Team.
Distributed under the terms of the Modified BSD License.
Example
-------
To run the example, see the instructions in the README to build it. Then
run ``python main.py``.
"""
import json
import os
from jupyterlab_serv... | 54 | 1,511 |
onnx | onnx/backend/test/case/node/ai_onnx_ml/binarizer.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
from onnx.reference.ops.aionnxml.op_binarizer import compute_binarizer
class ... | 29 | 781 |
sphinx | tests/roots/test-ext-autosummary-ext/underscore_module_.py | .py | """module with trailing underscores everywhere"""
class class_:
"""Class"""
def method_(_arg): # NoQA: N805
"""Method"""
pass
def function_(_arg):
"""Function"""
pass
| 15 | 205 |
onnxruntime | orttraining/orttraining/python/training/utils/hooks/_statistics_subscriber.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import os
import shutil
import warnings
from io import TextIOWrapper
fro... | 288 | 12,735 |
beam | sdks/python/apache_beam/coders/typecoders.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... | 263 | 10,463 |
saleor | saleor/order/lock_objects.py | .py | from django.db.models import QuerySet
from .models import Order, OrderLine
def order_lines_qs_select_for_update() -> QuerySet[OrderLine]:
return OrderLine.objects.order_by("pk").select_for_update(of=["self"])
def order_qs_select_for_update() -> QuerySet[Order]:
return Order.objects.order_by("pk").select_fo... | 12 | 344 |
luigi | test/import_test.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... | 75 | 2,325 |
biopython | Tests/test_ProtParam.py | .py | # Copyright 2003-2004 by Iddo Friedberg. All rights reserved.
# Revisions copyright 2008-2010 by Peter Cock. All rights reserved.
# Revisions copyright 2012 by Matt Fenwick. All rights reserved.
# Revisions copyright 2012 by Kai Blin. All rights reserved.
# This code is part of the Biopython distribution and governed ... | 260 | 12,918 |
scikit-bio | skbio/io/tests/test_registry.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,765 | 58,616 |
pyro | tests/infer/reparam/test_studentt.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from scipy.stats import ks_2samp
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer.reparam import StudentTReparam
from tests.common import... | 82 | 3,021 |
openvino | tests/layer_tests/pytorch_tests/test_pythonop.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestPythonOp(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(1, 3, 128, 128),)
def create_model(self):
import to... | 55 | 1,429 |
dirty-equals | tests/test_base.py | .py | import platform
from functools import singledispatch
import packaging.version
import pytest
from _pytest._io.pprint import PrettyPrinter
from dirty_equals import Contains, DirtyEquals, IsApprox, IsInt, IsList, IsNegative, IsOneOf, IsPositive, IsStr
from dirty_equals.version import VERSION
pprint = PrettyPrinter()
... | 227 | 5,127 |
biopython | Bio/Phylo/PAML/_parse_baseml.py | .py | # Copyright (C) 2011 by Brandon Invergo (b.invergo@gmail.com)
#
# 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.
"""Methods for pars... | 262 | 11,408 |
rq | rq/logutils.py | .py | from __future__ import annotations
import logging
import sys
from rq.defaults import DEFAULT_LOGGING_DATE_FORMAT, DEFAULT_LOGGING_FORMAT
class _Colorizer:
def __init__(self):
esc = '\x1b['
self.codes = {}
self.codes[''] = ''
self.codes['reset'] = esc + '39;49;00m'
self.... | 163 | 5,163 |
saleor | saleor/graphql/order/mutations/draft_order_cleaner.py | .py | from django.core.exceptions import ValidationError
from ....channel.models import Channel
from ....core.utils.url import validate_storefront_url
from ....discount.models import Voucher, VoucherCode
from ....discount.utils.voucher import (
get_active_voucher_code,
get_voucher_code_instance,
)
from ....order.err... | 118 | 4,027 |
biopython | Bio/PDB/MMCIFParser.py | .py | # Copyright (C) 2002, Thomas Hamelryck (thamelry@binf.ku.dk)
# 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.
"""mmCIF parsers."""
import warnings
import numpy as np
from Bio.File import as_handle
... | 636 | 25,471 |
beam | sdks/python/apache_beam/utils/__init__.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... | 22 | 896 |
wagtail | wagtail/contrib/routable_page/tests.py | .py | from unittest import mock
from django.core import checks
from django.test import RequestFactory, TestCase
from django.test.utils import override_settings
from django.urls import path
from django.urls.exceptions import NoReverseMatch
from wagtail.contrib.routable_page.templatetags.wagtailroutablepage_tags import (
... | 561 | 20,353 |
saleor | saleor/graphql/discount/tests/queries/test_promotions_filtering.py | .py | import datetime
import graphene
import pytest
from django.utils import timezone
from .....discount.models import Promotion
from ....tests.utils import get_graphql_content
from ...enums import PromotionTypeEnum
QUERY_PROMOTIONS = """
query Promotions($where: PromotionWhereInput){
promotions(first: 10, whe... | 330 | 9,664 |
httpie | tests/fixtures/__init__.py | .py | """Test data"""
import json
from pathlib import Path
from typing import Optional, Dict, Any
import httpie
from httpie.encoding import UTF8
from httpie.output.formatters.xml import pretty_xml, parse_xml
def patharg(path):
"""
Back slashes need to be escaped in ITEM args,
even in Windows paths.
"""
... | 67 | 2,091 |
pyomo | pyomo/repn/tests/ampl/test_ampl_comparison.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... | 157 | 5,602 |
mlflow | mlflow/tracing/otel/translation/__init__.py | .py | """
Utilities for translating OTEL span attributes to MLflow span format.
This module provides functions to translate span attributes from various
OTEL semantic conventions (OpenInference, Traceloop, GenAI) to MLflow span types.
It uses modular translator classes for each OTEL schema for better organization
and perfor... | 487 | 17,665 |
onnxruntime | onnxruntime/python/tools/microbench/cast.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 109 | 3,511 |
metrics | tests/unittests/shape/__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... | 14 | 578 |
sqlmap | thirdparty/chardet/euctwprober.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... | 47 | 1,747 |
httpie | httpie/plugins/__init__.py | .py | """
WARNING: The plugin API is still work in progress and will
probably be completely reworked in the future.
"""
from .base import (
AuthPlugin, FormatterPlugin,
ConverterPlugin, TransportPlugin
)
__all__ = ('AuthPlugin', 'ConverterPlugin', 'FormatterPlugin', 'TransportPlugin')
| 12 | 299 |
sphinx | sphinx/ext/autodoc/_property_types.py | .py | from __future__ import annotations
import dataclasses
from sphinx.ext.autodoc._sentinels import RUNTIME_INSTANCE_ATTRIBUTE, UNINITIALIZED_ATTR
TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Sequence
from pathlib import Path
from typing import Any, Literal
from sphinx.ext.autodoc... | 241 | 6,528 |
saleor | saleor/graphql/discount/tests/benchmark/test_vouchers.py | .py | import pytest
from ....tests.utils import get_graphql_content
VOUCHERS_QUERY = """
query GetVouchers($channel: String){
vouchers(last: 10, channel: $channel) {
edges {
node {
id
name
type
startDate
endDate
usageLimit
code
applyOncePerOrder
... | 118 | 2,305 |
wagtail | wagtail/admin/tests/test_reports_views.py | .py | import datetime
from io import BytesIO
from unittest import mock
from django.conf import settings
from django.conf.locale import LANG_INFO
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType
from django.db.models import F
from django.test import RequestFa... | 1,521 | 56,079 |
onnx | tests/python/version_converter/automatic_downgrade_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import automatic_conversion_test_base
import numpy as np
import pytest
import onnx
from onnx import helper
#####################################################################################
# Every ... | 131 | 4,448 |
mlflow | examples/haystack/tracing.py | .py | import os
from getpass import getpass
from haystack import Pipeline
from haystack.components.builders import ChatPromptBuilder
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
from haystack.components.routers import Condition... | 150 | 5,807 |
jupytext | demo/Benchmarking Jupytext.py | .py | # In this notebook, we benchmark the Jupytext formats for Jupyter notebooks against the base format
# Open this script as a notebook in Jupyter to run it and see the plots
import time
import copy
import pandas as pd
import plotly.graph_objects as go
from plotly.colors import DEFAULT_PLOTLY_COLORS
import nbformat
impo... | 100 | 3,317 |
pyro | pyro/contrib/gp/models/gpr.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
import torch.distributions as torchdist
from torch.distributions import constraints
import pyro
import pyro.distributions as dist
from pyro.contrib.gp.models.model import GPModel
from pyro.contrib.gp.util import condi... | 234 | 8,932 |
mlflow | tests/pyfunc/utils.py | .py | import json
import os
from typing import TYPE_CHECKING
from fastapi.testclient import TestClient
import mlflow
from mlflow.pyfunc import scoring_server
if TYPE_CHECKING:
import httpx
def score_model_in_process(model_uri: str, data: str, content_type: str) -> "httpx.Response":
"""Score a model using in-proc... | 40 | 1,381 |
saleor | saleor/graphql/account/mutations/authentication/utils.py | .py | import datetime
import jwt
from django.conf import settings
from django.core.exceptions import ValidationError
from django.middleware.csrf import ( # type: ignore[attr-defined]
_get_new_csrf_string,
_mask_cipher_secret,
_unmask_cipher_token,
)
from django.utils import timezone
from django.utils.crypto imp... | 84 | 2,704 |
biopython | Bio/Blast/_writers.py | .py | import codecs
import html
from abc import ABC
from abc import abstractmethod
from Bio.Seq import UndefinedSequenceError
def _html_entity_replace(error):
start = error.start
end = error.end
character = error.object[start:end]
codepoint = ord(character)
entity = f"&{html.entities.codepoint2name... | 1,521 | 39,674 |
saleor | saleor/graphql/product/mutations/collection/collection_create.py | .py | import datetime
import graphene
from django.core.exceptions import ValidationError
from .....core.utils.date_time import convert_to_utc_date_time
from .....discount.utils.promotion import mark_active_catalogue_promotion_rules_as_dirty
from .....permission.enums import ProductPermissions
from .....product import model... | 144 | 5,595 |
scikit-bio | skbio/sequence/tests/test_sequence.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.
# --------------------------------------------... | 2,868 | 115,007 |
wandb | tests/unit_tests/test_registries/test_freezable_list.py | .py | import pytest
from wandb.apis.public.registries._freezable_list import FreezableList
@pytest.fixture
def empty_list() -> FreezableList[str]:
return FreezableList[str]()
@pytest.fixture
def list_2_frozen() -> FreezableList[str]:
return FreezableList[str](["frozen_one", "frozen_two", "frozen_three"])
@pytes... | 365 | 11,563 |
onnxruntime | onnxruntime/test/testdata/transform/fusion/attention_gen.py | .py | import sys
import onnx
from onnx import TensorProto, helper
matmul_q_weights = [
-0.10791015625,
-0.04193115234375,
0.09051513671875,
0.025787353515625,
-0.11572265625,
-0.126953125,
-0.043304443359375,
-0.02984619140625,
0.033538818359375,
-0.05755615234375,
-0.04986572265... | 635 | 20,033 |
cvxpy | cvxpy/atoms/log_det.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... | 121 | 3,600 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.