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 |
|---|---|---|---|---|---|
onnxruntime | onnxruntime/test/python/transformers/benchmark_mha.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
"""
Benchmark performance of MultiHeadAttention with ORT or PyTorch.
I... | 1,421 | 51,866 |
pyomo | examples/pyomo/p-median/solver2.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... | 71 | 2,533 |
coveragepy | coverage/plugin_support.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
"""Support for plugins."""
from __future__ import annotations
import os
import os.path
import sys
from collections.abc import Callable, Iterable, Iterator
from ... | 296 | 10,369 |
beam | sdks/python/apache_beam/runners/dataflow/__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... | 26 | 1,135 |
beam | sdks/python/apache_beam/runners/render_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... | 136 | 4,843 |
sqlmap | tests/test_reflection.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Adversarial coverage for reflection removal.
Two independent mechanisms exist and the non-SQL engines rely on BOTH:
lib.core.common.removeReflectiveValues - the scan-wide heurist... | 193 | 8,598 |
wandb | tests/unit_tests/test_eval_table.py | .py | """Unit tests for wandb.EvalTable."""
from __future__ import annotations
import datetime
import sys
import types
from unittest.mock import MagicMock
import pytest
import wandb
import wandb.data_types as wandb_data_types
from wandb.errors import UsageError
from wandb.sdk.data_types import eval_table as eval_table_mod... | 1,029 | 31,899 |
openvino | tests/layer_tests/jax_tests/test_add.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import jax.numpy as jnp
import numpy as np
import pytest
from jax_layer_test_class import JaxLayerTest
def get_rand_jnp_array(shape, dtype):
if dtype in [np.float32, np.float16, np.float64]:
return jnp.array(np.random.unif... | 138 | 4,499 |
python-prompt-toolkit | src/prompt_toolkit/widgets/toolbars.py | .py | from __future__ import annotations
from typing import Any
from prompt_toolkit.application.current import get_app
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.enums import SYSTEM_BUFFER
from prompt_toolkit.filters import (
Condition,
FilterOrBool,
emacs_mode,
has_arg,
has_completion... | 371 | 12,178 |
bazel | tools/python/runfiles/runfiles.py | .py | # Copyright 2018 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... | 24 | 997 |
wagtail | wagtail/contrib/settings/registry.py | .py | from django.apps import apps
from django.contrib.auth.models import Permission
from django.urls import reverse
from django.utils.text import capfirst
from wagtail import hooks
from wagtail.admin.admin_url_finder import (
ModelAdminURLFinder,
register_admin_url_finder,
)
from wagtail.admin.menu import MenuItem
... | 150 | 4,787 |
mlflow | tests/test_skinny_client_anthropic_import.py | .py | # Regression test for https://github.com/mlflow/mlflow/issues/21779:
# mlflow-skinny users couldn't use mlflow.anthropic.autolog() because importing
# mlflow.types.chat transitively pulled in numpy via
# mlflow.types.__init__ -> mlflow.types.llm -> mlflow.types.schema.
import importlib.util
import os
import pytest
... | 25 | 876 |
sqlmap | plugins/dbms/mimersql/__init__.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.enums import DBMS
from lib.core.settings import MIMERSQL_SYSTEM_DBS
from lib.core.unescaper import unescaper
from plugins.dbms.mimersql.enumeration import Enumerati... | 31 | 929 |
saleor | saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_checkout_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... | 244 | 7,349 |
pyro | tests/contrib/funsor/test_infer_discrete.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import logging
import os
import pyroapi
import pytest
import torch
from pyro.infer.autoguide import AutoNormal
from tests.common import assert_equal
# put all funsor-related imports here, so test collection works without funsor
try:... | 457 | 16,722 |
pyomo | pyomo/contrib/gdpopt/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 11 | 608 |
saleor | saleor/graphql/product/mutations/collection/collection_delete.py | .py | import graphene
from .....discount.utils.promotion import mark_active_catalogue_promotion_rules_as_dirty
from .....permission.enums import ProductPermissions
from .....product import models
from .....product.tasks import collection_product_updated_task
from ....core import ResolveInfo
from ....core.context import Chan... | 62 | 2,329 |
pynacl | src/nacl/encoding.py | .py | # Copyright 2013 Donald Stufft and individual contributors
#
# 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... | 106 | 2,915 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/jupyter.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: region,endregion
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# # Jupyter notebook
#
# This notebook is a simple jupyter notebook. It only has markdown and code cells. And it does not contain consecutive markdown cells.... | 26 | 461 |
coremltools | deps/protobuf/python/google/protobuf/internal/containers.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... | 644 | 21,560 |
sphinx | tests/test_builders/test_build.py | .py | """Test all builders."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from docutils import nodes
from sphinx.errors import SphinxError
from tests.utils import extract_element, extract_node
if TYPE_CHECKING:
from collections.abc import Callable
from pathlib import Path
... | 121 | 4,249 |
astropy | astropy/coordinates/tests/test_icrs_observed_transformations.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Accuracy tests for ICRS transformations, primarily to/from AltAz."""
import numpy as np
from astropy import units as u
from astropy.coordinates import (
CIRS,
ICRS,
AltAz,
EarthLocation,
HADec,
SkyCoord,
frame_transform_gra... | 81 | 2,863 |
openvino | tests/layer_tests/onnx_tests/test_not.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... | 196 | 6,622 |
confluent-kafka-python | tests/test_Consumer.py | .py | #!/usr/bin/env python
import pytest
from confluent_kafka import (
OFFSET_INVALID,
TIMESTAMP_NOT_AVAILABLE,
Consumer,
KafkaError,
KafkaException,
Message,
TopicPartition,
)
from tests.common import TestConsumer
def test_basic_api():
"""Basic API tests, these wont really do anything sin... | 788 | 24,474 |
pynacl | src/bindings/build.py | .py | # Copyright 2013 Donald Stufft and individual contributors
#
# 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... | 66 | 1,789 |
wandb | tests/system_tests/test_core/test_console.py | .py | import logging
import os
import re
import time
import pytest
import tqdm
import wandb
from click.testing import CliRunner
from wandb.cli import cli
from wandb.sdk.lib import runid
from tests.fixtures.wandb_backend_spy import WandbBackendSpy
def test_console_wrap_raw(wandb_backend_spy):
with wandb.init(settings=... | 153 | 5,106 |
confluent-kafka-python | tests/schema_registry/_sync/test_bearer_field_provider.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2025 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... | 318 | 11,358 |
black | tests/data/cases/pattern_matching_with_if_stmt.py | .py | # flags: --minimum-version=3.10
match match:
case "test" if case != "not very loooooooooooooog condition": # comment
pass
match smth:
case "test" if "any long condition" != "another long condition" and "this is a long condition":
pass
case test if "any long condition" != "another long cond... | 73 | 2,180 |
saleor | saleor/tests/e2e/channel/utils/__init__.py | .py | from .channel_create import create_channel
from .channel_update import update_channel
__all__ = [
"create_channel",
"update_channel",
]
| 8 | 145 |
openvino | tests/layer_tests/pytorch_tests/test_square.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestSquareTypes(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(*self.shape, dtype=self.type),)
def create... | 39 | 1,234 |
openvino | src/bindings/python/tests/test_graph/test_rdft.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import openvino.opset10 as ov
from openvino import Shape, Type
import numpy as np
import pytest
np.random.seed(0)
@pytest.mark.parametrize(("shape", "axes", "expected_shape"), [
([50], [0], [26, 2]),
(... | 73 | 2,885 |
hydra | hydra/_internal/hydra.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import logging
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict
from typing import Any, Callable, DefaultDict, List, Optional, Sequence, Type, Union
from omegaconf import (
MISSING,
... | 778 | 26,703 |
saleor | saleor/graphql/product/tests/mutations/test_collection_add_products.py | .py | from unittest.mock import patch
import graphene
from .....discount.utils.promotion import get_active_catalogue_promotion_rules
from ....tests.utils import (
get_graphql_content,
)
COLLECTION_ADD_PRODUCTS_MUTATION = """
mutation collectionAddProducts(
$id: ID!, $products: [ID!]!) {
collectionA... | 122 | 4,203 |
saleor | saleor/graphql/product/tests/queries/variants_where/test_over_validation.py | .py | import pytest
from .....tests.utils import get_graphql_content
from .shared import PRODUCT_VARIANTS_WHERE_QUERY
@pytest.mark.parametrize(
"attribute_value_filter",
[
{"numeric": None},
{"name": None},
{"slug": None},
{"boolean": False},
{"reference": {"referencedIds": ... | 339 | 9,789 |
probability | tensorflow_probability/python/internal/backend/numpy/v2.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... | 156 | 6,709 |
metrics | tests/unittests/conftest.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... | 90 | 2,852 |
wandb | wandb/plot/line_series.py | .py | from __future__ import annotations
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any
import wandb
from wandb.plot.custom_chart import plot_table
if TYPE_CHECKING:
from wandb.plot.custom_chart import CustomChart
def line_series(
xs: Iterable[Iterable[Any]] | Iterable[Any],
ys: I... | 175 | 5,613 |
textual | tests/select/test_blank_and_clear.py | .py | import pytest
from textual.app import App
from textual.widgets import Select
from textual.widgets.select import InvalidSelectValueError
SELECT_OPTIONS = [(str(n), n) for n in range(3)]
async def test_value_is_blank_by_default():
class SelectApp(App[None]):
def compose(self):
yield Select(SEL... | 77 | 2,055 |
openvino | tools/benchmark_tool/benchmark_app.py | .py | #!/usr/bin/python3
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import sys
from openvino.tools.benchmark.main import main
if __name__ == "__main__":
sys.exit(main() or 0)
| 12 | 216 |
clearml | clearml/hyperdatasets/__init__.py | .py | """
HyperDataset package exposing data entry types, management helpers, and dataview utilities.
"""
from .data_entry import DataEntry, DataSubEntry
from .data_entry_image import DataEntryImage, DataSubEntryImage
from .core import HyperDataset
from .management import HyperDatasetManagement
from .data_view import DataVi... | 21 | 532 |
pymc | pymc/backends/arviz.py | .py | # Copyright 2024 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 842 | 30,565 |
onnxruntime | onnxruntime/test/python/quantization/test_op_instance_normalization.py | .py | #!/usr/bin/env python
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# ---------------------------------------------------------------... | 157 | 5,722 |
pymc | tests/logprob/test_utils.py | .py | # Copyright 2024 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 333 | 12,473 |
openvino | tests/layer_tests/pytorch_tests/test_quantized_add.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class quantized_add(torch.nn.Module):
def __init__(self, scale, zero_point, dtype) -> None:
torch.nn.Modu... | 53 | 1,845 |
pyro | examples/contrib/cevae/synthetic.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
This example demonstrates how to use the Causal Effect Variational Autoencoder
[1] implemented in pyro.contrib.cevae.CEVAE, documented at
http://docs.pyro.ai/en/latest/contrib.cevae.html
**References**
[1] C. Louizos, U. Shal... | 109 | 3,803 |
hydra | tests/test_apps/run_as_module_1/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, OmegaConf
import hydra
@hydra.main(config_path=".", config_name="config")
def my_app(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))
if __name__ == "__main__":
my_app()
| 14 | 295 |
beam | sdks/python/apache_beam/examples/complete/game/game_stats.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... | 406 | 14,710 |
django-cms | cms/test_utils/project/objectpermissionsapp/models.py | .py | from django.conf import settings
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.translation imp... | 61 | 2,596 |
onnxruntime | tools/ci_build/github/windows/post_binary_sizes_to_dashboard.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import datetime
import os
import sys
# ingest from dataframe
import pandas
from azure.kusto.data import DataFormat, KustoConnectionStringBuilder
from azure.kusto.ingest import Ingestio... | 106 | 3,687 |
probability | tensorflow_probability/python/distributions/internal/correlation_matrix_volumes.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... | 95 | 3,541 |
wagtail | wagtail/snippets/views/snippets.py | .py | from django.apps import apps
from django.conf import settings
from django.contrib.admin.utils import quote
from django.core import checks
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
from django.http import Http404
from django.urls import path, re_path, reverse, reverse_lazy
from django.uti... | 1,295 | 47,572 |
sphinx | tests/roots/test-image-in-section/conf.py | .py | exclude_patterns = ['_build']
rst_epilog = """
.. |picture| image:: pic.png
:width: 15pt
:height: 15pt
:alt: alternative_text
"""
| 9 | 143 |
probability | tensorflow_probability/python/experimental/psd_kernels/__init__.py | .py | # Copyright 2021 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 38 | 1,875 |
mlflow | mlflow/entities/__init__.py | .py | """
The ``mlflow.entities`` module defines entities returned by the MLflow
`REST API <../rest-api.html>`_.
"""
from mlflow.entities.assessment import (
Assessment,
AssessmentError,
AssessmentSource,
AssessmentSourceType,
Expectation,
Feedback,
IssueReference,
)
from mlflow.entities.dataset ... | 229 | 6,932 |
cvxpy | cvxpy/reductions/solvers/nlp_solvers/diff_engine/c_problem.py | .py | """ Copyright 2025, the CVXPY developers
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, s... | 130 | 5,500 |
astropy | astropy/io/votable/exceptions.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""VOTable exceptions and warnings.
.. _warnings:
Warnings
--------
.. note::
Most of the following warnings indicate violations of the VOTable
specification. They should be reported to the authors of the
tools that produced the VOTable file... | 1,613 | 51,308 |
astropy | astropy/extern/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This packages contains python packages that are bundled with Astropy but are
external to Astropy, and hence are developed in a separate source tree. Note
that this package is distinct from the /cextern directory of the source code
distribution, as tha... | 11 | 457 |
mlflow | tests/genai/simulators/conftest.py | .py | from contextlib import contextmanager
from unittest.mock import Mock, patch
import pytest
@pytest.fixture
def mock_trace():
trace = Mock()
trace.info.trace_metadata = {}
trace.info.tags = {}
return trace
@pytest.fixture
def simulation_mocks(mock_trace):
"""Fixture providing common mocks for con... | 142 | 3,895 |
onnx | onnx/reference/ops/op_bitwise_and.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 OpRunBinary
class BitwiseAnd(OpRunBinary):
def _run(self, x, y):
return (np.bitwise_and(x, y),)
| 14 | 282 |
onnxruntime | onnxruntime/python/tools/transformers/onnx_exporter.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import ... | 720 | 24,621 |
saleor | saleor/graphql/account/tests/mutations/account/test_account_update.py | .py | from unittest.mock import patch
import graphene
import pytest
from ......account.error_codes import AccountErrorCode
from ......account.models import User
from ......checkout import AddressType
from ......giftcard.search import update_gift_cards_search_vector
from .....tests.utils import assert_no_permission, get_gra... | 586 | 18,903 |
coremltools | coremltools/converters/mil/backend/mil/load.py | .py | # Copyright (c) 2021, 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 os
import warnings
from collections import OrderedDict
from typing import Any, Dict, List, Opt... | 1,105 | 47,312 |
onnxruntime | tools/ci_build/patch_manylinux.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
import argparse
import os
import shutil
import sys
from pathlib import Path
from logger import get_logger
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
RE... | 66 | 2,213 |
qutip | qutip/solver/scattering.py | .py | """
Photon scattering in quantum optical systems
This module includes a collection of functions for numerically computing photon
scattering in driven arbitrary systems coupled to some configuration of output
waveguides. The implementation of these functions closely follows the
mathematical treatment given in K.A. Fisc... | 303 | 11,346 |
hatch | tests/cli/check/test_check_fmt.py | .py | from __future__ import annotations
import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
def construct_ruff_defaults_file(rules: tuple[str, ...]) -> str:
from hatch.cli.fmt.core import PER_FILE_IGNORED_RULES
lines = [
"line-length = 120",
"",
... | 375 | 13,068 |
openvino | src/bindings/python/src/openvino/opset14/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino.opset1.ops import absolute
from openvino.opset1.ops import absolute as abs
from openvino.opset1.ops import acos
from openvino.opset4.ops import acosh
from openvino.opset8.ops import adaptive_avg_pool... | 191 | 8,114 |
probability | tensorflow_probability/python/experimental/distributions/joint_distribution_pinned.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... | 869 | 35,393 |
onnxruntime | onnxruntime/test/testdata/dmmha_inside_mha_graph.py | .py | from onnx import TensorProto, helper, save_model
# Whisper decoder self attention with past_kv, present_kv, buffer sharing enabled, mask, and bias
# Used in decoder-with-past's self-attention layers
def dmmha_inside_mha_self_attn():
num_heads, head_size = 2, 32
hidden_size = num_heads * head_size
# Input... | 236 | 9,820 |
python-prompt-toolkit | examples/full-screen/simple-demos/cursorcolumn-cursorline.py | .py | #!/usr/bin/env python
"""
Cursorcolumn / cursorline example.
"""
from prompt_toolkit.application import Application
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout.containers import HSplit, Window
from prompt_toolkit.layout.controls import BufferCo... | 61 | 1,869 |
python-prompt-toolkit | examples/prompts/clock-input.py | .py | #!/usr/bin/env python
"""
Example of a 'dynamic' prompt. On that shows the current time in the prompt.
"""
import datetime
from prompt_toolkit.shortcuts import prompt
def get_prompt():
"Tokens to be shown before the prompt."
now = datetime.datetime.now()
return [
("bg:#008800 #ffffff", f"{now.ho... | 27 | 557 |
biopython | Bio/SeqIO/GckIO.py | .py | # Copyright 2019 Damien Goutte-Gattat. 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.
"""Bio.SeqIO support ... | 246 | 9,055 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_tanh_shrink.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# tanh_shrink paddle model generator
#
import numpy as np
import sys
from save_model import saveModel
def tanh_shrink(name: str, x):
import paddle
paddle.enable_static()
with paddle.static.program_guard(paddle.static.Pr... | 52 | 1,271 |
loguru | loguru/_recattrs.py | .py | import pickle
from collections import namedtuple
class RecordLevel:
"""A class representing the logging level record with name, number and icon.
Attributes
----------
icon : str
The icon representing the log level
name : str
The name of the log level
no : int
The numer... | 294 | 7,333 |
pyomo | examples/dae/dynamic_scheduling.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... | 145 | 4,017 |
sphinx | tests/test_environment/test_environment_indexentries.py | .py | """Test the sphinx.environment.adapters.indexentries."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from sphinx.environment.adapters.indexentries import IndexEntries
from sphinx.testing import restructuredtext
if TYPE_CHECKING:
from sphinx.testing.util import SphinxTestAp... | 292 | 8,991 |
textual | docs/examples/styles/grid_size_columns.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Label
class MyApp(App):
CSS_PATH = "grid_size_columns.tcss"
def compose(self):
yield Grid(
Label("1"),
Label("2"),
Label("3"),
Label("4"),
Label("5")... | 22 | 393 |
astropy | astropy/samp/hub.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import copy
import os
import queue
import select
import socket
import threading
import time
import uuid
import warnings
import xmlrpc.client as xmlrpc
from urllib.parse import urlunparse
from astropy import log
from .constants import SAMP_STATUS_OK, __... | 1,507 | 56,042 |
pyomo | pyomo/contrib/doe/doe.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... | 2,832 | 112,235 |
saleor | saleor/tests/e2e/taxes/utils/query_tax_configurations.py | .py | from ...utils import get_graphql_content
TAX_CONFIGURATIONS_QUERY = """
query TaxConfigurationsList($first: Int) {
taxConfigurations(first: $first) {
edges {
node {
id
channel {
id
slug
}
displayGrossPrices
pricesEnteredWithTax
chargeTaxes... | 35 | 664 |
openvino | tests/model_hub_tests/transformation_tests/generate_ref_diffs.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
'''
Use this script if you need to regenerate reference diffs for each model
to test SDPAToPA transformation.
The script will produce sdpa2pa_ref_diff.txt (or sdpa2pa_ref_diff_optimizations.txt
if using cache-eviction) containing a map ... | 139 | 6,110 |
saleor | saleor/graphql/app/filters.py | .py | import django_filters
import graphene
from ...app import models
from ...app.types import AppType
from ..core.descriptions import ADDED_IN_322
from ..core.filters import EnumFilter, ListObjectTypeFilter
from .enums import AppTypeEnum
def filter_app_search(qs, _, value):
if value:
qs = qs.filter(name__ilik... | 59 | 1,599 |
python-prompt-toolkit | examples/full-screen/simple-demos/alignment.py | .py | #!/usr/bin/env python
"""
Demo of the different Window alignment options.
"""
from prompt_toolkit.application import Application
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout.containers import HSplit, Window, WindowAlign
from prompt_toolkit.layout.controls import FormattedTextControl
fr... | 62 | 1,958 |
gunicorn | examples/asgi/__init__.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
ASGI example applications for gunicorn.
"""
| 8 | 154 |
biopython | Bio/Align/maf.py | .py | # Copyright 2011, 2012 by Andrew Sczesnak. All rights reserved.
# Revisions Copyright 2011, 2017 by Peter Cock. All rights reserved.
# Revisions Copyright 2014, 2015 by Adam Novak. All rights reserved.
# Revisions Copyright 2015, 2017 by Blaise Li. All rights reserved.
#
# This file is part of the Biopython distrib... | 458 | 18,139 |
saleor | saleor/graphql/warehouse/sorters.py | .py | from ..core.doc_category import DOC_CATEGORY_PRODUCTS
from ..core.types import BaseEnum, SortInputObjectType
class WarehouseSortField(BaseEnum):
NAME = ["name", "slug"]
class Meta:
doc_category = DOC_CATEGORY_PRODUCTS
@property
def description(self):
if self.name in WarehouseSortFiel... | 24 | 712 |
probability | tensorflow_probability/python/math/psd_kernels/schur_complement_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... | 442 | 17,902 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupintobatches.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");... | 65 | 1,908 |
pdm | src/pdm/cli/filters.py | .py | from __future__ import annotations
import argparse
from functools import cached_property
from typing import TYPE_CHECKING
from pdm.exceptions import PdmUsageError
from pdm.utils import normalize_name
if TYPE_CHECKING:
from collections.abc import Iterator, Sequence
from pdm.project import Project
class Gro... | 122 | 4,536 |
gunicorn | tests/test_gtornado.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for the tornado worker."""
import os
from unittest import mock
import pytest
tornado = pytest.importorskip("tornado")
from gunicorn.config import Config
from gunicorn.workers import gtornado
class Fa... | 512 | 15,214 |
gunicorn | tests/docker/asgi_framework_compat/conftest.py | .py | """
Pytest configuration for ASGI Framework Compatibility Tests
This module provides fixtures for parameterized testing across multiple
ASGI frameworks running in Docker containers with gunicorn's ASGI worker.
"""
import asyncio
import json
import os
import subprocess
import time
from typing import AsyncGenerator
im... | 212 | 5,936 |
onnx | onnx/backend/test/runner/__init__.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import functools
import glob
import os
import re
import shutil
import sys
import tempfile
import time
import unittest
from collections import defaultdict
from re import Pattern
from typing import TYPE_... | 549 | 22,128 |
saleor | saleor/account/i18n_valid_address_extension.py | .py | from enum import Enum
from ..graphql.account.enums import CountryCodeEnum
class AddressFieldsToSubstitute(Enum):
CITY_AREA = "city_area"
COUNTRY_AREA = "country_area"
IE_COUNTRY_AREA = {
"Carlow": "Co. Carlow",
"Cavan": "Co. Cavan",
"Clare": "Co. Clare",
"Cork": "Co. Cork",
"Donegal": "... | 46 | 1,216 |
astropy | astropy/samp/tests/test_helpers.py | .py | import os
import pickle
import random
import string
import time
from astropy.samp import SAMP_STATUS_OK
TEST_REPLY = {"samp.status": SAMP_STATUS_OK, "samp.result": {"txt": "test"}}
def write_output(mtype, private_key, sender_id, params):
filename = params["verification_file"]
f = open(filename, "wb")
pi... | 71 | 2,198 |
biopython | Scripts/xbbtools/xbb_widget.py | .py | #!/usr/bin/env python
# Copyright 2000 by Thomas Sicheritz-Ponten.
# Copyright 2016 by Markus Piotrowski.
# All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
# Created: Wed Jun 21 ... | 531 | 18,592 |
conda | tests/core/test_path_actions.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import importlib.util
import os
import sys
from logging import getLogger
from os.path import basename, dirname, getsize, isdir, isfile, join, lexists
from typing import TYPE_CHECKING
from uuid import uuid4
im... | 610 | 19,831 |
mlflow | mlflow/metrics/genai/utils.py | .py | _MIGRATION_GUIDE = (
"Use the new GenAI evaluation functionality instead. See "
"https://mlflow.org/docs/latest/genai/eval-monitor/legacy-llm-evaluation/ "
"for the migration guide."
)
def _get_latest_metric_version():
return "v1"
def _get_default_model():
return "openai:/gpt-4"
| 14 | 304 |
records | records.py | .py | # -*- coding: utf-8 -*-
import os
from sys import stdout
from collections import OrderedDict
from contextlib import contextmanager
from inspect import isclass
import tablib
from docopt import docopt
from sqlalchemy import create_engine, exc, inspect, text
def isexception(obj):
"""Given an object, return a boole... | 563 | 17,354 |
records | setup.py | .py | #!/usr/bin/env python
import io
import os
import sys
from codecs import open
from shutil import rmtree
from setuptools import setup, Command
here = os.path.abspath(os.path.dirname(__file__))
with io.open(os.path.join(here, "README.rst"), encoding="utf-8") as f:
long_description = "\n" + f.read()
class PublishC... | 107 | 2,984 |
records | tests/test_69.py | .py | def test_issue69(db):
db.query("CREATE table users (id text)")
db.query("SELECT * FROM users WHERE id = :user", user="Te'ArnaLambert")
| 4 | 143 |
records | tests/test_105.py | .py | import pytest
@pytest.mark.usefixtures("foo_table")
def test_issue105(db):
assert db.query("select count(*) as n from foo").scalar() == 0
| 7 | 144 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.