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 |
|---|---|---|---|---|---|
pyomo | pyomo/contrib/pynumero/__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 | 622 |
onnx | onnx/backend/test/case/node/abs.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 Abs(Base):
@staticmethod
def export() -> None:
node = ... | 25 | 567 |
readthedocs.org | readthedocs/core/tests/test_signup.py | .py | from unittest.mock import patch
from allauth.account.models import EmailAddress
from allauth.account.signals import email_confirmed
from django.conf import settings
from django.test import TestCase
class TestNewsletterSignup(TestCase):
def setUp(self):
self.form_data = {
"email": "test123@gma... | 55 | 1,863 |
saleor | saleor/graphql/product/tests/mutations/test_product_variant_stocks_update.py | .py | from unittest.mock import ANY, patch
import graphene
import pytest
from django.core.exceptions import ValidationError
from django.db.models import Sum
from .....warehouse.error_codes import StockErrorCode
from .....warehouse.models import Stock, Warehouse
from ....tests.utils import get_graphql_content
from ...bulk_m... | 896 | 28,903 |
cvxpy | cvxpy/atoms/gen_lambda_max.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... | 111 | 3,494 |
coremltools | coremltools/optimize/coreml/_config.py | .py | # Copyright (c) 2020, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from __future__ import annotations
import sys
from abc import ABC, abstractmethod
from collections i... | 1,199 | 51,115 |
hydra | hydra/plugins/config_source.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import re
from abc import abstractmethod
from dataclasses import dataclass
from typing import Dict, List, Optional
from omegaconf import Container
from hydra.core.default_element import InputDefault
from hydra.core.object_type import ObjectType
fr... | 154 | 4,915 |
saleor | saleor/core/tests/test_taxes.py | .py | import graphene
import pytest
from ...app.models import App
from ...permission.enums import (
CheckoutPermissions,
get_permissions_from_codenames,
)
from ...webhook.event_types import WebhookEventSyncType
from ...webhook.models import Webhook, WebhookEvent
@pytest.fixture
def app_factory():
def factory(n... | 63 | 1,788 |
mlflow | tests/tensorflow/test_keras_model_export.py | .py | import os
import random
import shutil
from pathlib import Path
from unittest import mock
import numpy as np
import pandas as pd
import pytest
import tensorflow as tf
import yaml
from packaging.version import Version
from sklearn import datasets
from tensorflow.keras import backend as K
from tensorflow.keras.layers imp... | 746 | 27,844 |
coremltools | deps/protobuf/python/docs/conf.py | .py | # -*- coding: utf-8 -*-
# Protocol Buffers - Google's data interchange format
# Copyright 2019 Google LLC. 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 a... | 255 | 8,260 |
sphinx | tests/roots/test-ext-autosummary-recursive/package/module_importfail.py | .py | # Fail module import in a catastrophic way
raise SystemExit(1)
| 3 | 63 |
saleor | saleor/graphql/meta/tests/mutations/test_update_metadata.py | .py | import base64
from unittest.mock import patch
import graphene
import pytest
from django.core.exceptions import ValidationError
from django.db import transaction
from .....checkout.models import Checkout
from .....core.error_codes import MetadataErrorCode
from .....core.models import ModelWithMetadata
from .....tests ... | 332 | 9,511 |
returns | returns/interfaces/failable.py | .py | from abc import abstractmethod
from collections.abc import Callable, Sequence
from typing import ClassVar, Never, TypeVar, final
from returns.interfaces import container as _container
from returns.interfaces import lashable, swappable
from returns.primitives.asserts import assert_equal
from returns.primitives.hkt impo... | 265 | 7,937 |
saleor | saleor/graphql/checkout/mutations/checkout_create_from_order.py | .py | from typing import Any, cast
import graphene
from django.contrib.sites.models import Site
from ....checkout import models as checkout_models
from ....checkout.utils import add_variants_to_checkout
from ....core.exceptions import InsufficientStock
from ....core.utils.country import get_active_country
from ....order im... | 430 | 16,005 |
textual | tests/snapshot_tests/snapshot_apps/disable_widgets.py | .py | from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Button
class WidgetDisableTestApp(App[None]):
CSS = """
Horizontal {
height: auto;
}
Button {
width: 1fr;
}
"""
def compose(self) -> ComposeResult:
for... | 35 | 915 |
mlflow | mlflow/data/huggingface_dataset.py | .py | import json
import logging
from functools import cached_property
from typing import TYPE_CHECKING, Any, Mapping, Sequence
from mlflow.data.dataset import Dataset
from mlflow.data.dataset_source import DatasetSource
from mlflow.data.digest_utils import compute_pandas_digest
from mlflow.data.evaluation_dataset import Ev... | 259 | 10,499 |
sphinx | tests/test_directives/test_directive_only.py | .py | """Test the only directive with the test root."""
from __future__ import annotations
import re
from typing import TYPE_CHECKING
import pytest
from docutils import nodes
if TYPE_CHECKING:
from typing import Any
from sphinx.testing.util import SphinxTestApp
@pytest.mark.sphinx('text', testroot='directive-o... | 64 | 2,146 |
hatch | src/hatch/dep/sync.py | .py | from __future__ import annotations
import re
import sys
from importlib.metadata import Distribution, DistributionFinder
from typing import TYPE_CHECKING
from packaging.markers import default_environment
from hatch.dep.core import Dependency
from hatch.utils.fs import Path
if TYPE_CHECKING:
from collections.abc ... | 157 | 6,479 |
saleor | saleor/graphql/product/tests/deprecated/test_collection.py | .py | import json
import warnings
from .....channel.utils import DEPRECATION_WARNING_MESSAGE
from ....tests.utils import get_graphql_content
def test_collections_query_with_default_channel_slug(
user_api_client,
published_collection,
unpublished_collection,
permission_manage_products,
channel_USD,
):
... | 50 | 1,509 |
pymc | tests/distributions/test_random_alternative_backends.py | .py | # Copyright 2025 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 67 | 2,539 |
openvino | tools/ovc/openvino/tools/ovc/moc_frontend/jax_frontend_utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
def get_jax_decoder(model, args):
try:
from openvino.frontend.jax.jaxpr_decoder import JaxprPythonDecoder
except Exception as e:
log.error("JAX frontend loading failed")
raise e
... | 20 | 481 |
jupytext | tests/data/notebooks/inputs/marimo/basic_marimo_example.py | .py | import marimo
__generated_with = "0.17.8"
app = marimo.App()
@app.cell(hide_code=True)
def _(mo):
mo.md(r"""
This is a simple marimo notebook
""")
return
@app.cell
def _():
x = 1
return (x,)
@app.cell
def _(x):
y = x+1
y
return
@app.cell
def _():
import marimo as mo
... | 36 | 376 |
wandb | wandb/sdk/lib/wbauth/saas.py | .py | from urllib.parse import urlsplit
def is_wandb_domain(url: str) -> bool:
"""Returns whether the URL points to an official W&B server."""
_, netloc, _, _, _ = urlsplit(url)
return netloc.endswith("wandb.ai")
| 8 | 221 |
openvino | src/frontends/tensorflow/tests/test_models/gen_scripts/generate_tf1_if_with_nonexistent_op.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import numpy as np
import tensorflow as tf
from tensorflow.python.framework.convert_to_constants import convert_variables_to_constants_v2
# generate a model with TF1 If operation that contains unsupported operatio... | 60 | 2,187 |
pyro | pyro/distributions/transforms/spline_coupling.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import torch
from pyro.nn import DenseNN
from .. import constraints
from ..torch_transform import TransformModule
from ..util import copy_docs_from
from .spline import ConditionalSpline, Spline
@copy_docs_from(TransformModule)
clas... | 199 | 6,917 |
pymc | tests/logprob/test_arithmetic.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... | 67 | 2,599 |
saleor | saleor/graphql/attribute/tests/queries/test_selected_attribute.py | .py | from datetime import UTC, datetime
import graphene
from .....attribute import AttributeEntityType, AttributeInputType, AttributeType
from .....attribute.models.base import AttributeValue, AttributeValueTranslation
from .....attribute.utils import associate_attribute_values_to_instance
from ....tests.utils import get_... | 1,780 | 51,822 |
textual | docs/examples/guide/dom1.py | .py | from textual.app import App
class ExampleApp(App):
pass
if __name__ == "__main__":
app = ExampleApp()
app.run()
| 11 | 128 |
readthedocs.org | readthedocs/oauth/tests/test_models.py | .py | from django.core.exceptions import ValidationError
from django.test import TestCase
from django_dynamic_fixture import get
from readthedocs.oauth.models import RemoteRepository
from readthedocs.oauth.validators import CloneURLValidator
from readthedocs.oauth.validators import SshURLValidator
from readthedocs.projects.... | 127 | 4,683 |
saleor | saleor/graphql/invoice/tests/test_invoice_request_delete.py | .py | from unittest.mock import patch
import graphene
import pytest
from ....graphql.tests.utils import assert_no_permission, get_graphql_content
from ....invoice.error_codes import InvoiceErrorCode
from ....invoice.models import Invoice, InvoiceEvent, InvoiceEvents
INVOICE_REQUEST_DELETE_MUTATION = """
mutation invoi... | 133 | 3,996 |
onnx | onnx/reference/ops/aionnxml/op_normalizer.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.aionnxml._op_run_aionnxml import OpRunAiOnnxMl
class Normalizer(OpRunAiOnnxMl):
@staticmethod
def norm_max(x):
"""Max normalization"""
... | 42 | 1,158 |
hydra | tests/standalone_apps/initialization_test_app/initialization_test_app/main.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import sys
from hydra import compose, initialize, initialize_config_dir, initialize_config_module
def main() -> None:
with initialize(config_path="conf"):
cfg = compose(config_name="config", return_hydra_config=True)
... | 48 | 1,913 |
astropy | astropy/nddata/tests/test_ccddata.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
import sys
import textwrap
import numpy as np
import pytest
from astropy import log
from astropy import units as u
from astropy.io import fits
from astropy.nddata import _testing as nd_testing
from astropy.nddata.ccddata import CCDData
from as... | 1,249 | 44,089 |
saleor | saleor/graphql/order/tests/integration/test_draft_order.py | .py | import graphene
import pytest
from .....order import OrderStatus
from ....account.tests.mutations.permission_group.test_permission_group_update import (
PERMISSION_GROUP_UPDATE_MUTATION,
)
from ....tests.utils import assert_no_permission, get_graphql_content
from ..mutations.test_draft_order_complete import DRAFT_... | 159 | 5,278 |
saleor | saleor/graphql/account/bulk_mutations/staff_bulk_delete.py | .py | from collections import defaultdict
from django.conf import settings
from django.core.exceptions import ValidationError
from ....account import models
from ....attribute.utils import delete_user_unique_attribute_values
from ....core.tracing import traced_atomic_transaction
from ....giftcard.utils import deactivate_as... | 86 | 3,506 |
openvino | tests/layer_tests/pytorch_tests/test_lstm.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
# torch.nn.modules.rnn performs tensor-to-bool shape checks (input_size and
# hidden_size validation) inside the traced forward pass. T... | 207 | 8,764 |
attrs | src/attrs/setters.py | .py | # SPDX-License-Identifier: MIT
from attr.setters import * # noqa: F403
| 4 | 73 |
hypercorn | src/hypercorn/middleware/dispatcher.py | .py | from __future__ import annotations
import asyncio
from collections.abc import Callable
from functools import partial
from ..asyncio.task_group import TaskGroup
from ..typing import ASGIFramework, ASGIReceiveEvent, Scope
MAX_QUEUE_SIZE = 10
class _DispatcherMiddleware:
def __init__(self, mounts: dict[str, ASGIF... | 112 | 4,403 |
confluent-kafka-python | src/confluent_kafka/schema_registry/common/schema_registry_client.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2020 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... | 1,266 | 40,945 |
probability | tensorflow_probability/python/experimental/linalg/no_pivot_ldl.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... | 175 | 7,222 |
luigi | test/worker_external_task_test.py | .py | # Copyright (c) 2015
#
# 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
# d... | 196 | 6,493 |
probability | tensorflow_probability/python/distributions/pert_test.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... | 225 | 9,293 |
confluent-kafka-python | src/confluent_kafka/_oauthbearer/aws/aws_oauthbearer_config.py | .py | # Copyright 2026 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | 230 | 9,051 |
mlflow | mlflow/genai/judges/prompts/fluency.py | .py | # NB: User-facing name for the fluency assessment.
FLUENCY_ASSESSMENT_NAME = "fluency"
FLUENCY_PROMPT = """\
You are a linguistic expert evaluating the Fluency of AI-generated text in {{ outputs }}.
Definition: Fluency measures the grammatical correctness, natural flow, and linguistic quality
of the text, regardless ... | 16 | 661 |
mlflow | mlflow/config/__init__.py | .py | from mlflow.environment_variables import (
MLFLOW_ENABLE_ASYNC_LOGGING,
)
from mlflow.system_metrics import (
disable_system_metrics_logging,
enable_system_metrics_logging,
set_system_metrics_node_id,
set_system_metrics_samples_before_logging,
set_system_metrics_sampling_interval,
)
from mlflow.... | 57 | 1,456 |
saleor | saleor/graphql/product/mutations/product/product_create.py | .py | import graphene
from django.core.exceptions import ValidationError
from .....attribute import models as attribute_models
from .....core.tracing import traced_atomic_transaction
from .....permission.enums import ProductPermissions
from .....product import models
from ....attribute.types import AttributeValueInput
from ... | 202 | 7,666 |
pyomo | examples/pyomo/suffixes/sipopt_hicks.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... | 268 | 7,271 |
pynacl | setup.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... | 202 | 5,888 |
clearml | clearml/utilities/requests_toolbelt/__init__.py | .py | # -*- coding: utf-8 -*-
"""
requests-toolbelt
=================
See https://toolbelt.readthedocs.io/ for documentation
:copyright: (c) 2014 by Ian Cordasco and Cory Benfield
:license: Apache v2.0, see LICENSE for more details
"""
from .multipart import (
MultipartEncoder, MultipartEncoderMonitor, MultipartDecode... | 30 | 918 |
ipython | IPython/core/magic.py | .py | from __future__ import annotations
"""Magic functions for InteractiveShell."""
# -----------------------------------------------------------------------------
# Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
# Copyright (C) 2001 Fernando Perez <fperez@colorado.edu>
# Copyright (C) 2008 The IPython Develop... | 829 | 30,953 |
wandb | wandb/cli/beta_core.py | .py | """Implements `wandb beta core` helpers.
These helpers manage a detached `wandb-core` process intended to be reused by
multiple independent Python processes on the same host.
Discovery is explicit via the WANDB_SERVICE environment variable.
"""
from __future__ import annotations
import logging
import click
from w... | 113 | 3,679 |
onnxruntime | tools/ci_build/linux_java_copy_strip_binary.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Prepares native shared libraries for the ONNX Runtime Java package.
This script is a build utility that run as part of a packaging pipeline and takes compiled C/C++ shared libraries
(.so, .dylib) a... | 198 | 8,406 |
beam | sdks/python/apache_beam/testing/benchmarks/inference/tensorflow_mnist_classification_cost_benchmark.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... | 42 | 1,652 |
saleor | saleor/webhook/transport/synchronous/tests/test_transport.py | .py | from unittest.mock import MagicMock, patch
import pytest
from opentelemetry.trace import StatusCode
from .....core.models import EventDeliveryStatus
from .....core.telemetry import set_global_attributes
from .....tests.utils import get_metric_data_point
from ...metrics import (
METRIC_EXTERNAL_REQUEST_BODY_SIZE,
... | 272 | 10,197 |
onnxruntime | tools/ci_build/github/apple/get_simulator_device_info.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 functools
import itertools
import json
import os
import subprocess
@functools.total_ordering
class Version: # noqa: PLW1641
"""
A si... | 166 | 6,360 |
sphinx | tests/roots/test-ext-autodoc/autodoc_dummy_module.py | .py | from dummy import * # NoQA: F403
def test():
"""Dummy function using dummy.*"""
dummy_function() # NoQA: F405
| 7 | 122 |
saleor | saleor/graphql/webhook/enums.py | .py | import graphene
from ...webhook.event_types import WebhookEventAsyncType, WebhookEventSyncType
from ..core.descriptions import (
ADDED_IN_323,
DEFAULT_DEPRECATION_REASON,
DEPRECATED_LEGACY_PAYMENTS,
)
from ..core.doc_category import DOC_CATEGORY_WEBHOOKS
from ..core.types import BaseEnum
from ..core.utils ... | 354 | 18,592 |
pyomo | pyomo/contrib/parmest/examples/rooney_biegler/regularization_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... | 93 | 3,359 |
onnxruntime | onnxruntime/test/python/onnxruntime_test_python_azure.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import unittest
import onnxruntime as ort
class TestAzureEP(unittest.TestCase):
def test_availability(self):
self.assertIn("AzureExecutionProvider", ort.get_available_providers())
if __name__ == "__main__":
... | 16 | 339 |
sqlmap | plugins/generic/connector.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import os
from lib.core.data import conf
from lib.core.data import logger
from lib.core.exception import SqlmapFilePathException
from lib.core.exception import SqlmapUndefinedMet... | 83 | 2,483 |
saleor | saleor/graphql/core/scalars.py | .py | import datetime
import decimal
import graphene
from graphene.types.generic import GenericScalar
from graphql.language import ast
from measurement.measures import Weight
from ...core.weight import (
convert_weight_to_default_weight_unit,
get_default_weight_unit,
)
class Decimal(graphene.Float):
"""Custom... | 264 | 7,885 |
deap | examples/es/onefifth.py | .py |
# This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed... | 81 | 2,770 |
probability | tensorflow_probability/python/internal/backend/numpy/numpy_keras.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... | 24 | 857 |
sphinx | tests/roots/test-ext-viewcode/spam/mod3.py | .py | from spam.mod1 import Class3
__all__ = ('Class3',)
| 4 | 52 |
coremltools | coremltools/optimize/torch/pruning/__init__.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
"""
.. _coremltools_optimize_torch_pruning:
.. include:: pruning_desc.rst
_`MagnitudePruner`
======... | 59 | 1,775 |
onnx | onnx/reference/ops/op_xor.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 Xor(OpRunBinary):
def _run(self, x, y):
return (np.logical_xor(x, y),)
| 14 | 275 |
django-cms | cms/test_utils/project/sampleapp/cms_toolbars.py | .py | from django.utils.translation import gettext_lazy as _
from cms.cms_toolbars import ADMIN_MENU_IDENTIFIER, ADMINISTRATION_BREAK
from cms.toolbar.items import Break
from cms.toolbar_base import CMSToolbar
from cms.toolbar_pool import toolbar_pool
from cms.utils.urlutils import admin_reverse
SAMPLEAPP_BREAK = 'Sample A... | 33 | 1,146 |
onnx | onnx/reference/ops/op_sequence_construct.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from onnx.reference.op_run import OpRun
class SequenceConstruct(OpRun):
def _run(self, *data):
return (list(data),)
| 12 | 247 |
beam | learning/katas/python/Core Transforms/Map/ParDo/tests/test_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"); you may not... | 33 | 1,127 |
textual | tests/layouts/test_horizontal.py | .py | import pytest
from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widget import Widget
@pytest.fixture
async def app():
class HorizontalAutoWidth(App):
def compose(self) -> ComposeResult:
child1 = Widget(id="child1")
child1.styles.widt... | 30 | 828 |
scikit-optimize | skopt/optimizer/gbrt.py | .py |
from sklearn.utils import check_random_state
from .base import base_minimize
from ..utils import cook_estimator
def gbrt_minimize(func, dimensions, base_estimator=None,
n_calls=100, n_random_starts=None,
n_initial_points=10,
initial_point_generator="random",
... | 188 | 8,069 |
hatch | src/hatch/cli/shell/__init__.py | .py | from __future__ import annotations
import os
from typing import TYPE_CHECKING
import click
from hatch.config.constants import AppEnvVars
if TYPE_CHECKING:
from hatch.cli.application import Application
@click.command(short_help="Enter a shell within a project's environment")
@click.argument("env_name", require... | 60 | 2,055 |
mlflow | tests/genai/evaluate/test_pytest_integration.py | .py | from __future__ import annotations
import os
import subprocess
import sys
import textwrap
from pathlib import Path
from mlflow.pytest.session import TAG_TEST_NAME
from mlflow.tracking import MlflowClient
_GENERATED_TEST = """
import mlflow
from mlflow.genai.scorers import scorer
@scorer
def always_pass(*, outputs)... | 62 | 1,651 |
onnx | onnx/backend/test/case/node/round.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 Round(Base):
@staticmethod
def export() -> None:
node ... | 63 | 1,322 |
pyomo | pyomo/contrib/pynumero/build.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... | 31 | 1,077 |
probability | tensorflow_probability/python/bijectors/matrix_inverse_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... | 115 | 4,156 |
pyomo | pyomo/contrib/latex_printer/tests/test_latex_printer.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... | 774 | 26,445 |
httpie | setup.py | .py | from setuptools import setup
setup()
| 4 | 38 |
mlflow | tests/store/workspace/test_workspace_validator.py | .py | import pytest
from mlflow.exceptions import MlflowException
from mlflow.store.workspace.abstract_store import WorkspaceNameValidator
@pytest.mark.parametrize(
"name",
[
"team-a",
"ab",
"a" * 63,
"123",
"a1-b2",
"team--a",
],
)
def test_workspace_name_valida... | 39 | 1,019 |
sphinx | tests/roots/test-templating/conf.py | .py | project = 'Sphinx templating <Tests>'
source_suffix = {
'.txt': 'restructuredtext',
}
keep_warnings = True
templates_path = ['_templates']
release = version = '2013.120'
exclude_patterns = ['_build']
extensions = ['sphinx.ext.autosummary']
autosummary_generate = ['autosummary_templating']
| 12 | 295 |
mlflow | mlflow/tracing/utils/otlp.py | .py | import base64
import gzip
import os
import zlib
from typing import Any
from opentelemetry.proto.common.v1.common_pb2 import AnyValue, ArrayValue, KeyValueList
from opentelemetry.proto.resource.v1.resource_pb2 import Resource as OTelProtoResource
from opentelemetry.sdk.resources import Resource as OTelResource
from ope... | 286 | 10,344 |
pyomo | pyomo/dae/tests/test_colloc.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... | 731 | 25,272 |
coremltools | deps/pybind11/tests/test_python_multiple_inheritance.py | .py | # Adapted from:
# https://github.com/google/clif/blob/5718e4d0807fd3b6a8187dde140069120b81ecef/clif/testing/python/python_multiple_inheritance_test.py
from __future__ import annotations
from pybind11_tests import python_multiple_inheritance as m
class PC(m.CppBase):
pass
class PPCC(PC, m.CppDrvd):
pass
d... | 37 | 894 |
openvino | tests/layer_tests/pytorch_tests/test_numel.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestNumel(PytorchLayerTest):
def _prepare_input(self, input_shape=(2)):
return (self.random.randn(*input_shape),)
def create_model(self):
... | 36 | 1,054 |
sqlmap | extra/esperanto/records.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
class OracleUndecided(RuntimeError):
"""The oracle gave no reliable True/False after retries/voting - a transport or
observation failure, NOT a definitive answer. Raised s... | 320 | 15,420 |
pdm | src/pdm/resolver/base.py | .py | from __future__ import annotations
import abc
import typing as t
from dataclasses import dataclass, field
from resolvelib import BaseReporter
from pdm.models.candidates import Candidate
from pdm.models.repositories import LockedRepository
if t.TYPE_CHECKING:
from pdm.environments import BaseEnvironment
from... | 69 | 2,141 |
mlflow | mlflow/entities/metric.py | .py | from mlflow.entities._mlflow_object import _MlflowObject
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
from mlflow.protos.service_pb2 import Metric as ProtoMetric
from mlflow.protos.service_pb2 import MetricWithRunId as ProtoMetricWithRunId
class Metric... | 196 | 5,538 |
pyro | examples/contrib/autoname/scoping_mixture.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import argparse
import torch
from torch.distributions import constraints
import pyro
import pyro.distributions as dist
import pyro.optim
from pyro.contrib.autoname import scope
from pyro.infer import SVI, TraceEnum_ELBO, config_e... | 79 | 2,239 |
openvino | tests/layer_tests/pytorch_tests/test_repeat_interleave.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
import numpy as np
import random
import torch
@pytest.mark.parametrize('input_data', ({'repeats': 1, 'dim': 0},
{'repeats': 2, ... | 134 | 5,841 |
qutip | qutip/core/coefficient.py | .py | # Required for Sphinx to follow autodoc_type_aliases
from __future__ import annotations
import os
import numpy as np
from numpy.typing import ArrayLike
import scipy
import scipy.interpolate
import sys
import re
import dis
import hashlib
import glob
import importlib
import warnings
import numbers
from collections impor... | 867 | 28,128 |
readthedocs.org | readthedocs/notifications/signals.py | .py | """Custom Django signals related to notifications."""
import structlog
from allauth.account.models import EmailAddress
from django.db.models.signals import post_save
from django.dispatch import receiver
from readthedocs.core.notifications import MESSAGE_EMAIL_VALIDATION_PENDING
from readthedocs.notifications.models i... | 79 | 2,786 |
coremltools | coremltools/test/xgboost_tests/test_decision_tree_classifier.py | .py | # Copyright (c) 2017, 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 unittest
import numpy as np
from ..utils import load_boston
from coremltools._deps import _HAS_... | 147 | 5,114 |
pyro | pyro/distributions/unit.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.distributions import constraints
from pyro.distributions.torch_distribution import TorchDistribution
from pyro.distributions.util import broadcast_shape
class Unit(TorchDistribution):
"""
Trivial ... | 51 | 1,886 |
marshmallow | src/marshmallow/decorators.py | .py | """Decorators for registering schema pre-processing and post-processing methods.
These should be imported from the top-level `marshmallow` module.
Methods decorated with
`pre_load <marshmallow.decorators.pre_load>`, `post_load <marshmallow.decorators.post_load>`,
`pre_dump <marshmallow.decorators.pre_dump>`, `post_dum... | 255 | 10,165 |
hatch | src/hatch/cli/clean/__init__.py | .py | import click
@click.command(short_help="Remove build artifacts")
@click.argument("location", required=False)
@click.option(
"--target",
"-t",
"targets",
multiple=True,
help=(
"The target with which to remove artifacts, overriding project defaults. "
"This may be selected multiple t... | 42 | 1,218 |
django-cms | cms/models/apphooks_reload.py | .py | import uuid
from django.db import models
class UrlconfRevision(models.Model):
revision = models.CharField(max_length=255)
class Meta:
app_label = 'cms'
def save(self, *args, **kwargs):
"""
Simply forces this model to be a singleton.
"""
self.pk = 1
super(... | 40 | 1,029 |
pyfilesystem2 | fs/multifs.py | .py | """Manage several filesystems through a single view.
"""
from __future__ import absolute_import, print_function, unicode_literals
import typing
from collections import OrderedDict, namedtuple
from operator import itemgetter
from six import text_type
from . import errors
from .base import FS
from .mode import check_... | 427 | 13,183 |
wagtail | wagtail/documents/tests/test_bulk_actions/test_bulk_delete.py | .py | from django.contrib.auth.models import Permission
from django.test import TestCase
from django.urls import reverse
from django.utils.http import urlencode
from wagtail.documents import get_document_model
from wagtail.test.testapp.models import VariousOnDeleteModel
from wagtail.test.utils import WagtailTestUtils
Docum... | 136 | 5,106 |
astropy | astropy/time/tests/test_comparisons.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import operator
import numpy as np
import pytest
import astropy.units as u
from astropy.time import Time, TimeDelta
class TestTimeComparisons:
"""Test Comparisons of Time and TimeDelta classes"""
def setup_method(self):
self.t1 = Time... | 219 | 7,287 |
biopython | Bio/motifs/jaspar/__init__.py | .py | # Copyright 2013 by Anthony Mathelier and David Arenillas. 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.
""... | 375 | 11,388 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.