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 | plugins/dbms/h2/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.common import hashDBRetrieve
from lib.core.common import hashDBWrite
from lib.core.data import... | 129 | 3,747 |
onnxruntime | onnxruntime/python/tools/quantization/execution_providers/qnn/quant_config.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from __fut... | 390 | 18,597 |
onnxruntime | orttraining/orttraining/python/pt_patch.py | .py | import torch
import torch.onnx.symbolic_helper as sym_help
from torch.onnx import symbolic_opset10, symbolic_opset12
from torch.onnx.symbolic_helper import parse_args
@parse_args("v", "v", "v", "v", "i", "none")
def nll_loss_10(g, self, target, weight=None, reduction="mean", ignore_index=-100):
if not weight and ... | 48 | 1,977 |
wandb | wandb/sdk/lib/timer.py | .py | import time
from typing import Any
from typing_extensions import Self
class Timer:
def __init__(self) -> None:
self.start_time: float = time.time()
self.start: float = time.perf_counter()
self.stop: float = self.start
def __enter__(self) -> Self:
return self
def __exit__... | 22 | 473 |
mlflow | mlflow/store/_unity_catalog/registry/prompt_info.py | .py | """
Internal PromptInfo entity for Unity Catalog prompt operations.
This is an implementation detail for the Unity Catalog store and should not be
considered part of the public MLflow API.
"""
class PromptInfo:
"""
Internal entity for prompt information from Unity Catalog. This represents
prompt metadata... | 74 | 2,198 |
funcy | tests/test_funcs.py | .py | from operator import __add__, __sub__
import sys
import pytest
from whatever import _
from funcy import lmap, merge_with
from funcy.funcs import *
from funcy.seqs import keep
def test_caller():
assert caller([1, 2])(sum) == 3
def test_constantly():
assert constantly(42)() == 42
assert constantly(42)('hi... | 201 | 6,281 |
astropy | astropy/utils/misc.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
A "grab bag" of relatively small general-purpose utilities that don't have
a clear module/package to live in.
"""
import contextlib
import difflib
import inspect
import json
import locale
import re
import sys
import threading
import traceback
import u... | 551 | 15,994 |
sqlmap | lib/core/replication.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import sqlite3
from lib.core.common import cleanReplaceUnicode
from lib.core.common import getSafeExString
from lib.core.common import unsafeSQLIdentificatorNaming
from lib.core.... | 144 | 5,371 |
sqlmap | tamper/commalesslimit.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import os
import re
from lib.core.common import singleTimeWarnMessage
from lib.core.enums import DBMS
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.HIGH
def depen... | 51 | 1,337 |
beam | sdks/python/apache_beam/runners/portability/fn_api_runner/trigger_manager_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... | 251 | 9,614 |
beam | sdks/python/apache_beam/runners/render.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... | 570 | 20,236 |
openvino | tests/layer_tests/pytorch_tests/test_fft.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from sys import platform
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestRFFTN(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(*self.input_shape),)
de... | 165 | 7,156 |
pdm | tests/fixtures/projects/demo-parent-package/package-a/setup.py | .py | from setuptools import setup
setup(name="package-a", py_modules=["foo"], version="0.1.0", install_requires=["flask"])
| 5 | 120 |
pyomo | pyomo/contrib/preprocessing/plugins/strip_bounds.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... | 101 | 4,047 |
openvino | tests/utils/utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Utility module."""
from pathlib import Path
import yaml
from pymongo import MongoClient
from copy import deepcopy
import requests
import logging
import re
# constants
DATABASES = ['timetests', 'memorytests']
DB_COLLECTIONS = ["comm... | 91 | 3,452 |
wandb | tools/generate-tool.py | .py | #!/usr/bin/env python
"""Generate code for wandb SDK.
Usage:
./tools/generate-tool.py --generate
./tools/generate-tool.py --check
./tools/generate-tool.py --generate --check
./tools/generate-tool.py --generate --check wandb/sdk/lib/_wburls_generated.py
"""
import argparse
import contextlib
import file... | 120 | 3,449 |
colorama | colorama/ansi.py | .py | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
'''
This module generates ANSI character codes to printing colors to terminals.
See: http://en.wikipedia.org/wiki/ANSI_escape_code
'''
CSI = '\033['
OSC = '\033]'
BEL = '\a'
def code_to_chars(code):
return CSI + str(code) + 'm'
def set_t... | 103 | 2,506 |
hatch | tests/dep/test_sync.py | .py | import os
import sys
import pytest
from hatch.dep.core import Dependency
from hatch.dep.sync import InstalledDistributions
from hatch.venv.core import TempUVVirtualEnv, TempVirtualEnv
def test_no_dependencies(platform):
with TempUVVirtualEnv(sys.executable, platform) as venv:
distributions = InstalledDi... | 247 | 10,664 |
openvino | src/bindings/python/src/openvino/frontend/pytorch/quantized.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import functools
import logging
from collections.abc import Callable
from typing import Any
import torch
from openvino.frontend.pytorch import ModuleExtension, compressed_tens... | 223 | 8,811 |
pyomo | examples/mpec/df.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... | 34 | 1,207 |
django-cms | cms/cache/__init__.py | .py | import re
from cms.utils.conf import get_cms_setting
CMS_PAGE_CACHE_VERSION_KEY = get_cms_setting("CACHE_PREFIX") + '_PAGE_CACHE_VERSION'
def _get_cache_version():
"""
Returns the current page cache version, explicitly setting one if not
defined.
"""
from django.core.cache import cache
vers... | 88 | 2,893 |
pyomo | examples/pyomo/piecewise/nonconvex.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... | 50 | 1,767 |
sphinx | sphinx/domains/python/_object.py | .py | from __future__ import annotations
import contextlib
import re
from typing import TYPE_CHECKING
from docutils import nodes
from docutils.parsers.rst import directives
from sphinx import addnodes
from sphinx.addnodes import pending_xref, pending_xref_condition
from sphinx.directives import ObjectDescription
from sphi... | 523 | 18,720 |
saleor | saleor/tests/e2e/orders/utils/order_mark_as_paid.py | .py | from saleor.graphql.tests.utils import get_graphql_content
ORDER_MARK_AS_PAID_MUTATION = """
mutation OrderMarkAsPaid($id: ID!, $transactionReference: String) {
orderMarkAsPaid(id: $id, transactionReference: $transactionReference) {
order {
id
isPaid
paymentStatus
payments {
... | 61 | 1,135 |
pyro | tests/contrib/funsor/test_pyroapi_funsor.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
try:
# triggers backend registration
import funsor
import pyro.contrib.funsor # noqa: F401
funsor.set_backend("torch")
except ImportError:
pytestmark = pytest.mark.skip()
from pyroapi import pyro_... | 24 | 488 |
pyomo | pyomo/gdp/plugins/between_steps.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 | 1,935 |
probability | tensorflow_probability/python/bijectors/transpose.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... | 385 | 14,793 |
pyomo | pyomo/solvers/tests/piecewise_linear/problems/convex_vararray.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... | 69 | 2,184 |
saleor | saleor/account/tests/test_customer_type.py | .py | import pytest
from django.db import IntegrityError
from django.db.models.deletion import ProtectedError
from ..exceptions import NoDefaultCustomerType
from ..migrations.tasks.saleor3_23 import assign_default_customer_type_to_users_task
from ..models import CustomerType, User
from ..utils import get_default_customer_ty... | 143 | 4,315 |
coremltools | coremltools/models/_interface_management.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
from coremltools import proto
from . import _feature_management as _fm
from . import datatypes
def se... | 216 | 7,137 |
coremltools | coremltools/converters/mil/mil/types/type_void.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
from .type_spec import Type
class void:
@classmethod
def __type_info__(cls):
return... | 13 | 352 |
saleor | saleor/graphql/account/mutations/account/confirm_account.py | .py | import logging
from typing import Any
import graphene
from django.contrib.sites.models import Site
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from .....account import models
from .....account.error_codes import AccountErrorCode
from .....account.throttling import authenticate_with_throttli... | 194 | 6,923 |
luigi | test/rpc_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... | 218 | 7,870 |
beam | sdks/python/apache_beam/typehints/pytorch_type_compatibility.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... | 145 | 4,945 |
mlflow | tests/entities/test_run.py | .py | import json
import pytest
from mlflow.entities import (
Dataset,
DatasetInput,
LifecycleStage,
LoggedModelOutput,
Metric,
Run,
RunData,
RunInfo,
RunInputs,
RunOutputs,
RunStatus,
)
from mlflow.exceptions import MlflowException
from tests.entities.test_run_data import _chec... | 155 | 4,824 |
beam | sdks/python/apache_beam/yaml/yaml_errors.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... | 92 | 3,261 |
probability | tensorflow_probability/python/stats/ranking.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... | 435 | 15,517 |
pyro | pyro/poutine/__init__.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from .handlers import (
block,
broadcast,
collapse,
condition,
do,
enum,
equalize,
escape,
infer_config,
lift,
markov,
mask,
queue,
reparam,
replay,
scale,
seed,
... | 59 | 952 |
sqlmap | lib/takeover/udf.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import os
from lib.core.agent import agent
from lib.core.common import Backend
from lib.core.common import checkFile
from lib.core.common import dataToStdout
from lib.core.common... | 397 | 14,030 |
saleor | saleor/graphql/warehouse/schema.py | .py | import graphene
from ...permission.enums import (
OrderPermissions,
ProductPermissions,
ShippingPermissions,
)
from ...warehouse import models
from ..core import ResolveInfo
from ..core.connection import create_connection_slice, filter_connection_queryset
from ..core.doc_category import DOC_CATEGORY_PRODUC... | 119 | 4,046 |
confluent-kafka-python | tests/schema_registry/conftest.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... | 472 | 19,797 |
conda | tests/plugins/data/test-plugin/test_plugin/success.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
# see tests.plugins.test_manager.test_load_entrypoints_success
# simulate a successful plugin
from conda import plugins
from conda.core.solve import Solver
@plugins.hookimpl
def conda_solvers():
"""The conda plugin hook implementation to l... | 16 | 438 |
onnxruntime | tools/python/util/run.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from __future__ import annotations
import logging
import os
import shlex
import subprocess
_log = logging.getLogger("util.run")
def run(
*args,
cwd=None,
input=None,
capture_stdout=False,
capture_stderr... | 64 | 1,703 |
astropy | astropy/units/quantity_helper/scipy_special.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Quantity helpers for the scipy.special ufuncs.
Available ufuncs in this module are at
https://docs.scipy.org/doc/scipy/reference/special.html
"""
from astropy.units.core import dimensionless_unscaled
from astropy.units.errors import UnitsError, UnitTy... | 91 | 3,051 |
wandb | wandb/sdk/artifacts/_generated/delete_aliases.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/artifacts/
from __future__ import annotations
from wandb._pydantic import GQLResult
class DeleteAliases(GQLResult):
result: DeleteAliasesResult | None
class DeleteAliasesResult(GQLResult):
success: bool
DeleteAliases.model_rebuild()
| 18 | 312 |
returns | tests/test_future/test_future_result/test_future_result_decorator.py | .py | import anyio
import pytest
from returns.future import FutureResult, future_safe
from returns.io import IOFailure, IOSuccess
@future_safe
async def _coro(arg: int) -> float:
assert isinstance(arg, int)
await anyio.sleep(0)
return 1 / arg
@future_safe(exceptions=(ZeroDivisionError,))
async def _coro_two(... | 64 | 1,822 |
beam | sdks/python/apache_beam/io/unbounded_source_test.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 1,253 | 43,988 |
textual | src/textual/_auto_scroll.py | .py | from textual.geometry import Region
def get_auto_scroll_regions(
widget_region: Region, auto_scroll_lines: int
) -> tuple[Region, Region]:
"""Get non-overlapping regions which should auto scroll when selecting.
Args:
widget_region: The region occupied by the widget.
auto_scroll_lines: Num... | 31 | 1,080 |
mlflow | examples/tracing/fluent.py | .py | """
This example demonstrates how to create a trace with multiple spans using the high-level MLflow fluent APIs.
"""
import mlflow
mlflow.set_experiment("mlflow-tracing-example")
# Decorating the function with `@mlflow.trace` decorator is the easiest way to trace your function.
# MLflow will create a trace for func... | 59 | 1,705 |
wagtail | wagtail/api/v3/auth.py | .py | from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.utils import timezone
from ninja.security import HttpBearer
from ninja.security.http import HttpAuthBase
from wagtail.models import APIToken
class BearerTokenAuth(HttpBearer):
"""
Resolves ``Authorization: Beare... | 67 | 2,308 |
pyfilesystem2 | tests/test_tools.py | .py | from __future__ import unicode_literals
import unittest
from fs import tools
from fs.mode import validate_open_mode, validate_openbin_mode
from fs.opener import open_fs
class TestTools(unittest.TestCase):
def test_remove_empty(self):
fs = open_fs("temp://")
fs.makedirs("foo/bar/baz/egg/")
... | 56 | 1,756 |
onnx | onnx/reference/ops/op_roi_align.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
class PreCalc:
def __init__(self, pos1=0, pos2=0, pos3=0, pos4=0, w1=0, w2=0, w3=0, w4=0):
self.pos1 = pos1
self.pos2 = p... | 297 | 10,843 |
openvino | tests/e2e_tests/common/comparator/ssim_4d.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
import sys
from statistics import mean
from skimage.metrics import structural_similarity as ssim
from .provider import ClassProvider
from e2e_tests.common.comparator.threshold_utils import get_default_ssim_thresho... | 73 | 3,315 |
onnx | onnx/backend/test/case/node/sin.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 Sin(Base):
@staticmethod
def export() -> None:
node = ... | 29 | 713 |
beam | sdks/python/apache_beam/runners/test/__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... | 32 | 1,320 |
probability | tensorflow_probability/python/experimental/auto_batching/allocation_strategy.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... | 208 | 8,677 |
mlflow | mlflow/utils/uri.py | .py | import os
import pathlib
import posixpath
import re
import urllib.parse
import uuid
from typing import Any
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
from mlflow.utils.os import is_windows
from mlflow.utils.validation import _validate_db_type_string
... | 613 | 22,625 |
qutip | qutip/solver/correlation.py | .py | __all__ = [
'correlation_3op',
'correlation_2op_1t', 'correlation_2op_2t', 'correlation_3op_1t',
'correlation_3op_2t', 'coherence_function_g1', 'coherence_function_g2'
]
import numpy as np
from ..core import (
Qobj, QobjEvo, liouvillian, spre, unstack_columns, stack_columns,
tensor, expect, qeye_l... | 631 | 23,204 |
mlflow | tests/tracing/utils/test_timeout.py | .py | import time
from concurrent.futures import ThreadPoolExecutor
from unittest import mock
import pytest
import mlflow
from mlflow.entities.span_event import SpanEvent
from mlflow.entities.span_status import SpanStatusCode
from mlflow.tracing.export.inference_table import _TRACE_BUFFER, pop_trace
from mlflow.tracing.tra... | 163 | 5,402 |
probability | tensorflow_probability/python/distributions/student_t_process_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... | 480 | 19,990 |
pyomo | doc/OnlineDocs/src/data/table0.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 | 749 |
textual | examples/sidebar.py | .py | """
A simple animated sidebar.
See comments for details.
"""
from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.reactive import reactive
from textual.widget import Widget
from textual.widgets import Footer, Label
TEXT = """I must not fear.
Fear is the mind-killer.
Fear i... | 96 | 2,234 |
pyomo | pyomo/dataportal/plugins/db_table.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... | 652 | 23,092 |
pyro | pyro/distributions/rejector.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from pyro.distributions.score_parts import ScoreParts
from pyro.distributions.torch_distribution import TorchDistribution
class Rejector(TorchDistribution):
"""
Rejection sampled distribution given an accept... | 74 | 2,933 |
textual | src/textual/screen.py | .py | """
This module contains the `Screen` class and related objects.
The `Screen` class is a special widget which represents the content in the terminal. See [Screens](/guide/screens/) for details.
"""
from __future__ import annotations
import asyncio
from functools import partial
from operator import attrgetter
from ... | 2,195 | 79,934 |
black | tests/data/cases/numeric_literals_skip_underscores.py | .py | x = 123456789
x = 1_2_3_4_5_6_7
x = 1E+1
x = 0xb1acc
x = 0.00_00_006
x = 12_34_567J
x = .1_2
x = 1_2.
# output
x = 123456789
x = 1_2_3_4_5_6_7
x = 1e1
x = 0xB1ACC
x = 0.00_00_006
x = 12_34_567j
x = 0.1_2
x = 1_2.0 | 19 | 215 |
mkdocs-material | material/plugins/tags/structure/tag/__init__.py | .py | # Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, c... | 179 | 4,963 |
textual | src/textual/expand_tabs.py | .py | from __future__ import annotations
import re
from rich.cells import cell_len
from rich.text import Text
_TABS_SPLITTER_RE = re.compile(r"(.*?\t|.+?$)")
def get_tab_widths(line: str, tab_size: int = 4) -> list[tuple[str, int]]:
"""Splits a string line into tuples (str, int).
Each tuple represents a section... | 109 | 3,538 |
textual | src/textual/widgets/option_list.py | .py | from textual.widgets._option_list import DuplicateID, Option, OptionDoesNotExist
__all__ = ["DuplicateID", "Option", "OptionDoesNotExist"]
| 4 | 140 |
scikit-bio | skbio/alignment/_score.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.
# --------------------------------------------... | 128 | 4,484 |
cvxpy | cvxpy/utilities/citations.py | .py | """
Copyright 2025, the CVXPY Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, sof... | 630 | 17,412 |
wandb | tests/system_tests/test_core/test_wandb_setup.py | .py | import asyncio
import json
import os
from unittest import mock
import pytest
import wandb
from wandb.sdk import wandb_setup
from wandb.sdk.lib import asyncio_manager
def test_service_logging_level_debug():
"""Test the service logging is debug.
Verifies that the service logging level is set to DEBUG when the... | 72 | 2,204 |
jupyterlab | examples/notebook/main.py | .py | """
An example demonstrating a stand-alone "notebook".
Copyright (c) Jupyter Development Team.
Distributed under the terms of the Modified BSD License.
Example
-------
To run the example, see the instructions in the README to build it. Then
run ``python main.py``.
"""
import json
import os
from jupyter_server.bas... | 80 | 2,561 |
beam | sdks/python/apache_beam/dataframe/transforms_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... | 456 | 17,094 |
wandb | tests/unit_tests/test_wandb_define_metric.py | .py | """metric user tests."""
import pytest
import wandb
from wandb.proto import wandb_internal_pb2 as pb
def test_metric_none(mock_run, parse_records, record_q):
run = mock_run()
run.log(dict(this=1))
run.log(dict(that=2))
parsed = parse_records(record_q)
assert len(parsed.records) == 2
history ... | 230 | 5,325 |
pdm | tests/cli/test_cache.py | .py | import pytest
from unearth import Link
from pdm.models.cached_package import CachedPackage
from tests import FIXTURES
@pytest.fixture
def prepare_wheel_cache(project):
cache_dir = project.cache("wheels")
(cache_dir / "arbitrary/path").mkdir(parents=True)
for name in (
"foo-0.1.0.whl",
"ba... | 175 | 5,190 |
mlflow | examples/transformers/conversational.py | .py | import transformers
import mlflow
conversational_pipeline = transformers.pipeline(model="microsoft/DialoGPT-medium")
with mlflow.start_run():
model_info = mlflow.transformers.log_model(
transformers_model=conversational_pipeline,
name="chatbot",
task="conversational",
input_exampl... | 26 | 680 |
qutip | qutip/measurement.py | .py | """
Module for measuring quantum objects.
"""
__all__ = [
'measurement_statistics_povm',
'measurement_statistics_observable',
'measure_observable',
'measure_povm',
'measurement_statistics',
'measure'
]
import numpy as np
from . import Qobj, expect, qeye_like, settings
def _verify_input(op, ... | 448 | 14,593 |
django-cms | cms/cache/permissions.py | .py | from cms.utils.conf import get_cms_setting
PERMISSION_KEYS = [
'add_page', 'change_page', 'change_page_advanced_settings',
'change_page_permissions', 'delete_page', 'move_page',
'publish_page', 'view_page',
]
def get_cache_key(user, key):
return "%s:permission:%d:%s" % (
get_cms_setting('CACH... | 67 | 1,990 |
hydra | tests/test_basic_launcher.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from pytest import mark, param
from hydra.test_utils.launcher_common_tests import (
BatchedSweeperTestSuite,
IntegrationTestSuite,
LauncherTestSuite,
)
@mark.parametrize("launcher_name, overrides", [("basic", [])])
class TestBasicLaun... | 52 | 1,130 |
conda | conda/common/signals.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Intercept signals and handle them gracefully."""
import signal
import threading
from contextlib import contextmanager
from logging import getLogger
log = getLogger(__name__)
INTERRUPT_SIGNALS = (
"SIGABRT",
"SIGINT",
"SIGTERM",... | 63 | 1,788 |
probability | tensorflow_probability/python/experimental/mcmc/sample_fold_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... | 500 | 18,939 |
mlflow | tests/projects/utils.py | .py | import filecmp
import logging
import os
import shutil
import pytest
from mlflow.entities import RunStatus
from mlflow.projects import _project_spec
from mlflow.utils.file_utils import TempDir, _copy_project
TEST_DIR = "tests"
TEST_PROJECT_DIR = os.path.abspath(os.path.join(TEST_DIR, "resources", "example_project"))
... | 81 | 2,853 |
pyro | pyro/infer/reparam/haar.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
from pyro.distributions.transforms.haar import HaarTransform
from .unit_jacobian import UnitJacobianReparam
class HaarReparam(UnitJacobianReparam):
"""
Haar wavelet reparameterizer, using a
:class:`~pyro.distributions.tr... | 37 | 1,594 |
jupytext | tests/data/notebooks/outputs/ipynb_to_percent/Notebook with html and latex cells.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %% language="html"
# <p><a href="https://github.com/mwouts/jupytext", style="color: rgb(0,0,255)">Jupytext</a> on GitHub</p>
# %% language="latex"
# $\frac{\pi}{2}$
# %%
# %load_ext rpy2.ipython
# %% lan... | 26 | 536 |
beam | sdks/python/apache_beam/ml/transforms/handlers.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... | 483 | 19,175 |
textual | src/textual/lazy.py | .py | """
Tools for lazy loading widgets.
"""
from __future__ import annotations
from textual.widget import Widget
class Lazy(Widget):
"""Wraps a widget so that it is mounted *lazily*.
Lazy widgets are mounted after the first refresh. This can be used to display some parts of
the UI very quickly, followed by... | 142 | 4,329 |
gunicorn | tests/requests/valid/pp_05.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.config import Config
cfg = Config()
cfg.set("proxy_protocol", True)
request = {
"method": "GET",
"uri": uri("/proxy/v2/ipv6"),
"version": (1, 1),
"headers": [
("HOST", "examp... | 20 | 387 |
probability | tensorflow_probability/python/distributions/half_normal_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... | 366 | 14,296 |
textual | tests/test_compositor.py | .py | from textual.app import App, ComposeResult
from textual.containers import Container
from textual.widgets import Static
async def test_compositor_scroll_placements():
"""Regression test for https://github.com/Textualize/textual/issues/5249
The Static should remain visible.
"""
class ScrollApp(App):
... | 43 | 1,172 |
astropy | astropy/constants/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Contains astronomical and physical constants for use in Astropy or other
places.
A typical use case might be::
>>> from astropy.constants import c, m_e
>>> # ... define the mass of something you want the rest energy of as m ...
>>> m = m_... | 63 | 1,563 |
confluent-kafka-python | src/confluent_kafka/aio/producer/__init__.py | .py | # Copyright 2025 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... | 24 | 755 |
ipython | IPython/core/page.py | .py | """
Paging capabilities for IPython.core
Notes
-----
For now this uses IPython hooks, so it can't be in IPython.utils. If we can get
rid of that dependency, we could move it there.
-----
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import os
import io
im... | 346 | 11,793 |
metrics | src/torchmetrics/functional/image/_deprecated.py | .py | from collections.abc import Sequence
from typing import Optional, Union
from torch import Tensor
from typing_extensions import Literal
from torchmetrics.functional.image.d_lambda import spectral_distortion_index
from torchmetrics.functional.image.ergas import error_relative_global_dimensionless_synthesis
from torchme... | 266 | 8,940 |
pyomo | pyomo/contrib/cp/sequence_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... | 150 | 5,527 |
probability | spinoffs/inference_gym/inference_gym/targets/lorenz_system.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... | 435 | 16,566 |
beam | sdks/python/apache_beam/io/gcp/bigtableio.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... | 391 | 15,093 |
pyomo | pyomo/contrib/fbbt/tests/test_expression_bounds_walker.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... | 414 | 14,524 |
django-cms | cms/test_utils/project/placeholderapp/cms_plugins.py | .py | from django.conf import settings
from cms.plugin_base import CMSPluginBase, PluginMenuItem
from cms.plugin_pool import plugin_pool
class EmptyPlugin(CMSPluginBase):
name = "Empty Plugin"
text_enabled = True
render_plugin = False
def render(self, context, instance, placeholder):
return contex... | 31 | 937 |
pdm | src/pdm/models/candidates.py | .py | from __future__ import annotations
import dataclasses
import hashlib
import importlib.metadata as im
import os
import re
import warnings
from functools import cached_property
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import TYPE_CHECKING, Any, ClassVar, cast, no_type_check
from zipfi... | 712 | 29,085 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.