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 |
|---|---|---|---|---|---|
probability | discussion/robust_inverse_graphics/models.py | .py | # Copyright 2024 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,051 | 30,629 |
openvino | docs/openvino_custom_sphinx_sitemap/openvino_custom_sphinx_sitemap/__init__.py | .py | import xml.etree.ElementTree as ET
import queue
from pathlib import Path
from sphinx_sitemap import setup as base_setup, add_html_link, record_builder_type
from sphinx.util.logging import getLogger
logger = getLogger(__name__)
def setup(app):
app.add_config_value('ov_sitemap_urlset', default=None, rebuild='')
... | 120 | 4,675 |
saleor | saleor/graphql/channel/filters.py | .py | def get_channel_slug_from_filter_data(filter_data: dict):
channel = filter_data.get("channel")
return str(channel) if channel else None
def get_currency_from_filter_data(filter_data: dict):
currency = filter_data.get("currency")
return str(currency) if currency else None
| 9 | 290 |
mlflow | examples/sklearn_elasticnet_diabetes/osx/train_diabetes.py | .py | #
# train_diabetes.py
#
# MLflow model using ElasticNet (sklearn) and Plots ElasticNet Descent Paths
#
# Uses the sklearn Diabetes dataset to predict diabetes progression using ElasticNet
# The predicted "progression" column is a quantitative measure of disease progression one year after baseline
# http... | 126 | 4,087 |
cvxpy | cvxpy/atoms/elementwise/minimum.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
... | 126 | 3,872 |
openvino | src/frontends/onnx/tests/tests_python/test_ops_batchnorm.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import onnx
from tests.tests_python.utils import run_node
def make_batch_norm_node(**node_attributes):
return onnx.helper.make_node(
"BatchNormalization", inputs=["X", "scale", "B... | 86 | 3,305 |
mlflow | mlflow/entities/logged_model.py | .py | from typing import Any
import mlflow.protos.service_pb2 as pb2
from mlflow.entities._mlflow_object import _MlflowObject
from mlflow.entities.logged_model_parameter import LoggedModelParameter
from mlflow.entities.logged_model_status import LoggedModelStatus
from mlflow.entities.logged_model_tag import LoggedModelTag
f... | 229 | 8,003 |
wagtail | wagtail/snippets/tests/test_chooser_views.py | .py | import json
from django.contrib.admin.utils import quote
from django.test import TestCase, TransactionTestCase, tag
from django.test.utils import override_settings
from django.urls import reverse
from wagtail.models import Locale
from wagtail.test.snippets.models import (
NonAutocompleteSearchableSnippet,
Sea... | 384 | 13,470 |
probability | tensorflow_probability/python/math/ode/__init__.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... | 32 | 1,243 |
mlflow | tests/autologging/test_training_session.py | .py | import pytest
from mlflow.utils.autologging_utils import _get_new_training_session_class
_TrainingSession = _get_new_training_session_class()
class Parent:
pass
class Child:
pass
class Grandchild:
pass
PARENT = Parent()
CHILD = Child()
GRAND_CHILD = Grandchild()
@pytest.fixture(autouse=True)
def... | 122 | 3,630 |
cvxpy | cvxpy/atoms/condition_number.py | .py | """
Copyright 2022, 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, soft... | 100 | 3,128 |
wagtail | wagtail/contrib/simple_translation/tests/test_forms.py | .py | from django.forms import CheckboxInput, HiddenInput
from django.test import TestCase, override_settings
from wagtail.contrib.simple_translation.forms import SubmitTranslationForm
from wagtail.models import Locale
from wagtail.test.i18n.models import TestPage
from wagtail.test.utils import Page, WagtailTestUtils
@ove... | 141 | 5,490 |
saleor | saleor/graphql/payment/tests/queries/test_payment_capture.py | .py | import graphene
from ....tests.utils import get_graphql_content
QUERY_PAYMENT_CAPTURE_AMOUNT = """
query payment($id: ID!) {
payment(id: $id) {
id,
availableCaptureAmount{
amount
}
}
}
"""
def test_resolve_available_capture_amount_cannot_c... | 51 | 1,295 |
probability | tensorflow_probability/python/experimental/mcmc/thinning_kernel_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... | 201 | 7,984 |
pdm | src/pdm/termui.py | .py | from __future__ import annotations
import contextlib
import enum
import logging
import os
import tempfile
import warnings
from typing import IO, TYPE_CHECKING
import rich
from rich.box import ROUNDED
from rich.console import Console
from rich.progress import Progress, ProgressColumn
from rich.prompt import Confirm, I... | 338 | 10,981 |
openvino | src/bindings/python/src/openvino/opset13/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino.opset1.ops import absolute
from openvino.opset1.ops import absolute as abs
from openvino.opset1.ops import acos
from openvino.opset4.ops import acosh
from openvino.opset8.ops import adaptive_avg_pool... | 189 | 8,016 |
toolz | bench/test_get.py | .py | from toolz import get
tuples = [(1, 2, 3) for i in range(100000)]
def test_get():
for tup in tuples:
get(1, tup)
| 9 | 128 |
toolz | bench/test_first.py | .py | from toolz import first, second
pairs = [(1, 2) for i in range(1000000)]
def test_first():
for p in pairs:
first(p)
def test_second():
for p in pairs:
second(p)
| 14 | 190 |
pyomo | pyomo/contrib/pynumero/interfaces/cyipopt_interface.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... | 532 | 19,359 |
metrics | tests/unittests/image/test_fid.py | .py | # Copyright The Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 253 | 9,256 |
pyomo | pyomo/contrib/sensitivity_toolbox/tests/test_sens.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... | 917 | 34,641 |
clearml | examples/frameworks/fastai/fastai_example.py | .py | # ClearML - Fastai v2 example code, automatic logging the model and various scalars
#
import argparse
from clearml import Task
import fastai
try:
from fastai.vision.all import (
untar_data,
URLs,
get_image_files,
ImageDataLoaders,
Resize,
cnn_learner,
resne... | 46 | 1,095 |
wandb | wandb/sdk/artifacts/artifact_state.py | .py | """Artifact state."""
from __future__ import annotations
from enum import Enum
class ArtifactState(Enum):
PENDING = "PENDING"
COMMITTED = "COMMITTED"
DELETED = "DELETED"
GARBAGE_COLLECTED = "GARBAGE_COLLECTED"
PENDING_DELETION = "PENDING_DELETION"
| 14 | 272 |
cvxpy | cvxpy/atoms/quantum_cond_entr.py | .py | from typing import Literal
import numpy as np
from cvxpy.atoms.affine.kron import kron
from cvxpy.atoms.affine.partial_trace import partial_trace
from cvxpy.atoms.affine.wraps import hermitian_wrap
from cvxpy.atoms.quantum_rel_entr import quantum_rel_entr
from cvxpy.expressions.expression import Expression
def quan... | 63 | 2,410 |
saleor | saleor/graphql/meta/tests/mutations/test_gift_card.py | .py | import graphene
from . import PRIVATE_KEY, PRIVATE_VALUE, PUBLIC_KEY, PUBLIC_VALUE
from .test_delete_metadata import (
execute_clear_public_metadata_for_item,
item_without_public_metadata,
)
from .test_delete_private_metadata import (
execute_clear_private_metadata_for_item,
item_without_private_metada... | 92 | 2,802 |
wandb | wandb/sdk/lib/wbauth/validation.py | .py | """Validation for API keys."""
from __future__ import annotations
import pathlib
import re
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from wandb.apis.public.service_api import ServiceApi
from .host_url import HostUrl
# Matches a JWT: three non-empty base64url segments separated by dots.
_JWT_RE = ... | 158 | 4,612 |
sphinx | sphinx/search/da.py | .py | """Danish search language."""
from __future__ import annotations
import snowballstemmer
from sphinx.search import SearchLanguage
from sphinx.search._stopwords.da import DANISH_STOPWORDS
class SearchDanish(SearchLanguage):
lang = 'da'
language_name = 'Danish'
js_stemmer_rawcode = 'danish-stemmer.js'
... | 23 | 589 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/cat_variable.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: '{{{,}}}'
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
cat = 42
| 12 | 165 |
probability | tensorflow_probability/python/distributions/lognormal.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... | 187 | 7,238 |
wagtail | wagtail/contrib/search_promotions/admin_urls.py | .py | from django.urls import path
from wagtail.contrib.search_promotions import views
from wagtail.contrib.search_promotions.views.reports import SearchTermsReportView
app_name = "wagtailsearchpromotions"
urlpatterns = [
path("", views.IndexView.as_view(), name="index"),
path("results/", views.IndexView.as_view(re... | 26 | 985 |
saleor | saleor/graphql/core/utils/resolvers.py | .py | from ...core.context import get_database_connection_name
from ...core.validators import validate_one_of_args_is_in_query
from . import from_global_id_or_error
def resolve_by_global_id_or_ext_ref(info, model, id, external_reference):
validate_one_of_args_is_in_query("id", id, "external_reference", external_referen... | 44 | 1,466 |
wandb | wandb/integration/prodigy/__init__.py | .py | from .prodigy import upload_dataset
__all__ = ["upload_dataset"]
| 4 | 66 |
hydra | tools/configen/example/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import hydra
# Generated config dataclasses
from example.config.configen.samples.my_module import AdminConf, UserConf
from hydra.core.config_store import ConfigStore
from omegaconf import DictConfig
# Underlying objects
from configen.samples.my_mo... | 32 | 824 |
saleor | saleor/graphql/account/mutations/authentication/external_authentication_url.py | .py | import graphene
from ....core import ResolveInfo
from ....core.doc_category import DOC_CATEGORY_AUTH
from ....core.fields import JSONString
from ....core.mutations import BaseMutation
from ....core.types import AccountError
from ....plugins.dataloaders import get_plugin_manager_promise
class ExternalAuthenticationUr... | 46 | 1,480 |
cvxpy | cvxpy/atoms/cvar.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
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | 56 | 1,987 |
onnx | onnx/compose.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING
from onnx import (
AttributeProto,
GraphProto,
ModelProto,
TensorProto,
checker,
helper,
utils,
)
if TYPE_CHECKING:
from collections.ab... | 757 | 27,494 |
metrics | src/torchmetrics/functional/segmentation/dice.py | .py | # Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to i... | 182 | 8,807 |
probability | tensorflow_probability/python/internal/docstring_util_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... | 83 | 2,005 |
pyfilesystem2 | tests/test_osfs.py | .py | # coding: utf-8
from __future__ import unicode_literals
import sys
import errno
import io
import os
import shutil
import tempfile
import time
import unittest
import warnings
from six import text_type
from fs import errors, open_fs, osfs
from fs.path import dirname, relpath
from fs.test import FSTestCases
try:
f... | 231 | 8,053 |
astropy | astropy/coordinates/tests/accuracy/test_fk4_no_e_fk4.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
from astropy import units as u
from astropy.coordinates import angular_separation
from astropy.coordinates.builtin_frames import FK4, FK4NoETerms
from astropy.table import Table
from astropy.time import Time
from astropy.utils.data im... | 71 | 2,089 |
sqlmap | lib/request/templates.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.data import kb
from lib.request.connect import Connect as Request
def getPageTemplate(payload, place):
retVal = (kb.originalPage, kb.errorIsNone)
if payloa... | 22 | 632 |
pyomo | doc/OnlineDocs/ext/pyomo_tocref.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... | 57 | 1,748 |
pyomo | pyomo/contrib/appsi/solvers/cplex.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... | 471 | 17,233 |
pdm | src/pdm/builders/sdist.py | .py | from __future__ import annotations
import os
from pdm.builders.base import EnvBuilder, wrap_error
class SdistBuilder(EnvBuilder):
"""Build sdist in isolated env with managed Python."""
@wrap_error
def build(self, out_dir: str, metadata_directory: str | None = None) -> str:
if self.isolated:
... | 19 | 611 |
gunicorn | examples/frameworks/django/testing/testing/apps/someapp/views.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import csv
import io
import os
from django import forms
from django.http import HttpResponse
from django.shortcuts import render
from django.template import RequestContext
class MsgForm(forms.Form):
subject =... | 71 | 1,654 |
clearml | examples/automation/programmatic_orchestration.py | .py | from clearml import Task
from time import sleep
# Initialize the Task Pipe's first Task used to start the Task Pipe
task = Task.init(
"examples", "Simple Controller Task", task_type=Task.TaskTypes.controller
)
# Create a hyper-parameter dictionary for the task
param = dict()
# Connect the hyper-parameter dictiona... | 50 | 1,852 |
probability | tensorflow_probability/python/distributions/loglogistic_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... | 252 | 8,922 |
pyomo | pyomo/contrib/solver/common/results.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... | 341 | 12,832 |
textual | docs/examples/app/question_title01.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Button, Header, Label
class MyApp(App[str]):
CSS_PATH = "question02.tcss"
TITLE = "A Question App"
SUB_TITLE = "The most important question"
def compose(self) -> ComposeResult:
yield Header()
yield Label("Do you lo... | 24 | 645 |
saleor | saleor/graphql/warehouse/tests/queries/test_stocks.py | .py | from .....permission.enums import ProductPermissions
from .....warehouse.models import Stock
from ....tests.utils import assert_no_permission, get_graphql_content
QUERY_STOCKS = """
query {
stocks(first:100) {
totalCount
edges {
node {
id
... | 52 | 1,367 |
wandb | wandb/sdk/artifacts/_generated/add_aliases.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/artifacts/
from __future__ import annotations
from wandb._pydantic import GQLResult
class AddAliases(GQLResult):
result: AddAliasesResult | None
class AddAliasesResult(GQLResult):
success: bool
AddAliases.model_rebuild()
| 18 | 300 |
jupytext | demo/World population.spx.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: region,endregion
# formats: ipynb,.pct.py:percent,.lgt.py:light,.spx.py:sphinx,md,Rmd,.pandoc.md:pandoc
# text_representation:
# extension: .py
# format_name: sphinx
# format_version: '1.1'
# jupytext_version: 1.1.0
# kernelspec:
# ... | 104 | 3,333 |
pyomo | examples/dae/run_Parameter_Estimation.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... | 52 | 1,601 |
saleor | saleor/tests/e2e/checkout/discounts/test_checkout_with_promotion_and_voucher.py | .py | import pytest
from .....product.tasks import recalculate_discounted_price_for_products_task
from ...product.utils.preparing_product import prepare_product
from ...promotions.utils import create_promotion, create_promotion_rule
from ...shop.utils.preparing_shop import prepare_default_shop
from ...utils import assign_pe... | 436 | 13,786 |
pdm | src/pdm/_types.py | .py | from __future__ import annotations
import dataclasses as dc
import re
from typing import TYPE_CHECKING, Any, NamedTuple, TypeVar
from typing_extensions import Self
if TYPE_CHECKING:
from typing import Protocol
def _normalize_pattern(pattern: str) -> str:
return re.sub(r"[^A-Za-z0-9?*\[\]-]+", "-", pattern)... | 148 | 4,559 |
luigi | test/create_packages_archive_root/module.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# 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... | 17 | 603 |
saleor | saleor/thumbnail/tests/test_views.py | .py | from unittest.mock import patch
import graphene
from PIL import Image
from ...product import ProductMediaTypes
from .. import IconThumbnailFormat, ThumbnailFormat
from ..models import Thumbnail
def test_handle_thumbnail_view_with_format(client, category_with_image, settings):
# given
size = 60
format = ... | 603 | 17,563 |
pyomo | pyomo/solvers/plugins/solvers/GAMS.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 1,496 | 58,923 |
scikit-bio | skbio/util/tests/test_array.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.
# --------------------------------------------... | 468 | 16,916 |
marshmallow | src/marshmallow/class_registry.py | .py | """A registry of :class:`Schema <marshmallow.Schema>` classes. This allows for string
lookup of schemas, which may be used with
class:`fields.Nested <marshmallow.fields.Nested>`.
.. warning::
This module is treated as private API.
Users should not need to use this module directly.
"""
# ruff: noqa: ERA001
fr... | 104 | 3,029 |
clearml | clearml/backend_interface/metrics/interface.py | .py | import json
import logging
import os
from functools import partial
from logging import warning
from multiprocessing.pool import ThreadPool, AsyncResult
from time import time
from typing import Optional, Callable, List, Union, TYPE_CHECKING, Any
from pathlib2 import Path
from ...backend_api import Session, CallResult
... | 426 | 17,488 |
onnx | onnx/backend/test/case/node/eyelike.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 EyeLike(Base):
@staticmethod
def export_without_dtype() -> Non... | 61 | 1,749 |
mlflow | dev/clint/tests/rules/test_assign_before_append.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 import AssignBeforeAppend
def test_assign_before_append_basic(index: SymbolIndex) -> None:
code = """
items = []
for x in data:
item = transform(x)... | 149 | 4,157 |
pyomo | pyomo/network/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 | 573 |
openvino | tests/layer_tests/common/layer_test_class.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import defusedxml.ElementTree as ET
import itertools
import numpy as np
import os
import re
import warnings
from common.constants import test_device, test_precision
from common.layer_utils import InferAPI
from common.utils.common_utils i... | 197 | 8,827 |
sphinx | tests/test_extensions/test_ext_apidoc.py | .py | """Test the sphinx.apidoc module."""
from __future__ import annotations
from collections import namedtuple
from typing import TYPE_CHECKING
import pytest
import sphinx.ext.apidoc._generate
from sphinx.ext.apidoc._cli import main as apidoc_main
if TYPE_CHECKING:
from pathlib import Path
from sphinx.testing... | 801 | 24,742 |
openvino | tests/e2e_tests/common/common/base_provider.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
class BaseProviderMeta(type):
def __new__(mcs, name, bases, attrs, **kwargs):
cls = super().__new__(mcs, name, bases, attrs)
# do not create container for abstract provider
if '_is_base_provider' in attrs:
... | 65 | 2,116 |
onnx | onnx/reference/ops/op_matmul_integer.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 MatMulInteger(OpRun):
def _run(self, A, B, a_zero_point=None, b_zero_point=None):
A32 = A.astype(np.int32)
if a_zer... | 20 | 503 |
astropy | astropy/cosmology/_src/tests/traits/test_trait_rhocrit.py | .py | import numpy as np
import pytest
import astropy.units as u
from astropy.cosmology._src.traits.rhocrit import CriticalDensity
from astropy.tests.helper import assert_quantity_allclose
class DummyRho(CriticalDensity):
critical_density0 = 1.0 * u.kg / (u.m**3)
def efunc(self, z):
return np.ones_like(np... | 25 | 583 |
openvino | tests/layer_tests/pytorch_tests/test_native_multi_head_attention.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
EMBED_DIM = 8
NUM_HEADS = 4
SEQ_LENGTH = 6
BATCH_SIZE = 1
NO_MASK, ATTN_MASK, KEY_PAD_MASK, MERGED_MASK = -1, 0, 1, 2
class aten_native... | 148 | 7,588 |
beam | sdks/python/apache_beam/internal/test_data/module_1_nested_function_added.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... | 32 | 1,124 |
probability | tensorflow_probability/python/distributions/mvn_low_rank_update_linear_operator_covariance.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... | 401 | 14,579 |
onnxruntime | onnxruntime/core/providers/coreml/mlprogram_test_scripts/resize_test.py | .py | import coremltools as ct
import numpy as np
from coremltools.converters.mil import Builder as mb
target = ct.target.iOS15
x_shape = (1, 1, 3, 6)
use_scale = False # set this to test upsample vs resize
@mb.program(input_specs=[mb.TensorSpec(shape=x_shape)], opset_version=target)
def prog(x):
global use_scale ... | 52 | 1,268 |
textual | src/textual/widgets/select.py | .py | from textual.widgets._select import (
NULL,
EmptySelectError,
InvalidSelectValueError,
NoSelection,
)
__all__ = ["EmptySelectError", "InvalidSelectValueError", "NoSelection", "NULL"]
| 9 | 200 |
sqlmap | lib/core/update.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import glob
import os
import re
import shutil
import subprocess
import time
import zipfile
from lib.core.common import dataToStdout
from lib.core.common import extractRegexResult... | 169 | 7,347 |
saleor | saleor/tests/e2e/orders/test_manage_products_on_draft_order.py | .py | import pytest
from .. import DEFAULT_ADDRESS
from ..product.utils.preparing_product import prepare_product
from ..shop.utils.preparing_shop import prepare_default_shop
from ..utils import assign_permissions
from .utils import (
draft_order_complete,
draft_order_create,
order_line_delete,
order_line_upd... | 122 | 4,427 |
saleor | saleor/graphql/checkout/utils.py | .py | import graphene
from django.core.exceptions import ValidationError
from ...core.exceptions import CircularSubscriptionSyncEvent
from ...webhook.event_types import WebhookEventSyncType
def prepare_insufficient_stock_checkout_validation_error(exc):
variants = [str(item.variant) for item in exc.items]
variant_i... | 47 | 1,724 |
loguru | tests/test_deepcopy.py | .py | import copy
from loguru import logger
def print_(message):
print(message, end="")
def test_add_sink_after_deepcopy(capsys):
logger_ = copy.deepcopy(logger)
logger_.add(print_, format="{message}", catch=False)
logger_.info("A")
logger.info("B")
out, err = capsys.readouterr()
assert ou... | 62 | 1,173 |
coremltools | deps/protobuf/python/google/protobuf/internal/encoder.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... | 830 | 28,656 |
confluent-kafka-python | tests/schema_registry/test_hcvault_driver.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2024 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... | 156 | 6,171 |
beam | sdks/python/apache_beam/examples/complete/top_wikipedia_sessions_it_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... | 99 | 3,473 |
mlflow | tests/assistant/providers/test_openai_compatible_provider.py | .py | import json
from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from mlflow.assistant.config import PermissionsConfig
from mlflow.assistant.providers.base import clear_config_cache
from mlflow.assistant.providers.ollama import OllamaProvider
from mlflow.assistant.providers.opena... | 1,231 | 44,868 |
coremltools | coremltools/converters/mil/mil/ops/defs/iOS18/tensor_transformation.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 numpy as np
from coremltools.converters.mil.mil import types
from coremltools.converters.mil.m... | 153 | 5,481 |
sqlmap | lib/utils/wafbypass.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import base64
import json
import os
import struct
import sys
from lib.core.common import fetchRandomAgent
from lib.core.data import conf
from lib.core.data import paths
from lib.... | 156 | 5,615 |
saleor | saleor/asgi/tests/asgi_test_utils.py | .py | from asgiref.typing import Scope, WebSocketScope
from django.core.handlers.asgi import ASGIHandler
class DummyASGIApplication(ASGIHandler):
"""A dummy ASGI application that always return a dummy string.
Used to indicate it was called successfully.
"""
RESPONSE_STRING = "Dummy ASGI Application: calle... | 37 | 1,154 |
beam | sdks/python/apache_beam/testing/benchmarks/chicago_taxi/setup.py | .py | # Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 39 | 1,330 |
saleor | saleor/core/hashers.py | .py | import base64
import hashlib
from django.contrib.auth.hashers import PBKDF2PasswordHasher
from django.utils.encoding import force_bytes
class SHA512Base64PBKDF2PasswordHasher(PBKDF2PasswordHasher):
"""Hasher for Symfony migrated password tokens.
5000 iterations of sha512 plus base64 encoder, with an extra
... | 33 | 1,115 |
owasp-mstg | demos/android/MASVS-PRIVACY/MASTG-DEMO-0009/mitm_sensitive_logger.py | .py | from mitmproxy import http
# This data would come from another file and should be defined after identifying the data that is considered sensitive for this application.
# For example by using the Google Play Store Data Safety section.
SENSITIVE_DATA = {
"precise_location_latitude": "37.7749",
"precise_location_... | 44 | 1,682 |
mlflow | examples/ag2/tracing.py | .py | """
This is an example for leveraging MLflow's auto tracing capabilities for AutoGen.
For more information about MLflow Tracing, see: https://mlflow.org/docs/latest/llms/tracing/index.html
"""
import os
from typing import Annotated, Literal
from autogen import ConversableAgent
import mlflow
# Turn on auto tracing ... | 64 | 1,913 |
saleor | saleor/graphql/payment/tests/benchmark/test_payment_transactions.py | .py | import pytest
from .....payment.models import Transaction
from ....tests.utils import get_graphql_content
PAYMENT_TRANSACTIONS_QUERY = """
query {
orders(first:100) {
edges {
node {
payments {
id
gateway
isActive
created
modified
token
... | 79 | 1,591 |
onnx | onnx/reference/ops/op_cosh.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 OpRunUnaryNum
class Cosh(OpRunUnaryNum):
def _run(self, x):
return (np.cosh(x),)
| 14 | 267 |
sqlmap | tests/test_dbwire.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Protocol-transcript coverage for the dependency-free wire clients in extra/dbwire: PostgreSQL SCRAM
server verification, MySQL capability negotiation, TDS framing and affected-row cou... | 697 | 33,617 |
gunicorn | tests/docker/asgi_framework_compat/tests/test_streaming.py | .py | """
Streaming Response Tests
Tests chunked streaming and Server-Sent Events across frameworks.
"""
import asyncio
import json
import pytest
pytestmark = pytest.mark.streaming
class TestChunkedStreaming:
"""Test chunked transfer encoding responses."""
async def test_streaming_response(self, http_client):... | 99 | 3,343 |
confluent-kafka-python | src/confluent_kafka/serialization/__init__.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... | 435 | 12,111 |
confluent-kafka-python | src/confluent_kafka/schema_registry/confluent/types/decimal_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: confluent/types/decimal.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_datab... | 29 | 1,172 |
metrics | tests/unittests/bases/test_collections.py | .py | # Copyright The Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 858 | 31,668 |
ipython | docs/sphinxext/magics.py | .py | import re
from sphinx import addnodes
from sphinx.domains.std import StandardDomain
from sphinx.roles import XRefRole
name_re = re.compile(r"[\w_]+")
def parse_magic(env, sig, signode):
m = name_re.match(sig)
if not m:
raise Exception("Invalid magic command: %s" % sig)
name = "%" + sig
signode... | 47 | 1,496 |
saleor | saleor/graphql/channel/types.py | .py | import collections
import itertools
from typing import TYPE_CHECKING
import graphene
from django_countries.fields import Country
from graphene.types.objecttype import ObjectType
from promise import Promise
from ...channel import models
from ...permission.auth_filters import AuthorizationFilters
from ...permission.enu... | 547 | 20,542 |
onnx | tools/gen_coverage_report.py | .py | #!/usr/bin/env python
# Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import argparse
import os
import shutil
import subprocess
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(os.path.basename(__file__))
parser.add... | 96 | 2,151 |
mlflow | mlflow/tracing/utils/prompt.py | .py | import json
from mlflow.entities.model_registry import PromptVersion
from mlflow.exceptions import MlflowException
from mlflow.tracing.constant import TraceTagKey
# TODO: Remove tag based linking once we migrate to LinkPromptsToTraces endpoint
def update_linked_prompts_tag(current_tag_value: str | None, prompt_versi... | 48 | 1,750 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.