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/mcmc/sample_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... | 510 | 19,595 |
sqlmap | plugins/dbms/derby/fingerprint.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.common import Backend
from lib.core.common import Format
from lib.core.data import conf
from lib.core.data import kb
from lib.core.data import logger
from lib.core.e... | 95 | 2,635 |
probability | tensorflow_probability/python/math/psd_kernels/schur_complement.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... | 600 | 25,844 |
readthedocs.org | readthedocs/proxito/tests/test_full.py | .py | import os
from textwrap import dedent
from unittest import mock
import django_dynamic_fixture as fixture
from django.conf import settings
from django.core.cache import cache
from django.http import HttpResponse
from django.test.utils import override_settings
from django.urls import reverse
from django_dynamic_fixture ... | 2,018 | 77,707 |
astropy | astropy/io/ascii/qdp.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package contains functions for reading and writing QDP tables that are
not meant to be used directly, but instead are available as readers/writers in
`astropy.table`. See :ref:`astropy:table_io` for more details.
"""
import copy
import os
import ... | 666 | 20,885 |
beam | sdks/python/apache_beam/io/gcp/bigquery.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... | 3,259 | 137,027 |
saleor | saleor/graphql/discount/resolvers.py | .py | from django.db.models import Exists, OuterRef, QuerySet
from ...channel.models import Channel
from ...discount import models
from ..core.context import (
ChannelContext,
ChannelQsContext,
get_database_connection_name,
)
from .filters import filter_sale_search, filter_voucher_search
def resolve_voucher(in... | 77 | 2,617 |
pyro | pyro/distributions/transforms/basic.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import math
import torch
import torch.nn.functional as F
from torch.distributions.transforms import TanhTransform, Transform
from .. import constraints
# TODO: Move upstream
class ELUTransform(Transform):
r"""
Bijective tr... | 93 | 2,073 |
metrics | tests/unittests/retrieval/test_map.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... | 191 | 7,381 |
pyomo | pyomo/contrib/preprocessing/plugins/equality_propagate.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... | 241 | 9,854 |
cvxpy | cvxpy/reductions/dnlp2smooth/canonicalizers/rel_entr_canon.py | .py | """
Copyright 2025 CVXPY 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 law or agreed to in writing, softwa... | 57 | 1,915 |
scikit-bio | skbio/metadata/_enan.py | .py | # ----------------------------------------------------------------------------
# Copyright (c) 2016-2023, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ------------------------------------------------... | 88 | 3,667 |
sqlmap | tamper/unionvalues.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.HIGHEST
def dependencies():
pass
def tamper(payload, **kwargs):
"""
Replaces UNION SELECT <co... | 61 | 1,995 |
eve | tests/config.py | .py | # -*- coding: utf-8 -*-
import os
import eve
from eve.exceptions import ConfigException, SchemaException
from eve.flaskapp import Eve, RegexConverter
from eve.io.base import DataLayer
from eve.io.mongo import Mongo, Validator
from . import TestBase
from .test_settings import MONGO_HOST, MONGO_PORT
class TestConfig... | 560 | 23,122 |
metrics | src/torchmetrics/image/tv.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... | 140 | 5,306 |
luigi | test/task_serialize_test.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... | 122 | 3,965 |
onnxruntime | onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/Graph.py | .py | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: fbs
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class Graph(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffer... | 321 | 10,719 |
conda | conda/cli/main_mock_activate.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Mock CLI implementation for `conda activate`.
A mock implementation of the activate shell command for better UX.
"""
from __future__ import annotations
from argparse import SUPPRESS
from typing import TYPE_CHECKING
from .. import CondaErr... | 33 | 893 |
astropy | astropy/wcs/wcsapi/wrappers/base.py | .py | import abc
from astropy.wcs.wcsapi import BaseLowLevelWCS, wcs_info_str
class BaseWCSWrapper(BaseLowLevelWCS, metaclass=abc.ABCMeta):
"""
A base wrapper class for things that modify Low Level WCSes.
This wrapper implements a transparent wrapper to many of the properties,
with the idea that not all o... | 84 | 2,014 |
coremltools | coremltools/test/xgboost_tests/test_boosted_trees_classifier.py | .py | # Copyright (c) 2017, 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 json
import tempfile
import unittest
import numpy as np
from ..utils import load_boston
from co... | 390 | 14,395 |
probability | tensorflow_probability/python/experimental/marginalize/logeinsumexp_test.py | .py | # Copyright 2019 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... | 271 | 9,105 |
conda | tests/common/test_io.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import sys
import time
from concurrent.futures import ThreadPoolExecutor
from contextlib import nullcontext
from io import StringIO
from logging import DEBUG, NOTSET, WARNING, getLogger
import pytest
from co... | 183 | 5,318 |
astropy | astropy/io/votable/tests/test_util.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
A set of tests for the util.py module.
"""
import pytest
from astropy.io.votable import util
def test_range_list():
assert util.coerce_range_list_param((5,)) == ("5.0", 1)
def test_range_list2():
assert util.coerce_range_list_param((5e-7,... | 68 | 1,671 |
sphinx | sphinx/transforms/post_transforms/code.py | .py | """transforms for code-blocks."""
from __future__ import annotations
import sys
from typing import TYPE_CHECKING, NamedTuple
from docutils import nodes
from pygments.lexers import PythonConsoleLexer, guess_lexer
from sphinx import addnodes
from sphinx.ext import doctest
from sphinx.transforms import SphinxTransform... | 144 | 4,534 |
confluent-kafka-python | tests/schema_registry/_sync/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... | 606 | 18,875 |
wandb | wandb/integration/sklearn/calculate/residuals.py | .py | from warnings import simplefilter
from sklearn import model_selection
import wandb
from wandb.integration.sklearn import utils
# ignore all future warnings
simplefilter(action="ignore", category=FutureWarning)
def residuals(regressor, X, y): # noqa: N803
# Create the train and test splits
x_train, x_test,... | 87 | 2,399 |
onnx | onnx/reference/ops/aionnx_preview_training/__init__.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
__all__ = ["load_op", "OpRunTraining"]
from onnx.reference.ops.aionnx_preview_training._op_list import load_op
from onnx.reference.ops.aionnx_preview_training._op_run_training import OpRunTraining
| 10 | 315 |
probability | tensorflow_probability/python/internal/batched_rejection_sampler_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... | 126 | 4,979 |
pyomo | doc/OnlineDocs/src/scripting/spy4PyomoCommand.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... | 35 | 1,322 |
mlflow | tests/tracking/_model_registry/test_model_registry_fluent.py | .py | import logging
import os
import subprocess
from pathlib import Path
from unittest import mock
import pytest
import requests
import mlflow
from mlflow import MlflowClient, register_model
from mlflow.entities.model_registry import ModelVersion, RegisteredModel
from mlflow.exceptions import MlflowException
from mlflow.p... | 607 | 22,571 |
pdm | src/pdm/cli/commands/outdated.py | .py | from __future__ import annotations
import functools
import json
from concurrent.futures import ThreadPoolExecutor
from dataclasses import asdict, dataclass
from fnmatch import fnmatch
from itertools import zip_longest
from typing import TYPE_CHECKING, cast
from pdm.cli.commands.base import BaseCommand
from pdm.cli.ut... | 145 | 5,705 |
onnx | onnx/backend/test/case/node/flatten.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 Flatten(Base):
@staticmethod
def export() -> None:
sha... | 66 | 1,932 |
biopython | Bio/SeqIO/NibIO.py | .py | # Copyright 2019 by Michiel de Hoon. All rights reserved.
# Based on code contributed and copyright 2016 by Peter Cock.
#
# 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 be... | 176 | 5,857 |
loguru | tests/exceptions/source/backtrace/missing_attributes_traceback_objects.py | .py | import sys
from collections import namedtuple
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="", colorize=False, backtrace=True, diagnose=False)
a, b = 1, 0
def div(x, y):
x / y
def foo():
div(a, b)
# See Twisted: https://github.com/twisted/twisted/blob/29cbe/src/twisted/pytho... | 43 | 1,136 |
astropy | astropy/cosmology/_src/io/__init__.py | .py | """Astropy Cosmology IO. **NOT public API**.
The public API is provided by :mod:`astropy.cosmology.io`.
"""
# Licensed under a 3-clause BSD style license - see LICENSE.rst
| 6 | 173 |
textual | tests/snapshot_tests/snapshot_apps/zero_scrollbar_size.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Static
class TestApp(App):
DEFAULT_CSS = """
Screen {
scrollbar-size: 0 0;
}
"""
def compose(self) -> ComposeResult:
yield Static("Hello, world!\n" * 100)
if __name__ == "__main__":
TestApp().run()
| 18 | 314 |
textual | tests/test_widget_visibility.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Label
async def test_hide() -> None:
"""Check that setting visibility produces Hide messages."""
# https://github.com/Textualize/textual/issues/3460
visibility: list[bool] = []
class ShowHideLabel(Label):
def on_show(self)... | 35 | 1,046 |
mlflow | mlflow/server/auth/db/models.py | .py | from sqlalchemy import (
Boolean,
Column,
ForeignKey,
Index,
Integer,
String,
UniqueConstraint,
)
from sqlalchemy.orm import declarative_base, relationship
from mlflow.server.auth.entities import (
Role,
RolePermission,
User,
UserRoleAssignment,
)
Base = declarative_base()
... | 120 | 3,845 |
confluent-kafka-python | tests/oauthbearer/aws/test_aws_oauthbearer_config.py | .py | # 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 required by applicable law or agreed to in writing, s... | 365 | 12,988 |
python-prompt-toolkit | examples/choices/simple-selection.py | .py | from __future__ import annotations
from prompt_toolkit.shortcuts import choice
def main() -> None:
result = choice(
message="Please select a dish:",
options=[
("pizza", "Pizza with mushrooms"),
("salad", "Salad with tomatoes"),
("sushi", "Sushi"),
],
... | 20 | 382 |
black | tests/data/cases/fmtskip6.py | .py | class A:
def f(self):
for line in range(10):
if True:
pass # fmt: skip
# output
class A:
def f(self):
for line in range(10):
if True:
pass # fmt: skip
| 14 | 235 |
mlflow | mlflow/utils/async_logging/run_batch.py | .py | import threading
from mlflow.entities.metric import Metric
from mlflow.entities.param import Param
from mlflow.entities.run_tag import RunTag
class RunBatch:
def __init__(
self,
run_id: str,
params: list["Param"] | None = None,
tags: list["RunTag"] | None = None,
metrics: ... | 58 | 1,802 |
mlflow | mlflow/system_metrics/metrics/network_monitor.py | .py | """Class for monitoring network stats."""
import psutil
from mlflow.system_metrics.metrics.base_metrics_monitor import BaseMetricsMonitor
class NetworkMonitor(BaseMetricsMonitor):
def __init__(self):
super().__init__()
self._set_initial_metrics()
def _set_initial_metrics(self):
# Se... | 35 | 1,351 |
beam | sdks/python/apache_beam/io/requestresponse.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... | 850 | 29,230 |
onnxruntime | orttraining/orttraining/python/training/api/optimizer.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
import os
from typing import TYPE_CHECKING
from onnxruntime.capi import _pybind_state as C
if TYPE_CHECKING:
from onnxruntime.training.api.module import Module
class Optimizer:
... | 51 | 1,569 |
metrics | src/torchmetrics/audio/_deprecated.py | .py | from typing import Any, Callable, Optional
from typing_extensions import Literal
from torchmetrics.audio.pit import PermutationInvariantTraining
from torchmetrics.audio.sdr import ScaleInvariantSignalDistortionRatio, SignalDistortionRatio
from torchmetrics.audio.snr import ScaleInvariantSignalNoiseRatio, SignalNoiseR... | 130 | 4,065 |
pyomo | examples/doc/samples/case_studies/transportation/transportation.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... | 48 | 1,519 |
wagtail | wagtail/documents/tests/test_permissions.py | .py | from django.test import TestCase, override_settings
from wagtail.documents import get_document_model
from wagtail.permission_policies.collections import CollectionOwnershipPermissionPolicy
from wagtail.permissions import policy_registry
from wagtail.test.testapp.models import CustomDocument
from wagtail.utils.deprecat... | 37 | 1,657 |
onnxruntime | onnxruntime/test/testdata/transform/stft_negative_frame_length.py | .py | from onnx import TensorProto, helper, save
def make_stft_model(frame_length_value, frame_step_value, has_window, filename):
batch = 1
signal_length = 16
dft_size = abs(frame_length_value) if frame_length_value != 0 else 4
onesided_bins = dft_size // 2 + 1
num_frames = max(1, (signal_length - dft_s... | 47 | 1,749 |
mlflow | dev/clint/src/clint/rules/log_model_artifact_path.py | .py | import ast
from typing import TYPE_CHECKING
from clint.rules.base import Rule
from clint.utils import resolve_expr
if TYPE_CHECKING:
from clint.index import SymbolIndex
class LogModelArtifactPath(Rule):
def _message(self) -> str:
return "`artifact_path` parameter of `log_model` is deprecated. Use `n... | 55 | 1,800 |
probability | tensorflow_probability/python/internal/backend/numpy/gen/tensor_shape.py | .py | # Copyright 2020 The TensorFlow Probability Authors. All Rights Reserved.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# THIS FILE IS AUTO-GENERATED BY `gen_tensor_shape.py`.
# DO NOT MODIFY DIRECTLY.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# ... | 1,653 | 52,691 |
clearml | clearml/utilities/io_manager.py | .py | from typing import Any
class IOCallsManager:
def __init__(self) -> None:
self.threads_io = {}
def add_io_to_thread(self, thread_id: int, io_object: Any) -> None:
if thread_id in self.threads_io:
self.threads_io[thread_id].add(id(io_object))
else:
self.threads_i... | 34 | 1,236 |
hypercorn | src/hypercorn/trio/task_group.py | .py | from __future__ import annotations
import sys
from collections.abc import Awaitable, Callable
from contextlib import AbstractAsyncContextManager
from types import TracebackType
from typing import Any
import trio
from ..config import Config
from ..typing import AppWrapper, ASGIReceiveCallable, ASGIReceiveEvent, ASGIS... | 83 | 2,521 |
probability | tensorflow_probability/python/internal/distribution_util_test.py | .py | # Copyright 2018 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 1,107 | 41,439 |
tqdm | tqdm/_utils.py | .py | from warnings import warn
from .std import TqdmDeprecationWarning
from .utils import ( # noqa: F401, pylint: disable=unused-import
CUR_OS, IS_NIX, IS_WIN, RE_ANSI, Comparable, FormatReplace, SimpleTextIOWrapper,
_environ_cols_wrapper, _is_ascii, _is_utf, _screen_shape_linux, _screen_shape_tput,
_screen_sh... | 12 | 559 |
cvxpy | cvxpy/tests/test_dgp_dpp.py | .py | """
Tests for DGP (Disciplined Geometric Programming) with DPP (Disciplined Parametrized Programming).
This verifies the fix for issue #3004: DGP problems can now have get_problem_data(gp=True)
called without all parameters having values. This is useful when the problem is DPP.
"""
import numpy as np
import pytest
im... | 215 | 8,697 |
saleor | saleor/graphql/account/tests/queries/test_customers_where_attributes.py | .py | import graphene
import pytest
from .....attribute import AttributeEntityType, AttributeInputType, AttributeType
from .....attribute.models import Attribute, AttributeValue
from .....attribute.utils import associate_attribute_values_to_instance
from .....page.models import Page
from ....tests.utils import get_graphql_c... | 579 | 19,743 |
luigi | luigi/contrib/ssh.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... | 345 | 12,242 |
sqlmap | plugins/dbms/firebird/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 | 978 |
onnx | onnx/backend/test/case/node/tensorscatter.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 TensorScatter(Base):
@staticmethod
def export_tensorscatter() ... | 175 | 5,207 |
pyomo | pyomo/solvers/tests/checks/test_pickle.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... | 191 | 5,795 |
beam | learning/katas/python/Common Transforms/Filter/Filter/task.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"); y... | 36 | 1,241 |
returns | returns/pointfree/apply.py | .py | from collections.abc import Callable
from typing import TypeVar
from returns.interfaces.applicative import ApplicativeN
from returns.primitives.hkt import Kinded, KindN, kinded
_FirstType = TypeVar('_FirstType')
_SecondType = TypeVar('_SecondType')
_ThirdType = TypeVar('_ThirdType')
_UpdatedType = TypeVar('_UpdatedTy... | 64 | 1,790 |
onnxruntime | onnxruntime/test/testdata/transform/fusion/reshape_fusion_gen.py | .py | import onnx
from onnx import TensorProto, helper
def save_model(graph, file_name):
model = helper.make_model(graph)
onnx.checker.check_model(model)
onnx.save(model, file_name)
graph = helper.make_graph(
[ # nodes
helper.make_node("Shape", ["SubgraphRoot"], ["shape1_out"], "shape1"),
... | 570 | 23,827 |
textual | docs/examples/guide/widgets/checker04.py | .py | from __future__ import annotations
from textual import events
from textual.app import App, ComposeResult
from textual.geometry import Offset, Region, Size
from textual.reactive import var
from textual.strip import Strip
from textual.scroll_view import ScrollView
from rich.segment import Segment
from rich.style import... | 107 | 3,622 |
onnx | onnx/reference/ops/op_log.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.ops._op import OpRunUnaryNum
class Log(OpRunUnaryNum):
def _run(self, x):
return (np.log(x).astype(x.dtype),)
| 14 | 281 |
saleor | saleor/graphql/notifications/error_codes.py | .py | from enum import Enum
class ExternalNotificationErrorCodes(Enum):
REQUIRED = "required"
INVALID_MODEL_TYPE = "invalid_model_type"
NOT_FOUND = "not_found"
CHANNEL_INACTIVE = "channel_inactive"
| 9 | 210 |
mlflow | tests/mcp/test_cli.py | .py | import sys
import pytest
from fastmcp import Client
from fastmcp.client.transports import StdioTransport
import mlflow
@pytest.mark.asyncio
async def test_cli():
transport = StdioTransport(
command=sys.executable,
args=[
"-m",
"mlflow",
"mcp",
"run... | 28 | 593 |
probability | tensorflow_probability/python/mcmc/sample.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... | 384 | 14,307 |
sqlmap | tests/test_parse_modules.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Parsers under lib/parse/: DBMS banner fingerprinting (banner.py + the shared
FingerprintHandler in handler.py) and the .ini configuration-file reader
(configfile.py). These are pure: ... | 180 | 6,601 |
biopython | Bio/SearchIO/InfernalIO/infernal_tab.py | .py | # Copyright 2024 by Samuel Prince. 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 fo... | 487 | 14,945 |
wandb | wandb/sdk/launch/__init__.py | .py | from ._launch import create_and_run_agent, launch
from ._launch_add import launch_add
from .agent.agent import LaunchAgent
from .inputs.manage import manage_config_file, manage_wandb_config
from .utils import load_wandb_config
__all__ = [
"create_and_run_agent",
"LaunchAgent",
"launch",
"launch_add",
... | 16 | 399 |
gunicorn | gunicorn/ctl/handlers.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Control Interface Command Handlers
Provides handlers for all control commands with access to arbiter state.
"""
import os
import signal
import socket
import time
class CommandHandlers:
"""
Command h... | 586 | 18,207 |
python-prompt-toolkit | examples/full-screen/split-screen.py | .py | #!/usr/bin/env python
"""
Simple example of a full screen application with a vertical split.
This will show a window on the left for user input. When the user types, the
reversed input is shown on the right. Pressing Ctrl-Q will quit the application.
"""
from prompt_toolkit.application import Application
from prompt_... | 158 | 5,144 |
wagtail | wagtail/api/v3/tests/test_page_input_schemas.py | .py | from types import UnionType
from typing import Literal
from django.db import models
from django.test import SimpleTestCase
from django.test.utils import isolate_apps
from modelcluster.fields import ParentalKey
from ninja import Schema
from wagtail.api import APIField
from wagtail.api.v3.schemas.generators.write impor... | 290 | 11,381 |
mlflow | examples/mlflow_artifacts/example.py | .py | import os
import tempfile
from pprint import pprint
import mlflow
from mlflow.artifacts import download_artifacts
from mlflow.tracking import MlflowClient
def save_text(path, text):
with open(path, "w") as f:
f.write(text)
def log_artifacts():
# Upload artifacts
with mlflow.start_run() as run, ... | 54 | 1,475 |
pyomo | pyomo/core/__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... | 220 | 5,353 |
mlflow | tests/genai/judges/optimizers/test_dspy_base.py | .py | from typing import Any, Callable, Collection
from unittest.mock import MagicMock, Mock, patch
import dspy
import litellm
import pytest
from mlflow.entities.trace import Trace
from mlflow.exceptions import MlflowException
from mlflow.genai.judges import make_judge
from mlflow.genai.judges.optimizers.dspy import DSPyAl... | 520 | 19,866 |
biopython | Tests/test_NCBIXML.py | .py | # Copyright 2005 by Michiel de Hoon. 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.
"""Test the NCBI XML parser."""
import io
import os
import unittest
import warnings
from Bi... | 4,409 | 197,793 |
coremltools | deps/pybind11/tests/extra_setuptools/test_setuphelper.py | .py | from __future__ import annotations
import os
import subprocess
import sys
from textwrap import dedent
import pytest
DIR = os.path.abspath(os.path.dirname(__file__))
MAIN_DIR = os.path.dirname(os.path.dirname(DIR))
WIN = sys.platform.startswith("win32") or sys.platform.startswith("cygwin")
@pytest.mark.parametrize(... | 154 | 4,189 |
openvino | src/bindings/python/tests/test_transformations/test_manager.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino.passes import Manager, GraphRewrite, BackwardGraphRewrite, Serialize
from tests.test_transformations.utils.utils import MyModelPass, PatternReplacement, expect_exception
def test_registration_and_p... | 42 | 1,523 |
pyomo | pyomo/contrib/pynumero/examples/nlp_interface_2.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... | 107 | 3,159 |
flit | flit/buildapi.py | .py | from warnings import warn
warn('A package has specified `build-backend = "flit.buildapi"` and is being '
'built with Flit >= 3.10. This is likely to break in a future version. '
'Please change the backend to flit_core.buildapi, and/or specify a '
'maximum version of Flit.')
from flit_core.buildapi import... | 7 | 323 |
readthedocs.org | readthedocs/core/utils/tasks/public.py | .py | """Celery tasks with publicly viewable status."""
from celery import Task
from celery import states
from django.conf import settings
__all__ = (
"PublicTask",
"TaskNoPermission",
)
STATUS_UPDATES_ENABLED = not settings.CELERY_TASK_ALWAYS_EAGER
# pylint: disable=abstract-method
# pylint: disable=broad-exce... | 121 | 3,672 |
pyomo | pyomo/contrib/solver/tests/unit/test_config.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... | 155 | 6,503 |
lemur | lemur/auth/views.py | .py | """
.. module: lemur.auth.views
: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 __future__ import annotations # Import annotations to make type hints backwards compati... | 751 | 27,772 |
sphinx | tests/roots/test-search/conf.py | .py | exclude_patterns = ['_build']
html_search_language = 'en'
| 3 | 58 |
wandb | wandb/sdk/internal/_generated/operations.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/utils/
__all__ = ["SERVER_FEATURES_QUERY_GQL"]
SERVER_FEATURES_QUERY_GQL = """
query ServerFeaturesQuery {
serverInfo {
features {
name
isEnabled
}
}
}
"""
| 16 | 245 |
onnxruntime | onnxruntime/python/torch_cpp_extensions/setup.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import os
from setuptools import setup
from torch.utils import cpp_exte... | 20 | 668 |
mlflow | examples/mlflow-3/langchain_databricks_example.py | .py | """
python examples/mlflow-3/langchain_databricks_example.py
"""
from databricks.sdk import WorkspaceClient
from langchain_core.runnables import RunnableLambda
import mlflow
mlflow.langchain.autolog(log_models=True)
wc = WorkspaceClient()
mlflow.set_tracking_uri("databricks")
mlflow.set_experiment(f"/Users/{wc.curr... | 21 | 498 |
saleor | saleor/graphql/giftcard/tests/mutations/test_gift_card_deactivate.py | .py | import json
from unittest import mock
import graphene
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....core.utils.json_serializer import CustomJsonEncoder
from .....giftcard import GiftCardEvents
from .....webhook.event_types import WebhookEventAsyncType
from .....webho... | 224 | 6,232 |
saleor | saleor/graphql/graphql_core.py | .py | from graphql.execution import executor
from graphql.execution.base import ExecutionResult
original_complete_value_catching_error = executor.complete_value_catching_error
def _patched_complete_value_catching_error(*args, **kwargs):
info = args[3]
from saleor.core.db.connection import allow_writer_in_context
... | 58 | 2,350 |
onnx | onnx/reference/ops/op_softmax.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.ops._op import OpRunUnaryNum
class Softmax(OpRunUnaryNum):
def _run(self, X, axis=None):
if X.size == 0:
return (X,)
axis = axis ... | 20 | 482 |
openvino | tests/layer_tests/pytorch_tests/test_fmod.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestFmodTypes(PytorchLayerTest):
def _prepare_input(self):
if len(self.lhs_shape) == 0:
return (self.random.randint(2, 5, ... | 75 | 3,385 |
black | tests/data/cases/pep_750.py | .py | # flags: --minimum-version=3.14
x = t"foo"
x = t'foo {{ {2 + 2}bar {{ baz'
x = t"foo {f'abc'} bar"
x = t"""foo {{ a
foo {2 + 2}bar {{ baz
x = f"foo {{ {
2 + 2 # comment
}bar"
{{ baz
}} buzz
{print("abc" + "def"
)}
abc"""
t'{(abc:=10)}'
t'''This is a really long string, but just ... | 84 | 1,126 |
qutip | qutip/tests/test_basis_transformation.py | .py | import numpy as np
import pytest
import qutip
def real_hermitian(n_levels):
qobj = qutip.Qobj(0.5 - np.random.random_sample((n_levels, n_levels)))
return qobj + qobj.dag()
def imaginary_hermitian(n_levels):
qobj = qutip.Qobj(1j*(0.5 - np.random.random_sample((n_levels, n_levels))))
return qobj + qob... | 56 | 2,076 |
textual | docs/examples/styles/link_color.py | .py | from textual.app import App
from textual.widgets import Label
class LinkColorApp(App):
CSS_PATH = "link_color.tcss"
def compose(self):
yield Label(
"Visit the [link='https://textualize.io']Textualize[/link] website.",
id="lbl1", # (1)!
)
yield Label(
... | 30 | 747 |
coremltools | coremltools/converters/mil/mil/ops/tests/iOS14/test_scatter_gather.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 coremltools as ct
from coremltools._deps i... | 719 | 26,021 |
mlflow | mlflow/tracing/utils/search.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal, NamedTuple
from mlflow.exceptions import MlflowException
SPANS_COLUMN_NAME = "spans"
if TYPE_CHECKING:
import pandas
import mlflow.entities
from mlflow.entities import Trace
def traces_to_df(
traces: list[Trace], e... | 199 | 6,157 |
cvxpy | cvxpy/reductions/solvers/solver_inverse_data.py | .py | """
Copyright 2013 Steven Diamond, 2017 Akshay Agrawal
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... | 72 | 2,217 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.