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 |
|---|---|---|---|---|---|
astropy | astropy/modeling/tests/test_units_mapping.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from astropy import units as u
from astropy.modeling.core import Model, fix_inputs
from astropy.modeling.models import Polynomial1D
class _ExampleModel(Model):
n_inputs = 1
n_outputs = 1
def __init__(self):
... | 57 | 1,665 |
saleor | saleor/webhook/tests/subscription_webhooks/subscription_queries.py | .py | from enum import Enum
from graphene.utils.str_converters import to_snake_case
from ....graphql.tests.queries import fragments
from ....graphql.webhook.subscription_types import TRANSLATIONS_TYPES_MAP
ACCOUNT_CONFIRMATION_REQUESTED = (
fragments.CUSTOMER_DETAILS
+ fragments.RECIPIENT_APP_DETAILS
+ """
... | 3,347 | 55,139 |
returns | returns/primitives/hkt.py | .py | from collections.abc import Callable
from typing import TYPE_CHECKING, Any, Generic, Never, Protocol, TypeVar
from typing_extensions import TypeVarTuple
_InstanceType_co = TypeVar('_InstanceType_co', covariant=True)
_TypeArgType1_co = TypeVar('_TypeArgType1_co', covariant=True)
_TypeArgType2_co = TypeVar('_TypeArgTyp... | 278 | 8,587 |
mlflow | mlflow/genai/scorers/ragas/scorers/comparison_metrics.py | .py | from __future__ import annotations
from typing import ClassVar
from mlflow.genai.judges.builtin import _MODEL_API_DOC
from mlflow.genai.scorers.ragas import RagasScorer
from mlflow.utils.docstring_utils import format_docstring
@format_docstring(_MODEL_API_DOC)
class FactualCorrectness(RagasScorer):
"""
Eval... | 170 | 4,406 |
wandb | wandb/sdk/launch/sweeps/utils.py | .py | from __future__ import annotations
import json
import os
import re
from typing import TYPE_CHECKING, Any
import wandb
from wandb import util
from wandb.sdk.launch.errors import LaunchError
if TYPE_CHECKING:
from wandb.apis.public import Api as PublicApi
DEFAULT_SWEEP_COMMAND: list[str] = [
"${env}",
"${... | 327 | 10,199 |
textual | docs/examples/guide/layout/utility_containers.py | .py | from textual.app import App, ComposeResult
from textual.containers import Horizontal, Vertical
from textual.widgets import Static
class UtilityContainersExample(App):
CSS_PATH = "utility_containers.tcss"
def compose(self) -> ComposeResult:
yield Horizontal(
Vertical(
Stati... | 27 | 636 |
onnx | onnx/reference/ops/op_swiglu.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 SwiGLU(OpRun):
def _run(self, a, b, alpha=None):
# SwiGLU requires identical shapes and dtypes for A and B: broadcasting is... | 33 | 1,352 |
textual | docs/examples/styles/border_sub_title_align_all.py | .py | from textual.app import App
from textual.containers import Container, Grid
from textual.widgets import Label
def make_label_container( # (11)!
text: str, id: str, border_title: str, border_subtitle: str
) -> Container:
lbl = Label(text, id=id)
lbl.border_title = border_title
lbl.border_subtitle = bor... | 76 | 2,444 |
wagtail | wagtail/admin/forms/account.py | .py | import io
import os
import warnings
import swapper
from django import forms
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.utils.translation import get_language_info
from django.utils.translation import gettext... | 210 | 6,681 |
astropy | astropy/visualization/wcsaxes/tests/test_coordinate_helpers.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from unittest.mock import MagicMock, patch
import matplotlib.transforms as transforms
import pytest
from matplotlib.backends.backend_agg import FigureCanvasAgg
from matplotlib.figure import Figure
from astropy import units as u
from astropy.io import fi... | 399 | 13,123 |
cvxpy | cvxpy/expressions/constants/callback_param.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... | 56 | 1,814 |
probability | tensorflow_probability/python/bijectors/joint_map_test.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 221 | 8,928 |
astropy | astropy/io/misc/tests/test_hdf5.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
import numpy as np
import pytest
from astropy.io.misc.hdf5 import meta_path
from astropy.table import Column, QTable, Table
from astropy.table.table_helpers import simple_table
from astropy.units import allclose as quantity_allclose
from astro... | 890 | 29,059 |
onnxruntime | orttraining/orttraining/python/training/onnxblock/model_accessor.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
import copy
import os
from contextlib import contextmanager
import onnx
class ModelAccessor:
"""This class stores the onnx model that is manipulated by the onnx blocks.
Attribut... | 171 | 5,769 |
cvxpy | cvxpy/tests/nlp_tests/test_initialization.py | .py | """
Copyright, the CVXPY 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 or agreed to in writing, software
... | 105 | 3,663 |
pymc | tests/variational/test_updates.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... | 93 | 2,821 |
mlflow | mlflow/langchain/databricks_dependencies.py | .py | import importlib
import inspect
import logging
import warnings
from typing import Any, Generator
from mlflow.models.resources import (
DatabricksFunction,
DatabricksServingEndpoint,
DatabricksSQLWarehouse,
DatabricksVectorSearchIndex,
Resource,
)
_logger = logging.getLogger(__name__)
def _get_em... | 439 | 17,896 |
python-prompt-toolkit | examples/progress-bar/two-tasks.py | .py | #!/usr/bin/env python
"""
Two progress bars that run in parallel.
"""
import threading
import time
from prompt_toolkit.shortcuts import ProgressBar
def main():
with ProgressBar() as pb:
# Two parallal tasks.
def task_1():
for i in pb(range(100)):
time.sleep(0.05)
... | 41 | 930 |
mlflow | dev/clint/tests/rules/test_no_class_based_tests.py | .py | from pathlib import Path
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import Position, Range, lint_file
from clint.rules.no_class_based_tests import NoClassBasedTests
def test_no_class_based_tests(index: SymbolIndex) -> None:
code = """import pytest
# Bad - class-based t... | 66 | 1,758 |
biopython | Tests/test_Phylo_igraph.py | .py | # Copyright (C) 2023 by Fabio Zanini (fabio.zanini@unsw.edu.au)
# 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.
"""Unit tests for Bio.Phylo functions with external dependencies."""
import unittest
fr... | 57 | 2,020 |
scikit-bio | skbio/metadata/tests/test_metadata.py | .py | import collections
import unittest
import warnings
from packaging.version import Version
import pandas as pd
import numpy as np
from skbio.metadata._metadata import (SampleMetadata, CategoricalMetadataColumn,
NumericMetadataColumn)
PANDAS_3 = Version(pd.__version__) >= Version(... | 987 | 41,415 |
beam | infra/keys/keys.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 use t... | 383 | 18,113 |
wagtail | wagtail/admin/tests/test_block_preview.py | .py | from django.contrib.auth.models import Permission
from django.http import HttpRequest
from django.test import TestCase
from django.urls import reverse
from django.utils.http import urlencode
from django.utils.translation import gettext_lazy as _
from wagtail import blocks
from wagtail.test.utils import WagtailTestUtil... | 253 | 9,633 |
mlflow | mlflow/server/handlers.py | .py | # Define all the service endpoint handlers here.
import io
import json
import logging
import os
import pathlib
import posixpath
import re
import tempfile
import threading
import time
import unicodedata
import urllib
from collections.abc import Iterable
from functools import partial, wraps
from typing import Any, Callab... | 8,241 | 304,094 |
openvino | tests/layer_tests/onnx_tests/test_conv.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... | 515 | 27,290 |
pyro | pyro/contrib/epidemiology/distributions.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import math
from contextlib import contextmanager
import torch
from torch.distributions.utils import broadcast_all
import pyro.distributions as dist
from pyro.distributions.util import is_validation_enabled
_RELAX = False
_RELAX_MIN... | 342 | 13,549 |
wagtail | wagtail/admin/widgets/auto_height_text.py | .py | from django.forms import widgets
class AdminAutoHeightTextInput(widgets.Textarea):
def __init__(self, attrs=None):
# Use more appropriate rows default, given autosize will alter this anyway
default_attrs = {
"rows": 1,
"data-controller": "w-autosize",
}
if a... | 21 | 606 |
beam | sdks/python/apache_beam/runners/interactive/display/pipeline_graph_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... | 131 | 4,845 |
mlflow | tests/utils/test_semver_utils.py | .py | from functools import cmp_to_key
from itertools import product
import pytest
from mlflow.exceptions import MlflowException
from mlflow.utils.semver_utils import (
SemVer,
compare_semver,
encode_prerelease_sort_key,
parse_semver,
)
def _compare_identifiers(left: str, right: str) -> int:
left_is_n... | 393 | 11,273 |
saleor | saleor/tax/tests/webhooks/test_shared.py | .py | import json
from unittest import mock
import graphene
import pytest
from saleor.core.taxes import TaxDataError
from ....core import EventDeliveryStatus
from ....core.models import EventDelivery
from ....webhook.event_types import WebhookEventSyncType
from ....webhook.models import Webhook, WebhookEvent
from ...webho... | 433 | 13,861 |
coveragepy | tests/zipsrc/zip1/zip1.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
# My zip file!
lighter = "Zippo"
says = "coo-coo cachoo"
| 8 | 216 |
cvxpy | cvxpy/utilities/scopes.py | .py | """
Copyright, the CVXPY 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 or agreed to in writing, software
... | 76 | 2,412 |
mlflow | mlflow/store/artifact/http_artifact_repo.py | .py | import logging
import os
import posixpath
import time
from concurrent.futures import as_completed
import requests
from requests import HTTPError
from mlflow.entities import FileInfo
from mlflow.entities.multipart_upload import (
CreateMultipartUploadResponse,
MultipartUploadCredential,
MultipartUploadPart... | 388 | 16,141 |
mlflow | tests/gateway/providers/test_groq.py | .py | from unittest import mock
import pytest
from fastapi.encoders import jsonable_encoder
from mlflow.gateway.config import EndpointConfig
from mlflow.gateway.providers.groq import GroqProvider
from mlflow.gateway.schemas import chat
from tests.gateway.tools import MockAsyncResponse, mock_http_client
def _make_provide... | 78 | 2,182 |
mlflow | mlflow/genai/labeling/databricks_utils.py | .py | """
Databricks utilities for MLflow GenAI labeling functionality.
"""
_ERROR_MSG = (
"The `databricks-agents` package is required to use labeling functionality. "
"Please install it with `pip install databricks-agents`."
)
def get_databricks_review_app(experiment_id: str | None = None):
"""Import databri... | 19 | 564 |
pyomo | pyomo/contrib/parmest/examples/semibatch/scenario_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... | 58 | 2,042 |
eve | eve/io/mongo/mongo.py | .py | # -*- coding: utf-8 -*-
"""
eve.io.mongo.mongo (eve.io.mongo)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The actual implementation of the MongoDB data layer.
:copyright: (c) 2017 by Nicola Iarocci.
:license: BSD, see LICENSE for more details.
"""
import ast
import decimal
import itertools
from collections ... | 1,182 | 42,804 |
ipython | IPython/terminal/pt_inputhooks/asyncio.py | .py | """
Inputhook for running the original asyncio event loop while we're waiting for
input.
By default, in IPython, we run the prompt with a different asyncio event loop,
because otherwise we risk that people are freezing the prompt by scheduling bad
coroutines. E.g., a coroutine that does a while/true and never yield ba... | 41 | 1,271 |
readthedocs.org | readthedocs/api/v3/urls.py | .py | from .routers import DefaultRouterWithNesting
from .views import BuildsCreateViewSet
from .views import BuildsViewSet
from .views import EnvironmentVariablesViewSet
from .views import NotificationsBuildViewSet
from .views import NotificationsForUserViewSet
from .views import NotificationsOrganizationViewSet
from .views... | 175 | 4,586 |
pyomo | examples/pyomo/piecewise/indexed_nonlinear.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... | 32 | 1,182 |
textual | tests/snapshot_tests/snapshot_apps/layout_containers.py | .py | """
App to test layout containers.
"""
from typing import Iterable
from textual.app import App, ComposeResult
from textual.containers import (
Grid,
Horizontal,
HorizontalScroll,
Vertical,
VerticalScroll,
)
from textual.widget import Widget
from textual.widgets import Button, Input, Label
def su... | 57 | 1,171 |
pyomo | pyomo/kernel/__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... | 289 | 7,445 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script/nteract_with_parameter.py | .py | # ---
# jupyter:
# kernel_info:
# name: python3
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# + inputHidden=false outputHidden=false tags=["parameters"]
param = 4
# + inputHidden=false outputHidden=false
import pandas as pd
# + inputHidden=false outputHidden=fa... | 25 | 522 |
sqlmap | plugins/dbms/extremedb/filesystem.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.exception import SqlmapUnsupportedFeatureException
from plugins.generic.filesystem import Filesystem as GenericFilesystem
class Filesystem(GenericFilesystem):
d... | 19 | 676 |
coremltools | deps/protobuf/benchmarks/python/py_benchmark.py | .py | from __future__ import print_function
import sys
import os
import timeit
import math
import argparse
import fnmatch
import json
parser = argparse.ArgumentParser(description="Python protobuf benchmark")
parser.add_argument("data_files", metavar="dataFile", nargs="+",
help="testing data files.")
pars... | 162 | 6,786 |
pyomo | pyomo/solvers/tests/models/MIQCP_simple.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... | 66 | 2,441 |
mlflow | tests/tracing/utils/test_utils.py | .py | import json
import logging
from unittest import mock
from unittest.mock import Mock, patch
import litellm
import pytest
from opentelemetry import trace as trace_api
from pydantic import ValidationError
import mlflow
from mlflow.entities import (
LiveSpan,
SpanType,
)
from mlflow.entities.span import SpanType
... | 871 | 28,999 |
saleor | saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_deleted_voucher_code.py | .py | import pytest
from ....product.utils.preparing_product import prepare_product
from ....shop.utils import prepare_default_shop
from ....utils import assign_permissions
from ....vouchers.utils import (
create_voucher,
create_voucher_channel_listing,
get_voucher,
voucher_code_bulk_delete,
)
from ...utils ... | 138 | 4,180 |
wagtail | wagtail/api/v3/pagination.py | .py | from math import inf
from typing import Any
from django.conf import settings
from django.db.models import QuerySet
from django.http import HttpRequest
from ninja import Field
from ninja.errors import HttpError
from ninja.pagination import LimitOffsetPagination
def _get_max_limit() -> float | int:
limit_max = get... | 45 | 1,485 |
openvino | tests/layer_tests/pytorch_tests/test_upsample.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from sys import platform
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestUpsample1D(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(1, 3, 224),)
def create_model(s... | 248 | 8,515 |
beam | sdks/python/apache_beam/examples/inference/pytorch_image_classification_with_side_inputs.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... | 218 | 7,979 |
sqlmap | plugins/dbms/oracle/__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 ORACLE_SYSTEM_DBS
from lib.core.unescaper import unescaper
from plugins.dbms.oracle.enumeration import Enumeration
fr... | 30 | 908 |
probability | tensorflow_probability/python/bijectors/iterated_sigmoid_centered.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... | 144 | 5,320 |
ipython | IPython/testing/__init__.py | .py | """Testing support (tools to test IPython itself).
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2009-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this so... | 21 | 784 |
saleor | saleor/graphql/menu/tests/bulk_mutations/test_menu_bulk_delete.py | .py | from unittest import mock
import graphene
import pytest
from .....menu.models import Menu
from ....tests.utils import get_graphql_content
@pytest.fixture
def menu_list():
menu_1 = Menu.objects.create(name="test-navbar-1", slug="test-navbar-1")
menu_2 = Menu.objects.create(name="test-navbar-2", slug="test-na... | 80 | 2,184 |
cvxpy | cvxpy/reductions/eliminate_pwl/canonicalizers/abs_canon.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... | 35 | 1,179 |
pyro | pyro/distributions/distribution.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import functools
import inspect
from abc import ABCMeta, abstractmethod
import torch
from pyro.distributions.score_parts import ScoreParts
COERCIONS = []
class DistributionMeta(ABCMeta):
def __init__(cls, *args, **kwargs):... | 223 | 8,481 |
pyomo | pyomo/dae/tests/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 13 | 571 |
tqdm | examples/include_no_requirements.py | .py | # How to import tqdm in any frontend without enforcing it as a dependency
try:
from tqdm.auto import tqdm
except ImportError:
def tqdm(*args, **kwargs):
if args:
return args[0]
return kwargs.get('iterable', None)
__all__ = ['tqdm']
| 12 | 270 |
funcy | funcy/primitives.py | .py | __all__ = ['isnone', 'notnone', 'inc', 'dec', 'even', 'odd']
class EmptyType:
def __repr__(self):
return 'EMPTY'
EMPTY = EmptyType() # Used as unique default for optional arguments
def isnone(x):
return x is None
def notnone(x):
return x is not None
def inc(x):
return x + 1
def dec(x):
... | 29 | 408 |
onnxruntime | orttraining/orttraining/python/training/ortmodule/_logger.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import logging
import os
import sys
import tempfile
import textwrap
impo... | 300 | 11,247 |
probability | tensorflow_probability/python/distributions/stopping_ratio_logistic.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... | 352 | 12,993 |
pyomo | pyomo/solvers/tests/models/QP_simple.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... | 111 | 3,634 |
gunicorn | tests/requests/invalid/019.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.config import Config
from gunicorn.http.errors import InvalidSchemeHeaders
request = InvalidSchemeHeaders
cfg = Config()
cfg.set('forwarded_allow_ips', '*')
| 11 | 278 |
probability | tensorflow_probability/python/distributions/variational_gaussian_process.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... | 1,370 | 60,713 |
saleor | saleor/graphql/account/mutations/staff/base.py | .py | from ....core.mutations import ModelDeleteMutation, ModelWithExtRefMutation
from ..base import UserDeleteMixin
class UserDelete(UserDeleteMixin, ModelDeleteMutation, ModelWithExtRefMutation):
class Meta:
abstract = True
| 8 | 234 |
saleor | saleor/graphql/attribute/filters.py | .py | import django_filters
import graphene
from django.db.models import Exists, OuterRef, Q
from ...attribute import AttributeInputType
from ...attribute.models import Attribute, AttributeValue
from ...attribute.models.product import AttributeProduct
from ...attribute.models.product_variant import AttributeVariant
from ...... | 346 | 11,522 |
lemur | lemur/pending_certificates/service.py | .py | """
.. module: lemur.pending_certificates.service
Copyright (c) 2018 and onwards Netflix, Inc. All rights reserved.
.. moduleauthor:: James Chuong <jchuong@instartlogic.com>
"""
import arrow
from flask import current_app
from sqlalchemy import or_, cast, Integer
from lemur import database
from lemur.authorities i... | 320 | 11,578 |
onnx | onnx/backend/test/case/node/deformconv.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 DeformConv(Base):
@staticmethod
def export() -> None:
... | 162 | 5,368 |
onnxruntime | onnxruntime/test/python/transformers/test_whisper.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 ... | 919 | 36,603 |
qutip | qutip/core/data/expm.py | .py | import numpy as np
import scipy.sparse.linalg
import scipy.linalg
from .eigen import eigs_dense
from .dense import Dense
from .csr import CSR
from .dia import Dia
from . import dia
from .make import diag
from .matmul import matmul_dense, matmul_dag_dense
from .properties import isdiag_csr, isdiag_dia, isherm_dense
fro... | 172 | 5,439 |
python-prompt-toolkit | tests/test_history.py | .py | from __future__ import annotations
from asyncio import run
from prompt_toolkit.history import FileHistory, InMemoryHistory, ThreadedHistory
def _call_history_load(history):
"""
Helper: Call the history "load" method and return the result as a list of strings.
"""
result = []
async def call_load... | 104 | 3,069 |
wagtail | wagtail/admin/wagtail_hooks.py | .py | import swapper
from django.conf import settings
from django.contrib.auth.models import Permission
from django.urls import reverse, reverse_lazy
from django.utils.functional import cached_property
from django.utils.http import urlencode
from django.utils.translation import gettext_lazy as _
from draftjs_exporter import ... | 1,200 | 34,215 |
wagtail | wagtail/tests/test_hooks.py | .py | from unittest import mock
from django.contrib.sessions.middleware import SessionMiddleware
from django.http import HttpResponse
from django.test import RequestFactory, TestCase
from wagtail import hooks
from wagtail.models import PageViewRestriction
from wagtail.test.utils import Page, PageFixturesMixin, WagtailTestU... | 202 | 7,021 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/filter_lambda.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,137 |
pyomo | doc/OnlineDocs/src/dataportal/set_initialization.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 54 | 1,426 |
sphinx | tests/test_util/test_util_images.py | .py | """Test images util."""
from __future__ import annotations
import pytest
from sphinx.util.images import (
get_image_extension,
get_image_size,
guess_mimetype,
parse_data_uri,
)
TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path
GIF_FILENAME = 'img.gif'
PNG_FILENAME = 'img.png'
PDF... | 101 | 3,306 |
wagtail | wagtail/api/v3/tests/test_page_schemas.py | .py | import json
from typing import Any, cast
from django.test import TestCase
from wagtail.api.v3.schemas import BasePageSchema, read_generator
from wagtail.images.models import Image
from wagtail.images.tests.utils import get_test_image_file
from wagtail.test.demosite.models import BlogEntryPage, BlogIndexPage, HomePage... | 206 | 8,402 |
gunicorn | gunicorn/uwsgi/errors.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# We don't need to call super() in __init__ methods of our
# BaseException and Exception classes because we also define
# our own __str__ methods so there is no need to pass 'message'
# to the base class to get a m... | 47 | 1,318 |
onnxruntime | cmake/maccatalyst_prepare_objects_for_prelink.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
import shutil
import sys
# Note: This script is mainly used for sanity checking/validating the files in the .a library equal to the .o files
# in the source dir to handle the case of source ... | 73 | 2,958 |
kafka | tests/kafkatest/tests/client/consumer_protocol_migration_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 use ... | 335 | 15,972 |
onnxruntime | onnxruntime/test/testdata/model_with_external_initializer_come_from_user.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import numpy as np
import onnx
from onnx import TensorProto, helper
from onnx.external_data_helper import set_external_data
from onnx.numpy_helper import from_array
def create_external_data_tensor(value, tensor_name): # ty... | 61 | 2,069 |
jupytext | tests/external/docs/test_using_cli.py | .py | import os
import shlex
import pytest
from nbformat.v4.nbbase import new_code_cell, new_notebook
import jupytext
from jupytext.cli import jupytext as jupytext_cli
doc_path = os.path.join(os.path.dirname(__file__), "..", "..", "..", "website", "src", "content", "docs")
@pytest.mark.requires_user_kernel_python3
@pyte... | 57 | 1,866 |
biopython | Tests/test_PDB_alphafold_db.py | .py | """Tests for the alphafold_db module."""
import os
import unittest
import requires_internet
from Bio.PDB import alphafold_db
requires_internet.check()
class AlphafoldDBTests(unittest.TestCase):
def test_get_predictions(self):
predictions = alphafold_db.get_predictions("P00520")
for prediction... | 27 | 768 |
openvino | tests/e2e_tests/common/ref_collector/tf_hub_ref_provider.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import inspect
from e2e_tests.common.common.base_provider import BaseProvider, BaseStepProvider
class ClassProvider(BaseProvider):
registry = {}
@classmethod
def validate(cls):
methods = [
f[0] for f i... | 34 | 1,028 |
sqlmap | plugins/dbms/cubrid/takeover.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.exception import SqlmapUnsupportedFeatureException
from plugins.generic.takeover import Takeover as GenericTakeover
class Takeover(GenericTakeover):
def osCmd(s... | 29 | 970 |
sqlmap | lib/techniques/xslt/inject.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
"""
XSLT injection ('--xslt').
An application that builds a stylesheet by concatenating user input hands over a whole transformation
language, not just a value. The tiers are ord... | 683 | 33,634 |
wagtail | wagtail/test/apps.py | .py | from wagtail.users.apps import WagtailUsersAppConfig
class CustomUsersAppConfig(WagtailUsersAppConfig):
user_viewset = "wagtail.test.customuser.viewsets.CustomUserViewSet"
| 6 | 178 |
saleor | saleor/graphql/page/tests/queries/pages_with_where/test_with_where_unassigned_attribute.py | .py | import graphene
import pytest
from ......attribute.utils import associate_attribute_values_to_instance
from .....tests.utils import get_graphql_content
PAGE_UNASSIGN_ATTR_MUTATION = """
mutation PageAttributeUnassign($pageTypeId: ID!, $attributeIds: [ID!]!) {
pageAttributeUnassign(
pageTypeId:... | 92 | 2,789 |
openvino | tests/e2e_tests/pipelines/pipeline_templates/preproc_templates.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Preprocessing templates processed by testing framework.
"""
from collections import OrderedDict
def assemble_preproc(batch=None,
h=None,
w=None,
resize_mode="nearest",
... | 191 | 6,930 |
scikit-bio | skbio/sequence/_repr.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.
# --------------------------------------------... | 112 | 4,258 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_conv2d_transpose.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import paddle
paddle.enable_static()
from save_model import saveModel
import sys
def run_and_save_model(input_x, name, feed, fetch_list, main_prog, start_prog):
cpu = paddle.static.cpu_places(1)
exe = paddle.... | 148 | 7,023 |
onnxruntime | onnxruntime/python/tools/transformers/models/stable_diffusion/engine_builder_tensorrt.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# Modified from TensorRT demo diffusion, which has the following license... | 396 | 15,621 |
clearml | clearml/backend_interface/model.py | .py | import logging
from collections import namedtuple
from functools import partial
from typing import Optional, Callable, Union, Dict, List, Any
from pathlib2 import Path
from .base import IdObjectBase
from .util import make_message
from ..backend_api import Session
from ..backend_api.services import models, tasks
from ... | 678 | 22,559 |
hypercorn | src/hypercorn/protocol/h11.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable
from itertools import chain
from typing import cast
import h11
from .events import (
Body,
Data,
EndBody,
EndData,
Event as StreamEvent,
InformationalResponse,
Request,
Response,
StreamClosed,
)
fro... | 324 | 11,873 |
mlflow | examples/shap/explainer_logging.py | .py | import shap
import sklearn
from sklearn.datasets import load_diabetes
import mlflow
# prepare training data
X, y = load_diabetes(return_X_y=True, as_frame=True)
# train a model
model = sklearn.ensemble.RandomForestRegressor(n_estimators=100)
model.fit(X, y)
# create an explainer
explainer_original = shap.Explainer(... | 28 | 710 |
onnxruntime | onnxruntime/python/tools/pytorch_export_contrib_ops.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Support for registering ONNX Runtime's built-in contrib ops with
PyTorch-ONNX exporter (torch.onnx.export).
"""
import contextlib
import typing
try:
# TODO(justinchuby): Create a function to alert users when torch i... | 138 | 5,214 |
saleor | saleor/graphql/webhook/tests/mutations/test_webhook_create.py | .py | import json
from unittest.mock import patch
import graphene
import pytest
from .....app.error_codes import AppErrorCode
from .....webhook.error_codes import WebhookErrorCode
from .....webhook.models import Webhook
from ....tests.utils import assert_no_permission, get_graphql_content
from ...enums import WebhookEventT... | 607 | 17,462 |
astropy | astropy/uncertainty/tests/test_containers.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Test that Distribution works with classes other than ndarray and Quantity."""
import numpy as np
import pytest
from numpy.testing import assert_array_equal
import astropy.units as u
from astropy.coordinates import (
Angle,
CartesianDifferentia... | 232 | 8,959 |
onnx | onnx/backend/test/case/node/less_equal.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 Less(Base):
@staticmethod
def export() -> None:
node =... | 69 | 2,508 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.