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 |
|---|---|---|---|---|---|
saleor | saleor/graphql/order/mutations/order_line_discount_remove.py | .py | import copy
import graphene
from ....core.tracing import traced_atomic_transaction
from ....order import events
from ....order.utils import invalidate_order_prices, remove_discount_from_order_line
from ....permission.enums import OrderPermissions
from ...app.dataloaders import get_app_promise
from ...core import Reso... | 67 | 2,383 |
pyomo | examples/pyomobook/mpec-ch/ex1b.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... | 27 | 1,089 |
hydra | examples/advanced/ray_example/ray_compose_example.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import time
from typing import List, Tuple
import ray
from omegaconf import DictConfig, OmegaConf
import hydra
@ray.remote # type: ignore
def train(overrides: List[str], cfg: DictConfig) -> Tuple[List[str], float]:
print(OmegaConf.to_yaml(c... | 36 | 939 |
biopython | Bio/SeqUtils/IsoelectricPoint.py | .py | # Copyright 2003 Yair Benita. All rights reserved.
# Revisions copyright 2020 by Tianyi Shi. 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 incl... | 168 | 6,557 |
hydra | plugins/hydra_nevergrad_sweeper/example/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import hydra
from omegaconf import DictConfig
log = logging.getLogger(__name__)
@hydra.main(config_path=".", config_name="config")
def dummy_training(cfg: DictConfig) -> float:
"""A dummy function to minimize
Minimum is 0.... | 31 | 792 |
hatch | scripts/write_coverage_summary_report.py | .py | import json
from decimal import ROUND_DOWN, Decimal
from pathlib import Path
PRECISION = Decimal(".01")
def main():
project_root = Path(__file__).resolve().parent.parent
coverage_summary = project_root / "coverage-summary.json"
coverage_data = json.loads(coverage_summary.read_text(encoding="utf-8"))
... | 50 | 1,713 |
saleor | saleor/graphql/account/tests/mutations/account/test_send_confirmation_email.py | .py | import datetime
from unittest.mock import patch
from urllib.parse import urlencode
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from ......account.error_codes import SendConfirmationEmailErrorCode
from ......account.notifications import get_default_user... | 230 | 7,083 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_greater_than.py | .py | #
# greater_than paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle as pdpd
import sys
def greater_than(name: str, x, y, data_type, cast_to_fp32=False):
pdpd.enable_static()
with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()):
node_x = ... | 64 | 1,875 |
sphinx | tests/test_builders/test_build_manpage.py | .py | """Test the build process with manpage builder with the test root."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from sphinx.builders.manpage import default_man_pages
from sphinx.config import Config
if TYPE_CHECKING:
from sphinx.testing.util import SphinxTestApp
@pytes... | 108 | 2,814 |
ipython | IPython/core/payloadpage.py | .py | """A payload based version of page."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import warnings
from IPython.core.getipython import get_ipython
# see https://github.com/ipython/ipykernel/issues/1304
# this should be moved to ipykernel and removed in the lon... | 42 | 1,177 |
black | tests/data/cases/walrus_in_dict.py | .py | {
"is_update": (up := commit.hash in update_hashes)
}
# output
{"is_update": (up := commit.hash in update_hashes)}
| 7 | 120 |
hydra | tools/configen/configen/samples/my_module.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
class User:
def __init__(self, age: int, name: str):
self.age = age
self.name = name
def __repr__(self):
return f"User: name={self.name}, age={self.age}"
class Admin(User):
def __init__(self, private_key: str... | 22 | 566 |
kombu | kombu/transport/pyro.py | .py | """Pyro transport module for kombu.
Pyro transport, and Kombu Broker daemon.
Requires the :mod:`Pyro4` library to be installed.
Features
========
* Type: Virtual
* Supports Direct: Yes
* Supports Topic: Yes
* Supports Fanout: No
* Supports Priority: No
* Supports TTL: No
Connection String
=================
To use ... | 213 | 5,844 |
sqlmap | tests/test_odata.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Offline, deterministic tests for the OData '$filter' injection engine. A mock oracle mirrors the
boolean-blind semantics of a real OData service (a broken-out filter reduced to its in... | 472 | 19,993 |
wagtail | wagtail/admin/tests/pages/test_reorder_page.py | .py | from django.test import TestCase
from django.urls import reverse
from wagtail.test.testapp.models import (
BusinessChild,
BusinessIndex,
NoCreatableSubpageTypesPage,
NoSubpageTypesPage,
SimplePage,
)
from wagtail.test.utils import Page, PageFixturesMixin, WagtailTestUtils
class TestPageReorder(Pa... | 243 | 9,286 |
saleor | saleor/graphql/product/mutations/product/__init__.py | .py | from .product_create import ProductCreate
from .product_delete import ProductDelete
from .product_media_create import ProductMediaCreate
from .product_media_delete import ProductMediaDelete
from .product_media_reorder import ProductMediaReorder
from .product_media_update import ProductMediaUpdate
from .product_update i... | 18 | 523 |
astropy | astropy/samp/standard_profile.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import socketserver
import sys
import traceback
import warnings
import xmlrpc.client as xmlrpc
from xmlrpc.server import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer
from .constants import SAMP_ICON
from .errors import SAMPWarning
from .utils import s... | 164 | 5,749 |
structlog | src/structlog/processors.py | .py | # SPDX-License-Identifier: MIT OR Apache-2.0
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the MIT License. See the LICENSE file in the root of this
# repository for complete details.
"""
Processors useful regardless of the logging framework.
"""
from __future__ import annota... | 1,006 | 31,183 |
saleor | saleor/graphql/app/mutations/app_delete.py | .py | import graphene
from django.core.exceptions import ValidationError
from ....app import models
from ....app.actions import delete_app
from ....app.error_codes import AppErrorCode
from ....permission.enums import AppPermission
from ....webhook.event_types import WebhookEventAsyncType
from ...account.utils import can_man... | 62 | 2,198 |
cvxpy | cvxpy/constraints/zero.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... | 192 | 5,676 |
deap | deap/tools/indicator.py | .py | import numpy
import moocore
def hypervolume(front, **kargs):
"""Returns the index of the individual with the least the hypervolume
contribution. The provided *front* should be a set of non-dominated
individuals having each a :attr:`fitness` attribute.
The hypervolume is computed using the `moocore` p... | 33 | 1,158 |
wandb | tests/system_tests/test_artifacts/test_wandb_run_artifacts.py | .py | from __future__ import annotations
import os
from contextlib import nullcontext
from pathlib import Path
from typing import TYPE_CHECKING
import wandb
from pytest import FixtureRequest, fixture, mark, raises
from pytest_mock import MockerFixture
from wandb import Artifact, env
from wandb.errors import CommError
from ... | 394 | 12,753 |
readthedocs.org | readthedocs/api/v3/tests/test_notifications.py | .py | import django_dynamic_fixture as fixture
from django.contrib.contenttypes.models import ContentType
from django.test import override_settings
from django.urls import reverse
from readthedocs.notifications.constants import CANCELLED, DISMISSED
from readthedocs.notifications.models import Notification
from readthedocs.p... | 74 | 2,584 |
pyro | tests/params/test_module.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
import torch.nn as nn
from torch.nn import Parameter
import pyro
import pyro.distributions as dist
import pyro.optim
class outest(nn.Module):
def __init__(self):
super().__init__()
... | 95 | 2,567 |
mlflow | tests/genai/label_schemas/test_label_schemas_oss.py | .py | from unittest.mock import patch
import pytest
from mlflow.exceptions import MlflowException
from mlflow.genai.label_schemas import (
InputCategorical,
InputPassFail,
LabelSchema,
LabelSchemaType,
create_label_schema,
delete_label_schema,
get_label_schema,
list_label_schemas,
update... | 153 | 5,608 |
coveragepy | tests/test_core.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
"""Tests for core selection of coverage.py."""
from __future__ import annotations
import pytest
import coverage
from coverage import env
from coverage.exceptio... | 156 | 5,950 |
cvxpy | cvxpy/reductions/solvers/nlp_solvers/ipopt_nlpif.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... | 231 | 9,113 |
wandb | tools/perf/scripts/__init__.py | .py | import logging
_PACKAGE_LOGGER = logging.getLogger(__name__)
| 4 | 62 |
clearml | clearml/backend_interface/metrics/reporter.py | .py | import atexit
import datetime
import json
import logging
import math
import os
from time import sleep, time
from types import TracebackType
from typing import Optional, Union, List, Tuple, Type, Dict, TYPE_CHECKING, Any
from typing import Iterable as _Iterable
import PIL
import numpy
import numpy as np
if TYPE_CHECKI... | 1,239 | 44,079 |
cvxpy | cvxpy/reductions/dgp2dcp/canonicalizers/constant_canon.py | .py | """
Copyright 2018 Akshay Agrawal
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | 24 | 732 |
openvino | tools/ovc/unit_tests/ovc/main_test_error_log.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import argparse
from unittest.mock import patch
from openvino.tools.ovc.error import FrameworkError
def mocked_parse_args(*argv):
# Mock parse_args method which generates warning
import logging as log
log.error("warning", ... | 31 | 928 |
jupyterlab | galata/test/documentation/add.py | .py | def add(x, y):
return x + y
| 3 | 32 |
probability | tensorflow_probability/python/math/sparse_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... | 164 | 6,272 |
mlflow | mlflow/telemetry/track.py | .py | import functools
import inspect
import logging
import time
from typing import Any, Callable, ParamSpec, TypeVar
from mlflow.environment_variables import MLFLOW_EXPERIMENT_ID
from mlflow.telemetry.client import get_telemetry_client
from mlflow.telemetry.events import Event
from mlflow.telemetry.schemas import Record, S... | 124 | 4,277 |
onnx | onnx/reference/ops/op_string_concat.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
_acceptable_str_dtypes = ("U", "O")
class StringConcat(OpRun):
def _run(self, x, y):
if (
x.dtype.kind not in _accep... | 24 | 708 |
pymc | pymc/progress_bar/marimo_progress_css.py | .py | # Copyright 2026 - 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... | 61 | 1,638 |
pdm | src/pdm/project/__init__.py | .py | from pdm.project.config import Config, ConfigItem
from pdm.project.core import Project
__all__ = ["Config", "ConfigItem", "Project"]
| 5 | 134 |
saleor | saleor/shipping/tests/fixtures/shipping_method_translation.py | .py | import pytest
from ...models import ShippingMethodTranslation
@pytest.fixture
def shipping_method_translation_fr(shipping_method):
return ShippingMethodTranslation.objects.create(
language_code="fr",
shipping_method=shipping_method,
name="French shipping method name",
)
| 13 | 306 |
clearml | clearml/backend_api/services/v2_20/projects.py | .py | """
projects service
Provides support for defining Projects containing Tasks, Models and Dataset Versions.
"""
from typing import List, Optional, Any
import six
from datetime import datetime
from dateutil.parser import parse as parse_datetime
from clearml.backend_api.session import (
Request,
Response,
Non... | 4,524 | 160,413 |
onnx | onnx/backend/test/case/node/onehot.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 one_hot(indices, depth, axis=-1, dtype=np.float32):
"""Compute one h... | 160 | 5,063 |
sqlmap | thirdparty/chardet/sbcsgroupprober.py | .py | ######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Universal charset detector code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All R... | 84 | 4,309 |
returns | tests/test_context/test_requires_context_ioresult/test_requires_context_ioresult.py | .py | from returns.context import RequiresContextIOResultE
from returns.io import IOSuccess
def test_regression394():
"""
It used to raise ``ImmutableStateError`` for type aliases.
Here we use the minimal reproduction sample.
.. code:: python
Traceback (most recent call last):
File "ex.py",... | 28 | 912 |
coremltools | deps/protobuf/python/google/protobuf/internal/symbol_database_test.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... | 134 | 5,560 |
wagtail | wagtail/admin/views/mixins.py | .py | import csv
import datetime
from collections import OrderedDict
from functools import partial
from io import BytesIO
from django.contrib.admin.utils import label_for_field
from django.core.exceptions import FieldDoesNotExist
from django.http import FileResponse, StreamingHttpResponse
from django.utils import timezone
f... | 336 | 12,993 |
pyomo | doc/OnlineDocs/src/kernel/examples/kernel_example.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... | 173 | 3,498 |
wandb | tests/system_tests/test_functional/test_tensorboard/test_tb_w_sb3.py | .py | """Test stable_baselines3 integration."""
import gymnasium as gym
import wandb
from stable_baselines3 import PPO
from stable_baselines3.common.monitor import Monitor
from stable_baselines3.common.vec_env import DummyVecEnv
def test_sb3_tensorboard(wandb_backend_spy):
"""Integration test for Stable Baselines 3 Te... | 35 | 1,118 |
scikit-bio | skbio/alignment/_utils.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.
# --------------------------------------------... | 479 | 16,010 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/combinevalues_side_inputs_iter.py | .py | # coding=utf-8
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License");... | 71 | 2,145 |
readthedocs.org | readthedocs/doc_builder/director.py | .py | """
The ``director`` module can be seen as the entrypoint of the build process.
It "directs" all of the high-level build jobs:
* checking out the repo
* setting up the environment
* fetching instructions etc.
"""
import datetime
import os
import tarfile
import structlog
import yaml
from django.conf import settings
... | 931 | 36,691 |
readthedocs.org | readthedocs/filetreediff/dataclasses.py | .py | import fnmatch
from dataclasses import asdict
from dataclasses import dataclass
from enum import StrEnum
from enum import auto
from functools import cached_property
from typing import Iterator
from readthedocs.builds.models import Build
from readthedocs.builds.models import Version
from readthedocs.core.resolver impor... | 183 | 5,698 |
python-prompt-toolkit | src/prompt_toolkit/input/posix_utils.py | .py | from __future__ import annotations
import os
import select
from codecs import getincrementaldecoder
__all__ = [
"PosixStdinReader",
]
class PosixStdinReader:
"""
Wrapper around stdin which reads (nonblocking) the next available 1024
bytes and decodes it.
Note that you can't be sure that the inp... | 98 | 3,973 |
onnx | onnx/reference/ops/experimental/_op_list.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import textwrap
from typing import Any
from onnx.reference.op_run import OpFunction, OpRun
from onnx.reference.ops._helpers import build_registered_operators_any_domain
from onnx.reference.ops.experimen... | 73 | 2,284 |
cvxpy | cvxpy/reductions/dcp2cone/canonicalizers/rel_entr_canon.py | .py | """
Copyright 2021 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, so... | 31 | 1,034 |
coveragepy | tests/test_regions.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
"""Tests for coverage/regions.py."""
from __future__ import annotations
import collections
import textwrap
from pathlib import Path
import pytest
from coverag... | 114 | 4,054 |
coremltools | coremltools/converters/mil/mil/ops/tests/iOS17/__init__.py | .py | # Copyright (c) 2023, 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 coremltools as ct
from coremltools.converters.mil.testing_reqs import backends_internal, clean... | 10 | 399 |
pyro | examples/dmm.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
An implementation of a Deep Markov Model in Pyro based on reference [1].
This is essentially the DKS variant outlined in the paper. The primary difference
between this implementation and theirs is that in our version any KL div... | 602 | 25,375 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_elu.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasELU(CommonTF2LayerTest):
def create_keras_elu_net(self, input_names, input_shapes, input_type, alpha, ir_version):
... | 69 | 3,455 |
scikit-bio | skbio/io/format/blast7.py | .py | """BLAST+7 format (:mod:`skbio.io.format.blast7`)
==============================================
.. currentmodule:: skbio.io.format.blast7
The BLAST+7 format (``blast+7``) stores the results of a BLAST [1]_ database
search. This format is produced by both BLAST+ output
format 7 and legacy BLAST output format 9. The r... | 406 | 14,690 |
wandb | wandb/apis/_generated/fragments.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/api/
from __future__ import annotations
from typing import Literal
from pydantic import Field
from wandb._pydantic import GQLId, GQLResult, Typename
class AgentFragment(GQLResult):
id: GQLId
name: str
host: str
state: str | None
to... | 154 | 3,895 |
saleor | saleor/graphql/order/tests/queries/test_order_excluded_shipping_methods.py | .py | from unittest import mock
import pytest
from promise import Promise
from .....order import OrderStatus
from .....order.webhooks.exclude_shipping import ExcludedShippingMethod
from ....core.utils import to_global_id_or_none
from ....tests.utils import get_graphql_content
ORDER_QUERY_SHIPPING_METHOD = """
query OrderQ... | 140 | 4,174 |
lemur | lemur/metrics.py | .py | """
.. module: lemur.metrics
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
"""
from typing import List
from flask import current_app
from lemur.plugins.base import plugins
class Metrics:
"""
:param app: The Flask application object. Default... | 39 | 1,125 |
onnx | onnx/reference/ops/op_random_uniform.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from onnx.reference.ops._op_common_random import _CommonRandom
class RandomUniform(_CommonRandom):
def _run(self, dtype=None, high=None, low=None, seed=None, shape=None):
dtype = self._dtyp... | 17 | 501 |
pyomo | pyomo/gdp/tests/test_disjunct.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... | 729 | 26,311 |
python-prompt-toolkit | examples/prompts/get-password.py | .py | #!/usr/bin/env python
from prompt_toolkit import prompt
if __name__ == "__main__":
password = prompt("Password: ", is_password=True)
print(f"You said: {password}")
| 7 | 173 |
astropy | astropy/utils/xml/validate.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Functions to do XML schema and DTD validation. At the moment, this
makes a subprocess call to xmllint. This could use a Python-based
library at some point in the future, if something appropriate could be
found.
"""
import os
import subprocess
from ... | 56 | 1,518 |
onnxruntime | tools/python/util/update_onnx_opset.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import os
import pathlib
from .onnx_model_utils import update_onnx_opset
def update_onnx_opset_helper():
parser = argparse.ArgumentParser(
f"{os.path.basename(__file__)}:{... | 32 | 1,151 |
saleor | saleor/graphql/order/tests/deprecated/test_discount_order.py | .py | from decimal import Decimal
from functools import partial
import graphene
import pytest
from prices import TaxedMoney, percentage_discount
from .....discount import DiscountValueType
from .....order import OrderEvents, OrderStatus
from ....discount.enums import DiscountValueTypeEnum
from ....tests.utils import get_gr... | 183 | 5,244 |
mlflow | mlflow/genai/scorers/online/sampler.py | .py | """Dense sampling strategy for online scoring."""
import hashlib
import logging
from collections import defaultdict
from typing import TYPE_CHECKING
from mlflow.genai.scorers.base import Scorer
if TYPE_CHECKING:
from mlflow.genai.scorers.online.entities import OnlineScorer
_logger = logging.getLogger(__name__)
... | 107 | 3,896 |
mlflow | mlflow/genai/scorers/trulens/registry.py | .py | from __future__ import annotations
import re
from typing import Any
# Mapping: metric name -> (feedback method name, argument mapping)
# Argument mapping: generic key -> TruLens-specific argument name
_METRIC_REGISTRY: dict[str, tuple[str, dict[str, str]]] = {
# RAG metrics
"Groundedness": (
"grounded... | 65 | 2,224 |
cvxpy | cvxpy/tests/test_attributes.py | .py | import sys
import numpy as np
import pytest
import scipy.sparse as sp
import cvxpy as cp
from cvxpy.constraints.nonpos import Inequality
from cvxpy.constraints.psd import PSD
from cvxpy.constraints.zero import Equality
from cvxpy.reductions.cvx_attr2constr import CvxAttr2Constr
class TestAttributes:
@pytest.ma... | 601 | 24,177 |
coremltools | coremltools/converters/mil/mil/ops/tests/iOS18/test_recurrent.py | .py | # Copyright (c) 2024, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import itertools
import numpy as np
import pytest
import torch
import coremltools as ct
from coremltoo... | 178 | 5,765 |
mlflow | mlflow/data/artifact_dataset_sources.py | .py | import re
import warnings
from pathlib import Path
from typing import Any, TypeVar
from urllib.parse import urlparse
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
from mlflow.store.artifact.artifact_repository_registry import get_registered_artifact_repo... | 172 | 6,833 |
django-cms | cms/tests/test_views.py | .py | import re
import sys
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.core.cache import cache
from django.http import Http404, HttpResponse
from django.template import... | 700 | 30,676 |
hatch | src/hatch/cli/self/update.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
import click
if TYPE_CHECKING:
from hatch.cli.application import Application
@click.command(
short_help="Install the latest version", context_settings={"help_option_names": [], "ignore_unknown_options": True}
)
@click.argument("args", narg... | 18 | 466 |
onnx | onnx/reference/ops/op_shape.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
class Shape_1(OpRun):
def _run(self, data):
return (np.array(data.shape, dtype=np.int64),)
class Shape_15(Shape_1):
@static... | 36 | 1,023 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_layer_normalization.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasLayerNormalization(CommonTF2LayerTest):
def create_keras_lnorm_net(self, input_names, input_shapes, input_type, axis, ... | 60 | 2,734 |
onnx | onnx/backend/test/case/node/reducel2.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 ReduceL2(Base):
@staticmethod
def export_do_not_keepdims() -> ... | 208 | 6,012 |
clearml | examples/frameworks/tensorflow/tensorflow_mnist.py | .py | from __future__ import absolute_import, division, print_function, unicode_literals
import os
from tempfile import gettempdir
import tensorflow as tf
from tensorflow.keras.layers import Dense, Flatten, Conv2D
from tensorflow.keras import Model
from clearml import Task
# Connecting ClearML with the current process,... | 159 | 5,063 |
django-cms | cms/test_utils/project/urls.py | .py | from django.conf import settings
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
from django.contrib.auth.views import LoginView
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import include, re_path
from django.views.i18n import JavaScriptCatalog
f... | 49 | 1,825 |
biopython | Tests/test_Ace.py | .py | # Copyright 2004 by Frank Kauff. All rights reserved.
# Revisions copyright 2008-2013 by Peter Cock. All rights reserved.
# Revisions copyright 2009-2009 by Michiel de Hoon. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should ha... | 2,180 | 121,943 |
coveragepy | tests/moremodules/othermods/othera.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
o = 1
p = 2
| 6 | 170 |
sqlmap | tests/test_users_enum.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Unit tests for the enumeration methods of plugins/generic/users.py.
The injection layer (lib.request.inject.getValue) is mocked so the methods can
be exercised against canned result ... | 512 | 20,626 |
wandb | wandb/sdk/data_types/table_decorators.py | .py | """Decorators for W&B Table operations."""
from __future__ import annotations
from collections.abc import Callable
from functools import wraps
from typing import Any, Concatenate, TypeVar
from typing_extensions import ParamSpec
import wandb
_P = ParamSpec("_P")
_T = TypeVar("_T")
def allow_relogging_after_mutati... | 108 | 3,675 |
openvino | src/bindings/python/tests/test_graph/test_nms_rotated.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import openvino.opset13 as ov_opset13
from openvino import PartialShape, Dimension, Type
from openvino.utils.types import make_constant_node
@pytest.mark.parametrize(
("box... | 84 | 4,195 |
django-cms | cms/test_utils/project/sampleapp/urls_extra.py | .py | from django.urls import re_path
from . import views
urlpatterns = [
re_path(r'extra_2/$', views.extra_view, {'message': 'test included urlconf'}, name='extra_second'),
]
| 8 | 176 |
saleor | saleor/graphql/attribute/tests/mutations/test_attribute_update.py | .py | import json
from unittest import mock
import graphene
import pytest
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....attribute import AttributeEntityType, AttributeInputType
from .....attribute.error_codes import AttributeErrorCode
from .....attribute.models import Attr... | 1,423 | 42,029 |
sphinx | tests/test_transforms/test_transforms_post_transforms_images.py | .py | from __future__ import annotations
from types import SimpleNamespace
from typing import TYPE_CHECKING
from docutils import nodes
from sphinx.transforms.post_transforms.images import ImageConverter
from sphinx.util.docutils import new_document
if TYPE_CHECKING:
from pathlib import Path
WEBP_DATA = (
b'RIFF\... | 53 | 2,373 |
sphinx | tests/test_events.py | .py | """Test the EventManager class."""
from __future__ import annotations
from types import SimpleNamespace
from typing import TYPE_CHECKING
import pytest
from sphinx.errors import ExtensionError
from sphinx.events import EventManager
if TYPE_CHECKING:
from typing import NoReturn
from sphinx.application impor... | 67 | 2,161 |
wandb | tests/unit_tests/test_job_builder.py | .py | import json
import os
import random
import string
import pytest
from wandb.sdk.internal.job_builder import JobBuilder
from wandb.sdk.internal.settings_static import SettingsStatic
from wandb.util import make_artifact_name_safe
def str_of_length(n):
return "".join(random.choices(string.ascii_uppercase + string.di... | 369 | 11,746 |
onnxruntime | onnxruntime/python/tools/transformers/models/longformer/generate_test_data.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# Generate test data for a longformer model, so that we can use onnxrun... | 348 | 9,617 |
pyro | tests/ops/test_tensor_utils.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import math
import numpy as np
import pytest
import scipy.fftpack as fftpack
import torch
import pyro
from pyro.ops.tensor_utils import (
block_diag_embed,
block_diagonal,
convolve,
dct,
idct,
next_fast_le... | 197 | 6,592 |
wagtail | wagtail/images/rich_text/__init__.py | .py | from wagtail.images import get_image_model
from wagtail.images.formats import get_image_format
from wagtail.rich_text import EmbedHandler
# Front-end conversion
class ImageEmbedHandler(EmbedHandler):
identifier = "image"
@staticmethod
def get_model():
return get_image_model()
@classmethod
... | 43 | 1,253 |
luigi | luigi/batch_notifier.py | .py | """
Library for sending batch notifications from the Luigi scheduler. This module
is internal to Luigi and not designed for use in other contexts.
"""
import collections
import time
from datetime import datetime
import luigi
import luigi.parameter
import luigi.task
from luigi.notifications import email, send_email
... | 208 | 8,797 |
pyomo | examples/pyomobook/nonlinear-ch/deer/DeerProblem.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... | 100 | 2,507 |
luigi | luigi/contrib/hdfs/webhdfs_client.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2015 VNG Corporation
#
# 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... | 175 | 6,482 |
sphinx | tests/roots/test-directive-only/conf.py | .py | project = 'test-directive-only'
exclude_patterns = ['_build']
| 3 | 62 |
textual | docs/examples/widgets/selection_list_selected.py | .py | from textual import on
from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.events import Mount
from textual.widgets import Footer, Header, Pretty, SelectionList
from textual.widgets.selection_list import Selection
class SelectionListApp(App[None]):
CSS_PATH = "selecti... | 41 | 1,461 |
pyfilesystem2 | fs/compress.py | .py | """Functions to compress the contents of a filesystem.
Currently zip and tar are supported, using the `zipfile` and
`tarfile` modules from the standard library.
"""
from __future__ import absolute_import, print_function, unicode_literals
import typing
import six
import tarfile
import time
import zipfile
from dateti... | 188 | 7,048 |
conda | conda/plugins/environment_specifiers/requirements_txt.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
**EXPERIMENTAL**
Register the conda env spec for requirements.txt files.
"""
from .. import hookimpl
from ..types import CondaEnvironmentSpecifier
@hookimpl
def conda_environment_specifiers():
from ...env.specs.requirements import Req... | 23 | 624 |
kafka | docker/docker_build_test.py | .py | #!/usr/bin/env python
# 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 "Lice... | 100 | 5,750 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.