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
tensorflow_probability/python/distributions/beta_quotient_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...
215
8,627
saleor
saleor/graphql/core/tests/test_json_string_scalar.py
.py
import pytest from graphql.language.ast import IntValue, ObjectValue, StringValue from ..fields import JSONString @pytest.mark.parametrize( ("value", "expected"), [ ('{"a": 1}', {"a": 1}), ("[1, 2, 3]", [1, 2, 3]), ('"text"', "text"), ("null", None), ], ) def test_parse_va...
49
1,091
textual
tools/widget_documentation.py
.py
""" Helper script to help document all widgets. This goes through the widgets listed in textual.widgets and prints the scaffolding for the tables that are used to document the classvars BINDINGS and COMPONENT_CLASSES. """ from __future__ import annotations from typing import TYPE_CHECKING import textual.widgets if ...
80
2,127
mlflow
tests/assistant/test_tool_executor.py
.py
import asyncio import pytest from mlflow.assistant.config import PermissionsConfig from mlflow.assistant.providers.tool_executor import execute_tool @pytest.fixture def workspace(tmp_path): src = tmp_path / "src" src.mkdir() (src / "main.py").write_text("print('hello')") (tmp_path / "README.md").wri...
104
3,075
onnxruntime
orttraining/orttraining/test/python/orttraining_test_ortmodule_hooks.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import os import tempfile import pytest import torch from onnxruntime.training.ortmodule import ORTModule from onnxruntime.training.utils.hooks import GlobalSubscriberManager, StatisticsSubscriber, inspect_activation clas...
203
7,307
wagtail
wagtail/utils/loading.py
.py
from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.utils.module_loading import import_string def get_custom_form(form_setting): """Return custom form class if defined and available""" try: return import_string(getattr(settings, form_setting)) excep...
15
516
beam
sdks/python/apache_beam/internal/cloudpickle/cloudpickle.py
.py
"""Pickler class to extend the standard pickle.Pickler functionality The main objective is to make it natural to perform distributed computing on clusters (such as PySpark, Dask, Ray...) with interactively defined code (functions, classes, ...) written in notebooks or console. In particular this pickler adds the foll...
1,748
63,688
wandb
wandb/apis/_generated/get_project.py
.py
# Generated by ariadne-codegen # Source: tools/graphql_codegen/api/ from __future__ import annotations from wandb._pydantic import GQLResult from .fragments import ProjectFragment class GetProject(GQLResult): project: ProjectFragment | None GetProject.model_rebuild()
16
279
biopython
Tests/test_SeqIO_Insdc.py
.py
# Copyright 2013 by Peter Cock. All rights reserved. # 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. """Tests for SeqIO Insdc module.""" import unittest import warnings from io import StringIO from...
156
5,767
saleor
saleor/tests/e2e/product/test_product_no_longer_on_promotion_when_promotion_is_removed.py
.py
import pytest from ....product.tasks import recalculate_discounted_price_for_products_task from ..promotions.utils import ( create_promotion, create_promotion_rule, delete_promotion, promotion_query, ) from ..shop.utils.preparing_shop import prepare_default_shop from ..utils import assign_permissions f...
103
3,643
mlflow
examples/johnsnowlabs/export.py
.py
import json import os import pandas as pd from johnsnowlabs import nlp import mlflow from mlflow.pyfunc import spark_udf # 1) Write your raw license.json string into the 'JOHNSNOWLABS_LICENSE_JSON' env variable for MLflow creds = { "AWS_ACCESS_KEY_ID": "...", "AWS_SECRET_ACCESS_KEY": "...", "SPARK_NLP_LI...
53
1,596
onnx
tests/python/version_converter_test.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import contextlib import os import struct import tempfile import numpy as np import pytest import onnx.version_converter from onnx import ( GraphProto, ModelProto, OperatorSetIdProto, T...
3,217
123,122
confluent-kafka-python
tests/integration/schema_registry/_async/test_api_client.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2020 Confluent Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
510
17,843
lemur
lemur/plugins/lemur_adcs/plugin.py
.py
from lemur.plugins.bases import IssuerPlugin, SourcePlugin import requests from lemur.plugins import lemur_adcs as ADCS from certsrv import Certsrv from OpenSSL import crypto from flask import current_app class ADCSIssuerPlugin(IssuerPlugin): title = "ADCS" slug = "adcs-issuer" description = "Enables the ...
126
5,311
openvino
src/bindings/python/tests/test_graph/test_fake_convert.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest import openvino.opset13 as ops from openvino import PartialShape, Type @pytest.mark.parametrize( ("data_shape", "scale_shape", "shift_shape", "input_type", "destination_type...
59
2,455
luigi
luigi/__main__.py
.py
# -*- coding: utf-8 -*- # # Copyright 2012-2016 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...
21
683
textual
tests/document/test_document.py
.py
import pytest from textual.widgets.text_area import Document TEXT = """I must not fear. Fear is the mind-killer.""" TEXT_NEWLINE = TEXT + "\n" TEXT_WINDOWS = TEXT.replace("\n", "\r\n") TEXT_WINDOWS_NEWLINE = TEXT_NEWLINE.replace("\n", "\r\n") @pytest.mark.parametrize( "text", [TEXT, TEXT_NEWLINE, TEXT_WINDOWS,...
153
4,548
sqlmap
tamper/space2mysqldash.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import os from lib.core.common import singleTimeWarnMessage from lib.core.compat import xrange from lib.core.enums import DBMS from lib.core.enums import PRIORITY __priority__ =...
58
1,569
wagtail
wagtail/utils/utils.py
.py
from collections.abc import Mapping def deep_update(source, overrides): """Update a nested dictionary or similar mapping. Modify ``source`` in place. """ for key, value in overrides.items(): if isinstance(value, Mapping) and value: returned = deep_update(source.get(key, {}), value...
43
1,407
wandb
wandb/_filters/expressions.py
.py
"""Pydantic-compatible representations of MongoDB expressions.""" from __future__ import annotations import re from collections.abc import Iterable from typing import Any, TypeAlias from pydantic import ConfigDict, model_serializer from typing_extensions import Self from wandb._pydantic import CompatBaseModel, mode...
193
6,356
jupytext
tests/external/pre_commit/test_pre_commit_3_sync_black_nbstripout.py
.py
import pytest from git.exc import HookExecutionError from pre_commit.main import main as pre_commit from jupytext import read, write import sys @pytest.mark.skipif(sys.version_info >= (3, 14), reason="this test fails on Python 3.14") def test_pre_commit_hook_sync_black_nbstripout( tmpdir, cwd_tmpdir, tmp...
77
2,092
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/request_header_provider.py
.py
from mlflow.tracking.request_header.abstract_request_header_provider import RequestHeaderProvider class PluginRequestHeaderProvider(RequestHeaderProvider): """RequestHeaderProvider provided through plugin system""" def in_context(self): return False def request_headers(self): return {"te...
12
335
metrics
src/torchmetrics/functional/regression/mape.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...
92
3,023
pyomo
pyomo/solvers/tests/testcases.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...
617
20,434
mlflow
tests/gateway/providers/test_cohere.py
.py
from unittest import mock import pytest from aiohttp import ClientTimeout from fastapi.encoders import jsonable_encoder from pydantic import ValidationError from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS from mlflow.gateway.config import EndpointConfig from mlflow.gateway.exceptions imp...
641
20,625
onnxruntime
tools/ci_build/op_registration_validator.py
.py
# !/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """ Validate ORT kernel registrations. """ from __future__ import annotations import argparse import dataclasses import itertools import os import sys import typing import op_registration_utils from ...
224
8,860
beam
sdks/python/apache_beam/runners/interactive/interactive_beam_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...
1,067
39,998
saleor
saleor/graphql/giftcard/tests/bulk_mutations/test_gift_card_bulk_create.py
.py
import datetime from unittest import mock import pytest from .....giftcard import GiftCardEvents from .....giftcard.error_codes import GiftCardErrorCode from ....tests.utils import assert_no_permission, get_graphql_content GIFT_CARD_BULK_CREATE_MUTATION = """ mutation GiftCardBulkCreate($input: GiftCardBulkCreat...
538
15,541
astropy
astropy/io/fits/tests/test_convenience.py
.py
# Licensed under a 3-clause BSD style license - see PYFITS.rst import io import os import pathlib import warnings import numpy as np import pytest from numpy.testing import assert_array_equal from astropy import units as u from astropy.io import fits from astropy.io.fits import printdiff from astropy.io.fits.connect...
535
19,425
sphinx
tests/test_directives/test_directives_no_typesetting.py
.py
"""Tests the directives""" from __future__ import annotations import pytest from docutils import nodes from sphinx import addnodes from sphinx.testing import restructuredtext from sphinx.testing.util import assert_node TYPE_CHECKING = False if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp ty...
269
7,209
metrics
src/torchmetrics/functional/pairwise/helpers.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...
61
2,246
coremltools
deps/protobuf/python/google/protobuf/internal/text_encoding_test.py
.py
# Protocol Buffers - Google's data interchange format # Copyright 2008 Google Inc. All rights reserved. # https://developers.google.com/protocol-buffers/ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redi...
68
2,813
astropy
astropy/io/ascii/core.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """An extensible ASCII table reader and writer. core.py: Core base classes and functions for reading and writing tables. :Copyright: Smithsonian Astrophysical Observatory (2010) :Author: Tom Aldcroft (aldcroft@head.cfa.harvard.edu) """ from __future__...
1,862
66,606
biopython
Tests/test_phenotype.py
.py
# Copyright 2014-2016 Marco Galardini. All rights reserved. # Adapted from test_Mymodule.py by Jeff Chang # # This file is part of the Biopython distribution and governed by your # choice of the "Biopython License Agreement" or the "BSD 3-Clause License". # Please see the LICENSE file that should have been included as...
334
13,153
wagtail
wagtail/test/testapp/wagtail_hooks.py
.py
import os import django_filters from django import forms from django.http import HttpResponse from django.utils.safestring import mark_safe import wagtail.admin.rich_text.editors.draftail.features as draftail_features from wagtail import hooks from wagtail.admin.action_menu import ActionMenuItem from wagtail.admin.fi...
498
14,965
pyro
pyro/infer/csis.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import itertools import torch import pyro import pyro.poutine as poutine from pyro.infer.importance import Importance from pyro.infer.util import torch_item from pyro.poutine.util import prune_subsample_sites from pyro.util impor...
202
7,251
qutip
qutip/solver/floquet_bwcomp.py
.py
""" Floquet solver compatibility functions that behave like the corresponding functions from QuTiP 4.7. These functions are indented to be used when porting code from QuTiP 4.7 to QuTiP 5. They are deprecated and will be removed in QuTiP 5.1. """ __all__ = [ "floquet_modes", "floquet_modes_t", "floquet_mo...
245
7,660
confluent-kafka-python
tests/test_ShareConsumer.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2026 Confluent Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
949
34,321
hydra
tools/configen/setup.py
.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from setuptools import find_packages, setup setup( name="hydra-configen", version="0.9.0.dev9", packages=find_packages(include=["configen"]), entry_points={"console_scripts": ["configen = configen.configen:mai...
20
614
astropy
astropy/utils/data_info.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """This module contains functions and methods that relate to the DataInfo class which provides a container for informational attributes as well as summary info methods. A DataInfo object is attached to the Quantity, SkyCoord, and Time classes in astropy....
814
28,143
wagtail
wagtail/management/commands/purge_revisions.py
.py
from django.conf import settings from django.core.management.base import BaseCommand from django.db.models import Q from django.db.models.deletion import ProtectedError from django.utils import timezone from wagtail.models import Revision, WorkflowState class Command(BaseCommand): help = "Delete revisions which ...
94
3,336
probability
tensorflow_probability/python/internal/callable_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...
87
3,457
pdm
tests/cli/test_use.py
.py
import os import shutil import sys from pathlib import Path import pytest from pdm.cli.commands.use import Command as UseCommand from pdm.exceptions import NoPythonVersion from pdm.models.caches import JSONFileCache def test_use_command(project, pdm): python = "python" if os.name == "nt" else "python3" pyth...
106
3,927
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_expired.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
232
6,970
tomli
scripts/use_setuptools.py
.py
"""Script that switches build backend to setuptools with mypyc support. Overwrites pyproject.toml. Does not create a backup. """ from pathlib import Path import tomllib import tomli_w # type: ignore[import-not-found] def use_setuptools() -> None: pyproject_path = Path(__file__).parent.parent / "pyproject.toml...
24
646
returns
returns/_internal/pipeline/managed.py
.py
from collections.abc import Callable from typing import TypeVar from returns.interfaces.specific.ioresult import IOResultLikeN from returns.primitives.hkt import Kinded, KindN, kinded from returns.result import Result _FirstType = TypeVar('_FirstType') _SecondType = TypeVar('_SecondType') _ThirdType = TypeVar('_Third...
140
4,714
toolz
toolz/__init__.py
.py
from .itertoolz import * from .functoolz import * from .dicttoolz import * from .recipes import * from functools import partial, reduce sorted = sorted map = map filter = filter # Aliases comp = compose from . import curried, sandbox functoolz._sigs.create_signature_registry() def __getattr__(name): if ...
33
543
confluent-kafka-python
tests/test_DeserializingConsumer.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2026 Confluent Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
124
4,428
django-cms
cms/tests/test_po.py
.py
import os import shutil import subprocess import sys from pathlib import Path from django.core.management.base import CommandError from django.core.management.commands.compilemessages import has_bom from django.test.testcases import TestCase from cms.test_utils.util.context_managers import TemporaryDirectory THIS_DI...
78
3,140
conda
tests/cli/test_main_commands.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from __future__ import annotations from typing import TYPE_CHECKING from conda.base.context import context from conda.cli.conda_argparse import BUILTIN_COMMANDS if TYPE_CHECKING: from conda.testing import CondaCLIFixture def test_comman...
25
646
saleor
saleor/graphql/attribute/utils/attribute_assignment.py
.py
from collections import defaultdict from typing import TYPE_CHECKING, cast import graphene from django.core.exceptions import ValidationError from django.db.models import Prefetch, Q from django.db.models.expressions import Exists, OuterRef from graphql.error import GraphQLError from ....attribute import AttributeInp...
478
17,991
cvxpy
cvxpy/interface/base_matrix_interface.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...
139
5,137
biopython
Tests/test_GenomeDiagram.py
.py
# 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. """Tests for GenomeDiagram general functionality.""" import math import os import unittest # Do we have ReportLab? Raise error if not present. from B...
1,278
47,046
saleor
saleor/graphql/account/mutations/staff/address_update.py
.py
from .....account import models from .....permission.enums import AccountPermissions from .....webhook.event_types import WebhookEventAsyncType from ....account.types import Address from ....core.doc_category import DOC_CATEGORY_USERS from ....core.types import AccountError from ....core.utils import WebhookEventInfo f...
27
969
textual
tests/snapshot_tests/snapshot_apps/app_blur.py
.py
from textual.app import App, ComposeResult from textual.events import AppBlur from textual.widgets import Input class AppBlurApp(App[None]): CSS = """ Screen { align: center middle; } Input { width: 50%; margin-bottom: 1; &:focus { width: 75%; ...
33
668
saleor
saleor/graphql/plugins/resolvers.py
.py
from collections import defaultdict from django.conf import settings from ...plugins.base_plugin import BasePlugin, ConfigurationTypeField from .filters import ( filter_plugin_by_type, filter_plugin_search, filter_plugin_status_in_channels, ) from .sorters import sort_plugins from .types import Plugin d...
118
3,789
pyomo
pyomo/core/plugins/transform/eliminate_fixed_vars.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...
86
3,414
saleor
saleor/graphql/product/mutations/product_variant/product_variant_preorder_deactivate.py
.py
import graphene from django.core.exceptions import ValidationError from .....core.exceptions import PreorderAllocationError from .....core.tracing import traced_atomic_transaction from .....permission.enums import ProductPermissions from .....product import models from .....product.error_codes import ProductErrorCode ...
69
2,656
onnx
onnx/serialization.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import warnings __all__ = [ "registry", ] import typing from typing import Any, Protocol, TypeVar import google.protobuf.json_format import google.protobuf.message import google.protobuf.text_fo...
213
7,910
biopython
Tests/test_Cluster.py
.py
# 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. """Tests for Cluster module.""" import unittest try: import numpy as np except ImportError: from Bio import MissingPythonDependencyError ...
3,116
111,233
hydra
examples/plugins/example_configsource_plugin/hydra_plugins/example_configsource_plugin/example_configsource_plugin.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from typing import Any, Dict, List, Optional from hydra.core.object_type import ObjectType from hydra.plugins.config_source import ConfigLoadError, ConfigResult, ConfigSource from omegaconf import OmegaConf class ConfigSourceExample(ConfigSource)...
131
5,279
qutip
qutip/core/qobj.py
.py
"""The Quantum Object (Qobj) class, for representing quantum states and operators, and related functions. """ from __future__ import annotations import functools import numbers import warnings from typing import Any, Literal, TypeVar, Union, overload from collections.abc import Callable import numpy as np from numpy.t...
2,127
74,919
biopython
Bio/SearchIO/HmmerIO/hmmer3_domtab.py
.py
# Copyright 2012 by Wibowo Arindrarto. All rights reserved. # This file is part of the Biopython distribution and governed by your # choice of the "Biopython License Agreement" or the "BSD 3-Clause License". # Please see the LICENSE file that should have been included as part of this # package. """Bio.SearchIO parser ...
379
14,071
onnx
onnx/backend/test/case/node/bitcast.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 BitCast(Base): @staticmethod def export_bitcast_float32_to_int...
148
5,158
onnxruntime
orttraining/orttraining/python/training/onnxblock/onnxblock.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import logging from abc import abstractmethod import onnx import onnxruntime.training.onnxblock._graph_utils as _graph_utils import onnxruntime.training.onnxblock._training_graph_utils as _training_graph_utils import onnxru...
214
8,778
lemur
lemur/defaults/views.py
.py
""" .. module: lemur.defaults.views :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. """ from flask import current_app, Blueprint from flask_restful import Api from lemur.common.schema import validate_schema from lemur.authorities.service import get_by_...
81
2,367
mlflow
examples/multistep_workflow/main.py
.py
""" Downloads the MovieLens dataset, ETLs it into Parquet, trains an ALS model, and uses the ALS model to train a Keras neural network. See README.md for more details. """ import os import click import mlflow from mlflow.entities import RunStatus from mlflow.tracking import MlflowClient from mlflow.tracking.fluent ...
108
4,405
qutip
qutip/tests/solver/test_integrator.py
.py
from qutip.solver.sesolve import SESolver from qutip.solver.mesolve import MESolver from qutip.solver.mcsolve import MCSolver from qutip.solver.solver_base import Solver from qutip.solver.integrator import * from qutip.solver.integrator._rhs import RHS import qutip import qutip.core.data as _data import functools impo...
297
10,681
pyomo
pyomo/contrib/pynumero/interfaces/tests/test_external_grey_box_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...
2,153
86,297
openvino
src/bindings/python/tests/test_graph/test_ops_matmul.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest import openvino.opset8 as ov @pytest.mark.parametrize( ("shape_a", "shape_b", "transpose_a", "transpose_b", "output_shape"), [ # matrix, vector ([2, 4], ...
36
1,180
wandb
wandb/wandb_run.py
.py
"""Compatibility wandb_run module. Please use `wandb.Run` instead. """ from wandb.sdk.wandb_run import Run __all__ = ["Run"]
9
128
sqlmap
tamper/misunion.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import os import re from lib.core.common import singleTimeWarnMessage from lib.core.enums import DBMS from lib.core.enums import PRIORITY __priority__ = PRIORITY.HIGHEST def de...
37
954
mlflow
tests/langgraph/sample_code/langgraph_with_custom_span.py
.py
from typing import Literal from langchain_core.messages import AIMessage, ToolCall from langchain_core.output_parsers import StrOutputParser from langchain_core.outputs import ChatGeneration, ChatResult from langchain_core.prompts import PromptTemplate from langchain_core.tools import tool from langchain_openai import...
60
1,817
pyomo
pyomo/contrib/piecewise/transform/piecewise_linear_transformation_base.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...
282
11,425
mlflow
mlflow/haystack/__init__.py
.py
from mlflow.haystack.autolog import setup_haystack_tracing, teardown_haystack_tracing from mlflow.utils.autologging_utils import autologging_integration FLAVOR_NAME = "haystack" def autolog( log_traces: bool = True, disable: bool = False, silent: bool = False, ): """ Enables (or disables) and con...
39
1,256
readthedocs.org
readthedocs/rtd_tests/tests/test_imported_file.py
.py
import os from unittest import mock import pytest from django.core.files.storage import storages from django.test import TestCase from django.test.utils import override_settings from django_dynamic_fixture import get from readthedocs.builds.constants import BUILD_STATE_FINISHED, EXTERNAL, LATEST from readthedocs.buil...
404
13,772
rq
tests/__init__.py
.py
import logging import os import unittest import pytest from redis import Redis from rq.utils import get_version def find_empty_redis_database(ssl=False): """Tries to connect to a random Redis database (starting from 4), and will use/connect it when no keys are in there. """ for dbnum in range(4, 17)...
76
2,127
hatch
tests/helpers/templates/new/feature_cli.py
.py
from hatch.template import File from hatch.utils.fs import Path from ..licenses import MIT def get_files(**kwargs): return [ File( Path("LICENSE.txt"), MIT.replace("<year>", f"{kwargs['year']}-present", 1).replace( "<copyright holders>", f"{kwargs['author']} <{kwar...
169
4,794
pyro
examples/contrib/gp/sv-dkl.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 """ An example to use Pyro Gaussian Process module to classify MNIST and binary MNIST. Follow the idea from reference [1], we will combine a convolutional neural network (CNN) with a RBF kernel to create a "deep" kernel: >>> ...
266
8,529
conda
tests/notices/test_fetch.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from unittest.mock import patch import requests from conda.notices.cache import is_notice_response_cache_expired from conda.notices.core import display_notices, retrieve_notices from conda.testing.notices.helpers import add_resp_to_mock def ...
56
1,894
pymc
pymc/step_methods/hmc/quadpotential.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...
960
33,106
cvxpy
cvxpy/tests/nlp_tests/test_nlp_parameters.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 ...
463
17,329
mlflow
tests/genai/scorers/online/test_trace_processor.py
.py
import json import uuid from unittest.mock import MagicMock, patch import pytest from mlflow.entities import Trace, TraceData, TraceInfo from mlflow.genai.scorers.builtin_scorers import Completeness from mlflow.genai.scorers.online.entities import OnlineScorer, OnlineScoringConfig from mlflow.genai.scorers.online.sam...
530
19,853
cvxpy
cvxpy/tests/test_scalarize.py
.py
import pytest import cvxpy as cp from cvxpy.error import DCPError from cvxpy.tests.base_test import BaseTest from cvxpy.transforms import scalarize class ScalarizeTest(BaseTest): """ Tests for the scalarize transform. """ def setUp(self) -> None: self.x = cp.Variable() obj1 = cp.Min...
491
19,758
hatch
tests/cli/test/test_test.py
.py
from __future__ import annotations import sys import pytest from hatch.config.constants import ConfigEnvVars from hatch.env.utils import get_env_var from hatch.project.core import Project from hatch.utils.structures import EnvVars @pytest.fixture(scope="module", autouse=True) def _terminal_width(): with EnvVar...
1,200
42,889
onnx
onnx/reference/ops/op_bitcast.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.reference.op_run import OpRun class BitCast(OpRun): def _run(self, x, to: int): # type: ignore[override] if to == onnx.TensorProto.STRING: ...
30
957
astropy
astropy/cosmology/_src/tests/io/test_ecsv.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pytest from astropy.cosmology._src.core import _COSMOLOGY_CLASSES from astropy.cosmology._src.io.builtin.ecsv import read_ecsv, write_ecsv from astropy.table import QTable, Table, vstack from .base import ReadWriteDirectTestBase, ReadWriteTestMix...
231
8,260
wandb
tools/generate_stubs.py
.py
r"""Generate and verify stubs for public APIs in the wandb module. This script automates the process of creating and validating type stub files for the wandb module's public APIs. It performs the following steps: 1. Generate stubs: - Read the __init__.template.pyi file, which contains signatures of public APIs ...
247
8,591
deap
doc/code/benchmarks/himmelblau.py
.py
from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm from matplotlib.colors import LogNorm import matplotlib.pyplot as plt try: import numpy as np except: exit() from deap import benchmarks def himmelblau_arg0(sol): return benchmarks.himmelblau(sol)[0] fig = plt.figure() ax = Axes3D(fig, az...
28
671
saleor
saleor/graphql/channel/mutations/base_channel_listing.py
.py
import datetime from collections import defaultdict from collections.abc import Iterable from django.core.exceptions import ValidationError from ....channel import models from ....core.utils.date_time import convert_to_utc_date_time from ...core import ResolveInfo from ...core.mutations import BaseMutation from ...co...
135
4,855
loguru
loguru/_defaults.py
.py
from os import environ def env(key, type_, default=None): if key not in environ: return default val = environ[key] if type_ is str: return val if type_ is bool: if val.lower() in ["1", "true", "yes", "y", "ok", "on"]: return True if val.lower() in ["0", "f...
76
3,009
mlflow
mlflow/genai/git_versioning/__init__.py
.py
import logging from typing_extensions import Self import mlflow from mlflow.genai.git_versioning.git_info import GitInfo, GitOperationError from mlflow.telemetry.events import GitModelVersioningEvent from mlflow.telemetry.track import record_usage_event from mlflow.tracking.fluent import _set_active_model from mlflow...
162
5,382
astropy
astropy/visualization/transform.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst __all__ = ["BaseTransform", "CompositeTransform"] class BaseTransform: """ A transformation object. This is used to construct transformations such as scaling, stretching, and so on. """ def __add__(self, other): return...
42
1,083
saleor
saleor/plugins/base_plugin.py
.py
from collections import defaultdict from collections.abc import Callable from copy import copy from dataclasses import dataclass from decimal import Decimal from typing import TYPE_CHECKING, Any, Optional, Union from django.http import HttpResponse from django.utils.functional import SimpleLazyObject from prices impor...
1,917
77,129
mlflow
mlflow/genai/judges/optimizers/gepa.py
.py
"""GEPA alignment optimizer implementation.""" import logging from typing import Any, Callable, Collection from mlflow.exceptions import MlflowException from mlflow.genai.judges.optimizers.dspy import DSPyAlignmentOptimizer from mlflow.genai.judges.optimizers.dspy_utils import create_gepa_metric_adapter from mlflow.p...
140
5,278
biopython
Tests/test_SearchIO_fasta_m10.py
.py
# Copyright 2012 by Wibowo Arindrarto. All rights reserved. # 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. """Tests for SearchIO FastaIO parsers.""" import os import unittest from Bio.SearchIO im...
3,138
139,531
mlflow
mlflow/data/polars_dataset.py
.py
import json import logging from functools import cached_property from inspect import isclass from typing import Any, Final, TypedDict import polars as pl from packaging.version import Version if Version(pl.__version__).major < 1: raise ImportError(f"mlflow.data.polars_dataset requires polars>=1.0.0, found {pl.__v...
358
12,087
probability
spinoffs/inference_gym/inference_gym/targets/logistic_regression_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...
123
4,297
beam
sdks/python/apache_beam/io/external/generate_sequence.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...
66
2,467
conda
conda/cli/main_mock_deactivate.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Mock CLI implementation for `conda deactivate`. A mock implementation of the deactivate shell command for better UX. """ from __future__ import annotations from typing import TYPE_CHECKING from .. import CondaError if TYPE_CHECKING: ...
31
823