repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
saleor | saleor/webhook/tests/response_schemas/test_validators.py | .py | import pytest
from saleor.webhook.response_schemas.utils.validators import lower_values
@pytest.mark.parametrize(
("input_value", "expected_output"),
[
("HELLO", "hello"),
("world", "world"),
(["HELLO", "WORLD"], ["hello", "world"]),
(["Python", "TEST"], ["python", "test"]),
... | 20 | 525 |
openvino | src/frontends/tensorflow/tests/test_models/gen_scripts/generate_saved_model_multi-graph.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import tensorflow as tf
export_dir = os.path.join(sys.argv[1], "saved_model_multi-graph")
#Slash replacing required because otherwise fails on Windows
builder = tf.compat.v1.saved_model.Builder(export_dir if os.na... | 49 | 1,951 |
pymc | tests/gp/test_hsgp_approx.py | .py | # Copyright 2024 - present The PyMC Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 333 | 12,768 |
conda | conda/plugins/reporter_backends/__init__.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from . import console, json
plugins = [json, console]
| 6 | 130 |
coremltools | coremltools/converters/mil/mil/passes/helper.py | .py | # Copyright (c) 2021, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from typing import Callable, List, Optional
import numpy as np
from coremltools.converters.mil.mil ... | 148 | 4,186 |
saleor | saleor/graphql/core/tests/test_view.py | .py | import json
import logging
from unittest import mock
from unittest.mock import patch
import graphene
import pytest
from django.shortcuts import render
from django.test import override_settings
from freezegun import freeze_time
from graphql.execution.base import ExecutionResult
from opentelemetry.trace import StatusCod... | 760 | 24,295 |
probability | tensorflow_probability/python/internal/backend/numpy/gen/linear_operator_composition.py | .py | # Copyright 2020 The TensorFlow Probability Authors. All Rights Reserved.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# THIS FILE IS AUTO-GENERATED BY `gen_linear_operators.py`.
# DO NOT MODIFY DIRECTLY.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@... | 441 | 18,075 |
wagtail | wagtail/admin/tests/test_page_chooser.py | .py | import json
from urllib.parse import parse_qs, urlsplit
import swapper
from django.contrib.auth import get_user_model
from django.test import TestCase, TransactionTestCase, override_settings, tag
from django.urls import reverse
from django.utils.html import escape
from django.utils.http import urlencode
from wagtail.... | 1,704 | 70,187 |
beam | sdks/python/apache_beam/examples/complete/autocomplete_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... | 97 | 3,393 |
mkdocs-material | includes/debug/cairo-lookup-macos.py | .py | import os
from ctypes.macholib import dyld
from itertools import chain
library_names = ("cairo-2", "cairo", "libcairo-2")
filenames = ("libcairo.so.2", "libcairo.2.dylib", "libcairo-2.dll")
first_found = ""
names = []
for name in library_names:
names += [
"lib%s.dylib" % name,
"%s.dylib" % name,
... | 50 | 1,303 |
pyomo | examples/performance/misc/diag1_100.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,000 |
jupytext | tests/data/notebooks/outputs/ipynb_to_percent/cat_variable.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %%
cat = 42
| 11 | 126 |
clearml | examples/frameworks/pytorch/pytorch_mnist.py | .py | # ClearML - Example of Pytorch mnist training integration
#
from __future__ import print_function
import argparse
import os
from tempfile import gettempdir
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
from clearml import T... | 248 | 6,431 |
scikit-bio | skbio/io/format/taxdump.py | .py | r"""Taxdump format (:mod:`skbio.io.format.taxdump`)
===============================================
.. currentmodule:: skbio.io.format.taxdump
The NCBI Taxonomy database dump (``taxdump``) format stores information of
organism names, classifications and other properties. It is a tabular format
with a delimiter: ``<ta... | 327 | 13,154 |
slimit | src/slimit/tests/test_lexer.py | .py | ###############################################################################
# encoding: utf-8
#
# Copyright (c) 2011 Ruslan Spivak
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software withou... | 298 | 13,099 |
onnxruntime | orttraining/orttraining/python/training/ort_triton/kernel/__init__.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import os
import torch
from ._mm import triton_gemm, triton_gemm_out, ... | 33 | 992 |
probability | tensorflow_probability/python/math/psd_kernels/feature_transformed.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... | 141 | 4,720 |
wagtail | wagtail/snippets/tests/test_usage.py | .py | from io import StringIO
from django.contrib.admin.utils import quote
from django.contrib.auth.models import Permission
from django.core import management
from django.test import TestCase
from django.urls import reverse
from wagtail.models import ReferenceIndex
from wagtail.test.testapp.models import (
Advert,
... | 220 | 8,739 |
attrs | tests/test_init_subclass.py | .py | # SPDX-License-Identifier: MIT
"""
Tests for `__init_subclass__` related functionality.
"""
import attr
def test_init_subclass_vanilla(slots):
"""
`super().__init_subclass__` can be used if the subclass is not an attrs
class both with dict and slotted classes.
"""
@attr.s(slots=slots)
class... | 67 | 1,368 |
probability | tensorflow_probability/python/bijectors/split.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... | 517 | 19,882 |
hatch | tests/helpers/templates/wheel/standard_default_build_script_force_include_no_duplication.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 51 | 1,371 |
textual | tests/snapshot_tests/snapshot_apps/layer_order_independence.py | .py | from textual.app import App, ComposeResult
from textual.screen import Screen
from textual.widgets import Header, Footer, Label
from textual.containers import VerticalScroll, Container
class Overlay(Container):
def compose(self) -> ComposeResult:
yield Label("This should float over the top")
class Body1(... | 75 | 1,559 |
structlog | src/structlog/_native.py | .py | # SPDX-License-Identifier: MIT OR Apache-2.0
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the MIT License. See the LICENSE file in the root of this
# repository for complete details.
"""
structlog's native high-performance loggers.
"""
from __future__ import annotations
imp... | 287 | 9,439 |
saleor | saleor/graphql/giftcard/tests/queries/test_gift_card.py | .py | import datetime
from copy import deepcopy
import graphene
import pytest
from django.utils import timezone
from .....giftcard import GiftCardEvents, events
from .....giftcard.models import GiftCardEvent
from .....permission.enums import AccountPermissions
from ....tests.utils import (
assert_no_permission,
get... | 957 | 29,039 |
saleor | saleor/graphql/account/mutations/permission_group/permission_group_delete.py | .py | import graphene
from django.core.exceptions import ValidationError
from .....account import models
from .....account.error_codes import PermissionGroupErrorCode
from .....core.exceptions import PermissionDenied
from .....permission.enums import AccountPermissions
from .....webhook.event_types import WebhookEventAsyncT... | 108 | 4,680 |
rq | tests/config_files/dummy_logging.py | .py | # example config taken from <https://stackoverflow.com/a/7507842/784804>
DICT_CONFIG = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {'format': 'MY_LOG_FMT: %(asctime)s [%(levelname)s] %(name)s: %(message)s'},
},
'handlers': {
'default': {
... | 20 | 625 |
qutip | qutip/core/numpy_backend.py | .py | from ..settings import settings
class NumpyBackend:
__slots__ = (
"_qt_np",
"abs",
"angle",
"arccos",
"array",
"ceil",
"conj",
"cos",
"cumsum",
"diff",
"e",
"histogram",
"imag",
"inf",
"inner",
... | 52 | 934 |
probability | tensorflow_probability/python/internal/structural_tuple_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... | 193 | 6,311 |
coremltools | coremltools/converters/mil/frontend/torch/load.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
import os.path as _os_path
from typing import List, Optional, Union
import torch as _torch
from torc... | 161 | 6,149 |
saleor | saleor/tests/e2e/checkout/utils/checkout_email_update.py | .py | from ...utils import get_graphql_content
CHECKOUT_EMAIL_UPDATE_MUTATION = """
mutation checkoutEmailUpdate($checkoutId: ID!, $email: String!){
checkoutEmailUpdate(
id: $checkoutId
email: $email
) {
checkout {
email
}
errors {
field
message
}
}
}
"""
def checkout_update... | 37 | 742 |
astropy | astropy/uncertainty/function_helpers.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Helpers for letting numpy functions interact with distributions.
The module supplies helper routines for numpy functions that propagate
distributions appropriately., for use in the ``__array_function__``
implementation of `~astropy.uncertainty.core.Dis... | 160 | 5,447 |
kombu | kombu/asynchronous/http/curl.py | .py | """HTTP Client using pyCurl."""
from __future__ import annotations
from collections import deque
from functools import partial
from io import BytesIO
from time import time
from kombu.asynchronous.hub import READ, WRITE, Hub, get_event_loop
from kombu.exceptions import HttpError
from kombu.utils.encoding import bytes... | 294 | 9,863 |
deap | examples/ga/nqueens.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 ... | 97 | 3,343 |
mlflow | tests/server/assistant/test_api.py | .py | import os
import shutil
import subprocess
import sys
import threading
from pathlib import Path
from typing import Any
from unittest.mock import MagicMock, patch
import pytest
from fastapi import APIRouter, FastAPI, HTTPException
from fastapi.testclient import TestClient
from mlflow.assistant.config import AssistantCo... | 1,293 | 47,024 |
kafka | tests/kafkatest/services/streams_property.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 ... | 26 | 1,087 |
coremltools | deps/pybind11/tests/test_eigen_matrix.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import ConstructorStats
np = pytest.importorskip("numpy")
m = pytest.importorskip("pybind11_tests.eigen_matrix")
ref = np.array(
[
[0.0, 3, 0, 0, 0, 11],
[22, 0, 0, 0, 17, 11],
[7, 5, 0, 1, 0, 11],
[0, 0, 0, 0,... | 817 | 29,211 |
pyomo | examples/pyomobook/scripts-ch/warehouse_model.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... | 46 | 1,541 |
saleor | saleor/graphql/product/tests/queries/products_filtrations/test_over_attributes_numeric.py | .py | import pytest
from ......attribute.utils import associate_attribute_values_to_instance
from .....tests.utils import get_graphql_content
from .shared import PRODUCTS_FILTER_QUERY, PRODUCTS_WHERE_QUERY
@pytest.mark.parametrize("query", [PRODUCTS_WHERE_QUERY, PRODUCTS_FILTER_QUERY])
@pytest.mark.parametrize(
("nume... | 92 | 3,072 |
saleor | saleor/product/__init__.py | .py | MEDIA_URL_CHAR_LIMIT = 2048
class ProductMediaTypes:
IMAGE = "IMAGE"
VIDEO = "VIDEO"
CHOICES = [
(IMAGE, "An uploaded image or an URL to an image"),
(VIDEO, "A URL to an external video"),
]
class ProductTypeKind:
NORMAL = "normal"
GIFT_CARD = "gift_card"
CHOICES = [
... | 22 | 419 |
cvxpy | cvxpy/tests/test_sign.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... | 70 | 2,694 |
mlflow | mlflow/gateway/guardrail_utils.py | .py | from __future__ import annotations
import dataclasses
import logging
from typing import TYPE_CHECKING, Any
from fastapi import Request
from mlflow.entities.gateway_guardrail import GuardrailStage
from mlflow.gateway.guardrails import JudgeGuardrail
from mlflow.gateway.schemas import chat
from mlflow.server.asgi_util... | 127 | 4,802 |
pyomo | pyomo/common/tests/test_numeric_types.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... | 218 | 10,021 |
astropy | astropy/modeling/utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module provides utility functions for the models package.
"""
import warnings
# pylint: disable=invalid-name
from collections import UserDict
from collections.abc import Sequence
from inspect import signature
from typing import TypeVar, overloa... | 344 | 10,255 |
astropy | astropy/utils/masked/tests/test_dynamic_subclasses.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Test importability of common Masked classes and their info classes."""
import pytest
from astropy.coordinates.angles.core import Angle, Latitude, Longitude
from astropy.units.quantity import Quantity
from astropy.utils.masked import core
@pytest.mar... | 22 | 751 |
wandb | wandb/sdk/artifacts/_generated/input_types.py | .py | # Generated by ariadne-codegen
# Source: core/api/graphql/schemas/schema-latest.graphql
from __future__ import annotations
from pydantic import Field
from wandb._pydantic import GQLId, GQLInput
class AddAliasesInput(GQLInput):
aliases: list[ArtifactCollectionAliasInput]
artifact_id: GQLId = Field(alias="ar... | 218 | 8,557 |
probability | spinoffs/inference_gym/inference_gym/targets/banana_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... | 59 | 1,966 |
jupytext | tests/external/simple_external_notebooks/test_read_simple_pandoc.py | .py | import pytest
from nbformat.v4.nbbase import new_markdown_cell, new_notebook
import jupytext
from jupytext.cli import jupytext as jupytext_cli
from jupytext.compare import compare, compare_notebooks
from jupytext.pandoc import PandocError
@pytest.mark.requires_pandoc
def test_pandoc_implicit(
cell_id,
markdo... | 87 | 2,163 |
probability | tensorflow_probability/python/distributions/hypothesis_testlib.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,654 | 67,748 |
astropy | astropy/io/fits/tests/test_groups.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
import time
import numpy as np
import pytest
from astropy.io import fits
from astropy.utils.misc import _NOT_OVERWRITING_MSG_MATCH
from .conftest import FitsTestCase
from .test_table import comparerecords
class TestGroupsFunctions(FitsTestC... | 253 | 9,057 |
saleor | saleor/webhook/tests/fixtures/__init__.py | .py | from .subscription_webhooks import * # noqa: F403
from .webhook import * # noqa: F403
from .webhook_data import * # noqa: F403
from .webhook_event import * # noqa: F403
from .webhook_response import * # noqa: F403
| 6 | 219 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_global_average_pooling3D.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasGlobalAvgPool3D(CommonTF2LayerTest):
def create_keras_global_avg_pooling3D_net(self, input_names, input_shapes, input_... | 41 | 1,756 |
probability | tensorflow_probability/python/experimental/nn/util/convolution_util_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... | 572 | 20,337 |
readthedocs.org | readthedocs/core/views/__init__.py | .py | """
Core views.
Including the main homepage, documentation and header rendering,
and server errors.
"""
import structlog
from django.conf import settings
from django.http import Http404
from django.http import JsonResponse
from django.shortcuts import redirect
from django.urls import reverse
from django.views.generic... | 171 | 5,820 |
mlflow | mlflow/genai/judges/prompts/user_frustration.py | .py | # NB: User-facing name for the user frustration assessment.
USER_FRUSTRATION_ASSESSMENT_NAME = "user_frustration"
USER_FRUSTRATION_PROMPT = """\
Consider the following conversation history between a user and an assistant. Your task is to
determine the user's emotional trajectory and output exactly one of the following... | 20 | 1,183 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_Fill.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shape': [2, 3], 'value': 1, 'kwargs_to_prepare_input': 'int32_positive'},
{'shape': [2, 3, 3, 4], 'value': -1, 'kwargs_to_prepare_input': 'int32_positive'},
{'shape': [1], 'value': 0, 'kwargs... | 33 | 1,270 |
probability | tensorflow_probability/python/math/psd_kernels/polynomial_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... | 315 | 10,303 |
saleor | saleor/graphql/giftcard/tests/mutations/test_gift_card_add_note.py | .py | import datetime
import json
from unittest import mock
import graphene
import pytest
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....core.utils.json_serializer import CustomJsonEncoder
from .....giftcard import GiftCardEvents
from .....giftcard.error_codes import GiftCa... | 263 | 7,376 |
textual | tests/snapshot_tests/snapshot_apps/data_table_remove_row.py | .py | from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.widgets import DataTable
ROWS = [
("lane", "swimmer", "country", "time"),
(5, "Chad le Clos", "South Africa", 51.14),
(4, "Joseph Schooling", "Singapore", 50.39),
(2, "Michael Phelps", "United States", 51.14),
... | 52 | 1,451 |
sphinx | tests/roots/test-warnings/autodoc_fodder.py | .py | class MarkupError:
""".. note:: This is a docstring with a
small markup error which should have
correct location information.
"""
| 6 | 146 |
wagtail | wagtail/test/urls.py | .py | from django.apps import apps
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.http import HttpResponse
from django.urls import include, path
from wagtail import urls as wagtail_urls
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.admin.views import home
from wagtail.api.... | 70 | 2,687 |
mlflow | mlflow/tracing/display/display_handler.py | .py | import html
import json
import logging
from typing import TYPE_CHECKING
from urllib.parse import urlencode, urljoin
import mlflow
from mlflow.environment_variables import (
MLFLOW_MAX_TRACES_TO_DISPLAY_IN_NOTEBOOK,
MLFLOW_NOTEBOOK_TRACE_RENDERER_BASE_URL,
)
from mlflow.tracing.constant import TRACE_RENDERER_AS... | 213 | 7,242 |
sqlmap | plugins/dbms/clickhouse/connector.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
try:
import clickhouse_connect
import clickhouse_connect.dbapi
except:
pass
import logging
from lib.core.common import getSafeExString
from lib.core.data import conf... | 56 | 1,693 |
hydra | examples/instantiate/object_recursive/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import List
from omegaconf import DictConfig
import hydra
from hydra.utils import instantiate, target_whitelist
class Driver:
def __init__(self, name: str, age: int) -> None:
self.name = name
self.age = age
clas... | 40 | 904 |
mamba | libmambapy/tests/test_solver_libsolv.py | .py | import copy
import json
import pytest
import libmambapy
import libmambapy.solver.libsolv as libsolv
def test_import_submodule():
import libmambapy.solver.libsolv as solv
# Dummy execution
_p = solv.Priorities
def test_import_recursive():
import libmambapy as mamba
# Dummy execution
_p = ... | 420 | 12,886 |
bazel | scripts/release/relnotes.py | .py | # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 245 | 8,046 |
pyomo | pyomo/contrib/preprocessing/plugins/var_aggregator.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... | 344 | 13,270 |
pyomo | pyomo/repn/tests/cpxlp/test_cpxlp.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... | 409 | 14,577 |
confluent-kafka-python | src/confluent_kafka/schema_registry/_sync/protobuf.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2020-2022 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 ... | 845 | 43,852 |
readthedocs.org | readthedocs/notifications/tests/test_messages.py | .py | from readthedocs.notifications.constants import INFO
from readthedocs.notifications.messages import Message
class TestMessage:
def test_xss_protection(self):
message = Message(
id="test",
header="XSS: {{header}}",
body="XSS: {{body}}",
type=INFO,
)
... | 33 | 1,018 |
pymc | tests/logprob/test_composite_logprob.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... | 265 | 8,764 |
confluent-kafka-python | src/confluent_kafka/schema_registry/_async/json_schema.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... | 856 | 44,752 |
probability | tensorflow_probability/python/distributions/beta.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... | 450 | 17,898 |
cvxpy | cvxpy/transforms/scalarize.py | .py | """
Copyright 2017 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... | 160 | 5,575 |
mlflow | tests/utils/test_data.py | .py | import os
from mlflow.projects import _project_spec
from mlflow.utils.data_utils import is_uri
TEST_DIR = "tests"
TEST_PROJECT_DIR = os.path.join(TEST_DIR, "resources", "example_project")
def load_project():
return _project_spec.load_project(directory=TEST_PROJECT_DIR)
def test_is_uri():
assert is_uri("s3... | 20 | 509 |
sphinx | doc/development/tutorials/examples/autodoc_intenum.py | .py | from __future__ import annotations
from enum import IntEnum
from typing import TYPE_CHECKING
from sphinx.ext.autodoc import ClassDocumenter, Documenter, bool_option
if TYPE_CHECKING:
from typing import Any
from docutils.statemachine import StringList
from sphinx.application import Sphinx
from sphin... | 64 | 1,920 |
wagtail | wagtail/images/tests/test_api_v3/base.py | .py | from django.test import TestCase
from wagtail.api.v3.tests.base import TestV3Base
from wagtail.images import get_image_model
from wagtail.images.tests.utils import get_test_image_file
from wagtail.test.utils import WagtailTestUtils
from wagtail.test.utils.wagtail_factories import CollectionFactory
Image = get_image_m... | 23 | 729 |
pyomo | pyomo/environ/__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... | 278 | 6,138 |
mlflow | dev/proto_plugin.py | .py | import json
import sys
import textwrap
from dataclasses import asdict, dataclass
from dataclasses import field as dataclass_field
from enum import Enum
from google.protobuf import descriptor_pb2
from google.protobuf.compiler import plugin_pb2
from mlflow.protos import databricks_pb2
class Visibility(Enum):
PUBL... | 559 | 19,369 |
pdm | src/pdm/cli/commands/publish/package.py | .py | from __future__ import annotations
import email
import email.message
import email.policy
import hashlib
import io
import os
import re
import subprocess
from dataclasses import dataclass
from typing import IO, Any, cast
from pdm.exceptions import PdmUsageError, ProjectError
from pdm.termui import logger
DIST_EXTENSIO... | 221 | 8,267 |
wandb | tests/system_tests/test_artifacts/test_wandb_artifacts_api.py | .py | from __future__ import annotations
import json
import os
import re
import time
from pathlib import Path
import responses
import wandb
from pytest import mark, raises
from wandb import Api
from wandb.errors import CommError
from wandb.sdk.artifacts.artifact import Artifact
def _fetch_artifact_with_tags(
api: Api... | 632 | 21,320 |
mlflow | tests/genai/judges/test_alignment_optimizer.py | .py | from unittest.mock import Mock, patch
import pytest
from mlflow.entities.trace import Trace
from mlflow.genai.judges import AlignmentOptimizer, Judge, make_judge
from mlflow.genai.judges.base import JudgeField
from mlflow.genai.judges.optimizers import MemAlignOptimizer
from mlflow.genai.judges.utils import get_defau... | 190 | 6,254 |
onnxruntime | tools/python/wgsl_template/test/test_generator.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Unit tests for the PASS2 generator.
Combines focused unit tests with a fixture-driven runner that pulls
``generator-*`` cases from the ``testcases/`` fixtures next to this
file. We only fixture-test cases where:
* The fix... | 298 | 10,775 |
black | tests/data/cases/fmtonoff2.py | .py | import pytest
TmSt = 1
TmEx = 2
# fmt: off
# Test data:
# Position, Volume, State, TmSt/TmEx/None, [call, [arg1...]]
@pytest.mark.parametrize('test', [
# Test don't manage the volume
[
('stuff', 'in')
],
])
def test_fader(test):
pass
def check_fader(test):
pass
def verify_fader(tes... | 41 | 604 |
saleor | saleor/graphql/payment/mutations/transaction/transaction_request_refund_for_granted_refund.py | .py | from typing import TYPE_CHECKING, cast
import graphene
from django.core.exceptions import ValidationError
from .....giftcard.const import GIFT_CARD_PAYMENT_GATEWAY_ID
from .....giftcard.gateway import refund_gift_card_transaction
from .....order import OrderGrantedRefundStatus
from .....order import models as order_m... | 213 | 9,306 |
saleor | saleor/webhook/observability/tests/test_observability.py | .py | from unittest.mock import Mock, patch
from celery.canvas import Signature
from ....core import EventDeliveryStatus
from ...event_types import WebhookEventAsyncType
from ...transport.asynchronous.transport import (
observability_reporter_task,
observability_send_events,
send_observability_events,
)
from ..... | 137 | 5,011 |
hydra | examples/plugins/example_launcher_plugin/setup.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# type: ignore
from setuptools import find_namespace_packages, setup
with open("README.md") as fh:
LONG_DESC = fh.read()
setup(
name="hydra-example-launcher",
version="1.0.0",
author="Omry Yadan",
author_emai... | 40 | 1,713 |
saleor | saleor/graphql/webhook/dataloaders/__init__.py | .py | from .models import (
PayloadByIdLoader,
WebhookEventsByWebhookIdLoader,
WebhooksByAppIdLoader,
WebhooksByEventTypeLoader,
)
__all__ = [
"PayloadByIdLoader",
"WebhookEventsByWebhookIdLoader",
"WebhooksByAppIdLoader",
"WebhooksByEventTypeLoader",
]
| 14 | 281 |
scikit-bio | skbio/alignment/tests/test_distance.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.
# --------------------------------------------... | 676 | 28,984 |
tqdm | tqdm/contrib/discord.py | .py | """
Sends updates to a Discord bot.
Usage:
>>> from tqdm.contrib.discord import tqdm, trange
>>> for i in trange(10, token='{token}', channel_id='{channel_id}'):
... ...

"""
from warnings import warn
from requests import Session
from requests.utils... | 156 | 5,337 |
clearml | examples/frameworks/keras/keras_tensorboard.py | .py | # ClearML - Keras with Tensorboard example code, automatic logging model and Tensorboard outputs
#
# Train a simple deep NN on the MNIST dataset.
# Gets to 98.40% test accuracy after 20 epochs
# (there is *a lot* of margin for parameter tuning).
# 2 seconds per epoch on a K520 GPU.
from __future__ import print_function... | 125 | 4,356 |
mlflow | tests/tracking/context/test_databricks_cluster_context.py | .py | from unittest import mock
from mlflow.tracking.context.databricks_cluster_context import DatabricksClusterRunContext
from mlflow.utils.mlflow_tags import MLFLOW_DATABRICKS_CLUSTER_ID
def test_databricks_cluster_run_context_in_context():
with mock.patch("mlflow.utils.databricks_utils.is_in_cluster") as in_cluster... | 22 | 844 |
saleor | saleor/graphql/webhook/tests/mutations/test_webhook_delete.py | .py | from unittest.mock import Mock, patch
import graphene
from django.db import IntegrityError
from .....app.models import App
from .....webhook.error_codes import WebhookErrorCode
from .....webhook.models import Webhook
from ....tests.utils import assert_no_permission, get_graphql_content
WEBHOOK_DELETE_BY_APP = """
... | 168 | 5,080 |
conda | tests/cli/test_common.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import os
from pathlib import Path
import pytest
from pytest import MonkeyPatch, raises
from pytest_mock import MockerFixture
from conda.base.context import context, reset_context
from conda.cli.common import (
check_non_admin,
get_nam... | 292 | 8,675 |
saleor | saleor/graphql/webhook/mixins.py | .py | from django.core.exceptions import ValidationError
from ...webhook.error_codes import WebhookErrorCode
from ...webhook.event_types import WebhookEventAsyncType
class NotifyUserEventValidationMixin:
@classmethod
def validate_events(cls, events):
# NOTIFY_USER needs to be the only one event registered ... | 22 | 853 |
deap | deap/tools/mutation.py | .py | import math
import random
from itertools import repeat
try:
from collections.abc import Sequence
except ImportError:
from collections import Sequence
######################################
# GA Mutations #
######################################
def mutGaussian(individual, mu, sigma, i... | 248 | 9,837 |
readthedocs.org | readthedocs/redirects/constants.py | .py | from django.utils.translation import gettext_lazy as _
HTTP_STATUS_CHOICES = (
(302, _("302 - Temporary Redirect")),
(301, _("301 - Permanent Redirect")),
)
PAGE_REDIRECT = "page"
EXACT_REDIRECT = "exact"
CLEAN_URL_TO_HTML_REDIRECT = "clean_url_to_html"
HTML_TO_CLEAN_URL_REDIRECT = "html_to_clean_url"
SPLAT... | 22 | 606 |
wandb | wandb/apis/public/registries/registries_search.py | .py | """Public API: registries search."""
from __future__ import annotations
from collections.abc import Iterator
from itertools import chain
from typing import TYPE_CHECKING, Annotated, Any, ClassVar, Protocol, TypeAlias, TypeVar
from pydantic import AfterValidator, PositiveInt, ValidationError
from typing_extensions im... | 637 | 22,647 |
voila | tests/app/template_arg_test.py | .py | # tests the --template argument of Voilà
import pytest
@pytest.fixture
def voila_args_extra():
return ["--template=test_template", "--VoilaExecutor.timeout=240"]
async def test_template(http_server_client, base_url):
response = await http_server_client.fetch(base_url)
assert response.code == 200
ass... | 15 | 434 |
onnxruntime | onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/FloatProperty.py | .py | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: fbs
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class FloatProperty(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(fl... | 68 | 2,008 |
cvxpy | cvxpy/tests/test_errors.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
... | 125 | 4,296 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.