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 |
|---|---|---|---|---|---|
sqlmap | lib/utils/getch.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
class _Getch(object):
"""
Gets a single character from standard input. Does not echo to
the screen (reference: http://code.activestate.com/recipes/134892/)
"""
... | 82 | 2,325 |
scikit-bio | doc/suburl.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.
# --------------------------------------------... | 53 | 1,610 |
qutip | qutip/core/superop_reps.py | .py | #
# This module was initially contributed by Ben Criger.
#
"""
This module implements transformations between superoperator representations,
including supermatrix, Kraus, Choi and Chi (process) matrix formalisms.
"""
from __future__ import annotations
__all__ = [
'kraus_to_choi', 'kraus_to_super', 'to_superpauli',... | 613 | 19,894 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_global_maxpool2D.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 TestKerasGlobalMaxPool2D(CommonTF2LayerTest):
def create_keras_global_maxpool2D_net(self, input_names, input_shapes, input_type... | 42 | 1,726 |
pyomo | pyomo/common/cmake_builder.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... | 131 | 5,020 |
readthedocs.org | readthedocs/api/v2/apps.py | .py | from django.apps import AppConfig
class APIV2Config(AppConfig):
name = "readthedocs.api.v2"
verbose_name = "API V2"
| 7 | 126 |
pyro | pyro/infer/mcmc/nuts.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from collections import namedtuple
import pyro
import pyro.distributions as dist
from pyro.distributions.util import scalar_like
from pyro.infer.autoguide import init_to_uniform
from pyro.infer.mcmc.hmc import HMC
from pyro.ops.in... | 523 | 21,893 |
mlflow | tests/pyfunc/sample_code/python_model_with_utils.py | .py | from mlflow.models import set_model
from mlflow.pyfunc import PythonModel
class MyModel(PythonModel):
def predict(self, context, model_input):
from utils import my_function
return my_function(model_input)
set_model(MyModel())
| 13 | 251 |
python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | .py | """
Key bindings which are also known by GNU Readline by the given names.
See: http://www.delorie.com/gnu/docs/readline/rlman_13.html
"""
from __future__ import annotations
from collections.abc import Callable
from typing import TypeVar, cast
from prompt_toolkit.document import Document
from prompt_toolkit.enums im... | 693 | 18,421 |
saleor | saleor/webhook/transport/synchronous/transport.py | .py | import json
import logging
from json import JSONDecodeError
from typing import TYPE_CHECKING, Any, TypeVar, Union
from urllib.parse import urlparse
from django.conf import settings
from django.core.cache import cache
from django.db import transaction
from opentelemetry.trace import StatusCode
from promise import Promi... | 517 | 18,367 |
probability | tensorflow_probability/python/experimental/bijectors/scalar_function_with_inferred_inverse_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... | 265 | 11,614 |
conda | conda/cli/actions.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Collection of custom argparse actions.
"""
from argparse import Action, _CountAction
from ..common.constants import NULL
from ..deprecations import deprecated
class NullCountAction(_CountAction):
@staticmethod
@deprecated("26.9",... | 63 | 1,673 |
saleor | saleor/tests/e2e/promotions/test_staff_can_translate_promotions.py | .py | import json
import pytest
from ..product.utils.preparing_product import prepare_product
from ..promotions.utils import (
create_promotion,
create_promotion_rule,
translate_promotion,
translate_promotion_rule,
)
from ..shop.utils.preparing_shop import prepare_default_shop
from ..translations.utils impo... | 150 | 4,916 |
textual | src/textual/message_pump.py | .py | """
A `MessagePump` is a base class for any object which processes messages, which includes Widget, Screen, and App.
!!! tip
Most of the method here are useful in general app development.
"""
from __future__ import annotations
import asyncio
import threading
from asyncio import CancelledError, QueueEmpty, Tas... | 921 | 32,221 |
saleor | saleor/graphql/csv/filters.py | .py | import django_filters
from django.db.models import Exists, OuterRef, Q
from ...account.models import User
from ...app.models import App
from ..core.filters import BaseJobFilter, FilterInputObjectType
def filter_user(qs, _, value):
users = (
User.objects.using(qs.db)
.filter(
Q(first_n... | 35 | 957 |
black | tests/data/cases/prefer_rhs_split.py | .py | first_item, second_item = (
some_looooooooong_module.some_looooooooooooooong_function_name(
first_argument, second_argument, third_argument
)
)
some_dict["with_a_long_key"] = (
some_looooooooong_module.some_looooooooooooooong_function_name(
first_argument, second_argument, third_argument
... | 119 | 3,708 |
coremltools | coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/fuse_dilation_conv.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
import numpy as np
from ..basic_graph_ops import delete_node, replace_source
from coremltools.converte... | 181 | 6,498 |
beam | sdks/python/apache_beam/ml/transforms/embeddings/open_ai.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 ... | 175 | 5,800 |
pyomo | pyomo/gdp/plugins/transform_current_disjunctive_state.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... | 296 | 12,542 |
bazel | src/test/py/bazel/testdata/bazel_external_repository_test/hello-1.0.0/hello.py | .py | """Returns the constant 'hello world'."""
def hello():
return "hello world"
if __name__ == "__main__":
print(hello())
| 10 | 126 |
beam | sdks/python/apache_beam/ml/inference/sklearn_inference_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... | 626 | 23,144 |
pyomo | pyomo/contrib/preprocessing/plugins/deactivate_trivial_constraints.py | .py | # -*- coding: utf-8 -*-
# ____________________________________________________________________________________
#
# 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 En... | 150 | 5,716 |
pyomo | examples/pyomo/amplbook2/prod.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... | 51 | 1,302 |
astropy | astropy/io/fits/tests/test_hdulist.py | .py | # Licensed under a 3-clause BSD style license - see PYFITS.rst
import copy
import io
import os
import subprocess
import sys
from contextlib import nullcontext
import numpy as np
import pytest
from astropy.io import fits
from astropy.io.fits.hdu.base import _NonstandardHDU, _ValidHDU
from astropy.io.fits.verify impor... | 1,282 | 46,932 |
mlflow | mlflow/entities/view_type.py | .py | from mlflow.protos import service_pb2
class ViewType:
"""Enum to filter requested experiment types."""
ACTIVE_ONLY, DELETED_ONLY, ALL = range(1, 4)
_VIEW_TO_STRING = {
ACTIVE_ONLY: "active_only",
DELETED_ONLY: "deleted_only",
ALL: "all",
}
_STRING_TO_VIEW = {value: key for... | 52 | 1,816 |
biopython | Bio/AlignIO/PhylipIO.py | .py | # Copyright 2006-2016 by Peter Cock. All rights reserved.
# Revisions copyright 2011 Brandon Invergo. 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... | 455 | 17,138 |
mlflow | mlflow/genai/judges/tools/list_spans.py | .py | """
Tool definitions for MLflow GenAI judges.
This module provides concrete JudgeTool implementations that judges can use
to analyze traces and extract information during evaluation.
"""
from dataclasses import dataclass
from mlflow.entities.trace import Trace
from mlflow.genai.judges.tools.base import JudgeTool
fro... | 127 | 4,350 |
mkdocs-material | includes/debug/cairo-lookup-linux.py | .py | import inspect
import os
import shutil
import subprocess
from ctypes import util
class CustomPopen(subprocess.Popen):
def __init__(self, *args, **kwargs):
print(f"Subprocess command:\n {' '.join(args[0])}")
super().__init__(*args, **kwargs)
def communicate(self, *args, **kwargs):
ou... | 112 | 3,491 |
beam | sdks/python/apache_beam/dataframe/frame_base.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... | 764 | 25,412 |
mlflow | tests/genai/review_queues/test_review_queues_entity.py | .py | import pytest
from mlflow.exceptions import MlflowException
from mlflow.genai.review_queues import (
ReviewItemType,
ReviewQueue,
ReviewQueueItem,
ReviewQueueType,
ReviewStatus,
)
from mlflow.protos import review_queues_pb2 as pb
@pytest.mark.parametrize(
("enum_cls", "member", "proto_value")... | 140 | 3,981 |
conda | tests/shell/conftest.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from conda.common.compat import on_win
from . import Shell
if TYPE_CHECKING:
from collections.abc import Iterator
from pytest import FixtureRequest
... | 41 | 1,019 |
onnx | tests/python/symbolic_shape_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import onnx.shape_inference
from onnx import ModelProto, TensorProto, TensorShapeProto, ValueInfoProto, helper
from onnx.helper import make_model, make_tensor_value_info
class TestSymbolicShape:
de... | 194 | 8,394 |
beam | sdks/python/apache_beam/utils/subprocess_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... | 614 | 21,041 |
luigi | test/contrib/ecs_test.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2015 Outlier Bio, LLC
#
# 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... | 187 | 6,488 |
coremltools | deps/protobuf/python/google/protobuf/internal/extension_dict.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... | 214 | 8,443 |
loguru | tests/test_filesink_rotation.py | .py | import datetime
import os
import pathlib
import tempfile
import time
from unittest.mock import Mock
import pytest
import loguru
from loguru import logger
from loguru._ctime_functions import load_ctime_functions
from .conftest import check_dir
@pytest.fixture
def tmp_path_local(reset_logger):
# Pytest 'tmp_path... | 1,151 | 37,430 |
gunicorn | tests/docker/asgi_compliance/apps/__init__.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
ASGI test applications for compliance testing.
"""
| 8 | 161 |
astropy | astropy/timeseries/tests/test_binned.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
from numpy.testing import assert_allclose, assert_equal
from astropy import units as u
from astropy.tests.helper import assert_quantity_allclose
from astropy.time import Time, TimeDelta
from astropy.timeseries.binned import BinnedTimeSeries... | 499 | 13,562 |
lemur | lemur/domains/models.py | .py | """
.. module: lemur.domains.models
:platform: Unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
from sqlalchemy import Column, Integer, String, Boolean
from lemur.database import Base... | 24 | 608 |
beam | sdks/python/apache_beam/metrics/__init__.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... | 19 | 884 |
lemur | lemur/plugins/lemur_jks/plugin.py | .py | """
.. module: lemur.plugins.lemur_jks.plugin
:platform: Unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Marti Raudsepp <marti@juffo.org>
"""
from cryptography.fernet import Fernet
from cryptography.hazmat.primitives import ... | 141 | 4,677 |
funcy | tests/test_strings.py | .py | from funcy.strings import *
def test_re_find():
assert re_find(r'\d+', 'x34y12') == '34'
assert re_find(r'y(\d+)', 'x34y12') == '12'
assert re_find(r'([a-z]+)(\d+)', 'x34y12') == ('x', '34')
assert re_find(r'(?P<l>[a-z]+)(?P<d>\d+)', 'x34y12') == {'l': 'x', 'd': '34'}
def test_re_all():
assert r... | 30 | 982 |
conda | tests/test_resolve.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from conda.common.compat import on_win
from conda.exceptions import UnsatisfiableError
from conda.models.match_spec import MatchSpec
from conda.resolve import ... | 75 | 2,349 |
voila | tests/server/show_traceback_test.py | .py | import pytest
@pytest.fixture(params=[True, False])
def show_tracebacks(request):
return request.param
@pytest.fixture
def jupyter_server_args_extra(show_tracebacks):
return [f"--VoilaConfiguration.show_tracebacks={show_tracebacks}"]
async def test_syntax_error(
http_server_client, syntax_error_notebo... | 28 | 849 |
mlflow | tests/genai/discovery/conftest.py | .py | import pytest
import mlflow
from mlflow.entities.span import SpanType
from mlflow.entities.trace import Trace
from mlflow.entities.trace_info import TraceInfo
from mlflow.genai.scorers.base import Scorer
class _TestScorer(Scorer):
"""Minimal Scorer subclass for use in discovery pipeline tests."""
def __call... | 77 | 2,309 |
textual | docs/examples/styles/min_width.py | .py | from textual.app import App
from textual.containers import VerticalScroll
from textual.widgets import Placeholder
class MinWidthApp(App):
CSS_PATH = "min_width.tcss"
def compose(self):
yield VerticalScroll(
Placeholder("min-width: 25%", id="p1"),
Placeholder("min-width: 75%", ... | 21 | 512 |
pyomo | pyomo/contrib/pynumero/interfaces/tests/external_grey_box_models.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... | 608 | 21,717 |
pyomo | examples/pyomo/callbacks/sc_callback.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... | 27 | 848 |
coveragepy | coverage/cmdline.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Command-line support for coverage.py."""
from __future__ import annotations
import glob
import optparse
import os
import os.path
import shlex
import signal
i... | 1,209 | 37,773 |
mkdocs | mkdocs/contrib/search/__init__.py | .py | from __future__ import annotations
import logging
import os
from typing import TYPE_CHECKING, List
from mkdocs import utils
from mkdocs.config import base
from mkdocs.config import config_options as c
from mkdocs.contrib.search.search_index import SearchIndex
from mkdocs.plugins import BasePlugin
if TYPE_CHECKING:
... | 121 | 5,230 |
saleor | saleor/tax/tests/webhooks/test_parser.py | .py | import pytest
from ....core.taxes import TaxData, TaxDataError
from ....webhook.event_types import WebhookEventSyncType
from ...webhooks.parser import parse_tax_data
def test_parse_tax_data_success(tax_data_response):
# given
line_count = len(tax_data_response["lines"])
# when
tax_data = parse_tax_d... | 66 | 1,774 |
openvino | tests/e2e_tests/common/model_loader/__init__.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from . import load_pytorch_model, tf_hub_model_loader
from .provider import StepProvider
| 6 | 172 |
openvino | tests/layer_tests/pytorch_tests/test_logaddexp.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import numpy as np
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
class TestLogAddExp(PytorchLayerTest):
def _prepare_input(self, input1, input2, dtype1="float32", dtype2="float32", out=False):
... | 150 | 4,819 |
mlflow | tests/dspy/test_dspy_evaluate.py | .py | import importlib.metadata
import dspy
import pandas as pd
import pytest
from dspy.utils.dummies import DummyLM
from packaging.version import Version
import mlflow
from mlflow.tracing.constant import TraceMetadataKey
from tests.openai.test_openai_evaluate import purge_traces
from tests.tracing.helper import get_trace... | 143 | 4,418 |
pyomo | pyomo/contrib/mpc/modeling/constraints.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... | 61 | 2,621 |
onnxruntime | onnxruntime/python/tools/transformers/onnx_model_bert.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
import numpy as np
from convert_to_packi... | 513 | 21,425 |
beam | sdks/python/apache_beam/runners/job/manager.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... | 58 | 1,848 |
mlflow | mlflow/assistant/providers/__init__.py | .py | import logging
from mlflow.assistant.providers.base import AssistantProvider
from mlflow.assistant.providers.claude_code import ClaudeCodeProvider
from mlflow.assistant.providers.codex import CodexProvider
from mlflow.assistant.providers.mlflow_gateway import MlflowGatewayProvider
from mlflow.assistant.providers.ollam... | 62 | 1,851 |
gunicorn | examples/readline_app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
#
# Simple example of readline, reading from a stream then echoing the response
#
# Usage:
#
# Launch a server with the app in a terminal
#
# $ gunicorn -w3 readline_app:app
#
# Then in another terminal launch t... | 44 | 993 |
biopython | Bio/SearchIO/_index.py | .py | # Copyright 2012 by Wibowo Arindrarto. All rights reserved.
# Revisions copyright 2012-2016 by Peter Cock. 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 shoul... | 36 | 1,233 |
coveragepy | __main__.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Be able to execute coverage.py by pointing Python at a working tree."""
import runpy
import os
PKG = "coverage"
run_globals = runpy.run_module(PKG, run_name... | 13 | 423 |
pyro | pyro/ops/contract.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import itertools
import warnings
from collections import OrderedDict, defaultdict
import opt_einsum
import torch
from opt_einsum import shared_intermediates
from pyro.ops.rings import BACKEND_TO_RING, LogRing
from pyro.util impor... | 575 | 22,550 |
biopython | Tests/test_PDB_PDBList.py | .py | # Copyright 2016 by Jacek Smietanski. 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.
"""Testing access to th... | 260 | 9,882 |
ipython | IPython/core/tbtools.py | .py | from __future__ import annotations
import functools
import sys
import types
import warnings
from types import TracebackType
from typing import TYPE_CHECKING, Any
from collections.abc import Callable
from pygments.token import Token
from IPython.core.getipython import get_ipython
from IPython.utils.PyColorize import ... | 584 | 18,241 |
readthedocs.org | readthedocs/projects/backends/views.py | .py | """
Project views loaded by configuration settings.
Use these views instead of calling the views directly, in order to allow for
settings override of the view class.
"""
from readthedocs.core.utils.extend import SettingsOverrideObject
from readthedocs.projects.views import private
# Project Import Wizard
class Impo... | 16 | 450 |
readthedocs.org | readthedocs/audit/models.py | .py | """Audit models."""
from django.contrib.auth.models import User
from django.db import models
from django.utils.translation import gettext_lazy as _
from django_extensions.db.models import TimeStampedModel
from readthedocs.acl.utils import get_auth_backend
from readthedocs.analytics.utils import get_client_ip
class ... | 264 | 7,734 |
openvino | src/bindings/python/src/openvino/frontend/pytorch/inlined_extension.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Union, Optional
from collections.abc import Callable
import torch
import numpy as np
import openvino as ov
from openvino.frontend.pytorch.ts_decoder import InlineConversionExtension
from op... | 262 | 10,333 |
metrics | src/torchmetrics/functional/text/helper_embedding_metric.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... | 303 | 12,021 |
mlflow | mlflow/genai/judges/prompts/conversational_guidelines.py | .py | CONVERSATIONAL_GUIDELINES_ASSESSMENT_NAME = "conversational_guidelines"
CONVERSATIONAL_GUIDELINES_PROMPT = """\
Consider the following conversation history between a user and an assistant.
Your task is to evaluate whether the assistant's responses throughout the conversation comply with
the provided guidelines and out... | 24 | 1,158 |
metrics | src/torchmetrics/retrieval/precision.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... | 168 | 6,919 |
funcy | setup.py | .py | from setuptools import setup
# Remove build status
README = open('README.rst').read().replace('|Build Status|', '', 1)
setup(
name='funcy',
version=open('VERSION').read().strip(),
author='Alexander Schepanovski',
author_email='suor.web@gmail.com',
description='A fancy and practical functional t... | 45 | 1,505 |
textual | tests/option_list/test_option_messages.py | .py | """Unit tests aimed at testing the option list messages."""
from __future__ import annotations
from textual.app import App, ComposeResult
from textual.geometry import Offset
from textual.widgets import OptionList
from textual.widgets.option_list import Option
class OptionListApp(App[None]):
"""Test option list ... | 113 | 4,303 |
beam | sdks/python/apache_beam/typehints/__init__.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... | 39 | 1,315 |
luigi | examples/ssh_remote_execution.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 87 | 2,721 |
saleor | saleor/graphql/product/tests/mutations/test_product_channel_listing_update.py | .py | import datetime
from unittest.mock import patch
import graphene
from django.utils import timezone
from freezegun import freeze_time
from .....checkout.fetch import fetch_checkout_info
from .....checkout.tests.utils import add_variant_to_checkout
from .....plugins.manager import get_plugins_manager
from .....product.e... | 1,472 | 51,963 |
pyro | pyro/infer/trace_tail_adaptive_elbo.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import warnings
import torch
from pyro.infer.trace_elbo import Trace_ELBO
from pyro.infer.util import check_fully_reparametrized, is_validation_enabled
class TraceTailAdaptive_ELBO(Trace_ELBO):
"""
Interface for Stochas... | 84 | 3,367 |
onnxruntime | tools/python/wgsl_template/code_generator/__init__.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Code generators that emit C++ from PASS2 results.
The single :class:`StaticCodeGenerator` covers both ``static-cpp`` and
``static-cpp-literal`` (the difference is whether a string table is
used).
"""
from __future__ impor... | 42 | 1,160 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_While.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from sys import platform
import numpy as np
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
class TestWhile(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
assert '... | 197 | 8,769 |
onnxruntime | tools/python/util/ort_format_model/ort_model_processor.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import ort_flatbuffers_py.fbs as fbs
from .operator_type_usage_processors import OperatorTypeUsageManager
class OrtFormatModelProcessor:
"Class to process an ORT format model and determine required operators and types.... | 87 | 4,386 |
mlflow | dev/classify_flaky_tests.py | .py | """Classify detected flaky tests and decide which to annotate @pytest.mark.flaky.
Second stage of the flaky-test pipeline. `detect_flaky_tests.py` produces the
*deterministic* signal (a test that failed on one run attempt and passed on the next
attempt of the same commit). This stage adds *judgment*: given each test's... | 200 | 8,014 |
openvino | tests/layer_tests/jax_tests/test_select_n.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import jax
import numpy as np
import pytest
from jax import numpy as jnp
from jax_layer_test_class import JaxLayerTest
rng = np.random.default_rng(5402)
class TestSelectN(JaxLayerTest):
def _prepare_input(self):
cases = [... | 46 | 1,590 |
wagtail | wagtail/embeds/rich_text/contentstate.py | .py | """
Draftail / contentstate conversion
"""
from draftjs_exporter import DOM
from wagtail.admin.rich_text.converters.contentstate_models import Entity
from wagtail.admin.rich_text.converters.html_to_contentstate import (
AtomicBlockEntityElementHandler,
)
from wagtail.embeds import embeds
from wagtail.embeds.excep... | 58 | 1,715 |
beam | sdks/python/apache_beam/io/jdbc.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... | 408 | 16,537 |
hydra | plugins/hydra_rq_launcher/hydra_plugins/hydra_rq_launcher/_core.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import time
import uuid
from base64 import b64decode
from binascii import Error as BinasciiError
from pathlib import Path
from pickle import UnpicklingError
from typing import Any, Dict, List, Optional, Sequence, cast
from fakeredis ... | 249 | 7,773 |
onnxruntime | tools/ci_build/build.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
# Licensed under the MIT License.
from __future__ import annotations
import contextlib
import json
import os
import platform
import ... | 2,728 | 121,481 |
sphinx | tests/roots/test-ext-autodoc/target/sort_by_all.py | .py | __all__ = ['baz', 'foo', 'Bar']
def foo():
pass
class Bar:
pass
def baz():
pass
def qux():
pass
class Quux:
pass
def foobar():
pass
| 26 | 168 |
onnxruntime | onnxruntime/test/python/quantization/test_op_matmul_8bits.py | .py | #!/usr/bin/env python
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# ---------------------------------------------------------------... | 221 | 8,340 |
probability | tensorflow_probability/python/experimental/auto_batching/lowering_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... | 63 | 2,572 |
pymc | pymc/logprob/mixture.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... | 579 | 21,801 |
mlflow | tests/pyfunc/test_pyfunc_class_methods.py | .py | import mlflow
from mlflow.pyfunc import PythonModel, load_model, log_model
def test_unwrap_python_model_from_pyfunc_class():
class MyModel(PythonModel):
def __init__(self, param_1: str, param_2: int):
self.param_1 = param_1
self.param_2 = param_2
def predict(self, context,... | 26 | 958 |
astropy | astropy/io/ascii/ipac.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""An extensible ASCII table reader and writer.
ipac.py:
Classes to read IPAC table format
:Copyright: Smithsonian Astrophysical Observatory (2011)
:Author: Tom Aldcroft (aldcroft@head.cfa.harvard.edu)
"""
import re
from collections import defaultdict... | 566 | 21,010 |
onnxruntime | orttraining/orttraining/python/training/api/checkpoint_state.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
import os
import numpy as np
from onnxruntime.capi import _pybind_state as C
from onnxruntime.capi.onnxruntime_inference_collection import OrtValue
class Parameter:
"""Class that re... | 257 | 8,461 |
mlflow | tests/entities/test_prompt.py | .py | import json
import pytest
from pydantic import ValidationError
from mlflow.entities.model_registry import PromptModelConfig
from mlflow.entities.model_registry.model_version import ModelVersion
from mlflow.entities.model_registry.prompt_version import (
IS_PROMPT_TAG_KEY,
PROMPT_TEXT_TAG_KEY,
PromptVersio... | 344 | 12,641 |
textual | tests/test_loop.py | .py | from textual._loop import loop_first, loop_first_last, loop_from_index, loop_last
def test_loop_first():
assert list(loop_first([])) == []
iterable = loop_first(["apples", "oranges", "pears", "lemons"])
assert next(iterable) == (True, "apples")
assert next(iterable) == (False, "oranges")
assert ne... | 66 | 1,784 |
confluent-kafka-python | src/confluent_kafka/admin/_resource.py | .py | # Copyright 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 required by applicable law or agreed to in writing, s... | 53 | 2,106 |
mlflow | mlflow/tracing/trace_manager.py | .py | import contextlib
import logging
import threading
from dataclasses import dataclass, field
from typing import Generator, Sequence
from mlflow.entities import LiveSpan, Trace, TraceData, TraceInfo
from mlflow.entities.model_registry import PromptVersion
from mlflow.environment_variables import MLFLOW_TRACE_TIMEOUT_SECO... | 238 | 9,148 |
beam | sdks/python/apache_beam/examples/inference/online_clustering/clustering_pipeline/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 us... | 29 | 1,278 |
gunicorn | examples/example_config.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# Sample Gunicorn configuration file.
#
# Server socket
#
# bind - The socket to bind.
#
# A string of the form: 'HOST', 'HOST:PORT', 'unix:PATH'.
# An IP is a valid HOST.
#
# backlog - The number ... | 245 | 7,699 |
cvxpy | cvxpy/expressions/__init__.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... | 18 | 590 |
confluent-kafka-python | tests/integration/schema_registry/data/proto/exampleProtoCriteo_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: tests/integration/schema_registry/data/proto/exampleProtoCriteo.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from goo... | 46 | 4,175 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.