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/test_flavors.py | .py | import ast
import os
import mlflow
def read_file(path):
with open(path) as f:
return f.read()
def is_model_flavor(src):
for node in ast.iter_child_nodes(ast.parse(src)):
if (
isinstance(node, ast.Assign)
and isinstance(node.targets[0], ast.Name)
and node.... | 41 | 988 |
flit | tests/test_validate.py | .py | import errno
import pytest
import responses
from flit import validate as fv
def test_validate_entrypoints():
assert fv.validate_entrypoints(
{'console_scripts': {'flit': 'flit:main'}}) == []
assert fv.validate_entrypoints(
{'some.group': {'flit': 'flit.buildapi'}}) == []
res = fv.validate... | 244 | 7,482 |
readthedocs.org | readthedocs/projects/views/base.py | .py | """Mix-in classes for project views."""
from functools import lru_cache
import structlog
from django.conf import settings
from django.contrib.messages.views import SuccessMessageMixin
from django.shortcuts import get_object_or_404
from django.shortcuts import render
from readthedocs.projects.models import Project
... | 126 | 4,083 |
wandb | tests/unit_tests/test_wandb_summary.py | .py | """summary test."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from typing_extensions import Self
from wandb.sdk import Summary
if TYPE_CHECKING:
from wandb.sdk.interface.summary_record import SummaryRecord
class MockCallback:
current_dict: dict
summary_record: SummaryRec... | 127 | 3,143 |
mlflow | tests/assistant/test_types.py | .py | import json
import pytest
from mlflow.assistant.types import Event, EventType
@pytest.mark.parametrize(
("exc", "expected"),
[
(NotImplementedError(), "NotImplementedError()"),
(ValueError(), "ValueError()"),
(RuntimeError("boom"), "boom"),
(ValueError("bad value"), "bad valu... | 61 | 2,012 |
onnx | onnx/backend/test/case/node/softmax.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
def softmax(x: np.ndarray, axis: int = -1) -> np.ndarray:
x_max = np.max... | 92 | 2,686 |
saleor | saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_draft_order_created.py | .py | import json
from unittest.mock import patch
import graphene
from django.test import override_settings
from ......core.models import EventDelivery
from ......graphql.webhook.subscription_query import SubscriptionQuery
from ......webhook.event_types import WebhookEventAsyncType
from .....manager import get_plugins_mana... | 236 | 7,072 |
pyomo | pyomo/core/plugins/__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... | 13 | 605 |
hydra | examples/instantiate/partial/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Any
from omegaconf import DictConfig
import hydra
from hydra.utils import instantiate, target_whitelist
class Optimizer:
algo: str
lr: float
def __init__(self, algo: str, lr: float) -> None:
self.algo = al... | 40 | 871 |
pyomo | pyomo/contrib/pynumero/sparse/__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 | 798 |
sphinx | tests/roots/test-ext-autosummary/autosummary_dummy_module.py | .py | from os import path
from typing import Union
from autosummary_class_module import Class
__all__ = [
'CONSTANT1',
'Exc',
'Foo',
'_Baz',
'bar',
'qux',
'path',
]
#: module variable
CONSTANT1 = None
CONSTANT2 = None
class Foo:
#: class variable
CONSTANT3 = None
CONSTANT4 = None
... | 69 | 961 |
wagtail | wagtail/blocks/__init__.py | .py | # Import block types defined in submodules into the wagtail.blocks namespace
from .base import * # NOQA: F403
from .field_block import * # NOQA: F403
from .list_block import * # NOQA: F403
from .static_block import * # NOQA: F403
from .stream_block import * # NOQA: F403
from .struct_block import * # NOQA: F403
| 8 | 318 |
astropy | astropy/wcs/wcsapi/high_level_api.py | .py | import abc
import numbers
from collections import OrderedDict, defaultdict
from collections.abc import Callable
from typing import Any, Protocol
import numpy as np
from numpy.typing import ArrayLike
from astropy.utils.masked import Masked, MaskedNDArray, combine_masks
from .utils import deserialize_class
__all__ = ... | 437 | 15,690 |
coremltools | coremltools/converters/mil/mil/passes/tests/test_lower_complex_dialect_ops.py | .py | # Copyright (c) 2022, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import copy
import numpy as np
import pytest
from coremltools import ComputeUnit
from coremltools.c... | 141 | 5,494 |
saleor | saleor/shipping/utils.py | .py | import logging
from typing import TYPE_CHECKING, Optional
from django_countries import countries
from prices import Money
from ..checkout.models import Checkout, CheckoutDelivery
from ..core.db.connection import allow_writer
from ..shipping.interface import ExcludedShippingMethod
from ..tax.models import TaxClass
fro... | 142 | 5,542 |
mlflow | mlflow/llama_index/__init__.py | .py | from mlflow.llama_index.autolog import autolog
from mlflow.llama_index.constant import FLAVOR_NAME
from mlflow.version import IS_TRACING_SDK_ONLY
__all__ = ["autolog", "FLAVOR_NAME"]
# Import model logging APIs only if mlflow skinny or full package is installed,
# i.e., skip if only mlflow-tracing package is installe... | 23 | 594 |
ipython | IPython/utils/wildcard.py | .py | """Support for wildcard pattern matching in object inspection.
Authors
-------
- Jörgen Stenarson <jorgen.stenarson@bostream.nu>
- Thomas Kluyver
"""
#*****************************************************************************
# Copyright (C) 2005 Jörgen Stenarson <jorgen.stenarson@bostream.nu>
#
# Distribut... | 111 | 4,591 |
readthedocs.org | readthedocs/search/api/v3/executor.py | .py | from functools import cached_property
from itertools import islice
from readthedocs.builds.constants import INTERNAL
from readthedocs.projects.models import Project
from readthedocs.search.api.v3.queryparser import SearchQueryParser
from readthedocs.search.faceted_search import PageSearch
class SearchExecutor:
"... | 241 | 8,988 |
onnx | onnx/reference/ops/op_div.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.ops._op import OpRunBinaryNumpy
class Div(OpRunBinaryNumpy):
def __init__(self, onnx_node, run_params):
def func(x, y):
if issubclass(x.d... | 31 | 1,034 |
onnx | onnx/gen_proto.py | .py | #!/usr/bin/env python
# Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import argparse
import glob
import os
import re
import subprocess
from textwrap import dedent
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import I... | 273 | 8,718 |
pyro | tests/contrib/tracking/test_dynamic_models.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from pyro.contrib.tracking.dynamic_models import (
NcpContinuous,
NcpDiscrete,
NcvContinuous,
NcvDiscrete,
)
from tests.common import assert_equal, assert_not_equal
def assert_cov_validity(cov, eigen... | 189 | 5,020 |
wandb | wandb/sdk/artifacts/artifact_saver.py | .py | """Artifact saver."""
from __future__ import annotations
import concurrent.futures
import json
import os
import tempfile
from collections.abc import Awaitable, Sequence
from typing import TYPE_CHECKING
import wandb
import wandb.filesync.step_prepare
from wandb import util
from wandb.sdk.artifacts.artifact_manifest i... | 276 | 9,623 |
cvxpy | cvxpy/tests/test_bounds.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... | 1,232 | 47,471 |
beam | sdks/python/apache_beam/io/gcp/bigquery_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... | 2,917 | 108,913 |
pyomo | pyomo/contrib/viewer/tests/test_report.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... | 210 | 7,340 |
sphinx | sphinx/_cli/__init__.py | .py | """Base 'sphinx' command.
Subcommands are loaded lazily from the ``_COMMANDS`` table for performance.
All subcommand modules must define three attributes:
- ``parser_description``, a description of the subcommand. The first paragraph
is taken as the short description for the command.
- ``set_up_parser``, a callabl... | 312 | 9,893 |
beam | sdks/python/apache_beam/examples/complete/game/user_score.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... | 191 | 6,069 |
openvino | tools/ovc/openvino/tools/ovc/environment_setup_utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
# do not print INFO and WARNING messages from TensorFlow
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
def get_imported_module_version(imported_module):
"""
Get imported module version
:return: version(str)... | 51 | 1,656 |
conda | conda/env/specs/__init__.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from typing import TYPE_CHECKING
from ...base.context import context
from ...exceptions import (
EnvironmentSpecPluginNotDetected,
SpecNotFound,
)
if TYPE_CHECKING:
from .requirements import Requ... | 36 | 960 |
mkdocs | mkdocs/tests/cli_tests.py | .py | #!/usr/bin/env python
import io
import logging
import unittest
from unittest import mock
from click.testing import CliRunner
from mkdocs import __main__ as cli
class CLITests(unittest.TestCase):
def setUp(self):
self.runner = CliRunner()
@mock.patch('mkdocs.commands.serve.serve', autospec=True)
... | 647 | 25,528 |
mlflow | mlflow/genai/evaluation/harness.py | .py | """Entry point to the evaluation harness"""
from __future__ import annotations
import logging
import queue
import threading
import time
import traceback
import uuid
from concurrent.futures import FIRST_COMPLETED, Future, ThreadPoolExecutor, as_completed, wait
from typing import Any, Callable
import pandas as pd
try... | 1,120 | 41,605 |
returns | tests/test_contrib/test_hypothesis/test_laws/test_custom_type_with_init.py | .py | from collections.abc import Callable
from typing import TypeVar
from returns.contrib.hypothesis.laws import check_all_laws
from returns.interfaces import equable, mappable
from returns.primitives.container import BaseContainer, container_equality
from returns.primitives.hkt import SupportsKind1
_ValueType = TypeVar('... | 34 | 888 |
beam | sdks/python/apache_beam/runners/interactive/testing/integration/tests/screen_diff_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... | 60 | 1,890 |
mkdocs | mkdocs/structure/files.py | .py | from __future__ import annotations
import enum
import fnmatch
import logging
import os
import posixpath
import shutil
import warnings
from functools import cached_property
from pathlib import PurePath, PurePosixPath
from typing import TYPE_CHECKING, Callable, Iterable, Iterator, Mapping, Sequence, overload
from urllib... | 627 | 23,569 |
textual | tests/snapshot_tests/snapshot_apps/programmatic_scrollbar_gutter_change.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Label
class ProgrammaticScrollbarGutterChange(App[None]):
CSS = """
Grid { grid-size: 2 2; scrollbar-size: 5 5; }
Label { width: 100%; height: 100%; background: red; }
"""
def compose(self):
yield ... | 28 | 659 |
textual | docs/examples/widgets/radio_set.py | .py | from rich.text import Text
from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import RadioButton, RadioSet
class RadioChoicesApp(App[None]):
CSS_PATH = "radio_set.tcss"
def compose(self) -> ComposeResult:
with Horizontal():
# A Radio... | 47 | 1,578 |
astropy | astropy/io/misc/connect.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This file connects any readers/writers defined in io.misc to the
# astropy.table.Table class
from astropy.io.misc.ecsv import register_ecsv_table
from astropy.io.misc.pyarrow.csv import register_pyarrow_csv_table
from . import hdf5, parquet
hdf5.regis... | 15 | 444 |
scikit-bio | skbio/stats/ordination/_correspondence_analysis.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.
# --------------------------------------------... | 204 | 7,719 |
metrics | tests/unittests/wrappers/test_multioutput.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... | 156 | 5,789 |
jupytext | src/jupytext/sync_pairs.py | .py | """
This file is automatically generated by
tests/functional/contents_manager/test_async_and_sync_contents_manager_are_in_sync.py
Do not edit this file manually.
"""
import jupytext
from .combine import combine_inputs_with_outputs
from .compare import compare
from .formats import check_file_version, long_form_multipl... | 81 | 2,707 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_flip.py | .py | #
# flip paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle
import sys
def flip(name: str, x, axis, is_dynamic=False):
paddle.enable_static()
with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()):
if is_dynamic:
data = p... | 74 | 1,984 |
conda | tests/cli/conftest.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import logging
import pytest
@pytest.fixture(autouse=True)
def urllib3_logger_error(caplog):
"""Increase log level to error to prevent retries from polluting stderr."""
caplog.set_level(logging.ERROR, logger="urllib3.connectionpool")
| 12 | 320 |
biopython | Bio/motifs/matrix.py | .py | # Copyright 2013 by Michiel de Hoon. All rights reserved.
#
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been included as part of this
# package.
"""Support for various... | 624 | 24,049 |
saleor | saleor/graphql/product/mutations/category/category_update.py | .py | import graphene
from django.db.models import Exists, OuterRef
from .....discount.utils.promotion import mark_active_catalogue_promotion_rules_as_dirty
from .....permission.enums import ProductPermissions
from .....product import models
from .....thumbnail import models as thumbnail_models
from ....core import ResolveI... | 53 | 2,194 |
astropy | astropy/modeling/tests/test_functional_models.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# pylint: disable=invalid-name
from contextlib import nullcontext
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_array_equal, assert_array_less
from astropy import units as u
from astropy.coordinates import Angle
from... | 627 | 20,032 |
beam | sdks/python/apache_beam/transforms/userstate.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... | 454 | 15,955 |
saleor | saleor/graphql/menu/tests/queries/test_menus_filtering.py | .py | import pytest
from .....menu.models import Menu, MenuItem
from ....tests.utils import get_graphql_content
QUERY_MENU_WITH_FILTER = """
query ($filter: MenuFilterInput) {
menus(first: 5, filter:$filter) {
totalCount
edges {
node {
id
... | 118 | 3,587 |
pyomo | pyomo/repn/tests/nl_diff.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... | 122 | 4,638 |
mlflow | tests/langchain/sample_code/openai_agent.py | .py | import itertools
from langchain.agents import create_agent
from langchain.tools import tool
from langchain_core.messages import AIMessageChunk, ToolCall
from langchain_core.outputs import ChatGeneration, ChatGenerationChunk, ChatResult
from langchain_openai import ChatOpenAI
import mlflow
class FakeOpenAI(ChatOpenA... | 52 | 1,787 |
pyomo | pyomo/neos/__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... | 43 | 1,763 |
openvino | tests/layer_tests/onnx_tests/test_trigonometry.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
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
fro... | 321 | 12,797 |
saleor | saleor/graphql/attribute/tests/deprecated/test_attributes.py | .py | import warnings
import graphene
from django.db.models import Q
from .....attribute.models import Attribute
from .....channel.models import Channel
from .....channel.utils import DEPRECATION_WARNING_MESSAGE
from .....product import ProductTypeKind
from .....product.models import Category, Product, ProductType
from ...... | 72 | 2,381 |
probability | tensorflow_probability/python/internal/backend/numpy/gen/linear_operator_low_rank_update.py | .py | # Copyright 2020 The TensorFlow Probability Authors. All Rights Reserved.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# THIS FILE IS AUTO-GENERATED BY `gen_linear_operators.py`.
# DO NOT MODIFY DIRECTLY.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@... | 548 | 22,144 |
sphinx | sphinx/domains/c/_parser.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from sphinx.domains.c._ast import (
ASTAlignofExpr,
ASTArray,
ASTAssignmentExpr,
ASTBinOpExpr,
ASTBooleanLiteral,
ASTBracedInitList,
ASTCastExpr,
ASTCharLiteral,
ASTDeclaration,
ASTDeclaratorNameBitField,
A... | 1,114 | 41,734 |
mlflow | tests/pyfunc/test_chat_model_validation.py | .py | import pytest
from mlflow.types.llm import (
ChatChoice,
ChatCompletionRequest,
ChatCompletionResponse,
ChatMessage,
TokenUsageStats,
)
MOCK_RESPONSE = {
"id": "123",
"object": "chat.completion",
"created": 1677652288,
"model": "MyChatModel",
"choices": [
{
... | 274 | 8,477 |
saleor | saleor/graphql/shop/enums.py | .py | from typing import Final
import graphene
from ...site import (
AccountConfirmMode,
AnnouncementImportance,
GiftCardSettingsExpiryType,
PasswordLoginMode,
)
from ..core.doc_category import (
DOC_CATEGORY_AUTH,
DOC_CATEGORY_GIFT_CARDS,
DOC_CATEGORY_SHOP,
)
from ..core.enums import to_enum
G... | 41 | 1,125 |
returns | returns/_internal/__init__.py | .py | """
This package contains code that was "generated" via metaprogramming.
This happens, because Python is not flexible enough to do most tasks
common in typed functional programming.
Policy:
1. We store implementations in regular ``.py`` files.
2. We store generated type annotations in ``.pyi`` files.
3. We re-export... | 15 | 448 |
probability | tensorflow_probability/python/bijectors/softplus.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... | 201 | 7,205 |
jupyterlab | packages/services/examples/browser-require/main.py | .py | """
Copyright (c) Jupyter Development Team.
Distributed under the terms of the Modified BSD License.
"""
import os
import os.path as osp
from jupyter_server.base.handlers import JupyterHandler
from jupyter_server.extension.handler import ExtensionHandlerJinjaMixin, ExtensionHandlerMixin
from jupyter_server.utils impo... | 67 | 2,321 |
mlflow | mlflow/entities/model_registry/model_version_deployment_job_state.py | .py | from mlflow.entities.model_registry._model_registry_entity import _ModelRegistryEntity
from mlflow.entities.model_registry.model_version_deployment_job_run_state import (
ModelVersionDeploymentJobRunState,
)
from mlflow.entities.model_registry.registered_model_deployment_job_state import (
RegisteredModelDeploy... | 71 | 2,364 |
pyomo | pyomo/contrib/pyros/pyros_algorithm_methods.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... | 377 | 14,613 |
probability | tensorflow_probability/python/bijectors/fill_scale_tril.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... | 139 | 5,406 |
openvino | docs/articles_en/assets/snippets/ov_layout.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
import openvino as ov
import openvino.opset12 as ops
# ! [ov:layout:simple]
from openvino import Layout
layout = Layout('NCHW')
# ! [ov:layout:simple]
# ! [ov:layout:complex]
# Each dimension has name separated by comma
# Layout is wra... | 81 | 2,271 |
mlflow | tests/tracking/default_experiment/test_databricks_notebook_experiment_provider.py | .py | from unittest import mock
import pytest
from mlflow import MlflowClient
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
from mlflow.tracking.default_experiment.databricks_notebook_experiment_provider import (
DatabricksNotebookExperimentProvider,
)
fr... | 84 | 3,181 |
openvino | tools/ovc/openvino/tools/ovc/moc_frontend/offline_transformations.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino.tools.ovc.error import Error
def get_new_placeholder_name(node_id: str, is_out_port: bool = False, port: int = 0):
"""
Forms a name of new placeholder created by cutting a graph
:param node_id: a node name tha... | 106 | 4,274 |
gunicorn | tests/docker/http2/__init__.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""HTTP/2 Docker integration tests package."""
| 6 | 153 |
onnxruntime | onnxruntime/test/testdata/transform/model_parallel/self_attention_megatron_basic_test.py | .py | import numpy as np
import onnx
from onnx import OperatorSetIdProto, TensorProto, helper, numpy_helper
hidden_size = 4
attention_head = 2
hidden_per_attention = 2
# Self-attention.
# Handle self-attention.
# MatMul->Add->Split->Reshape->Transpose->MatMul->Div->Mul->Sub->Softmax->Dropout->MatMul->Transpose->Reshape->Ma... | 152 | 6,087 |
pyomo | pyomo/contrib/solver/solvers/scip/base.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... | 324 | 9,673 |
clearml | clearml/__init__.py | .py | """ ClearML open SDK """
from .version import __version__
from .task import Task
from .model import InputModel, OutputModel, Model
from .logger import Logger
from .storage import StorageManager
from .errors import UsageError
from .datasets import Dataset
from .hyperdatasets import (
HyperDataset,
DataView,
... | 53 | 1,100 |
funcy | funcy/funcmakers.py | .py | from collections.abc import Mapping, Set
from operator import itemgetter
from .strings import re_tester, re_finder, _re_type
__all__ = ('make_func', 'make_pred')
def make_func(f, test=False):
if callable(f):
return f
elif f is None:
# pass None to builtin as predicate or mapping function fo... | 29 | 809 |
saleor | saleor/graphql/meta/tests/queries/test_attribute.py | .py | import graphene
from ....tests.utils import assert_no_permission, get_graphql_content
from .utils import PRIVATE_KEY, PRIVATE_VALUE, PUBLIC_KEY, PUBLIC_VALUE
QUERY_ATTRIBUTE_PUBLIC_META = """
query attributeMeta($id: ID!){
attribute(id: $id){
metadata{
key
value... | 176 | 5,514 |
beam | learning/katas/python/Core Transforms/Tee/Tee/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... | 48 | 1,717 |
probability | tensorflow_probability/python/experimental/marginalize/marginalizable.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... | 301 | 11,849 |
hypercorn | tests/asyncio/test_lifespan.py | .py | from __future__ import annotations
import asyncio
from collections.abc import Callable
from time import sleep
import pytest
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.asyncio.lifespan import Lifespan
from hypercorn.config import Config
from hypercorn.typing import ASGIReceiveCallable, ASGISendCall... | 92 | 3,065 |
jupytext | tests/data/notebooks/outputs/ipynb_to_percent/jupyterlab-slideshow_1441.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---
# %% [markdown] @deathbeds/jupyterlab-fonts={"styles": {"": {"body[data-jp-deck-mode='presenting'] &": {"right": "0", "top": "30%", "width": "25%", "z-index": 1}}}} jupyterlab-slideshow={"layer": ... | 13 | 387 |
wandb | tests/system_tests/test_functional/xgboost/test_xgboost.py | .py | import pathlib
def test_classification(wandb_backend_spy, execute_script):
script_path = pathlib.Path(__file__).parent / "classification.py"
execute_script(script_path)
with wandb_backend_spy.freeze() as snapshot:
run_ids = snapshot.run_ids()
assert len(run_ids) == 1
run_id = run_... | 62 | 2,597 |
sqlmap | tamper/dunion.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import os
import re
from lib.core.common import singleTimeWarnMessage
from lib.core.enums import DBMS
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.HIGHEST
def de... | 35 | 905 |
mlflow | mlflow/entities/trace_data.py | .py | from collections import Counter
from dataclasses import dataclass, field
from typing import Any
from mlflow.entities import Span
from mlflow.tracing.constant import SpanAttributeKey
from mlflow.utils.annotations import deprecated
@dataclass
class TraceData:
"""A container object that holds the spans data of a tr... | 86 | 3,531 |
pyomo | pyomo/contrib/cp/transform/logical_to_disjunctive_walker.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... | 276 | 10,629 |
wagtail | wagtail/locales/api/v3/router.py | .py | from django.core.exceptions import ValidationError
from django.http import HttpRequest
from django.shortcuts import get_object_or_404
from ninja import Router, Schema, Status
from ninja.pagination import paginate
from pydantic import PositiveInt
from wagtail.actions import action_registry
from wagtail.api.v3.auth impo... | 131 | 3,954 |
openvino | src/bindings/python/tests/test_runtime/test_compiled_model.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import pytest
import numpy as np
from tests.utils.helpers import (
get_relu_model,
generate_image,
tensor_from_bytes,
generate_model_and_image,
generate_concat_compiled_model,
ge... | 386 | 12,796 |
saleor | saleor/order/tests/webhooks/subscriptions/test_order_calculate_taxes.py | .py | import json
from decimal import Decimal
from unittest.mock import ANY, Mock, patch
import pytest
from freezegun import freeze_time
from prices import Money, TaxedMoney
from promise import Promise
from .....core.prices import quantize_price
from .....discount import (
DiscountType,
DiscountValueType,
Rewar... | 1,346 | 49,439 |
textual | src/textual/_on.py | .py | from __future__ import annotations
from typing import Callable, TypeVar
from textual.css.model import SelectorSet
from textual.css.parse import parse_selectors
from textual.css.tokenizer import TokenError
from textual.message import Message
DecoratedType = TypeVar("DecoratedType")
class OnDecoratorError(Exception)... | 94 | 3,336 |
textual | tests/test_border.py | .py | import pytest
from rich.segment import Segment
from rich.style import Style as RichStyle
from rich.text import Text
from textual._border import render_border_label, render_row
from textual.content import Content
from textual.style import Style
from textual.widget import Widget
def test_border_render_row():
style... | 272 | 7,651 |
sqlmap | plugins/dbms/hsqldb/connector.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
try:
import jaydebeapi
import jpype
except:
pass
import logging
from lib.core.common import checkFile
from lib.core.common import getSafeExString
from lib.core.commo... | 91 | 2,918 |
ipython | IPython/terminal/debugger.py | .py | import asyncio
import os
import sys
from IPython.core.debugger import Pdb
from IPython.core.completer import IPCompleter
from .ptutils import IPythonPTCompleter
from .shortcuts import create_ipython_shortcuts
from pathlib import Path
from pygments.token import Token
from prompt_toolkit.application import create_app_s... | 182 | 6,910 |
ipython | IPython/core/payload.py | .py | """Payload system for IPython.
Authors:
* Fernando Perez
* Brian Granger
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, di... | 54 | 1,739 |
django-cms | cms/signals/apphook.py | .py | import logging
import sys
from django.core.management import color_style
from django.core.signals import request_finished
from django.urls import clear_url_caches
from cms.utils.apphook_reload import mark_urlconf_as_changed
logger = logging.getLogger(__name__)
DISPATCH_UID = 'cms-restart'
def trigger_server_resta... | 50 | 1,389 |
wagtail | wagtail/admin/tests/test_dashboard.py | .py | from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from django.urls import reverse
from django.utils import timezone
from freezegun import freeze_time
from wagtail.admin.view... | 434 | 16,487 |
openvino | tools/commit_slider/tests/commit_slider_test.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import sys
import os
from unittest import TestCase
from tempfile import TemporaryDirectory
from tests import skip_commit_slider_devtest
sys.path.append('./')
from test_util import getExpectedCommit, \
getBordersByTestData, getActual... | 522 | 18,564 |
pyomo | pyomo/core/base/param.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,088 | 41,547 |
saleor | saleor/tax/webhooks/shared.py | .py | import logging
from typing import TYPE_CHECKING, Any, Union
from django.conf import settings
from promise import Promise
from ...app.models import App
from ...core.taxes import TaxData, TaxDataError
from ...webhook.transport.synchronous.transport import (
trigger_webhook_sync_promise,
)
from ...webhook.utils impo... | 140 | 4,301 |
wagtail | wagtail/admin/messages.py | .py | from django.contrib import messages
from django.core.exceptions import NON_FIELD_ERRORS
from django.template.loader import render_to_string
from django.utils.html import format_html, format_html_join
def render(message, buttons, detail=""):
return render_to_string(
"wagtailadmin/shared/messages.html",
... | 69 | 2,357 |
readthedocs.org | readthedocs/builds/signals.py | .py | """Build signals."""
import django.dispatch
# Useful to know when to purge the footer
version_changed = django.dispatch.Signal()
| 8 | 132 |
openvino | docs/articles_en/assets/snippets/export_compiled_model.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
from utils import get_path_to_model
device = "CPU"
model_path = get_path_to_model()
properties = {}
#! [export_compiled_model]
import openvino as ov
core = ov.Core()
compiled_model = core.compile_model(model_path, device, properti... | 20 | 397 |
sqlmap | plugins/dbms/mssqlserver/takeover.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import binascii
from lib.core.common import Backend
from lib.core.compat import xrange
from lib.core.convert import getBytes
from lib.core.data import logger
from lib.core.except... | 147 | 6,497 |
black | tests/data/cases/preview_prefer_rhs_split_indexed_assignment.py | .py | # flags: --preview
# Indexed assignment with a short RHS expression should not get unnecessary parens.
dictionary_of_arrays["long_key_name_for_the_example"][
very_long_index_name, index_zero
] = 10 - 5
# Unformatted input: the unnecessary parens should be removed.
dictionary_of_arrays["long_key_name_for_the_examp... | 95 | 3,679 |
pyomo | doc/OnlineDocs/src/data/set3.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... | 29 | 1,040 |
beam | sdks/python/apache_beam/io/__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... | 44 | 1,729 |
saleor | saleor/graphql/product/mutations/product_variant/variant_media_assign.py | .py | import graphene
from django.core.exceptions import ValidationError
from .....core.tracing import traced_atomic_transaction
from .....permission.enums import ProductPermissions
from .....product import models
from .....product.error_codes import ProductErrorCode
from ....core import ResolveInfo
from ....core.context im... | 75 | 3,185 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.