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
beam
sdks/python/apache_beam/io/source_test_utils_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...
134
4,925
mlflow
examples/langchain/chain_as_code_driver.py
.py
# This is an example for logging a Langchain model from code using the # mlflow.langchain.log_model API. When a path to a valid Python script is submitted to the # lc_model argument, the model code itself is serialized instead of the model object. # Within the targeted script, the model implementation must be defined a...
40
1,267
readthedocs.org
readthedocs/oauth/notifications.py
.py
"""Notifications related to OAuth.""" import textwrap from django.utils.translation import gettext_lazy as _ from readthedocs.notifications.constants import ERROR from readthedocs.notifications.constants import INFO from readthedocs.notifications.constants import WARNING from readthedocs.notifications.messages impor...
180
7,117
astropy
astropy/io/fits/scripts/fitsinfo.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ ``fitsinfo`` is a command-line script based on astropy.io.fits for printing a summary of the HDUs in one or more FITS files(s) to the standard output. Example usage of ``fitsinfo``: 1. Print a summary of the HDUs in a FITS file:: $ fitsinfo file...
77
2,142
coremltools
coremltools/converters/mil/mil/ops/tests/iOS14/test_reduction.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 itertools import numpy as np import pytest import scipy from coremltools.converters.mil.mil ...
344
13,779
beam
sdks/python/apache_beam/runners/portability/job_server_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...
83
2,573
mlflow
mlflow/tracking/default_experiment/databricks_notebook_experiment_provider.py
.py
from functools import lru_cache from mlflow.exceptions import MlflowException from mlflow.protos import databricks_pb2 from mlflow.tracking.client import MlflowClient from mlflow.tracking.default_experiment.abstract_context import DefaultExperimentProvider from mlflow.utils import databricks_utils from mlflow.utils.ml...
45
1,851
astropy
astropy/visualization/wcsaxes/core.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from collections import defaultdict from functools import partial import numpy as np from matplotlib import rcParams from matplotlib.artist import Artist from matplotlib.axes import Axes, subplot_class_factory from matplotlib.transforms import Affine2D, ...
951
38,690
pyomo
doc/OnlineDocs/src/data/param5a.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...
24
837
probability
tensorflow_probability/python/distributions/half_student_t_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...
627
23,107
readthedocs.org
readthedocs/api/v2/utils.py
.py
"""Utility functions that are used by both views and celery tasks.""" import itertools import re import structlog from django.conf import settings from rest_framework.pagination import PageNumberPagination from readthedocs.builds.constants import BRANCH from readthedocs.builds.constants import INTERNAL from readthed...
316
10,571
conda
conda/core/portability.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Tools for cross-OS portability.""" from __future__ import annotations import os import re import struct import subprocess import threading from contextlib import contextmanager from logging import getLogger from os.path import basename, rea...
495
18,489
pyomo
pyomo/contrib/piecewise/__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...
49
2,087
saleor
saleor/giftcard/tests/test_gateway.py
.py
from decimal import Decimal import pytest from ...giftcard import GiftCardEvents from ...giftcard.const import GIFT_CARD_PAYMENT_GATEWAY_ID from ...giftcard.gateway import ( charge_gift_card_transactions, refund_gift_card_transaction, ) from ...giftcard.models import GiftCardEvent from ...payment import Trans...
133
4,281
onnxruntime
onnxruntime/test/common/test_cpuinfo_sysfs_fallback.py
.py
#!/usr/bin/env python3 """ Simulation test for the cpuinfo sysfs fallback fix. This test verifies two fixes for https://github.com/microsoft/onnxruntime/issues/10038: 1. Safe logging in env.cc - PosixEnv constructor no longer crashes when the logging system is not yet initialized and cpuinfo_initialize() fails. 2...
564
21,514
sqlmap
extra/icmpsh/icmpsh_m.py
.py
#!/usr/bin/env python # # icmpsh - simple icmp command shell (port of icmpsh-m.pl written in # Perl by Nico Leidecker <nico@leidecker.info>) # # Copyright (c) 2010, Bernardo Damele A. G. <bernardo.damele@gmail.com> # # # This program is free software: you can redistribute it and/or modify # it under the terms of t...
145
4,809
saleor
saleor/graphql/shipping/types.py
.py
import graphene from django.db.models import QuerySet from graphene import relay from ...core.weight import convert_weight_to_default_weight_unit from ...permission.auth_filters import AuthorizationFilters from ...permission.enums import ShippingPermissions from ...product import models as product_models from ...shipp...
436
16,226
saleor
saleor/graphql/meta/tests/mutations/test_delete_private_metadata.py
.py
import base64 import graphene from .....core.error_codes import MetadataErrorCode from .....core.models import ModelWithMetadata from .....tests import race_condition from ....tests.utils import get_graphql_content from . import ( PRIVATE_KEY, PRIVATE_VALUE, PUBLIC_KEY, PUBLIC_KEY2, PUBLIC_VALUE, ...
259
6,966
textual
src/textual/_wrap.py
.py
from __future__ import annotations import re from typing import Iterable from rich.cells import get_character_cell_size from textual._cells import cell_len from textual._loop import loop_last from textual.expand_tabs import get_tab_widths re_chunk = re.compile(r"\S+\s*|\s+") def chunks(text: str) -> Iterable[tupl...
148
5,986
gunicorn
tests/test_http.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. import io import t import pytest from unittest import mock from gunicorn import util from gunicorn.http.body import Body, LengthReader, EOFReader from gunicorn.http.wsgi import FileWrapper, Response from gunicorn....
440
13,615
pyomo
doc/OnlineDocs/src/data/ABCD1.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...
19
719
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_elu.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # relu6 paddle model generator # import numpy as np from save_model import saveModel import paddle import sys def elu(name: str, x, alpha=None, data_type='float32'): paddle.enable_static() with paddle.static.program_guard(pa...
45
1,261
returns
returns/contrib/mypy/_features/partial.py
.py
from collections.abc import Iterator from itertools import starmap from typing import Final, final from mypy.nodes import ARG_STAR, ARG_STAR2 from mypy.plugin import FunctionContext from mypy.types import ( CallableType, FunctionLike, Instance, Overloaded, ProperType, TypeType, get_proper_t...
271
9,017
wagtail
wagtail/documents/tests/test_search.py
.py
import unittest from io import StringIO from django.conf import settings from django.core import management from django.core.files.base import ContentFile from django.test import TestCase from django.urls import reverse from wagtail.documents import models from wagtail.search.backends import get_search_backend from w...
135
4,965
scikit-bio
skbio/io/format/embl.py
.py
"""EMBL format (:mod:`skbio.io.format.embl`) ========================================= .. currentmodule:: skbio.io.format.embl EMBL format stores sequence and its annotation together. The start of the annotation section is marked by a line beginning with the word "ID". The start of sequence section is marked by a lin...
1,620
54,567
wagtail
wagtail/admin/rich_text/converters/contentstate.py
.py
import json import logging import re from draftjs_exporter import DOM, HTMLExporter, render_children from wagtail.admin.rich_text.converters.html_to_contentstate import ( BLOCK_KEY_NAME, HtmlToContentStateHandler, ) from wagtail.rich_text import features as feature_registry from wagtail.whitelist import check...
148
4,845
onnxruntime
orttraining/orttraining/python/training/ortmodule/_custom_gradient_registry.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- # Support registration of ATen op's symbolic (PyTorch exporter overridin...
316
12,623
ipython
tests/test_path.py
.py
# encoding: utf-8 """Tests for IPython.utils.path.py""" # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. import os import shutil import sys import tempfile from contextlib import contextmanager from importlib import reload from os.path import abspath, join from unit...
508
15,669
coremltools
coremltools/test/optimize/torch/palettization/test_palettization_utils.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 copy import pytest import torch from coremltools.optimize.torch.palettization._utils import ...
55
1,835
onnxruntime
orttraining/orttraining/python/training/ortmodule/_graph_execution_manager.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import copy import logging import os from abc import ABC, abstractmethod...
557
25,378
metrics
src/torchmetrics/functional/classification/eer.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...
285
13,176
gunicorn
tests/treq_asgi.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Test request utilities for ASGI callback parser. Provides the same test infrastructure as treq.py but for testing the ASGI callback parsers (PythonProtocol and H1CProtocol). """ import importlib.machinery impo...
355
12,258
kafka
tests/kafkatest/services/kafka/config.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 ...
52
2,112
pyro
pyro/distributions/transforms/batchnorm.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import torch import torch.nn as nn import torch.nn.functional as F from .. import constraints from ..torch_transform import TransformModule from ..util import copy_docs_from @copy_docs_from(TransformModule) class BatchNorm(Trans...
158
6,147
pyomo
pyomo/core/base/var.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,015
36,585
gunicorn
tests/test_statsd.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. import io import logging import os import shutil import socket import tempfile from datetime import timedelta from types import SimpleNamespace from gunicorn.config import Config from gunicorn.instrument.statsd im...
162
4,916
hydra
hydra/test_utils/completion.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from omegaconf import DictConfig, OmegaConf import hydra @hydra.main(config_path="configs/completion_test", config_name="config") def run_cli(cfg: DictConfig) -> None: print(OmegaConf.to_yaml(cfg)) if __name__ == "__main__": run_cli()
14
319
conda
tests/gateways/disk/test_lock.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from pathlib import Path import pytest from pytest_mock import MockerFixture from conda.common.compat import on_win from conda.exceptions import LockError from conda.gateways.disk.lock import _lock_impl def test_LockError_raised(mocker: Mo...
58
1,534
saleor
saleor/graphql/channel/tests/mutations/test_channel_activate.py
.py
import json from unittest import mock import graphene from django.utils.functional import SimpleLazyObject from freezegun import freeze_time from .....channel.error_codes import ChannelErrorCode from .....core.utils.json_serializer import CustomJsonEncoder from .....webhook.event_types import WebhookEventAsyncType fr...
127
3,711
wagtail
wagtail/api/v3/schemas/base.py
.py
from collections.abc import Callable from dataclasses import dataclass from typing import Annotated, Any, Iterable, Union from django.core.exceptions import ImproperlyConfigured from django.db.models import Model from ninja import Schema from pydantic import Discriminator, Tag class BaseMetaSchema(Schema): type:...
145
4,616
funcy
funcy/tree.py
.py
from collections import deque from .types import is_seqcont __all__ = ['tree_leaves', 'ltree_leaves', 'tree_nodes', 'ltree_nodes'] def tree_leaves(root, follow=is_seqcont, children=iter): """Iterates over tree leaves.""" q = deque([[root]]) while q: node_iter = iter(q.pop()) for sub in n...
41
1,130
qutip
qutip/fileio.py
.py
__all__ = ['file_data_store', 'file_data_read', 'qsave', 'qload'] import pickle import numpy as np from .core import Qobj from pathlib import Path # ----------------------------------------------------------------------------- # Write matrix data to a file # def file_data_store(filename, data, numtype="complex", num...
236
7,117
mlflow
mlflow/server/jobs/_periodic_tasks_consumer.py
.py
""" This module is used for launching the periodic tasks Huey consumer. This is a dedicated consumer that only runs periodic tasks (like the online scoring scheduler). It is launched by the job runner and runs in a separate process from job execution consumers. """ import threading from mlflow.server.jobs.logging_ut...
33
1,056
pyomo
pyomo/core/expr/numvalue.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...
440
13,294
mlflow
mlflow/tracking/request_header/default_request_header_provider.py
.py
from mlflow import __version__ from mlflow.tracking.request_header.abstract_request_header_provider import RequestHeaderProvider _USER_AGENT = "User-Agent" _CLIENT_VERSION = "X-MLflow-Client-Version" _MLFLOW_PYTHON_CLIENT_USER_AGENT_PREFIX = "mlflow-python-client/" # We need to specify client version in separate heade...
24
761
astropy
astropy/io/votable/tests/test_table.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Test the conversion to/from astropy.table. """ import io import os import pathlib import struct import warnings import numpy as np import pytest from astropy import units as u from astropy.io.votable import conf, from_table, is_votable, tree, valida...
997
31,009
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_confirmed.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...
231
7,005
saleor
saleor/graphql/payment/tests/mutations/test_payment_capture.py
.py
import graphene from saleor.plugins.tests.gateways.dummy import ( TOKEN_EXPIRED, TOKEN_VALIDATION_MAPPING, ) from .....payment import TransactionKind from .....payment.models import ChargeStatus from ....tests.utils import assert_no_permission, get_graphql_content CAPTURE_QUERY = """ mutation PaymentCapt...
254
8,271
beam
sdks/python/apache_beam/runners/portability/spark_uber_jar_job_server.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...
277
10,210
mlflow
tests/tracing/utils/test_copy.py
.py
import time import pytest import mlflow from mlflow.tracing.utils.copy import copy_trace_to_experiment from tests.tracing.helper import purge_traces def _create_test_span_dict(request_id="test-trace", parent_id=None): """Helper to create a minimal valid span dict for testing""" return { "name": "ro...
124
3,659
pyomo
examples/pyomo/concrete/rosen.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...
19
723
openvino
tests/layer_tests/tensorflow_tests/test_tf_L2Loss.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest import tensorflow as tf from common.tf_layer_test_class import CommonTFLayerTest rng = np.random.default_rng(233453) class TestL2Loss(CommonTFLayerTest): def _prepare_input(self, inputs_info): ...
46
1,818
clearml
clearml/backend_api/session/errors.py
.py
from typing import Any class SessionError(Exception): pass class AsyncError(SessionError): def __init__(self, msg: str, *args: Any, **kwargs: Any) -> None: super(AsyncError, self).__init__(msg, *args) for k, v in kwargs.items(): setattr(self, k, v) class TimeoutExpiredError(Ses...
21
393
mlflow
mlflow/tracing/export/genai_semconv/converter.py
.py
""" Abstract base class for format-specific message converters. Each LLM provider stores inputs/outputs in its own format (e.g. OpenAI, Anthropic). Converters translate these provider-specific formats into the GenAI Semantic Convention attributes: gen_ai.input.messages, gen_ai.output.messages, request params, and resp...
84
3,536
sphinx
tests/test_util/test_util_docstrings.py
.py
"""Test sphinx.util.docstrings.""" from __future__ import annotations from sphinx.util.docstrings import ( prepare_commentdoc, prepare_docstring, separate_metadata, ) def test_separate_metadata() -> None: # metadata only text = ':meta foo: bar\n:meta baz:\n' docstring, metadata = separate_me...
85
2,864
lemur
lemur/plugins/lemur_acme/acme_handlers.py
.py
""" .. module: lemur.plugins.lemur_acme.plugin :platform: Unix :synopsis: This module contains handlers for certain acme related tasks. It needed to be refactored to avoid circular imports :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. Sni...
620
27,446
saleor
saleor/graphql/page/tests/mutations/test_page_reorder_attribute_values.py
.py
import graphene from .....attribute.models import AttributeValue from .....attribute.utils import associate_attribute_values_to_instance from .....page.error_codes import PageErrorCode from ....tests.utils import get_graphql_content PAGE_REORDER_ATTRIBUTE_VALUES_MUTATION = """ mutation PageReorderAttributeValues(...
239
7,249
metrics
tests/unittests/classification/test_logauc.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...
417
17,201
mlflow
tests/demo/test_judges_generator.py
.py
import pytest from mlflow.demo.base import DemoFeature, DemoResult from mlflow.demo.generators.judges import DEMO_JUDGE_PREFIX, JudgesDemoGenerator from mlflow.genai.scorers.registry import list_scorers @pytest.fixture def judges_generator(): generator = JudgesDemoGenerator() original_version = generator.ver...
87
2,382
lemur
lemur/sources/views.py
.py
""" .. module: lemur.sources.views :platform: Unix :synopsis: This module contains all of the accounts view code. :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. .. moduleauthor:: Kevin Glisson <kglisson@netflix.com> """ from flask import Bluepr...
380
11,713
beam
sdks/python/apache_beam/examples/snippets/transforms/elementwise/filter_side_inputs_dict.py
.py
# coding=utf-8 # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License");...
79
2,456
coremltools
coremltools/optimize/torch/quantization/modules/qat_modules.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 from collections import OrderedDict as _OrderedDict from typing import Type as _Type from typing impo...
264
7,367
probability
tensorflow_probability/python/bijectors/chain.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...
177
6,301
openvino
src/frontends/tensorflow/tests/test_models/models_pbtxt/model_with_output_shapes_attr.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import tensorflow.compat.v1 as tf tf.reset_default_graph() with tf.Session() as sess: x = tf.placeholder(dtype=tf.float32, shape=[2,3], name='x') tf.nn.relu(x, name="relu") tf.global_variables_initializer() sess.graph...
16
443
black
tests/conftest.py
.py
import pytest pytest_plugins = ["tests.optional"] PRINT_FULL_TREE: bool = False PRINT_TREE_DIFF: bool = True def pytest_addoption(parser: pytest.Parser) -> None: parser.addoption( "--print-full-tree", action="store_true", default=False, help="print full syntax trees on failed tes...
29
727
coremltools
coremltools/converters/mil/frontend/tensorflow/test/testing_utils.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 import tempfile import numpy as np import pytest import coremltools.models.utils as corem...
397
15,118
qutip
qutip/tests/core/test_superop_reps.py
.py
""" Created on Wed May 29 11:23:46 2013 @author: dcriger """ import numpy as np import pytest from qutip import ( Qobj, basis, identity, sigmax, sigmay, qeye, create, rand_super, rand_super_bcsz, rand_dm, tensor, super_tensor, kraus_to_choi, kraus_to_super, to_super, to_superpauli, superpauli_to_super, t...
397
13,987
pyomo
examples/pyomo/radertext/Ex2_5.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...
85
2,768
conda
conda/core/initialize.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Backend logic for `conda init`. Sections in this module are 1. top-level functions 2. plan creators 3. plan runners 4. individual operations 5. helper functions The top-level functions compose and execute full plans. A plan is c...
2,374
80,336
conda
conda/history.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Tools interfacing with conda's history file.""" from __future__ import annotations import logging import os import re import sys import time import warnings from ast import literal_eval from errno import EACCES, EPERM, EROFS from itertools ...
427
15,693
sqlmap
plugins/dbms/clickhouse/takeover.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ from lib.core.exception import SqlmapUnsupportedFeatureException from plugins.generic.takeover import Takeover as GenericTakeover class Takeover(GenericTakeover): def osCmd(s...
29
986
wagtail
wagtail/documents/rich_text/contentstate.py
.py
""" Draftail / contentstate conversion """ from draftjs_exporter import DOM from wagtail.admin.rich_text.converters.html_to_contentstate import LinkElementHandler from wagtail.documents import get_document_model def document_link_entity(props): """ Helper to construct elements of the form <a id="1" link...
59
1,451
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_flatten_contiguous_range.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # generate_flatten_contiguous_range paddle model generator # import numpy as np from save_model import saveModel import sys def generate_flatten_contiguous_range(name : str, x, start_axis, stop_axis, in_dtype): import paddle p...
42
1,316
onnx
onnx/backend/test/case/node/reduce_log_sum_exp.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 ReduceLogSumExp(Base): @staticmethod def export_do_not_keepdim...
194
5,778
onnx
onnx/reference/ops/aionnxml/op_svm_classifier.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.ops.aionnxml._common_classifier import ( compute_logistic, compute_probit, compute_softmax_zero, logistic, softmax, softmax_zero, ) from on...
334
11,382
wandb
wandb/sdk/artifacts/_generated/artifact_membership_by_name.py
.py
# Generated by ariadne-codegen # Source: tools/graphql_codegen/artifacts/ from __future__ import annotations from pydantic import Field from wandb._pydantic import GQLResult from .fragments import ArtifactMembershipFragment class ArtifactMembershipByName(GQLResult): project: ArtifactMembershipByNameProject | ...
25
598
pyomo
pyomo/core/base/indexed_component.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,277
50,779
mlflow
examples/mistral/tracing.py
.py
""" This is an example for leveraging MLflow's auto tracing capabilities for Mistral AI. For more information about MLflow Tracing, see: https://mlflow.org/docs/latest/llms/tracing/index.html """ import os from mistralai import Mistral import mlflow # Turn on auto tracing for Mistral AI by calling mlflow.mistral.a...
30
762
beam
sdks/python/apache_beam/dataframe/pandas_top_level_functions.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...
188
6,115
metrics
src/torchmetrics/functional/image/qnr.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...
82
3,201
lemur
lemur/tests/test_sources.py
.py
import pytest from lemur.sources.views import * # noqa from .vectors import ( VALID_ADMIN_API_TOKEN, VALID_ADMIN_HEADER_TOKEN, VALID_USER_HEADER_TOKEN, WILDCARD_CERT_STR, WILDCARD_CERT_KEY, ) def validate_source_schema(client): from lemur.sources.schemas import SourceInputSchema input_...
202
4,677
beam
sdks/python/apache_beam/transforms/ptransform.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,267
45,968
textual
tests/test_await_remove.py
.py
from textual.app import App from textual.widgets import Label class SelfRemovingLabel(Label): async def on_mount(self) -> None: await self.remove() class RemoveOnTimerApp(App[None]): def on_mount(self): for _ in range(5): self.mount(SelfRemovingLabel("I will remove myself!")) a...
22
670
confluent-kafka-python
tests/ducktape/consumer_strategy.py
.py
""" Consumer strategies for testing sync and async Kafka consumers. This module contains strategy classes that encapsulate the different consumer implementations (sync vs async) with consistent interfaces for testing. """ import asyncio import json import os import time from confluent_kafka import Consumer from conf...
592
22,188
wagtail
wagtail/contrib/styleguide/wagtail_hooks.py
.py
from django.urls import path, reverse from django.utils.translation import gettext_lazy as _ from wagtail import hooks from wagtail.admin.menu import MenuItem from . import views @hooks.register("register_admin_urls") def register_admin_urls(): return [ path("styleguide/", views.IndexView.as_view(), nam...
26
600
pyro
tests/distributions/test_hmm.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import logging import operator from functools import reduce import opt_einsum import pytest import torch import pyro import pyro.distributions as dist from pyro.distributions.hmm import ( _sequential_gamma_gaussian_tensordot,...
1,027
36,873
textual
src/textual/timer.py
.py
""" Contains the `Timer` class. Timer objects are created by [set_interval][textual.message_pump.MessagePump.set_interval] or [set_timer][textual.message_pump.MessagePump.set_timer]. """ from __future__ import annotations import weakref from asyncio import CancelledError, Event, Task, create_task, gather from ty...
204
6,255
wagtail
wagtail/api/v2/apps.py
.py
from django.apps import AppConfig, apps from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.utils.translation import gettext_lazy as _ class WagtailAPIV2AppConfig(AppConfig): name = "wagtail.api.v2" label = "wagtailapi_v2" verbose_name = _("Wagtail API v2")...
27
964
probability
discussion/turnkey_inference_candidate/__init__.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...
20
897
mlflow
mlflow/genai/discovery/entities.py
.py
from __future__ import annotations from dataclasses import dataclass, field import pydantic from mlflow.entities.issue import Issue, IssueSeverity from mlflow.entities.trace import Trace from mlflow.genai.discovery.constants import RATIONALE_TRUNCATION_LIMIT @dataclass class _TriageResult: failing_traces: list...
84
2,894
django-cms
cms/test_utils/project/bunch_of_plugins/models.py
.py
from cms.models import CMSPlugin class TestPlugin1(CMSPlugin): pass class LeftMixin: pass class RightMixin: pass class TestPlugin2(LeftMixin, CMSPlugin, RightMixin): pass
18
195
sphinx
tests/roots/test-add_enumerable_node/enumerable_node.py
.py
from docutils import nodes from docutils.parsers.rst import Directive class my_figure(nodes.figure): pass def visit_my_figure(self, node): self.visit_figure(node) def depart_my_figure(self, node): self.depart_figure(node) class MyFigure(Directive): required_arguments = 1 has_content = True ...
65
1,453
readthedocs.org
readthedocs/rtd_tests/tests/test_build_forms.py
.py
from unittest import mock from django.contrib.auth.models import User from django.test import TestCase, override_settings from django.urls import reverse from django_dynamic_fixture import get from readthedocs.builds.forms import VersionForm from readthedocs.builds.models import Version from readthedocs.projects.cons...
368
11,116
openvino
tests/layer_tests/tensorflow_lite_tests/test_tfl_Relu0To1.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os import numpy as np import pytest import tensorflow as tf from tensorflow.lite.python import schema_py_generated as schema_fb from tensorflow.lite.tools import flatbuffer_utils as utils from common.tflite_layer_test_class impo...
67
2,624
wagtail
wagtail/tests/test_draft_model.py
.py
from django.apps import apps from django.core import checks from django.db import models from django.test import TestCase from wagtail.models import DraftStateMixin, RevisionMixin class TestDraftStateMixin(TestCase): def tearDown(self): # Unregister the models from the overall model registry # so...
65
2,313
wagtail
wagtail/tests/test_utils.py
.py
import hashlib import os import pickle import tempfile import unittest from io import BytesIO from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation from django.core.files.uploadedfile import SimpleUploade...
659
21,836
jupyterlab
docs/source/conf.py
.py
#!/usr/bin/env python3 # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. # # JupyterLab documentation build configuration file, created by # sphinx-quickstart on Thu Jan 4 15:10:23 2018. # # This file is execfile()d with the current directory set to its # containing ...
628
21,193
loguru
tests/exceptions/source/backtrace/chained_expression_direct.py
.py
import sys from loguru import logger logger.remove() logger.add(sys.stderr, format="", colorize=False, backtrace=True, diagnose=False) @logger.catch() def a_decorated(): try: 1 / 0 except ZeroDivisionError: raise ValueError("NOK") def a_not_decorated(): try: 1 / 0 except Ze...
43
642
beam
sdks/python/apache_beam/internal/gcp/auth_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...
137
4,545
readthedocs.org
readthedocs/audit/apps.py
.py
"""Audit module.""" import structlog from django.apps import AppConfig log = structlog.get_logger(__name__) class AuditConfig(AppConfig): name = "readthedocs.audit" def ready(self): import readthedocs.audit.signals # noqa
15
245