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 |
|---|---|---|---|---|---|
wagtail | wagtail/test/utils/form_data.py | .py | """
The ``assertCanCreate`` method requires page data to be passed in
the same format that the page edit form would submit. For complex
page types, it can be difficult to construct this data structure by hand;
the ``wagtail.test.utils.form_data`` module provides a set of helper
functions to assist with this.
"""
impor... | 204 | 6,525 |
pyro | pyro/__init__.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pyro.poutine as poutine
from pyro.infer.inspect import render_model
from pyro.logger import log
from pyro.poutine import condition, do, markov
from pyro.primitives import (
barrier,
clear_param_store,
determinist... | 67 | 1,308 |
pyomo | pyomo/scripting/plugins/download.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... | 140 | 4,883 |
coremltools | coremltools/converters/mil/mil/var.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 copy
from collections import defaultdict
from typing import Dict, List, Optional, Tuple, Union... | 481 | 15,745 |
lemur | lemur/tests/test_permissions.py | .py | from unittest.mock import MagicMock, patch
from flask_principal import Identity, RoleNeed
from lemur.auth.permissions import AuthorityCreatorPermission, StrictRolePermission
def _config_get(overrides):
"""Returns a config.get side_effect function with the given key overrides."""
def config_get(key, default=... | 112 | 4,183 |
textual | tests/snapshot_tests/snapshot_apps/toggle_style_order.py | .py | from textual.app import App
from textual.widgets import Checkbox, Label
class CheckboxApp(App):
CSS = """
Checkbox > .toggle--label, Label {
color: white;
text-opacity: 50%;
}
"""
def compose(self):
yield Checkbox("[red bold]This is just[/] some text.")
yield Label... | 20 | 414 |
wandb | tests/unit_tests/test_lib/test_printer.py | .py | import pytest
import wandb
from wandb.sdk.lib import printer as p
@pytest.mark.parametrize("level", [1.3, {}, []])
def test_printer_invalid_level_type(level):
printer = p.new_printer()
with pytest.raises(ValueError, match="Unknown status level"):
printer.display("test string", level=level)
@pytest.... | 52 | 1,326 |
python-prompt-toolkit | src/prompt_toolkit/application/application.py | .py | from __future__ import annotations
import asyncio
import contextvars
import os
import re
import signal
import sys
import threading
import time
from asyncio import (
AbstractEventLoop,
Future,
Task,
ensure_future,
get_running_loop,
sleep,
)
from collections.abc import Callable, Coroutine, Genera... | 1,632 | 63,381 |
beam | sdks/python/apache_beam/examples/inference/table_row_inference_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... | 197 | 6,430 |
bazel | scripts/docs/clr_converter.py | .py | # Copyright 2026 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... | 693 | 19,520 |
python-prompt-toolkit | examples/progress-bar/scrolling-task-name.py | .py | #!/usr/bin/env python
"""
A very simple progress bar where the name of the task scrolls, because it's too long.
iterator.
"""
import time
from prompt_toolkit.shortcuts import ProgressBar
def main():
with ProgressBar(
title="Scrolling task name (make sure the window is not too big)."
) as pb:
... | 25 | 533 |
readthedocs.org | readthedocs/notifications/admin.py | .py | """Notifications admin."""
from django.contrib import admin
from readthedocs.notifications.models import Notification
@admin.register(Notification)
class NotificationAdmin(admin.ModelAdmin):
search_fields = ("message_id",)
list_filter = ("state",)
list_display = (
"id",
"message_id",
... | 18 | 376 |
readthedocs.org | readthedocs/api/v3/tests/test_remoterepositories.py | .py | import django_dynamic_fixture as fixture
from allauth.socialaccount.models import SocialAccount
from django.urls import reverse
from readthedocs.oauth.constants import GITHUB
from readthedocs.oauth.models import (
RemoteOrganization,
RemoteOrganizationRelation,
RemoteRepository,
RemoteRepositoryRelatio... | 114 | 3,899 |
bazel | examples/py/runfile.py | .py | """Example for using runfiles with Python."""
import pathlib
from python.runfiles import runfiles
SOME_FILE = pathlib.Path("examples/runfile.txt")
r = runfiles.Create()
root = r.CurrentRepository()
if not root:
root = "_main"
realPathToSomeFile = r.Rlocation(str(root / SOME_FILE))
print("The content of the runfi... | 18 | 396 |
openvino | tools/benchmark_tool/openvino/tools/benchmark/utils/logging.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging
import sys
logging.basicConfig(format="[ %(levelname)s ] %(message)s", level=logging.INFO, stream=sys.stdout)
logger = logging.getLogger('BenchmarkApp')
| 9 | 252 |
tablib | tests/test_tablib.py | .py | #!/usr/bin/env python
"""Tests for Tablib."""
import datetime as dt
import doctest
import json
import pickle
import re
import tempfile
import unittest
from decimal import Decimal
from io import BytesIO, StringIO
from pathlib import Path
from uuid import uuid4
import xlrd
from odf import opendocument, table
from openp... | 2,123 | 75,499 |
clearml | examples/cicd/example_task.py | .py | """This is a dummy ClearML task. This should be replaced by your own experiment code."""
import time
import random
from clearml import Task
from tqdm import tqdm
task = Task.init(
project_name='Github CICD Video',
task_name='dummy_task',
reuse_last_task_id=False
)
random.seed()
for i in tqdm(range(10)):... | 24 | 503 |
readthedocs.org | readthedocs/storage/filesystem.py | .py | import shutil
from functools import cached_property
import structlog
from django.core.exceptions import SuspiciousFileOperation
from django.core.files.storage import FileSystemStorage
from readthedocs.storage.mixins import RTDBaseStorage
from readthedocs.storage.rclone import RCloneLocal
from readthedocs.storage.util... | 75 | 2,725 |
saleor | saleor/core/telemetry/tests/test_utils.py | .py | import json
from unittest.mock import ANY, MagicMock, patch
import pytest
from opentelemetry.attributes import BoundedAttributes
from opentelemetry.trace import INVALID_SPAN_CONTEXT, Link, SpanContext, TraceFlags
from opentelemetry.util.types import AttributeValue
from ..utils import (
Scope,
TelemetryTaskCon... | 368 | 11,530 |
textual | docs/examples/widgets/text_area_extended.py | .py | from textual import events
from textual.app import App, ComposeResult
from textual.widgets import TextArea
class ExtendedTextArea(TextArea):
"""A subclass of TextArea with parenthesis-closing functionality."""
def _on_key(self, event: events.Key) -> None:
if event.character == "(":
self.i... | 24 | 627 |
scikit-optimize | examples/strategy-comparison.py | .py | """
==========================
Comparing surrogate models
==========================
Tim Head, July 2016.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
Bayesian optimization or sequential model-based optimization uses a surrogate
model to model the expensive to evaluate function `func`. There are se... | 148 | 4,686 |
astropy | astropy/io/ascii/tests/test_types.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from io import StringIO
import numpy as np
import pytest
from astropy.io import ascii
def test_types_from_dat():
converters = {"a": [ascii.convert_numpy(float)], "e": [ascii.convert_numpy(str)]}
dat = ascii.read(
["a b c d e", "1 1 c... | 126 | 3,580 |
astropy | astropy/modeling/math_functions.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Define Numpy Ufuncs as Models.
"""
import numpy as np
from astropy.modeling.core import Model
trig_ufuncs = [
"sin",
"cos",
"tan",
"arcsin",
"arccos",
"arctan",
"arctan2",
"hypot",
"sinh",
"cosh",
"tanh",
... | 135 | 2,572 |
onnxruntime | tools/python/wgsl_template/test/test_parser.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Unit tests for the PASS1 parser.
Mixes inline temp-dir tests for tightly scoped behaviors with a
fixture-driven runner that pulls ``parser-*`` and ``loader-*`` cases
from the ``testcases/`` fixtures next to this file.
"""
... | 314 | 11,559 |
probability | tensorflow_probability/python/internal/vectorization_util_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... | 232 | 9,227 |
wagtail | wagtail/admin/widgets/filtered_select.py | .py | from django import forms
from wagtail.admin.staticfiles import versioned_static
class FilteredSelect(forms.Select):
"""
A select box where the options are shown and hidden dynamically in response to another
form field whose HTML `id` is specified in `filter_field`.
The `choices` list accepts entries... | 123 | 4,305 |
wagtail | wagtail/admin/views/pages/bulk_actions/publish.py | .py | from django.utils.translation import gettext_lazy as _
from django.utils.translation import ngettext
from wagtail.admin.views.pages.bulk_actions.page_bulk_action import PageBulkAction
class PublishBulkAction(PageBulkAction):
display_name = _("Publish")
action_type = "publish"
aria_label = _("Publish sele... | 86 | 3,395 |
wagtail | wagtail/snippets/tests/test_api_v3/test_detail.py | .py | from django.test import TestCase, override_settings
from django.urls import reverse
from wagtail.api.v3.tests.base import TestV3Base
from wagtail.test.testapp.models import Advert, FullFeaturedSnippet
from wagtail.test.utils import WagtailTestUtils
class TestV3SnippetDetail(TestV3Base, WagtailTestUtils, TestCase):
... | 137 | 4,901 |
omegaconf | tests/test_merge.py | .py | import copy
import re
import sys
from contextlib import AbstractContextManager
from dataclasses import dataclass, field
from textwrap import dedent
from typing import (
Any,
Dict,
List,
MutableMapping,
MutableSequence,
Optional,
Tuple,
Union,
)
from pytest import mark, param, raises, wa... | 1,872 | 56,538 |
saleor | saleor/graphql/meta/tests/queries/test_meta_filters.py | .py | import pytest
from .....product.models import Product
from ....tests.utils import get_graphql_content
FILTER_BY_META_QUERY = """
query filterProductsByMetadata ($filter:ProductFilterInput, $channel: String){
products(first: 100, channel: $channel, filter: $filter){
edges {
node {
slug
meta... | 166 | 3,845 |
openvino | tests/layer_tests/pytorch_tests/test_slice.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestSlice1D(PytorchLayerTest):
def _prepare_input(self):
return (np.array(range(16), np.float32), np.array(self.param... | 121 | 3,984 |
coveragepy | tests/goldtest.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""A test base class for tests based on gold file comparison."""
from __future__ import annotations
import difflib
import filecmp
import fnmatch
import os
impor... | 197 | 7,115 |
wagtail | wagtail/admin/views/tags.py | .py | from django.contrib.contenttypes.models import ContentType
from django.http import Http404, JsonResponse
from taggit.models import Tag, TagBase
TAGS_AUTOCOMPLETE_LIMIT = 10
def autocomplete(request, app_name=None, model_name=None):
if app_name and model_name:
try:
content_type = ContentType.o... | 33 | 945 |
onnx | onnx/backend/test/case/node/string_split.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 StringSplit(Base):
@staticmethod
def export_basic() -> None:
... | 152 | 4,128 |
beam | sdks/python/apache_beam/ml/transforms/base_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... | 974 | 31,106 |
onnxruntime | onnxruntime/test/python/onnx_backend_test_series.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import collections
import json
import os
import platform
import re
import sys
import unittest
import numpy as np
import onnx
import onnx.backend.test.case.test_case
import onnx.backend.test.runner
import onnx... | 242 | 10,394 |
textual | tests/css/test_parse.py | .py | from __future__ import annotations
import pytest
from textual.color import Color
from textual.css.errors import UnresolvedVariableError
from textual.css.parse import is_id_selector, substitute_references
from textual.css.scalar import Scalar, Unit
from textual.css.stylesheet import Stylesheet, StylesheetParseError
fr... | 1,299 | 38,905 |
pyomo | pyomo/common/formatting.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... | 404 | 15,328 |
pyomo | examples/pyomo/piecewise/points.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... | 25 | 948 |
beam | sdks/python/apache_beam/examples/inference/online_clustering/write_data_to_pubsub_pipeline/pipeline/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... | 68 | 2,516 |
pyomo | pyomo/core/kernel/block.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... | 540 | 20,400 |
onnxruntime | onnxruntime/python/tools/transformers/models/sam2/benchmark_sam2.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
"""
Benchmark performance of SAM2 encoder with ORT or PyTorch. See benc... | 639 | 21,830 |
conda | tests/common/test_terminal.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import pytest
from conda.common.terminal import (
force_color,
no_color,
should_use_color,
term_dumb,
)
@pytest.mark.parametrize(
"term,expected",
[("dumb", True), ("unknown", True),... | 91 | 2,688 |
coremltools | deps/protobuf/python/google/protobuf/descriptor_pool.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... | 1,290 | 46,949 |
pyro | tests/contrib/autoname/test_scoping.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import torch
import pyro
import pyro.distributions.torch as dist
import pyro.poutine as poutine
from pyro.contrib.autoname import name_count, scope
logger = logging.getLogger(__name__)
def test_multi_nested():
... | 187 | 4,628 |
onnxruntime | tools/python/run_workflows_for_branch.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import os
import subprocess
import yaml
def get_repo_root():
result = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True, check=False)
if re... | 150 | 5,437 |
hatch | tests/helpers/templates/wheel/standard_tests.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 50 | 1,296 |
mlflow | mlflow/genai/judges/optimizers/dspy_utils.py | .py | """Utility functions for DSPy-based alignment optimizers."""
import logging
import os
from collections import defaultdict
from contextlib import contextmanager
from typing import TYPE_CHECKING, Any, Callable, Iterator
from mlflow import __version__ as VERSION
from mlflow.entities.assessment_source import AssessmentSo... | 668 | 23,923 |
beam | sdks/python/apache_beam/runners/worker/data_sampler.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... | 367 | 13,247 |
mlflow | tests/tracing/test_databricks.py | .py | from unittest import mock
import pytest
from mlflow.exceptions import MlflowException
from mlflow.tracing.databricks import set_databricks_monitoring_sql_warehouse_id
def test_set_databricks_monitoring_sql_warehouse_id_requires_databricks_tracking_uri():
with mock.patch("mlflow.get_tracking_uri", return_value="... | 52 | 2,167 |
pyomo | examples/doc/samples/case_studies/max_flow/MaxFlow.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... | 58 | 2,059 |
saleor | saleor/account/models.py | .py | from collections.abc import Iterable
from functools import partial
from uuid import uuid4
from django.conf import settings
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
from django.contrib.postgres.indexes import BTreeIndex, GinIndex
from django.contrib.postgres.search import SearchVector... | 482 | 17,590 |
textual | tests/snapshot_tests/snapshot_apps/button_multiline_label.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Button
class ButtonWithMultilineLabelApp(App):
def compose(self) -> ComposeResult:
yield Button("Button\nwith\nmulti-line\nlabel")
if __name__ == "__main__":
app = ButtonWithMultilineLabelApp()
app.run()
| 13 | 299 |
mlflow | tests/sagemaker/mock/test_sagemaker_service_mock.py | .py | import boto3
import pytest
from tests.helper_functions import set_boto_credentials # noqa: F401
from tests.sagemaker.mock import mock_sagemaker
@pytest.fixture
def sagemaker_client():
return boto3.client("sagemaker", region_name="us-west-2")
def create_sagemaker_model(sagemaker_client, model_name):
return... | 682 | 24,929 |
openvino | tests/e2e_tests/common/core.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
def get_list(key_name, delimiter=',', fallback=None):
value = os.environ.get(key_name, fallback)
if value != fallback:
value = value.split(delimiter)
elif not value:
value = []
return value
... | 46 | 1,233 |
onnxruntime | orttraining/orttraining/test/python/orttraining_test_dort_custom_ops.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
import sys
import unittest
import onnxscript
import torch
import torch._dynamo
from functorch.compile import min_cut_rematerialization_partition
from torch._dynamo.backends.common import aot_autograd
from torch.lib... | 207 | 7,836 |
wandb | tests/system_tests/test_plot.py | .py | from __future__ import annotations
import json
from typing import TYPE_CHECKING
import pytest
import wandb
if TYPE_CHECKING:
from wandb.plot.custom_chart import CustomChart
@pytest.fixture
def roc_curve() -> CustomChart:
return wandb.plot.roc_curve(
y_true=[0, 1],
y_probas=[
(0.... | 237 | 6,297 |
saleor | saleor/graphql/giftcard/tests/queries/test_gift_card_search.py | .py | import graphene
import pytest
from saleor.giftcard.models import GiftCard
from saleor.giftcard.search import update_gift_cards_search_vector
from .....account.models import User
from ....tests.utils import get_graphql_content
QUERY_GIFT_CARDS = """
query giftCards(
$sortBy: GiftCardSortingInput,
... | 147 | 4,507 |
readthedocs.org | dockerfiles/settings/proxito.py | .py | from readthedocs.settings.proxito.base import CommunityProxitoSettingsMixin
from .docker_compose import DockerBaseSettings
class ProxitoDevSettings(CommunityProxitoSettingsMixin, DockerBaseSettings):
DONT_HIT_DB = False
# El Proxito does not have django-debug-toolbar installed
@property
def DEBUG_TO... | 24 | 730 |
pdm | tests/test_project.py | .py | from __future__ import annotations
import os
import sys
import venv
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from pbs_installer import PythonVersion
from pytest_httpserver import HTTPServer
from pdm.environments import PythonEnvironment
from pdm.exceptions import PdmException, PdmUsage... | 743 | 28,126 |
pyomo | pyomo/solvers/tests/models/LP_constant_objective2.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... | 54 | 1,886 |
onnxruntime | onnxruntime/test/python/transformers/test_qmoe_nvfp4_cuda.py | .py | # --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
#
# Tes... | 899 | 35,421 |
astropy | astropy/coordinates/distances.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains the classes and utility functions for distance and
cartesian coordinates.
"""
import warnings
import numpy as np
from astropy import units as u
from astropy.utils.exceptions import AstropyWarning
from .angles import Angle
__a... | 267 | 9,209 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_CTCLoss.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from sys import platform
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
# Testing operation CTCLoss
# Documentation: https://www.tensorflow.org/api_docs/python/tf/raw_... | 70 | 2,967 |
voila | voila/tornado/handler.py | .py | #############################################################################
# Copyright (c) 2018, Voilà Contributors #
# Copyright (c) 2018, QuantStack #
# #
# Distri... | 21 | 919 |
django-cms | cms/test_utils/project/app_using_non_feature/apps.py | .py | from django.apps import AppConfig
class NonFeatureCMSConfig(AppConfig):
name = 'cms.test_utils.project.app_using_non_feature'
label = 'app_using_non_feature'
| 7 | 168 |
pyomo | doc/OnlineDocs/src/data/set2.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... | 21 | 734 |
onnxruntime | onnxruntime/core/providers/coreml/mlprogram_test_scripts/depthtospace_test.py | .py | import coremltools as ct
import numpy as np
from coremltools.converters.mil import Builder as mb
target = ct.target.iOS15
# replicate example from https://github.com/onnx/onnx/blob/main/docs/Operators.md#depthtospace
# to prove CoreML mode is DCR
x_shape = (1, 8, 2, 3)
@mb.program(input_specs=[mb.TensorSpec(shape=x... | 52 | 1,508 |
python-prompt-toolkit | examples/prompts/switch-between-vi-emacs.py | .py | #!/usr/bin/env python
"""
Example that displays how to switch between Emacs and Vi input mode.
"""
from prompt_toolkit import prompt
from prompt_toolkit.application.current import get_app
from prompt_toolkit.enums import EditingMode
from prompt_toolkit.key_binding import KeyBindings
def run():
# Create a `KeyBi... | 38 | 1,030 |
mlflow | mlflow/telemetry/utils.py | .py | import logging
import os
from pathlib import Path
from typing import Any
import requests
from packaging.version import Version
from mlflow.environment_variables import (
_MLFLOW_TELEMETRY_LOGGING,
_MLFLOW_TESTING_TELEMETRY,
MLFLOW_DISABLE_TELEMETRY,
)
from mlflow.telemetry.constant import (
CONFIG_STA... | 161 | 6,077 |
textual | docs/examples/styles/text_style_all.py | .py | from textual.app import App
from textual.containers import Grid
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 gone past, I will turn the... | 33 | 1,015 |
saleor | saleor/core/utils/translations.py | .py | from typing import Any
from django.conf import settings
from django.db import models
class TranslationWrapper:
def __init__(self, instance, locale):
self.instance = instance
self.translation = next(
(t for t in instance.translations.all() if t.language_code == locale), None
)
... | 54 | 1,529 |
wagtail | scripts/latest-deps-summary.py | .py | """Build the GitHub Actions job summary for the latest-deps CI workflow.
For each package listed in .github/latest-deps-overrides.txt, look up the
constraint declared in pyproject.toml and the version installed in the current
environment. Packages that resolved to a version outside their cap are shown
prominently — th... | 86 | 2,693 |
saleor | saleor/app/tests/test_app_tasks.py | .py | import logging
from unittest.mock import ANY, Mock
import pytest
from django.utils import timezone
from requests import RequestException
from requests_hardened import HTTPSession
from ...core import JobStatus, private_storage
from ...core.models import EventDelivery, EventDeliveryAttempt, EventPayload
from ...webhook... | 182 | 5,730 |
mlflow | mlflow/store/db_migrations/versions/0a8213491aaa_drop_duplicate_killed_constraint.py | .py | """drop_duplicate_killed_constraint
Create Date: 2020-01-28 15:26:14.757445
This migration drops a duplicate constraint on the `runs.status` column that was left as a byproduct
of an erroneous implementation of the `cfd24bdc0731_update_run_status_constraint_with_killed`
migration in MLflow 1.5. The implementation of ... | 48 | 1,944 |
tomli | src/tomli/__init__.py | .py | # SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2021 Taneli Hukkinen
# Licensed to PSF under a Contributor Agreement.
__all__ = ("loads", "load", "TOMLDecodeError")
__version__ = "2.4.1" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
from ._parser import TOMLDecodeError, load, loads
| 9 | 314 |
probability | tensorflow_probability/python/distributions/laplace_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... | 376 | 14,800 |
pyomo | pyomo/contrib/pyros/tests/test_preprocessor.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... | 3,280 | 129,569 |
openvino | tools/ovc/openvino/tools/ovc/cli_parser.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import argparse
import inspect
import os
import pathlib
import re
from collections import OrderedDict, namedtuple
from typing import Union
import openvino
from openvino import PartialShape, Dimension, Type # pylint: disable=no-name-in-... | 634 | 25,011 |
openvino | src/plugins/intel_cpu/tools/dump_jit_disassm/__main__.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import re
import argparse
import platform
import subprocess
import sys
from colorama import Fore
def addr2line(exefile, addrs, addr2line_path):
proc = subprocess.Popen([addr2line_path, "-C", "-e", exefile, "-f", "-s", "-p"... | 106 | 3,991 |
pyomo | pyomo/contrib/pynumero/linalg/tests/test_linear_solvers.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... | 104 | 4,280 |
saleor | saleor/graphql/core/types/base.py | .py | from graphene.relay.connection import Connection
from graphene.types.enum import Enum
from graphene.types.inputobjecttype import InputObjectType
from graphene.types.interface import Interface
from graphene.types.objecttype import ObjectType
class BaseObjectType(ObjectType):
@classmethod
def __init_subclass_wi... | 72 | 2,067 |
pynacl | src/libsodium/regen-msvc/regen-msvc.py | .py | #! /usr/bin/env python3
import glob
import os
import uuid
dirs = set()
tlv1 = ""
for file in glob.iglob("src/libsodium/**/*.c", recursive=True):
file = file.replace("/", "\\")
tlv1 = tlv1 + ' <ClCompile Include="..\\..\\{}" />\r\n'.format(file)
tlv2 = ""
for file in glob.iglob("src/libsodium/**/*.h", rec... | 254 | 7,308 |
saleor | saleor/tests/e2e/promotions/test_sale_updated_by_promotion_can_not_be_handled_by_sales.py | .py | import pytest
from ..product.utils.preparing_product import prepare_product
from ..promotions.utils import promotions_query, update_promotion_rule
from ..sales.utils import (
create_sale,
create_sale_channel_listing,
raw_create_sale_channel_listing,
sale_catalogues_add,
)
from ..shop.utils.preparing_sh... | 125 | 3,541 |
beam | sdks/python/apache_beam/io/range_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... | 520 | 19,691 |
saleor | saleor/webhook/validators.py | .py | from django.core.exceptions import ValidationError
HEADERS_NUMBER_LIMIT = 5
HEADERS_LENGTH_LIMIT = 998
KEY_CHARS_ALLOWED = (
"!\"#$%&'()*+,-./0123456789;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
)
VALUE_CHARS_ALLOWED = (
"!\"#$%&'()*+,-./0123456789;:<=>?@ABCDEFGHIJKLMNOPQRSTU... | 52 | 1,827 |
beam | sdks/python/apache_beam/io/filebasedsink.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... | 577 | 21,021 |
httpie | tests/test_compress.py | .py | """
We test against httpbin which doesn't return the request data in a
consistent way:
1. Non-form requests: the `data` field contains base64 encoded version of
our zlib-encoded request data.
2. Form requests: `form` contains a messed up version of the data.
"""
import base64
import zlib
from .fixtures import FILE_... | 141 | 3,874 |
probability | spinoffs/inference_gym/inference_gym/targets/model_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... | 99 | 3,417 |
jupytext | tests/data/notebooks/outputs/ipynb_to_sphinx/Line_breaks_in_LateX_305.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
"""
This cell uses no particular cell marker
$$
\begin{align}
\dot{x} & = \sigma(y-x)\\
\dot{y} & = \rho x - y - xz \\
\dot{z} & = -\beta z + xy
\end{align}
$$
"""
##########################################... | 43 | 806 |
textual | docs/examples/widgets/label.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Label
class LabelApp(App):
def compose(self) -> ComposeResult:
yield Label("Hello, world!")
if __name__ == "__main__":
app = LabelApp()
app.run()
| 13 | 241 |
saleor | saleor/plugins/openid_connect/tests/conftest.py | .py | import jwt
import pytest
from ...manager import get_plugins_manager
from ..plugin import OpenIDConnectPlugin
@pytest.fixture
def plugin_configuration():
def fun(
client_id=None,
client_secret=None,
enable_refresh_token=True,
oauth_authorization_url=None,
oauth_token_url=No... | 181 | 6,768 |
textual | tests/test_markdown.py | .py | """Unit tests for the Markdown widget."""
from __future__ import annotations
from pathlib import Path
from typing import Iterator
import pytest
from markdown_it.token import Token
from rich.text import Span
import textual.widgets._markdown as MD
from textual import on
from textual.app import App, ComposeResult
from... | 220 | 7,055 |
loguru | loguru/_get_frame.py | .py | import sys
from sys import exc_info
def get_frame_fallback(n):
try:
raise Exception
except Exception:
frame = exc_info()[2].tb_frame.f_back
for _ in range(n):
frame = frame.f_back
return frame
def load_get_frame_function():
if hasattr(sys, "_getframe"):
... | 24 | 458 |
mlflow | mlflow/data/pandas_dataset.py | .py | import json
import logging
from functools import cached_property
from typing import Any
import pandas as pd
from mlflow.data.dataset import Dataset
from mlflow.data.dataset_source import DatasetSource
from mlflow.data.digest_utils import compute_pandas_digest
from mlflow.data.evaluation_dataset import EvaluationDatas... | 230 | 8,174 |
confluent-kafka-python | tests/integration/schema_registry/_async/test_dlq.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2026 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 requi... | 105 | 3,770 |
pyomo | pyomo/common/collections/orderedset.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... | 86 | 2,543 |
textual | docs/examples/widgets/data_table_cursors.py | .py | from itertools import cycle
from textual.app import App, ComposeResult
from textual.widgets import DataTable
ROWS = [
("lane", "swimmer", "country", "time"),
(4, "Joseph Schooling", "Singapore", 50.39),
(2, "Michael Phelps", "United States", 51.14),
(5, "Chad le Clos", "South Africa", 51.14),
(6, ... | 41 | 1,110 |
probability | tensorflow_probability/python/distributions/power_spherical_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... | 651 | 26,120 |
probability | tensorflow_probability/python/experimental/mcmc/internal/__init__.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 15 | 678 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.