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 | mlflow/utils/autologging_utils/__init__.py | .py | import contextlib
import importlib
import importlib.metadata
import inspect
import logging
import threading
import time
from typing import Any, Callable
import mlflow
from mlflow.entities import Metric
from mlflow.utils.validation import MAX_METRICS_PER_BATCH
# Define the module-level logger for autologging utilities... | 725 | 29,613 |
wagtail | wagtail/documents/tests/test_collection_privacy.py | .py | from django.contrib.auth.models import Group
from django.core.files.base import ContentFile
from django.test import TestCase, override_settings
from django.urls import reverse
from wagtail.documents.models import Document
from wagtail.models import Collection, CollectionViewRestriction
from wagtail.test.utils import P... | 204 | 7,814 |
mlflow | examples/langchain/retrieval_qa_chain_azure_openai.py | .py | import os
import tempfile
from langchain.chains import RetrievalQA
from langchain.document_loaders import TextLoader
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import FAISS
from langchain_openai import AzureOpenAI, AzureOpenAIEmbeddings
import mlflow
# Set this to `azure`
o... | 64 | 2,472 |
scikit-optimize | skopt/learning/__init__.py | .py | """Machine learning extensions for model-based optimization."""
from .forest import RandomForestRegressor
from .forest import ExtraTreesRegressor
from .gaussian_process import GaussianProcessRegressor
from .gbrt import GradientBoostingQuantileRegressor
__all__ = ("RandomForestRegressor",
"ExtraTreesRegres... | 13 | 413 |
textual | src/textual/widgets/_select.py | .py | from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING, Generic, Hashable, Iterable, TypeVar
import rich.repr
from rich.console import RenderableType
from rich.text import Text
from textual import events, on
from textual.binding import Binding
from textual.containers im... | 720 | 23,970 |
scikit-bio | skbio/tree/tests/test_tree.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.
# --------------------------------------------... | 3,383 | 128,482 |
cvxpy | cvxpy/atoms/pf_eigenvalue.py | .py | """
Copyright 2018 Akshay Agrawal
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | 102 | 2,977 |
black | tests/data/cases/line_ranges_decorator_edge_case.py | .py | # flags: --line-ranges=6-7
class Foo:
@overload
def foo(): ...
def fox(self):
print()
| 9 | 108 |
wagtail | wagtail/documents/api/v3/form_data.py | .py | from copy import deepcopy
from typing import Any, cast
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import AnonymousUser
from django.db.models import Model
from django.forms import ModelChoiceField, ModelForm
from django.utils.datastructures import MultiValueDict
from ninj... | 68 | 2,408 |
wagtail | wagtail/images/tests/test_templatetags.py | .py | from django.template import Context, Engine, TemplateSyntaxError, Variable
from django.test import TestCase
from wagtail.images.models import Image, Rendition
from wagtail.images.templatetags.wagtailimages_tags import ImageNode
from wagtail.images.tests.utils import (
get_test_bad_image,
get_test_image_file,
... | 552 | 19,786 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_RFFT2D.py | .py | import platform
import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shape': [96, 1, 512], 'fft_length': [1, 512], 'reshape_to': [96, 257]},
{'shape': [5, 1, 16], 'fft_length': [1, 16], 'reshape_to': [5, 9]},
]
class TestTFLiteRFFT2DLayerTest(TF... | 39 | 1,523 |
probability | tensorflow_probability/python/experimental/distribute/joint_distribution_test.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... | 436 | 16,753 |
pyomo | pyomo/util/report_scaling.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... | 198 | 6,990 |
sqlmap | tests/test_comparison.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
The true/false/None response oracle (lib/request/comparison.py).
The seqMatcher ratio path needs a live page template and is intentionally left
to --vuln. What IS pure and worth pinn... | 133 | 4,257 |
sphinx | sphinx/ext/napoleon/__init__.py | .py | """Support for NumPy and Google style docstrings."""
from __future__ import annotations
from types import NoneType
from typing import TYPE_CHECKING
import sphinx
from sphinx.application import Sphinx
from sphinx.ext.napoleon.docstring import GoogleDocstring, NumpyDocstring
from sphinx.util import inspect
if TYPE_CH... | 510 | 18,761 |
textual | src/textual/widgets/_link.py | .py | from __future__ import annotations
from textual.binding import Binding
from textual.reactive import reactive
from textual.widgets import Static
class Link(Static, can_focus=True):
"""A simple, clickable link that opens a URL."""
DEFAULT_CSS = """
Link {
width: auto;
height: auto;
... | 72 | 1,978 |
saleor | saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_percentage_voucher.py | .py | import pytest
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
from ...utils import (
checkout_add_promo_code,
checkout_complete,... | 153 | 4,531 |
beam | sdks/python/apache_beam/runners/worker/sideinputs_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... | 190 | 5,762 |
saleor | saleor/graphql/product/mutations/category/category_delete.py | .py | import graphene
from .....permission.enums import ProductPermissions
from .....product import models
from .....product.utils import delete_categories
from ....core import ResolveInfo
from ....core.mutations import ModelDeleteMutation
from ....core.types import ProductError
from ....plugins.dataloaders import get_plugi... | 37 | 1,207 |
rq | tests/test_retry.py | .py | import time
from datetime import datetime, timedelta, timezone
from rq import Queue
from rq.executions import prepare_execution
from rq.job import Job, JobStatus, Retry
from rq.registry import FailedJobRegistry, StartedJobRegistry
from rq.results import Result
from rq.scheduler import RQScheduler
from rq.worker import... | 452 | 18,452 |
beam | learning/katas/python/Core Transforms/Combine/Simple Function/task.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"); y... | 47 | 1,340 |
readthedocs.org | readthedocs/core/utils/filesystem.py | .py | """
File system utilities.
Provides wrappers around common path operations
with some security checks in place.
"""
import shutil
from pathlib import Path
import structlog
from django.conf import settings
from django.core.exceptions import SuspiciousFileOperation
from readthedocs.doc_builder.exceptions import BuildU... | 176 | 6,023 |
wandb | tests/unit_tests/test_lib/test_printer_asyncio.py | .py | from __future__ import annotations
import contextlib
import threading
from collections.abc import Generator
from unittest.mock import Mock
import pytest
from wandb.sdk.lib import printer, printer_asyncio
class _Tester:
"""Helper to test run_async_with_spinner."""
def __init__(self, loading_symbol: str) -> ... | 85 | 2,406 |
clearml | clearml/backend_api/services/__init__.py | .py | from ..api_proxy import ApiServiceProxy
# allow us to replace the api version after we have completed the authentication process,
# and we know the backend server api version.
# ApiServiceProxy will dynamically load the correct api object based on the session api_version
auth = ApiServiceProxy("auth")
events = ApiSer... | 30 | 794 |
coremltools | deps/protobuf/python/google/protobuf/message.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 422 | 14,453 |
wagtail | wagtail/contrib/routable_page/apps.py | .py | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class WagtailRoutablePageAppConfig(AppConfig):
name = "wagtail.contrib.routable_page"
label = "wagtailroutablepage"
verbose_name = _("Wagtail routablepage")
| 9 | 260 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_DepthwiseConv2D.py | .py | 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, 22, 22, 8], 'ksize': [3, 3, 8, 2], 'strides': [1, 2, 2, 1], 'padding': 'SAME',
'dilations': [1, 1]},
{'shape': [1, 22, 22, 9], 'ksize': [3,... | 40 | 1,643 |
hydra | hydra/_internal/grammar/functions.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import inspect
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List
from omegaconf._utils import type_str
from hydra._internal.grammar.utils import is_type_matching
from hydra.core.override_parser.types import Quot... | 76 | 2,657 |
beam | sdks/python/apache_beam/ml/gcp/visionml.py | .py | # pylint: skip-file
#
# 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 "Licen... | 294 | 10,520 |
pyomo | pyomo/devel/initialization/__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... | 15 | 723 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/min_per_key.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");... | 60 | 1,726 |
beam | sdks/python/apache_beam/internal/test_data/__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... | 21 | 879 |
mlflow | tests/entities/test_assessment.py | .py | import json
import time
from unittest.mock import patch
import pytest
from mlflow.entities.assessment import (
Assessment,
AssessmentError,
AssessmentSource,
Expectation,
ExpectationValue,
Feedback,
FeedbackValue,
IssueReference,
IssueReferenceValue,
)
from mlflow.entities.assessme... | 757 | 26,152 |
saleor | saleor/graphql/shipping/mutations/shipping_zone_create.py | .py | import graphene
from ....permission.enums import ShippingPermissions
from ....shipping import models
from ...core import ResolveInfo
from ...core.context import ChannelContext
from ...core.doc_category import DOC_CATEGORY_SHIPPING
from ...core.mutations import DeprecatedModelMutation
from ...core.types import BaseInpu... | 67 | 2,294 |
beam | examples/notebooks/beam-ml/rag_usecase/chunks_generation.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... | 130 | 4,355 |
mlflow | mlflow/genai/scorers/online/session_checkpointer.py | .py | """Checkpoint management for session-level online scoring."""
import json
import logging
import time
from dataclasses import asdict, dataclass
from mlflow.entities.experiment_tag import ExperimentTag
from mlflow.environment_variables import (
MLFLOW_ONLINE_SCORING_DEFAULT_SESSION_COMPLETION_BUFFER_SECONDS,
)
from... | 106 | 4,079 |
pdm | src/pdm/models/cached_package.py | .py | from __future__ import annotations
import os
import shutil
from contextlib import AbstractContextManager
from functools import cached_property
from pathlib import Path
from typing import Any, ClassVar
from pdm.termui import logger
class CachedPackage:
"""A package cached in the central package store.
The di... | 85 | 3,061 |
onnx | onnx/backend/test/case/node/mish.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Mish(Base):
@staticmethod
def export() -> None:
node =... | 24 | 655 |
sphinx | tests/test_util/test_util_template.py | .py | """Tests sphinx.util.template functions."""
from __future__ import annotations
from sphinx.util.template import ReSTRenderer
def test_ReSTRenderer_escape() -> None:
r = ReSTRenderer()
template = '{{ "*hello*" | e }}'
assert r.render_string(template, {}) == r'\*hello\*'
def test_ReSTRenderer_heading() ... | 30 | 934 |
onnx | onnx/backend/test/case/node/thresholdedrelu.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class ThresholdedRelu(Base):
@staticmethod
def export() -> None:
... | 42 | 1,298 |
black | tests/data/cases/line_ranges_fmt_off_overlap.py | .py | # flags: --line-ranges=11-17
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
def myfunc( ): # This will not be reformatted.
print( {"also won't be reformatted"} )
# fmt: off
def myfunc( ): # This will not be r... | 38 | 1,155 |
saleor | saleor/tests/e2e/orders/discounts/test_order_voucher_entire_order.py | .py | import pytest
from .....product.tasks import recalculate_discounted_price_for_products_task
from ... import DEFAULT_ADDRESS
from ...product.utils.preparing_product import prepare_product
from ...shop.utils.preparing_shop import prepare_shop
from ...taxes.utils import update_country_tax_rates
from ...utils import assig... | 428 | 15,958 |
mlflow | dev/clint/src/clint/rules/prefer_dict_union.py | .py | import ast
from clint.rules.base import Rule
def _is_simple_name_or_attribute(node: ast.expr) -> bool:
"""
Check if a node is a simple name (e.g., `a`) or a chain of attribute
accesses on a simple name (e.g., `obj.attr` or `a.b.c`).
"""
if isinstance(node, ast.Name):
return True
if is... | 57 | 1,797 |
wandb | tests/system_tests/test_core/test_wandb_settings.py | .py | """settings test."""
import os
import platform
import subprocess
from unittest import mock
import pytest
import wandb
from wandb import env
@pytest.mark.skipif(
platform.system() == "Windows", reason="backend crashes on Windows in CI"
)
def test_sync_dir(user):
with wandb.init(settings={"mode": "offline"}) ... | 162 | 4,966 |
pyomo | pyomo/solvers/tests/models/__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... | 41 | 1,229 |
probability | tensorflow_probability/python/internal/test_util.py | .py | # Copyright 2018 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 2,057 | 78,975 |
cvxpy | cvxpy/reductions/dcp2cone/canonicalizers/tr_inv_canon.py | .py | """
Copyright 2022, the CVXPY authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, soft... | 66 | 1,761 |
sqlmap | lib/core/agent.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.common import Backend
from lib.core.common import extractRegexResult
from lib.core.common import filterNone
from lib.core.common import getSQLSnippet
from... | 1,390 | 66,685 |
httpie | httpie/output/lexers/http.py | .py | import re
import pygments
from httpie.output.lexers.common import precise
RE_STATUS_LINE = re.compile(r'(\d{3})( +)?(.+)?')
STATUS_TYPES = {
'1': pygments.token.Number.HTTP.INFO,
'2': pygments.token.Number.HTTP.OK,
'3': pygments.token.Number.HTTP.REDIRECT,
'4': pygments.token.Number.HTTP.CLIENT_ERR,
... | 98 | 3,044 |
pyomo | pyomo/contrib/doe/examples/reactor_experiment.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... | 213 | 7,602 |
coremltools | coremltools/optimize/torch/quantization/modules/learnable_fake_quantize.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
# Implementation for LearnableFakeQuantize class adapted from:
# - https://github.com/pytorch/pytorch... | 380 | 15,337 |
pyomo | pyomo/contrib/appsi/solvers/gurobi.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,573 | 60,427 |
mlflow | mlflow/assistant/custom_view.py | .py | """Custom View delivery for structured-output providers (Claude Code and Codex).
This module converts a structured response envelope into a terminal ``client_tool_call``.
Native-tool providers use ``tool_executor`` instead.
"""
import json
import uuid
from typing import Any, Literal
from pydantic import BaseModel, C... | 159 | 6,001 |
sqlmap | tests/test_websocket.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 PURE (network-free) parts of the native WebSocket client in
lib/request/websocket.py: the RFC 6455 accept-key computation, client frame masking,
the length-encod... | 139 | 4,859 |
wandb | tests/unit_tests/test_wandb_verify.py | .py | import unittest.mock
import pytest
import wandb
import wandb.sdk.verify.verify as wandb_verify
from wandb.proto import wandb_api_pb2 as apb
from wandb.sdk.lib.service.service_connection import WandbApiFailedError
def test_print_results(capsys):
failed_test_or_tests = ["test1", "test2"]
wandb_verify.print_res... | 140 | 4,398 |
openvino | tests/layer_tests/onnx_tests/test_reshape.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
pytest.importorskip("openvino.tools.mo", reason="Ticket - 157136")
from common.layer_test_class import check_ir_version
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
from unit_tests.utils.... | 297 | 12,083 |
wandb | wandb/apis/public/summary.py | .py | import os
import time
import wandb
from wandb import util
from wandb.apis.internal import Api
from wandb.sdk.data_types.utils import val_to_json
DEEP_SUMMARY_FNAME = "wandb.h5"
H5_TYPES = ("numpy.ndarray", "tensorflow.Tensor", "torch.Tensor")
h5py = util.get_module("h5py")
class SummarySubDict:
"""Nested dict-l... | 406 | 12,930 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/filter_side_inputs_iter.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");... | 79 | 2,436 |
eve | tests/methods/delete.py | .py | import copy
import simplejson as json
from bson import ObjectId
from eve import ETAG
from eve.methods.delete import deleteitem_internal
from eve.utils import ParsedRequest
from tests import TestBase
from tests.test_settings import MONGO_DBNAME
from tests.utils import DummyEvent
class TestDelete(TestBase):
def s... | 837 | 33,374 |
pyro | tests/distributions/test_sine_bivariate_von_mises.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from scipy.special import binom
from torch import tensor
from torch.distributions import Beta, HalfNormal, VonMises
import pyro
from pyro.distributions import Geometric, constraints
from pyro.distributions.s... | 153 | 5,089 |
biopython | Bio/GenBank/Record.py | .py | # 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.
#
"""Hold GenBank data in a straightforward format.
Classes:
- Record - All of the information in a GenBank record.
- Reference - hold reference dat... | 670 | 23,318 |
beam | sdks/python/apache_beam/utils/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... | 271 | 7,278 |
readthedocs.org | readthedocs/redirects/querysets.py | .py | """Queryset for the redirects app."""
from urllib.parse import urlparse
import structlog
from django.db import models
from django.db.models import CharField
from django.db.models import F
from django.db.models import Q
from django.db.models import Value
from readthedocs.core.permissions import AdminPermission
from r... | 172 | 6,754 |
black | tests/data/cases/line_ranges_unwrapping.py | .py | # flags: --line-ranges=5-5 --line-ranges=9-9 --line-ranges=13-13
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
alist = [
1, 2
]
adict = {
"key" : "value"
}
func_call (
arg = value
)
# output
... | 26 | 591 |
tqdm | examples/tqdm_wget.py | .py | """An example of wrapping manual tqdm updates for `urllib` reporthook.
See also: tqdm_requests.py.
# `urllib.urlretrieve` documentation
> If present, the hook function will be called once
> on establishment of the network connection and once after each block read
> thereafter. The hook will be passed three arguments; ... | 111 | 3,543 |
openvino | tests/layer_tests/onnx_tests/test_loop.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
class TestLoop(OnnxRuntimeLayerTest):
@staticmethod
def create_const(name, tensor_type, value):
from onnx ... | 287 | 11,183 |
saleor | saleor/graphql/discount/tests/test_validators.py | .py | from collections import defaultdict
import graphene
import pytest
from django.core.exceptions import ValidationError
from ....discount import PromotionType, RewardType, RewardValueType
from ..enums import PromotionCreateErrorCode
from ..mutations.promotion.validators import (
_clean_catalogue_predicate,
_clea... | 670 | 16,419 |
readthedocs.org | readthedocs/api/v3/tests/test_redirects.py | .py | from django.urls import reverse
from django_dynamic_fixture import get
from readthedocs.redirects.constants import (
CLEAN_URL_TO_HTML_REDIRECT,
EXACT_REDIRECT,
HTML_TO_CLEAN_URL_REDIRECT,
)
from readthedocs.redirects.models import Redirect
from .mixins import APIEndpointMixin
class RedirectsEndpointTes... | 411 | 13,556 |
saleor | saleor/webhook/error_codes.py | .py | from enum import Enum
class WebhookErrorCode(Enum):
GRAPHQL_ERROR = "graphql_error"
INVALID = "invalid"
NOT_FOUND = "not_found"
REQUIRED = "required"
UNIQUE = "unique"
DELETE_FAILED = "delete_failed"
SYNTAX = "syntax"
MISSING_SUBSCRIPTION = "missing_subscription"
UNABLE_TO_PARSE = ... | 42 | 1,283 |
textual | tests/selection_list/test_selection_list_create.py | .py | """Core selection list unit tests, aimed at testing basic list creation.
Note that the vast majority of the API *isn't* tested in here as
`SelectionList` inherits from `OptionList` and so that would be duplicated
effort. Instead these tests aim to just test the things that have been
changed or wrapped in some way.
"""... | 125 | 4,831 |
onnxruntime | onnxruntime/test/testdata/transform/fusion/skip_layer_norm_gen.py | .py | from enum import Enum
import onnx
from onnx import OperatorSetIdProto, TensorProto, helper
class Format(Enum):
Format1 = (1,)
Format2 = (2,)
Format3 = 3
def generate_model(model_format, model_name, multi_output_add=False, add_output_in_graph_output=False, with_cast=False):
nodes = [] # LayerNorm s... | 163 | 6,182 |
sphinx | tests/roots/test-latex-includegraphics/conf.py | .py | exclude_patterns = ['_build']
latex_elements = {
'preamble': r"""
\makeatletter
\def\dividetwolengths#1#2{\the\dimexpr
\numexpr65536*\dimexpr#1\relax/\dimexpr#2\relax sp}%
\newwrite\out
\immediate\openout\out=\jobname-dimensions.txt
\def\toout{\immediate\write\out}
\def\getWfromoptions #1width=#2,#3\relax{\def... | 48 | 1,573 |
wagtail | wagtail/admin/tests/pages/test_content_type_use_view.py | .py | import datetime
from io import BytesIO
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group, Permission
from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils.http import urlencode
from openpyxl import load_workbook
from wagtail.mod... | 469 | 18,648 |
biopython | Scripts/xbbtools/nextorf.py | .py | #!/usr/bin/env python
# Created: Thu Feb 15 14:22:12 2001
# Last changed: Time-stamp: <01/02/18 11:16:42 thomas>
# Copyright 2000 by Thomas Sicheritz-Ponten. 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... | 286 | 9,709 |
probability | tensorflow_probability/python/distributions/bates.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... | 522 | 20,967 |
saleor | saleor/csv/tests/export/products_data/test_prepare_headers.py | .py | from .....attribute.models import Attribute
from .....channel.models import Channel
from .....graphql.csv.enums import ProductFieldEnum
from ....utils.product_headers import (
get_attributes_headers,
get_channels_headers,
get_product_export_fields_and_headers,
get_product_export_fields_and_headers_info,... | 233 | 6,582 |
saleor | saleor/graphql/core/tests/garbage_collection/test_errors.py | .py | import gc
import json
from unittest import mock
import pytest
from django.core.serializers.json import DjangoJSONEncoder
from django.test import override_settings
from graphql.error import GraphQLError
from ....api import backend, schema
from ....tests.utils import get_graphql_content
from ....views import GraphQLVie... | 285 | 11,377 |
bazel | tools/ctexplain/ctexplain.py | .py | # Copyright 2020 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://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 173 | 5,187 |
qutip | qutip/tests/core/data/test_target_mode_matmul.py | .py | import pytest
import numpy as np
from qutip.core.data import target_mode_matmul
from qutip import (
rand_ket, rand_dm,
Qobj, local_matmul, expand_operator,
tensor, sigmax, destroy, gates, sprepost, qeye,
)
@pytest.mark.parametrize("dtype", ["csr", "dense", "dia"])
@pytest.mark.parametrize("trans", [True... | 49 | 1,444 |
coremltools | mlmodel/docs/readme_session.py | .py | import json
import os
from requests.auth import HTTPBasicAuth
import requests
_readme_api_url = "https://dash.readme.io/api/v1/"
class ReadMeSession:
# Passed for every API call
__headers = {"Accept": "application/json", "content-type": "application/json"}
# Map: <version string -> version info>
__v... | 321 | 12,026 |
coremltools | coremltools/test/optimize/torch/layerwise_compression/test_quant.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
import torch
from coremltools.optimize.torch.layerwise_compression._quant import Quant... | 84 | 2,840 |
astropy | astropy/io/fits/tests/test_checksum.py | .py | # Licensed under a 3-clause BSD style license - see PYFITS.rst
import warnings
import numpy as np
import pytest
from astropy.io import fits
from astropy.io.fits.hdu.base import _ValidHDU
from .conftest import FitsTestCase
from .test_table import comparerecords
class BaseChecksumTests(FitsTestCase):
def setup_... | 529 | 23,763 |
gunicorn | scripts/build_settings_doc.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Generate the Markdown settings reference for MkDocs."""
from __future__ import annotations
import inspect
import textwrap
from pathlib import Path
from typing import List
import re
import gunicorn.config as g... | 259 | 8,584 |
beam | sdks/python/apache_beam/runners/direct/test_direct_runner.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... | 57 | 2,141 |
saleor | saleor/graphql/menu/tests/mutations/test_menu_item_create.py | .py | import json
from unittest import mock
import graphene
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....core.utils.json_serializer import CustomJsonEncoder
from .....menu.models import MenuItem
from .....webhook.event_types import WebhookEventAsyncType
from .....webhook.... | 99 | 3,096 |
saleor | saleor/graphql/shop/tests/queries/test_shop_announcements.py | .py | from collections.abc import Callable
from contextlib import contextmanager
from datetime import datetime
import pytest
from .....site.apps import SiteAppConfig
from ....tests.utils import (
assert_no_permission,
get_graphql_content,
get_graphql_content_from_response,
)
from ...enums import AnnouncementImp... | 259 | 7,967 |
ipython | tests/test_imports.py | .py | # encoding: utf-8
from IPython.testing import decorators as dec
def test_import_backgroundjobs():
from IPython.lib import backgroundjobs
def test_import_deepreload():
from IPython.lib import deepreload
def test_import_demo():
from IPython.lib import demo
| 15 | 273 |
conda | conda/plugins/environment_specifiers/environment_yml.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
**EXPERIMENTAL**
Register the conda env spec for environment.yml files.
"""
from .. import hookimpl
from ..types import CondaEnvironmentSpecifier
@hookimpl(tryfirst=True)
def conda_environment_specifiers():
from ...env.specs.yaml_file... | 22 | 604 |
tqdm | tests/tests_contrib.py | .py | """
Tests for `tqdm.contrib`.
"""
import pytest
from tqdm import tqdm
from tqdm.contrib import tenumerate, tmap, tzip
from .tests_tqdm import StringIO, closing, importorskip
def incr(x):
"""Dummy function"""
return x + 1
@pytest.mark.parametrize("tqdm_kwargs", [{}, {"tqdm_class": tqdm}])
def test_enumerat... | 62 | 1,930 |
sphinx | tests/test_extensions/test_ext_todo.py | .py | """Test sphinx.ext.todo extension."""
from __future__ import annotations
import re
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from sphinx.application import Sphinx
from sphinx.ext.todo import todo_node
from sphinx.testing.util import SphinxTestApp
@pytest.mark.sphinx(
'html',... | 129 | 3,985 |
pymc | pymc/dims/model.py | .py | # Copyright 2025 - 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... | 91 | 3,871 |
jupytext | tests/data/notebooks/outputs/ipynb_to_sphinx/jupyterlab-slideshow_1441.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---
"""
> **Note**
>
> `slide` layer with a `top` of `30%`
"""
| 14 | 184 |
textual | docs/examples/styles/scrollbars.py | .py | from textual.app import App
from textual.containers import Horizontal, ScrollableContainer
from textual.widgets import Label
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has... | 28 | 753 |
mlflow | mlflow/store/db_migrations/versions/c3d9e7f1a2b4_add_target_value_to_budget_policies.py | .py | """add target_value to budget_policies
Adds a ``target_value`` column to the ``budget_policies`` table so budget
policies can be scoped to a single target, interpreted per ``target_scope``:
a gateway endpoint ID for ENDPOINT-scoped policies.
Create Date: 2026-07-09 00:00:00.000000
"""
import sqlalchemy as sa
from a... | 32 | 867 |
ipython | IPython/core/profileapp.py | .py | """
An application for managing IPython profiles.
To be invoked as the `ipython profile` subcommand.
Authors:
* Min RK
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2008 The IPython Development Team
#
# Distributed under the terms of the BSD License. The ful... | 315 | 10,603 |
mlflow | tests/types/test_type_hints.py | .py | import datetime
from typing import Any, Dict, List, Optional, Union, get_args
from unittest import mock
import numpy as np
import pandas as pd
import pydantic
import pytest
from scipy.sparse import csc_matrix, csr_matrix
from mlflow.exceptions import MlflowException
from mlflow.models.utils import PyFuncOutput, _enfo... | 510 | 18,021 |
textual | docs/examples/styles/link_style.py | .py | from textual.app import App
from textual.widgets import Label
class LinkStyleApp(App):
CSS_PATH = "link_style.tcss"
def compose(self):
yield Label(
"Visit the [link='https://textualize.io']Textualize[/link] website.",
id="lbl1", # (1)!
)
yield Label(
... | 30 | 747 |
readthedocs.org | readthedocs/storage/utils.py | .py | """Storage utilities."""
from storages.utils import clean_name
from storages.utils import safe_join as safe_join_storage
def safe_join(base, path):
"""
Safely join paths, ensuring that the final path isn't outside the directory.
We use clean_name before using safe_join,
replicating the logic from dj... | 20 | 649 |
openvino | src/bindings/python/src/openvino/frontend/pytorch/utils.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# mypy: ignore-errors
import inspect
import logging
import torch
import numpy as np
from contextlib import contextmanager
from openvino import op, Type as OVType, Shape, Tensor, OVAny
from openvino import opset1... | 413 | 15,497 |
onnxruntime | orttraining/orttraining/python/training/ortmodule/options.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# options.py
import os
from enum import IntFlag
from functools import reduce
from logging import Logger
from packaging import version
from onnxruntime.capi import _pybind_state as C
from onnxruntime.training import ortmodul... | 443 | 20,834 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.