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 |
|---|---|---|---|---|---|
onnx | onnx/reference/ops/op_grid_sample.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numbers
import numpy as np
from onnx.reference.op_run import OpRun
from onnx.reference.ops.op_resize import _get_all_coords
class GridSample(OpRun):
# https://github.com/pytorch/pytorch/bl... | 366 | 13,169 |
textual | tests/test_test_runner.py | .py | from textual import events
from textual.app import App
async def test_run_test() -> None:
"""Test the run_test context manager."""
keys_pressed: list[str] = []
class TestApp(App[str]):
def on_key(self, event: events.Key) -> None:
keys_pressed.append(event.key)
app = TestApp()
... | 24 | 779 |
onnx | onnx/fuzz/fuzz_shape_inference.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
"""Atheris fuzz harness for onnx.shape_inference.
Two input paths are exercised per iteration, selected by a fuzzer-controlled
toggle byte read from the *tail* of the input (so the head remains a valid
candidate for the raw-bytes path):
*... | 190 | 6,508 |
python-prompt-toolkit | examples/full-screen/no-layout.py | .py | #!/usr/bin/env python
"""
An empty full screen application without layout.
"""
from prompt_toolkit import Application
Application(full_screen=True).run()
| 9 | 156 |
probability | spinoffs/fun_mc/fun_mc/fun_mc_test.py | .py | # Copyright 2021 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... | 2,063 | 65,198 |
onnx | onnx/backend/test/case/node/negativeloglikelihoodloss.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
def compute_negative_log_likelihood_loss(
input, target, weight=None, re... | 586 | 19,618 |
saleor | saleor/tax/webhooks/parser.py | .py | import logging
from typing import Any
from pydantic import ValidationError
from ...core.taxes import TAX_ERROR_FIELD_LENGTH, TaxData, TaxDataError, TaxLineData
from ...core.utils.text import safe_truncate
from ...webhook.response_schemas.taxes import CalculateTaxesSchema
from ...webhook.response_schemas.utils.helpers... | 53 | 1,764 |
pyomo | doc/OnlineDocs/src/data/param3b.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,141 |
black | tests/data/cases/power_op_spacing.py | .py | def function(**kwargs):
t = a**2 + b**3
return t ** 2
def function_replace_spaces(**kwargs):
t = a **2 + b** 3 + c ** 4
def function_dont_replace_spaces():
{**a, **b, **c}
a = 5**~4
b = 5 ** f()
c = -(5**2)
d = 5 ** f["hi"]
e = lazy(lambda **kwargs: 5)
f = f() ** 5
g = a.b**c.d
h = 5 ** funcs.f()
... | 150 | 3,533 |
pyro | pyro/distributions/transforms/neural_autoregressive.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from functools import partial
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions.transforms import SigmoidTransform, TanhTransform
from pyro.nn import AutoRegressiveNN, ConditionalAutoRegr... | 272 | 9,794 |
saleor | saleor/plugins/openid_connect/tests/test_utils.py | .py | import datetime
import json
import time
import warnings
from functools import partial
from unittest import mock
from unittest.mock import MagicMock, Mock, call, patch
import pytest
import requests
from authlib.jose import JWTClaims
from django.core.cache import cache
from django.core.exceptions import ValidationError
... | 1,372 | 44,705 |
beam | sdks/python/apache_beam/runners/interactive/testing/pipeline_assertion.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... | 116 | 4,943 |
black | tests/data/cases/one_element_subscript.py | .py | # We should not treat the trailing comma
# in a single-element subscript.
a: tuple[int,]
b = tuple[int,]
# The magic comma still applies to multi-element subscripts.
c: tuple[int, int,]
d = tuple[int, int,]
# Magic commas still work as expected for non-subscripts.
small_list = [1,]
list_of_types = [tuple[int,],]
# o... | 37 | 674 |
textual | src/textual/css/tokenizer.py | .py | from __future__ import annotations
import re
from typing import TYPE_CHECKING, NamedTuple
import rich.repr
from rich.console import Group, RenderableType
from rich.highlighter import ReprHighlighter
from rich.padding import Padding
from rich.panel import Panel
from rich.text import Text
from textual.css._error_tools... | 385 | 11,826 |
cvxpy | cvxpy/tests/nlp_tests/stress_tests_diff_engine/test_compositions.py | .py | """
Copyright, the CVXPY authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
... | 201 | 7,495 |
sqlmap | lib/utils/nonsql.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Shared detection primitives for the non-SQL injection techniques (--nosql, --xpath, --ldap, --hql,
--ssti, --graphql, --xxe). Each of those engines historically carried its own copy o... | 189 | 9,318 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/regex_replace_all.py | .py | # coding=utf-8
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License");... | 60 | 1,811 |
openvino | tests/layer_tests/ovc_python_api_tests/test_tf.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import openvino as ov
import os
import sys
import pytest
import tempfile
import tensorflow as tf
import unittest
from common import constants
from common.layer_test_class import CommonLayerTest
from common.mo_convert_te... | 1,359 | 48,864 |
confluent-kafka-python | examples/confluent_cloud.py | .py | #!/usr/bin/env python
#
# Copyright 2018 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... | 148 | 5,072 |
gunicorn | gunicorn/ctl/client.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Control Socket Client
Client library for connecting to gunicorn control socket.
"""
import shlex
import socket
from gunicorn.ctl.protocol import (
ControlProtocol,
make_request,
)
class ControlClie... | 140 | 3,478 |
metrics | src/torchmetrics/image/kid.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... | 359 | 15,628 |
saleor | saleor/tax/tests/fixtures/tax_class.py | .py | import pytest
from django_countries import countries
from ....plugins.avatax import (
DEFAULT_TAX_CODE,
META_CODE_KEY,
META_DESCRIPTION_KEY,
TAX_CODE_NON_TAXABLE_PRODUCT,
)
from ...models import TaxClass, TaxClassCountryRate
@pytest.fixture(autouse=True)
def default_tax_class(db):
tax_class, _ = ... | 75 | 2,131 |
wagtail | wagtail/tests/test_migrations.py | .py | """
Check that all changes to Wagtail models have had migrations created. If there
are outstanding model changes that need migrations, fail the tests.
"""
from django.apps import apps
from django.db.migrations.autodetector import MigrationAutodetector
from django.db.migrations.loader import MigrationLoader
from django... | 64 | 2,199 |
wagtail | wagtail/contrib/sitemaps/apps.py | .py | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class WagtailSitemapsAppConfig(AppConfig):
name = "wagtail.contrib.sitemaps"
label = "wagtailsitemaps"
verbose_name = _("Wagtail sitemaps")
| 9 | 243 |
httpie | httpie/core.py | .py | import argparse
import os
import platform
import sys
import socket
from typing import List, Optional, Union, Callable
import requests
from pygments import __version__ as pygments_version
from requests import __version__ as requests_version
from . import __version__ as httpie_version
from .cli.constants import OUT_REQ... | 299 | 10,450 |
onnx | onnx/backend/test/case/node/equal.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 Equal(Base):
@staticmethod
def export() -> None:
node ... | 93 | 3,307 |
lemur | lemur/database.py | .py | """
.. module: lemur.database
:platform: Unix
:synopsis: This module contains all of the database related methods
needed for lemur to interact with a datastore
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson... | 341 | 8,335 |
saleor | saleor/graphql/core/filters/filter_input.py | .py | import itertools
from django.db import models
from django_filters.filterset import FILTER_FOR_DBFIELD_DEFAULTS, BaseFilterSet
from graphene import Argument, InputField, String
from graphene.types.inputobjecttype import InputObjectTypeOptions
from graphene.types.utils import yank_fields_from_attrs
from ..descriptions ... | 104 | 3,624 |
black | tests/data/cases/fmtskip_multiple_strings.py | .py | # Multiple fmt: skip on string literals
a = (
"this should " # fmt: skip
"be fine"
)
b = (
"this is " # fmt: skip
"not working" # fmt: skip
)
c = (
"and neither " # fmt: skip
"is this " # fmt: skip
"working"
)
d = (
"nor "
"is this " # fmt: skip
"working" # fmt: skip
)
... | 76 | 1,567 |
pyomo | doc/OnlineDocs/src/expr/performance.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 | 2,541 |
pyomo | pyomo/dae/tests/test_finite_diff.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... | 355 | 13,723 |
pyomo | pyomo/contrib/piecewise/tests/test_inner_repn_gdp.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... | 122 | 5,308 |
coremltools | coremltools/converters/mil/mil/utils.py | .py | # Copyright (c) 2024, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from copy import deepcopy
from typing import Any, Dict, List, Optional, Tuple
from .operation import ... | 189 | 6,067 |
probability | tensorflow_probability/python/layers/__init__.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... | 79 | 4,239 |
mlflow | mlflow/smolagents/autolog.py | .py | import inspect
import logging
from typing import Any
import mlflow
from mlflow.entities import SpanType
from mlflow.entities.span import LiveSpan
from mlflow.tracing.constant import SpanAttributeKey, TokenUsageKey
from mlflow.utils.autologging_utils.config import AutoLoggingConfig
_logger = logging.getLogger(__name__... | 151 | 5,269 |
hatch | src/hatch/python/core.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any
from hatch.python.resolve import ORDERED_DISTRIBUTION_NAMES, get_distribution, is_valid_distribution_name
from hatch.utils.fs import temp_directory
if TYPE_CHECKING:
from hatch.python.resolve import Distribution
from hatch.utils.fs impo... | 126 | 4,016 |
mlflow | mlflow/server/auth/client.py | .py | from mlflow.server.auth.entities import (
GetUserPermissionResult,
Role,
RolePermission,
User,
UserRoleAssignment,
)
from mlflow.server.auth.routes import (
ADD_ROLE_PERMISSION,
ASSIGN_ROLE,
CREATE_ROLE,
CREATE_USER,
DELETE_ROLE,
DELETE_USER,
GET_ROLE,
GET_USER,
G... | 395 | 12,956 |
bazel | src/test/py/bazel/bzlmod/bazel_vendor_test.py | .py | # pylint: disable=g-backslash-continuation
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# 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/LICEN... | 940 | 32,963 |
clearml | clearml/backend_interface/task/repo/freeze.py | .py | import sys
import os
import json
from typing import Tuple
from .util import get_command_output
def pip_freeze(combine_conda_with_pip: bool = False) -> Tuple[str, str]:
req_lines = []
local_packages = []
conda_lines = []
conda_prefix = os.environ.get("CONDA_PREFIX")
if conda_prefix and not conda_p... | 79 | 3,508 |
pyomo | pyomo/contrib/sensitivity_toolbox/tests/test_k_aug_interface.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... | 136 | 4,902 |
pyomo | examples/gdp/small_lit/ex_633_trespalacios.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... | 79 | 2,579 |
python-prompt-toolkit | examples/choices/color.py | .py | from __future__ import annotations
from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.shortcuts import choice
from prompt_toolkit.styles import Style
def main() -> None:
style = Style.from_dict(
{
"input-selection": "fg:#ff0000",
"number": "fg:#884444 bold",
... | 35 | 823 |
jupytext | src/jupytext/async_pairs.py | .py | import jupytext
from .combine import combine_inputs_with_outputs
from .compare import compare
from .formats import check_file_version, long_form_multiple_formats
from .paired_paths import find_base_path_and_format, full_path
from .pairs import PairedFilesDiffer
async def read_pair(inputs, outputs, read_one_file, mus... | 73 | 2,574 |
sqlmap | plugins/dbms/oracle/filesystem.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.agent import agent
from lib.core.common import dataToOutFile
from lib.core.common import decodeDbmsHexValue
from lib.core.common import getSQLSnippet
from lib.core.c... | 59 | 2,195 |
eve | tests/methods/patch.py | .py | import simplejson as json
from bson import ObjectId
from pymongo import ReadPreference
from eve import ETAG, ISSUES, LAST_UPDATED, STATUS, STATUS_OK
from eve.methods.patch import patch_internal
from tests import TestBase
from tests.test_settings import MONGO_DBNAME
from tests.utils import DummyEvent
class TestPatch(... | 941 | 36,607 |
textual | docs/examples/guide/styles/border01.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Label
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its... | 27 | 767 |
wagtail | wagtail/search/apps.py | .py | from django.utils.translation import gettext_lazy as _
from modelsearch.apps import ModelSearchAppConfig
class WagtailSearchAppConfig(ModelSearchAppConfig):
name = "wagtail.search"
label = "wagtailsearch"
verbose_name = _("Wagtail search")
backend_setting_name = "WAGTAILSEARCH_BACKENDS"
default = ... | 11 | 325 |
coremltools | coremltools/converters/mil/mil/passes/defs/cleanup/topological_reorder.py | .py | # Copyright (c) 2023, 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.converters.mil.mil import Builder as mb
from coremltools.converters.mil.mil.passes.... | 177 | 7,958 |
scikit-bio | skbio/sequence/__init__.py | .py | r"""Biological Sequences (:mod:`skbio.sequence`)
============================================
.. currentmodule:: skbio.sequence
This module provides functionality for storing and working with sequences, including
molecular sequences based on IUPAC-defined alphabets (:class:`DNA`, :class:`RNA`,
:class:`Protein`), sequ... | 594 | 17,774 |
pyomo | pyomo/contrib/solver/tests/solvers/test_gurobi_warm_start.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... | 115 | 4,073 |
openvino | src/bindings/python/src/openvino/opset11/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino.opset1.ops import absolute
from openvino.opset1.ops import absolute as abs
from openvino.opset1.ops import acos
from openvino.opset4.ops import acosh
from openvino.opset8.ops import adaptive_avg_pool... | 180 | 7,581 |
beam | sdks/python/apache_beam/examples/inference/pytorch_image_classification.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... | 172 | 6,022 |
beam | sdks/python/apache_beam/runners/portability/prism_runner_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... | 569 | 20,153 |
cvxpy | cvxpy/tests/test_labels.py | .py | """
Copyright, the CVXPY authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
... | 520 | 16,462 |
saleor | saleor/warehouse/tests/webhooks/test_channel_stock_events.py | .py | import json
from unittest import mock
import graphene
import pytest
from ....webhook.event_types import WebhookEventAsyncType
from ...interface import VariantChannelStockInfo
from ...webhooks.channel_stock_events import (
_trigger,
trigger_product_variant_back_in_stock_for_click_and_collect,
trigger_produ... | 288 | 8,458 |
metrics | tests/unittests/clustering/test_calinski_harabasz_score.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... | 57 | 2,173 |
mlflow | tests/artifacts/test_artifacts.py | .py | import os
import pathlib
import uuid
from typing import NamedTuple
from unittest import mock
import pytest
import mlflow
from mlflow.exceptions import MlflowException
from mlflow.utils.file_utils import mkdir, path_to_local_file_uri
from mlflow.utils.os import is_windows
class Artifact(NamedTuple):
uri: str
... | 405 | 15,653 |
biopython | Bio/Phylo/NeXML.py | .py | # Copyright (C) 2013 Ben Morris (ben@bendmorris.com)
#
# 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.
"""Classes corresponding to ... | 51 | 1,404 |
openvino | tests/layer_tests/jax_tests/test_dot_general.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from jax import lax
from jax_layer_test_class import JaxLayerTest
class TestDotGeneral(JaxLayerTest):
def _prepare_input(self):
lhs = np.random.randint(-10, 10, self.lhs_shape).astype(self.... | 49 | 1,948 |
wagtail | wagtail/test/non_root_urls.py | .py | """An alternative urlconf module where Wagtail front-end URLs
are rooted at '/site/' rather than '/'"""
from django.urls import include, path
from wagtail import urls as wagtail_urls
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.documents import urls as wagtaildocs_urls
from wagtail.images import u... | 17 | 556 |
mlflow | examples/lightgbm/lightgbm_sklearn/train.py | .py | from pprint import pprint
import lightgbm as lgb
from sklearn.datasets import load_iris
from sklearn.metrics import f1_score
from sklearn.model_selection import train_test_split
from utils import fetch_logged_data
import mlflow
import mlflow.lightgbm
def main():
# prepare example dataset
X, y = load_iris(re... | 37 | 1,034 |
pyomo | pyomo/core/tests/examples/test_amplbook2.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... | 41 | 1,370 |
kafka | release/textfiles.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... | 74 | 2,033 |
textual | src/textual/drivers/_input_reader_linux.py | .py | import os
import selectors
import sys
from threading import Event
from typing import Iterator
class InputReader:
"""Read input from stdin."""
def __init__(self, timeout: float = 0.1) -> None:
"""
Args:
timeout: Seconds to block for input.
"""
self._fileno = sys.__... | 41 | 1,165 |
saleor | saleor/asgi/usage_telemetry.py | .py | import asyncio
import hashlib
import json
import logging
import random
import sys
from asgiref.sync import sync_to_async
from asgiref.typing import (
ASGI3Application,
ASGIReceiveCallable,
ASGISendCallable,
Scope,
)
from django.apps import apps
from django.conf import settings
from django.db import con... | 235 | 8,181 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/flatmap_nofunction.py | .py | # coding=utf-8
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License");... | 55 | 1,654 |
sqlmap | extra/dbgtool/dbgtool.py | .py | #!/usr/bin/env python
"""
dbgtool.py - Portable executable to ASCII debug script converter
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from __future__ import print_function
import os
import sys
from optparse import OptionError
from optparse impor... | 97 | 2,474 |
saleor | saleor/tests/e2e/orders/test_changing_order_address_not_update_the_customer_one.py | .py | import pytest
from .. import ADDRESS_DE, DEFAULT_ADDRESS
from ..account.utils import get_own_data, get_user
from ..checkout.utils import (
checkout_create,
checkout_delivery_method_update,
raw_checkout_complete,
)
from ..product.utils.preparing_product import prepare_product
from ..shop.utils.preparing_sho... | 162 | 5,319 |
lemur | lemur/reporting/cli.py | .py | """
.. module: lemur.reporting.cli
: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>
"""
import click
from flask.cli import with_appcontext
from tabulate import tabulate
from lemu... | 106 | 2,754 |
mlflow | examples/databricks/multipart.py | .py | """
Benchmark for multi-part upload and download of artifacts.
"""
import hashlib
import json
import os
import pathlib
import tempfile
from concurrent.futures import ThreadPoolExecutor, as_completed
import pandas as pd
import psutil
from tqdm.auto import tqdm
import mlflow
from mlflow.environment_variables import (
... | 149 | 4,167 |
beam | sdks/python/apache_beam/runners/portability/fn_api_runner/fn_runner.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,612 | 68,344 |
coremltools | coremltools/converters/mil/frontend/torch/test/test_torch_quantization_ops.py | .py | # Copyright (c) 2023, 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
from contextlib import nullcontext
from typing import Optional
import numpy as np
i... | 1,499 | 62,196 |
mlflow | mlflow/genai/judges/custom_prompt_judge.py | .py | import re
from difflib import unified_diff
from typing import Callable
from mlflow.entities.assessment import Feedback
from mlflow.entities.assessment_source import AssessmentSource, AssessmentSourceType
from mlflow.genai.judges.builtin import _MODEL_API_DOC
from mlflow.genai.judges.constants import USE_CASE_CUSTOM_PR... | 171 | 6,420 |
saleor | saleor/tests/e2e/payment/utils/__init__.py | .py | from .query_payment import get_payment
__all__ = ["get_payment"]
| 4 | 66 |
coveragepy | coverage/phystokens.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
"""Better tokenizing for coverage.py."""
from __future__ import annotations
import ast
import io
import keyword
import re
import sys
import token
import tokeniz... | 210 | 8,140 |
confluent-kafka-python | tests/schema_registry/_sync/test_config.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... | 439 | 15,292 |
pyro | pyro/infer/reparam/strategies.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
"""
These reparametrization strategies are registered with
:func:`~pyro.poutine.reparam_messenger.register_reparam_strategy` and are
accessed by name via ``poutine.reparam(config=name_of_strategy)`` .
See :func:`~pyro.poutine.handlers.... | 217 | 7,528 |
mlflow | examples/gateway/togetherai/example.py | .py | from mlflow.deployments import get_deploy_client
def main():
client = get_deploy_client("http://localhost:7000")
print(f"Togetherai endpoints: {client.list_endpoints()}\n")
print(f"Togetherai completions endpoint info: {client.get_endpoint(endpoint='completions')}\n")
print(f"Togetherai chat endpoint... | 44 | 1,314 |
saleor | saleor/graphql/order/tests/queries/test_pagination.py | .py | import datetime
from decimal import Decimal
import graphene
import pytest
from freezegun import freeze_time
from prices import Money, TaxedMoney
from .....core.postgres import FlatConcatSearchVector
from .....discount.models import OrderDiscount
from .....order.models import Order, OrderStatus
from .....order.search ... | 868 | 26,697 |
biopython | Tests/test_EmbossPrimer.py | .py | # Copyright 2001 by Brad Chapman. All rights reserved.
# Revisions copyright 2008-2009 by Michiel de Hoon. All rights reserved.
# Revisions copyright 2010-2011 by Peter Cock. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should h... | 198 | 9,309 |
metrics | src/torchmetrics/functional/text/infolm.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... | 659 | 28,027 |
pdm | src/pdm/cli/commands/completion.py | .py | from __future__ import annotations
import argparse
import importlib.resources
import sys
from pdm.cli.commands.base import BaseCommand
from pdm.exceptions import PdmUsageError
from pdm.project import Project
class Command(BaseCommand):
"""Generate completion scripts for the given shell"""
arguments = ()
... | 35 | 1,254 |
conda | tests/cli/test_main_env_imports.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Verify that importing conda.cli.main_env does not eagerly load main_export."""
from __future__ import annotations
import subprocess
import sys
import textwrap
def test_main_env_does_not_eagerly_import_main_export() -> None:
"""main_en... | 29 | 895 |
metrics | src/torchmetrics/functional/retrieval/__init__.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... | 37 | 1,688 |
saleor | saleor/tests/e2e/warehouse/utils/__init__.py | .py | from .create_warehouse import create_warehouse
from .update_warehouse import update_warehouse
__all__ = ["create_warehouse", "update_warehouse"]
| 5 | 146 |
astropy | astropy/io/ascii/sextractor.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""sextractor.py:
Classes to read SExtractor table format.
Built on daophot.py:
:Copyright: Smithsonian Astrophysical Observatory (2011)
:Author: Tom Aldcroft (aldcroft@head.cfa.harvard.edu)
"""
import re
from . import core
class SExtractorHeader(co... | 166 | 6,254 |
onnxruntime | onnxruntime/python/tools/transformers/models/gpt2/gpt2_helper.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
# This s... | 1,032 | 40,300 |
astropy | astropy/table/tests/test_bst.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
from astropy.table.bst import BST
from astropy.utils.exceptions import AstropyDeprecationWarning
def get_tree(TreeType):
# BST is deprecated, so its constructor emits the warning here.
with pytest.warns(AstropyDeprecationWarning, ... | 112 | 2,859 |
saleor | saleor/graphql/shipping/mutations/shipping_method_channel_listing_update.py | .py | from collections import defaultdict
from typing import TYPE_CHECKING
import graphene
from django.core.exceptions import ValidationError
from ....core.tracing import traced_atomic_transaction
from ....permission.enums import ShippingPermissions
from ....shipping.error_codes import ShippingErrorCode
from ....shipping.m... | 280 | 10,988 |
mkdocs-material | material/plugins/tags/structure/listing/manager/toc.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... | 135 | 4,429 |
confluent-kafka-python | tests/integration/share_consumer_oauth/conftest.py | .py | """Fixtures for ShareConsumer OAUTHBEARER integration tests.
Starts a single-broker trivup KRaft cluster with the unsecured
OAUTHBEARER listener so tests can run a real SASL handshake. This suite
lives outside tests/integration/share_consumer/ on purpose, to avoid
that directory's autouse _delete_share_test_topics fix... | 87 | 3,232 |
mlflow | examples/shap/regression.py | .py | import os
import numpy as np
import shap
from sklearn.datasets import load_diabetes
from sklearn.linear_model import LinearRegression
import mlflow
from mlflow.artifacts import download_artifacts
from mlflow.tracking import MlflowClient
# prepare training data
X, y = load_diabetes(return_X_y=True, as_frame=True)
X =... | 39 | 1,080 |
tablib | src/tablib/__init__.py | .py | """ Tablib. """
__lazy_modules__ = {"tablib.core"}
try:
# Generated by setuptools-scm.
from ._version import version as __version__
except ImportError:
# Some broken installation.
__version__ = None
from .core import ( # noqa: F401
Databook,
Dataset,
InvalidDatasetType,
InvalidDimen... | 23 | 404 |
openvino | docs/scripts/apidoc.py | .py | # -*- coding: utf-8 -*-
"""
Script is originally taken from breathe repository.
It has been modified to match project's requirements.
breathe.apidoc
~~~~~~~~~~~~~~
Parses doxygen XML tree looking for C/C++ modules and creates ReST files
appropriately to create code documentation with Sphinx. I... | 295 | 9,122 |
pymc | pymc/__init__.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... | 73 | 2,523 |
luigi | test/task_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... | 591 | 20,114 |
django-cms | cms/test_utils/fixtures/menus.py | .py | from cms.api import create_page
class MenusFixture:
def create_fixtures(self):
"""
Tree from fixture:
+ P1
| + P2
| + P3
+ P4
| + P5
+ P6 (not in menu)
+ P7
+ P8
"""
defaults = {
... | 133 | 4,615 |
probability | tensorflow_probability/python/math/hypergeometric_test.py | .py | # Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 215 | 8,666 |
wandb | wandb/integration/dspy/dspy.py | .py | """DSPy ↔ Weights & Biases integration."""
from __future__ import annotations
import logging
import os
from collections.abc import Mapping, Sequence
from typing import Any, Literal
import wandb
import wandb.util
from wandb.sdk.lib import telemetry
from wandb.sdk.wandb_run import Run
dspy = wandb.util.get_module(
... | 424 | 15,546 |
wagtail | wagtail/snippets/tests/test_reordering.py | .py | from django.contrib.admin.utils import quote
from django.contrib.auth import get_permission_codename
from django.contrib.auth.models import Permission
from django.test import TestCase
from django.urls import reverse
from wagtail.test.testapp.models import FullFeaturedSnippet
from wagtail.test.utils import WagtailTestU... | 320 | 13,877 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.