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 | tests/gemini/test_gemini_genai_semconv_converter.py | .py | import json
from unittest.mock import patch
import pytest
from google import genai
import mlflow
from mlflow.gemini.genai_semconv_converter import _convert_part
from mlflow.tracing.constant import GenAiSemconvKey
from tests.gemini.test_gemini_autolog import (
_dummy_generate_content,
_generate_content_respon... | 163 | 5,495 |
black | tests/data/cases/composition_no_trailing_comma.py | .py | class C:
def test(self) -> None:
with patch("black.out", print):
self.assertEqual(
unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
)
self.assertEqual(
unstyle(str(report)),
"1 file reformatted, 1 file ... | 366 | 11,174 |
kombu | kombu/connection.py | .py | """Client (Connection)."""
from __future__ import annotations
import os
import socket
import sys
from contextlib import contextmanager
from itertools import count, cycle
from operator import itemgetter
from typing import TYPE_CHECKING, Any
try:
from ssl import CERT_NONE
ssl_available = True
except ImportErro... | 1,170 | 42,931 |
jupytext | tests/data/notebooks/outputs/ipynb_to_sphinx/jupyter_again.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
c = '''
title: "Quick test"
output:
ioslides_presentation:
widescreen: true
smaller: true
editor_options:
chunk_output_type console
'''
""
import yaml
print(yaml.dump(yaml.load(c)))
""
# ?nex... | 25 | 322 |
coremltools | coremltools/converters/mil/backend/mil/passes/decompose_const_base2_pow.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 numpy as np
from coremltools.converters.mil.mil import Builder as mb
from coremltools.convert... | 66 | 2,153 |
mlflow | tests/tracking/context/test_databricks_job_context.py | .py | from unittest import mock
from mlflow.entities import SourceType
from mlflow.tracking.context.databricks_job_context import DatabricksJobRunContext
from mlflow.utils.mlflow_tags import (
MLFLOW_DATABRICKS_JOB_ID,
MLFLOW_DATABRICKS_JOB_RUN_ID,
MLFLOW_DATABRICKS_JOB_TYPE,
MLFLOW_DATABRICKS_WEBAPP_URL,
... | 101 | 4,567 |
onnxruntime | onnxruntime/test/testdata/coreml_argmax_cast_test.py | .py | import onnx
from onnx import TensorProto, helper
# CoreML EP currently handles a special case for supporting ArgMax followed by a Cast to int32.
# Please see <repo_root>/onnxruntime/core/providers/coreml/builders/impl/argmax_op_builder.cc and
# <repo_root>/onnxruntime/core/providers/coreml/builders/impl/cast_op_builde... | 36 | 1,328 |
beam | sdks/python/apache_beam/utils/byte_limited_queue_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... | 271 | 8,059 |
saleor | saleor/payment/dataloaders.py | .py | from collections import defaultdict
from ..graphql.core.dataloaders import DataLoader
from .models import Payment
class PaymentsByOrderIdLoader(DataLoader):
context_key = "payments_by_order"
def batch_load(self, keys):
payments = (
Payment.objects.using(self.database_connection_name)
... | 20 | 619 |
mlflow | mlflow/store/db_migrations/versions/4465047574b1_increase_max_dataset_schema_size.py | .py | """increase max dataset schema size
Create Date: 2024-07-09 12:54:33.775087
"""
import logging
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects.mysql import MEDIUMTEXT
_logger = logging.getLogger(__name__)
# revision identifiers, used by Alembic.
revision = "4465047574b1"
down_revision = "... | 37 | 893 |
pyomo | pyomo/solvers/tests/mip/test_scip_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... | 285 | 10,707 |
pyomo | pyomo/solvers/plugins/converter/__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 | 611 |
onnxruntime | plugin-ep-webgpu/python/build_wheel.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Build a wheel for the onnxruntime-ep-webgpu package.
Combines pre-built plugin EP binaries with the Python package source to produce
a platform-specific wheel.
Usage:
python build_wheel.py --b... | 187 | 6,624 |
kafka | tests/kafkatest/__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 use ... | 26 | 1,350 |
saleor | saleor/graphql/payment/tests/mutations/test_transaction_initialize.py | .py | import datetime
from decimal import Decimal
from unittest import mock
from uuid import uuid4
import graphene
import pytest
from django.conf import settings
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from .....channel import TransactionFlowStrategy
fro... | 4,000 | 136,495 |
saleor | saleor/graphql/checkout/types.py | .py | from decimal import Decimal
from typing import TYPE_CHECKING
import graphene
from promise import Promise
from ...account.models import User
from ...checkout import models, problems
from ...checkout.calculations import recalculate_discounts
from ...checkout.delivery_context import (
get_valid_collection_points_for... | 1,514 | 54,297 |
saleor | saleor/graphql/product/tests/queries/products_filtrations/test_over_references_products.py | .py | import graphene
import pytest
from ......attribute import AttributeEntityType, AttributeType
from ......attribute.models import Attribute, AttributeValue
from ......attribute.utils import associate_attribute_values_to_instance
from ......product.models import Product
from .....core.utils import to_global_id_or_none
fr... | 400 | 12,115 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_Conv3D.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.tflite_layer_test_class import TFLiteLayerTest
np.random.seed(42)
test_params = [
{'shape': [1, 16, 28, 28, 3], 'ksize': [1, 3, 3, 3, 1], 'strides': (1, 1, 1, 1,... | 45 | 2,282 |
django-cms | cms/utils/admin.py | .py | from django.contrib.sites.models import Site
from django.forms import IntegerField, ValidationError
from django.http import JsonResponse
from django.utils.encoding import smart_str
from cms.utils import get_current_site
NOT_FOUND_RESPONSE = "NotFound"
def jsonify_request(response):
""" Turn any response in a 20... | 30 | 996 |
sqlmap | plugins/generic/misc.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import ntpath
import re
from lib.core.common import Backend
from lib.core.common import hashDBWrite
from lib.core.common import isStackingAvailable
from lib.core.common import no... | 205 | 6,886 |
saleor | saleor/graphql/meta/extra_methods.py | .py | from ...checkout.actions import call_checkout_events
from ...order.actions import call_order_event
from ...webhook.event_types import WebhookEventAsyncType
from ..core import ResolveInfo
from ..plugins.dataloaders import get_plugin_manager_promise
from ..site.dataloaders import get_site_promise
def extra_checkout_act... | 122 | 4,470 |
pyomo | pyomo/common/shutdown.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 30 | 1,139 |
saleor | saleor/graphql/discount/tests/queries/test_sales_pagination.py | .py | from decimal import Decimal
import pytest
from django.utils import timezone
from freezegun import freeze_time
from .....discount import RewardValueType
from .....discount.models import Promotion, PromotionRule
from ....tests.utils import get_graphql_content
@pytest.fixture
@freeze_time("2020-03-18 12:00:00")
def sa... | 187 | 5,918 |
loguru | tests/test_add_option_backtrace.py | .py | from loguru import logger
# See "test_catch_exceptions.py" for extended testing
def test_backtrace(writer):
logger.add(writer, format="{message}", backtrace=True)
try:
1 / 0 # noqa: B018
except Exception:
logger.exception("")
result_with = writer.read().strip()
logger.remove()
... | 25 | 607 |
coremltools | coremltools/test/optimize/torch/models/mnist.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
# type: ignore
import os
from collections import OrderedDict
import pytest
import torch
import torch... | 239 | 8,522 |
onnxruntime | onnxruntime/python/tools/transformers/models/torch_export_patches/cache_helper.py | .py | import packaging.version as pv
import torch
from transformers import __version__ as transformers_version
from transformers.cache_utils import DynamicCache, EncoderDecoderCache
def is_cache_dynamic_registered(fast: bool = False) -> bool:
"""
Tells class :class:`DynamicCache` can be
serialized and deseriali... | 73 | 2,334 |
beam | sdks/python/apache_beam/testing/analyzers/github_issues_utils.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 227 | 7,768 |
astropy | astropy/cosmology/_src/tests/flrw/test_w0wzcdm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Testing :mod:`astropy.cosmology.w0wzcdm`."""
import numpy as np
import pytest
import astropy.units as u
from astropy.cosmology import Flatw0wzCDM, w0wzCDM
from astropy.cosmology._src.parameter import Parameter
from astropy.cosmology._src.tests.test_c... | 304 | 11,093 |
astropy | astropy/coordinates/builtin_frames/fk5.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import erfa
from astropy.coordinates.attributes import TimeAttribute
from astropy.coordinates.baseframe import base_doc, frame_transform_graph
from astropy.coordinates.transformations import DynamicMatrixTransform
from astropy.utils.decorators import for... | 72 | 2,311 |
saleor | saleor/graphql/order/tests/queries/test_order_with_filter.py | .py | import datetime
from decimal import Decimal
import graphene
import pytest
from freezegun import freeze_time
from prices import Money, TaxedMoney
from .....core.postgres import FlatConcatSearchVector
from .....discount.models import OrderDiscount
from .....giftcard.events import gift_cards_bought_event, gift_cards_use... | 1,437 | 44,892 |
beam | sdks/python/apache_beam/transforms/combinefn_lifecycle_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... | 101 | 3,842 |
mlflow | mlflow/store/db_migrations/versions/27a6a02d2cf1_add_model_version_tags_table.py | .py | """add model version tags table
Create Date: 2020-06-26 13:30:27.611086
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
from mlflow.store.model_registry.dbmodels.models import SqlModelVersionTag
revision = "27a6a02d2cf1"
down_revision = "728d730b5ebd"
branch_labels = Non... | 37 | 1,011 |
readthedocs.org | readthedocs/rtd_tests/tests/test_doc_building.py | .py | import os
import uuid
from unittest import mock
from unittest.mock import Mock, PropertyMock, patch
import pytest
from django.test import TestCase, override_settings
from django_dynamic_fixture import get
from docker.errors import APIError as DockerAPIError
from readthedocs.projects.models import APIProject
from read... | 433 | 15,392 |
probability | tensorflow_probability/python/bijectors/ffjord_test.py | .py | # Copyright 2019 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... | 201 | 7,810 |
saleor | saleor/channel/models.py | .py | import datetime
from django.conf import settings
from django.db import models
from django_countries.fields import CountryField
from ..core.models import ModelWithMetadata
from ..permission.enums import ChannelPermissions
from . import AllocationStrategy, MarkAsPaidStrategy, TransactionFlowStrategy
class Channel(Mod... | 89 | 3,345 |
probability | tensorflow_probability/python/experimental/bayesopt/acquisition/max_value_entropy_search.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... | 222 | 8,489 |
clearml | examples/hyperdatasets/legacy/data-registration/register_dataset_masks.py | .py | """
How to register data with masks from a json file.
Create a list of masks for each image and add to a DatasetVersion.
Define DatasetVersion-level mask-label mapping, which maps RGB values from the mask to class labels.
Notice: This is a custom parser for a specific dataset. Each dataset requires a different parser.... | 138 | 5,420 |
sqlmap | tests/test_dns_engine.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
The DNS-exfiltration extraction engine (lib/techniques/dns/use.py dnsUse) and the
channel-detection probe (lib/techniques/dns/test.py dnsTest).
DNS exfil is normally driven by a back... | 403 | 18,957 |
readthedocs.org | readthedocs/core/fields.py | .py | """Shared model fields and defaults."""
import binascii
import os
def default_token():
"""Generate default value for token field."""
return binascii.hexlify(os.urandom(20)).decode()
| 10 | 193 |
httpie | httpie/compat.py | .py | import sys
from ssl import SSLContext
from typing import Any, Optional, Iterable
from httpie.cookies import HTTPieCookiePolicy
from http import cookiejar # noqa
# Request does not carry the original policy attached to the
# cookie jar, so until it is resolved we change the global cookie
# policy. <https://github.co... | 114 | 3,847 |
clearml | clearml/backend_config/defs.py | .py | from os.path import expanduser, expandvars, exists
from typing import Optional
from pathlib2 import Path
from .environment import EnvEntry
ENV_VAR = "CLEARML_ENV"
""" Name of system environment variable that can be used to specify the config environment name """
DEFAULT_CONFIG_FOLDER = "config"
""" Default config f... | 70 | 2,128 |
probability | tensorflow_probability/python/distributions/masked_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... | 172 | 7,623 |
readthedocs.org | readthedocs/notifications/tests/test_signals.py | .py | import django_dynamic_fixture as fixture
from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from readthedocs.core.notifications import MESSAGE_EMAIL_VALIDATION_PENDING
from readthedocs.n... | 92 | 3,458 |
pyomo | examples/pyomobook/abstract-ch/AbstHLinScript.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... | 55 | 1,471 |
saleor | saleor/graphql/translations/mutations/product_translate.py | .py | import graphene
from ....core.tracing import traced_atomic_transaction
from ....permission.enums import SitePermissions
from ....product import models as product_models
from ...core import ResolveInfo
from ...core.context import ChannelContext
from ...core.enums import LanguageCodeEnum
from ...core.types import Transl... | 56 | 2,244 |
clearml | examples/frameworks/fastai/legacy/fastai_example.py | .py | # ClearML - Fastai example code, automatic logging the model and scalars
#
import argparse
from clearml import Task
import fastai
try:
from fastai.vision import untar_data, URLs, ImageDataBunch, rand_pad, imagenet_stats, cnn_learner, models, accuracy
except ImportError:
raise ImportError("FastAI version %s i... | 34 | 950 |
pyomo | pyomo/gdp/tests/test_basic_step.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... | 152 | 6,216 |
cvxpy | cvxpy/reductions/complex2real/canonicalizers/equality_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... | 53 | 1,780 |
probability | tensorflow_probability/python/experimental/mcmc/thermodynamic_integrals.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... | 117 | 5,070 |
pyomo | pyomo/opt/tests/__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... | 12 | 568 |
cvxpy | cvxpy/reductions/dnlp2smooth/canonicalizers/quad_over_lin_canon.py | .py | """
Copyright 2025 CVXPY 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 law or agreed to in writing, softwa... | 53 | 1,853 |
black | tests/data/cases/fstring.py | .py | f"f-string without formatted values is just a string"
f"{{NOT a formatted value}}"
f"{{NOT 'a' \"formatted\" \"value\"}}"
f"some f-string with {a} {few():.2f} {formatted.values!r}"
f'some f-string with {a} {few(""):.2f} {formatted.values!r}'
f"{f'''{'nested'} inner'''} outer"
f"\"{f'{nested} inner'}\" outer"
f"space be... | 26 | 989 |
pyomo | examples/pyomo/tutorials/table.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... | 133 | 3,441 |
mlflow | tests/models/test_wheeled_model.py | .py | import os
import random
import re
from io import BytesIO
from typing import Any, NamedTuple
from unittest import mock
import numpy as np
import pandas as pd
import pytest
import sklearn.linear_model as logreg_module
import yaml
from sklearn import datasets
import mlflow
import mlflow.pyfunc.scoring_server as pyfunc_s... | 509 | 18,751 |
textual | docs/examples/widgets/option_list_tables.py | .py | from __future__ import annotations
from rich.table import Table
from textual.app import App, ComposeResult
from textual.widgets import Footer, Header, OptionList
COLONIES: tuple[tuple[str, str, str, str], ...] = (
("Aerilon", "Demeter", "1.2 Billion", "Gaoth"),
("Aquaria", "Hermes", "75,000", "None"),
("... | 44 | 1,468 |
sphinx | tests/roots/test-ext-autodoc/target/wrappedfunction.py | .py | from __future__ import annotations
from contextlib import contextmanager
from functools import lru_cache
from typing import Generator # NoQA: TC003,UP035
@lru_cache(maxsize=None) # NoQA: UP033
def slow_function(message, timeout):
"""This function is slow."""
print(message)
@contextmanager
def feeling_goo... | 18 | 408 |
sqlmap | lib/techniques/error/use.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from __future__ import print_function
import re
import time
from lib.core.agent import agent
from lib.core.bigarray import BigArray
from lib.core.common import Backend
from lib.... | 470 | 21,577 |
onnxruntime | onnxruntime/python/tools/quantization/CalTableFlatBuffers/TrtTable.py | .py | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: CalTableFlatBuffers
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class TrtTable:
__slots__ = ["_tab"]
@classmethod
def GetRootAs(cls, buf, offset=0): # noqa: N802
n = flatbu... | 91 | 2,592 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/Notebook_with_more_R_magic_111.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: region,endregion
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# region
# %load_ext rpy2.ipython
import pandas as pd
df = pd.DataFrame(
{
"Letter": ["a", "a", "a", "b", "b", "b", "c", "c", "c"],
"X":... | 29 | 610 |
black | tests/test_ipynb.py | .py | import contextlib
import pathlib
import re
from contextlib import AbstractContextManager
from contextlib import ExitStack as does_not_raise
from dataclasses import replace
import pytest
from click.testing import CliRunner
from pytest import MonkeyPatch
from black import (
Mode,
NothingChanged,
format_cell... | 566 | 17,469 |
wagtail | wagtail/snippets/side_panels.py | .py | from wagtail.admin.ui.side_panels import StatusSidePanel
class SnippetStatusSidePanel(StatusSidePanel):
def get_context_data(self, parent_context):
context = super().get_context_data(parent_context)
inherit = [
"view",
"workflow_history_url",
"revisions_compare_... | 22 | 682 |
textual | docs/examples/widgets/input_validation.py | .py | from textual import on
from textual.app import App, ComposeResult
from textual.validation import Function, Number, ValidationResult, Validator
from textual.widgets import Input, Label, Pretty
class InputApp(App):
# (6)!
CSS = """
Input.-valid {
border: tall $success 60%;
}
Input.-valid:foc... | 73 | 1,881 |
textual | tests/test_progress_bar.py | .py | import pytest
from pytest import approx
from rich.console import Console
from rich.text import Text
from textual.app import App, ComposeResult
from textual.color import Gradient
from textual.css.query import NoMatches
from textual.renderables.bar import _apply_gradient
from textual.widget import Widget
from textual.wi... | 206 | 4,613 |
wagtail | wagtail/images/utils.py | .py | import base64
import hashlib
import hmac
from django.conf import settings
from django.utils.crypto import constant_time_compare
from django.utils.encoding import force_str
# Helper functions for migrating the Rendition.filter foreign key to the filter_spec field,
# and the corresponding reverse migration
def get_fil... | 162 | 5,484 |
pyomo | examples/dae/run_Optimal_Control.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... | 48 | 1,444 |
astropy | astropy/wcs/tests/test_prjprm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from copy import copy, deepcopy
import numpy as np
import pytest
from astropy import wcs
def test_prjprm_init():
# test Prjprm_cnew
assert wcs.WCS().wcs.cel.prj
# test Prjprm_new
assert wcs.Prjprm()
with pytest.raises(wcs.InvalidP... | 248 | 5,441 |
openvino | tests/layer_tests/pytorch_tests/test_conv_transposend.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestConvTranspose2D(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(1, 3, 10, 10),)
def create_model(self, weights_shape... | 194 | 10,582 |
probability | tensorflow_probability/python/bijectors/sinh.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... | 71 | 2,095 |
confluent-kafka-python | src/confluent_kafka/schema_registry/common/avro.py | .py | import decimal
import json
import logging
import re
from collections import defaultdict
from copy import deepcopy
from io import BytesIO
from typing import Dict, Optional, Set, Tuple, Union, cast
from fastavro import repository, validate
from fastavro.schema import load_schema
from confluent_kafka.schema_registry.ser... | 339 | 12,303 |
confluent-kafka-python | src/confluent_kafka/schema_registry/rules/cel/cel_field_executor.py | .py | # Copyright 2024 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 53 | 1,942 |
clearml | examples/reporting/hyper_parameters.py | .py | # ClearML - example code for logging into "CONFIGURATION":
# - ArgumentParser parameter logging
# - user properties logging
# - logging of hyperparameters via dictionary
# - logging of hyperparameters via TaskParameters
# - logging of configuration objects via TaskParameters
#
from __future__ import absolute_import
fro... | 122 | 3,878 |
returns | returns/interfaces/specific/future_result.py | .py | """
Represents the base interfaces for types that do fear-some async operations.
This type means that ``FutureResult`` can (and will!) fail with exceptions.
Use this type to mark that this specific async opetaion can fail.
"""
from __future__ import annotations
from abc import abstractmethod
from collections.abc im... | 110 | 3,356 |
onnxruntime | onnxruntime/python/onnxruntime_inference_collection.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from __future__ import annotations
import collections
import collections... | 1,628 | 68,906 |
mlflow | mlflow/store/db/utils.py | .py | import hashlib
import logging
import os
import re
import sqlite3
import tempfile
import time
from contextlib import contextmanager
from pathlib import Path
import sqlalchemy
from alembic.migration import MigrationContext
from alembic.script import ScriptDirectory
from packaging.version import Version
from sqlalchemy i... | 469 | 19,013 |
wandb | tools/bench/bench.py | .py | #!/usr/bin/env python
import argparse
import multiprocessing
import _load_profiles
import _timing
import numpy
import wandb
VERSION: str = "v1-2024-04-11-0"
BENCH_OUTFILE: str = "bench.csv"
BENCH_FIELDS: tuple[str] = (
"test_name",
"test_profile",
"test_variant",
"client_version",
"client_type",
... | 133 | 4,033 |
sphinx | sphinx/util/__init__.py | .py | """Utility functions for Sphinx."""
from __future__ import annotations
import os
import posixpath
import re
TYPE_CHECKING = False
if TYPE_CHECKING:
import hashlib
from collections.abc import Callable
from types import ModuleType
from typing import Any
# Generally useful regular expressions.
ws_re: r... | 137 | 3,379 |
pyomo | pyomo/mpec/plugins/mpec3.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... | 48 | 1,806 |
coremltools | coremltools/models/compute_device.py | .py | # Copyright (c) 2024, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from abc import ABC as _ABC
from typing import List as _List
from coremltools import _logger
try:
... | 136 | 4,057 |
metrics | tests/unittests/text/test_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... | 155 | 6,949 |
django-cms | cms/test_utils/project/app_with_feature_not_implemented/apps.py | .py | from django.apps import AppConfig
class CMSFeatureConfig(AppConfig):
name = 'cms.test_utils.project.app_with_feature_not_implemented'
label = 'app_with_feature_not_implemented'
| 7 | 187 |
cvxpy | cvxpy/tests/test_coeff_extractor.py | .py | from dataclasses import dataclass
import numpy as np
import pytest
import cvxpy as cp
from cvxpy.atoms.quad_form import SymbolicQuadForm
from cvxpy.lin_ops.canon_backend import TensorRepresentation
from cvxpy.utilities.coeff_extractor import CoeffExtractor
@dataclass
class MockInverseData:
var_offsets: dict
... | 431 | 15,308 |
coremltools | coremltools/optimize/torch/_utils/k_means.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 logging as _logging
import queue as _queue
from abc import abstractmethod as _abstractmethod
f... | 1,102 | 43,883 |
mlflow | mlflow/genai/scorers/ensemble.py | .py | """Built-in ensemble functions for ``make_scorer_ensemble``.
Each function receives the list of per-sub-scorer values and returns a single
``Feedback``. The parameter is named ``values`` on purpose: ``make_scorer_ensemble``
introspects the parameter name to decide whether to pass raw values or full
``Feedback`` object... | 168 | 6,925 |
openvino | src/bindings/python/tests/test_graph/test_core.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import copy
import numpy as np
import pytest
from openvino import Dimension, Model, PartialShape, Shape
import openvino.opset13 as ov
def test_dimension():
dim = Dimension()
assert dim.is_dynamic
... | 471 | 14,612 |
mlflow | dev/clint/tests/rules/test_forbidden_deprecation_warning.py | .py | from pathlib import Path
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import Position, Range, lint_file
from clint.rules import ForbiddenDeprecationWarning
def test_forbidden_deprecation_warning(index: SymbolIndex) -> None:
code = """
import warnings
# Bad - should be fl... | 83 | 2,911 |
django-cms | cms/test_utils/project/sampleapp/admin.py | .py | from django.contrib import admin
from cms.admin.placeholderadmin import FrontendEditableAdminMixin
from cms.admin.utils import GrouperModelAdmin
from cms.test_utils.project.sampleapp.models import (
Category,
GrouperModel,
Picture,
SampleAppConfig,
SimpleGrouperModel,
SomeEditableModel,
)
cla... | 47 | 1,306 |
voila | tests/app/many_iopub_messages_test.py | .py | import os
import pytest
MAX_TIMEOUT_SECONDS = 240
@pytest.fixture
def preheat_mode():
return False
@pytest.fixture
def voila_args_extra():
return [f"--VoilaExecutor.timeout={MAX_TIMEOUT_SECONDS}"]
@pytest.fixture
def voila_notebook(notebook_directory):
return os.path.join(notebook_directory, "many_i... | 30 | 643 |
mlflow | dev/clint/tests/rules/test_prefer_next.py | .py | from pathlib import Path
import pytest
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import lint_file
from clint.rules import PreferNext
@pytest.mark.parametrize(
"code",
[
pytest.param("[x for x in items if f(x)][0]", id="basic_pattern"),
],
)
def test_fla... | 39 | 1,303 |
coremltools | coremltools/converters/mil/mil/ops/tests/iOS14/test_pool.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
import coremltools as ct
from coremltools.convert... | 512 | 18,257 |
kombu | kombu/transport/zookeeper.py | .py | # copyright: (c) 2010 - 2013 by Mahendra M.
# license: BSD, see LICENSE for more details.
"""Zookeeper transport module for kombu.
Zookeeper based transport. This transport uses the built-in kazoo Zookeeper
based queue implementation.
**References**
- https://zookeeper.apache.org/doc/current/recipes.html#sc_recipes... | 224 | 6,339 |
openvino | tests/model_hub_tests/tensorflow/utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf_v1
type_map = {
tf.float64: np.float64,
tf.float32: np.float32,
tf.int8: np.int8,
tf.int16: np.int16,
tf.int32: np.int32,
tf.int64: np.... | 210 | 8,256 |
saleor | saleor/order/tests/test_refresh_all_order_base_prices_and_discounts.py | .py | from datetime import timedelta
from decimal import Decimal
import graphene
import pytest
from django.utils import timezone
from freezegun import freeze_time
from ...core.prices import quantize_price
from ...core.taxes import zero_money
from ...discount import DiscountType, DiscountValueType, RewardValueType, VoucherT... | 613 | 26,501 |
mlflow | mlflow/server/auth/cli.py | .py | import click
from mlflow.server.auth.db import cli as db_cli
@click.group()
def commands():
pass
commands.add_command(db_cli.commands)
| 12 | 144 |
probability | tensorflow_probability/python/internal/backend/numpy/nn.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... | 241 | 7,696 |
luigi | luigi/metrics.py | .py | import abc
import importlib
from enum import Enum
class MetricsCollectors(Enum):
custom = -1
default = 1
none = 1
datadog = 2
prometheus = 3
@classmethod
def get(cls, which, custom_import=None):
if which == MetricsCollectors.none:
return NoMetricsCollector()
el... | 97 | 2,582 |
probability | tensorflow_probability/python/debugging/benchmarking/benchmark_tf_function.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... | 220 | 7,616 |
mlflow | mlflow/entities/model_registry/_model_registry_entity.py | .py | from abc import abstractmethod
from mlflow.entities._mlflow_object import _MlflowObject
class _ModelRegistryEntity(_MlflowObject):
@classmethod
@abstractmethod
def from_proto(cls, proto):
pass
def __eq__(self, other):
return dict(self) == dict(other)
| 14 | 287 |
deap | examples/ga/onemax_mp.py | .py | #!/usr/bin/env python2.7
# This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
... | 75 | 2,353 |
pymc | pymc/gp/util.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... | 235 | 7,295 |
wagtail | wagtail/snippets/tests/test_api_v3/test_create.py | .py | import json
from django.contrib.auth.models import Permission
from django.test import TestCase
from django.urls import reverse
from wagtail.api.v3.tests.base import TestV3Base
from wagtail.documents.models import Document
from wagtail.images.models import Image
from wagtail.images.tests.utils import get_test_image_fi... | 540 | 20,632 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.