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 |
|---|---|---|---|---|---|
wagtail | wagtail/admin/panels/multiple_chooser_panel.py | .py | from django.core.exceptions import ImproperlyConfigured
from wagtail.admin.telepath import JSContext
from wagtail.admin.telepath import register as register_telepath_adapter
from .inline_panel import InlinePanel
class MultipleChooserPanel(InlinePanel):
def __init__(self, relation_name, chooser_field_name=None, ... | 57 | 1,965 |
saleor | saleor/graphql/invoice/mutations/invoice_request.py | .py | import graphene
from django.core.exceptions import ValidationError
from ....core import JobStatus
from ....invoice import events, models
from ....invoice.error_codes import InvoiceErrorCode
from ....order import events as order_events
from ....order.search import update_order_search_vector
from ....permission.enums im... | 121 | 4,335 |
wagtail | wagtail/project_template/home/apps.py | .py | from django.apps import AppConfig
class HomeConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "home"
| 7 | 140 |
beam | sdks/python/apache_beam/runners/interactive/pipeline_instrument_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... | 792 | 34,728 |
wagtail | wagtail/rich_text/__init__.py | .py | import re
from functools import lru_cache
from html import unescape
from django.core.validators import MaxLengthValidator, MinLengthValidator
from django.db.models import Model
from django.template.loader import render_to_string
from django.utils.html import strip_tags
from django.utils.safestring import mark_safe
fr... | 193 | 6,498 |
cvxpy | cvxpy/utilities/warn.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
... | 92 | 3,506 |
pyomo | pyomo/contrib/parmest/examples/reactor_design/likelihood_ratio_example.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... | 58 | 1,961 |
mlflow | mlflow/claude_code/plugin.py | .py | """Plugin bootstrap helpers for Claude Code tracing."""
from __future__ import annotations
import shutil
import subprocess
from pathlib import Path
from typing import Any
import click
from mlflow.claude_code.config import (
ENVIRONMENT_FIELD,
MLFLOW_EXPERIMENT_ID,
MLFLOW_EXPERIMENT_NAME,
MLFLOW_TRAC... | 109 | 2,768 |
pyomo | pyomo/repn/quadratic.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... | 489 | 16,943 |
clearml | clearml/backend_api/services/v2_23/dataviews.py | .py | """
dataviews service
Dataview service
"""
import six
from datetime import datetime
import enum
from dateutil.parser import parse as parse_datetime
from clearml.backend_api.session import (
Request,
Response,
NonStrictDataModel,
schema_property,
StringEnum,
)
class FilterByRoiEnum(StringEnum):
... | 5,043 | 175,239 |
readthedocs.org | readthedocs/subscriptions/tests/test_event_handlers.py | .py | from unittest import mock
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from django.utils import timezone
from django_dynamic_fixture import get
from djstripe import models as djstripe
from djstripe import webhooks
from djstripe.enums import SubscriptionStatus
from re... | 541 | 18,290 |
scikit-bio | skbio/metadata/_repr.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.
# --------------------------------------------... | 189 | 6,664 |
probability | tensorflow_probability/python/experimental/linalg/linear_operator_interpolated_psd_kernel.py | .py | # Copyright 2022 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... | 515 | 18,183 |
coremltools | deps/protobuf/python/google/protobuf/internal/decoder.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 1,030 | 37,567 |
beam | sdks/python/apache_beam/yaml/conftest.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... | 35 | 1,277 |
saleor | saleor/tests/e2e/promotions/utils/promotions_query.py | .py | from ...utils import get_graphql_content
PROMOTIONS_QUERY = """
query Promotions($first: Int, $sortBy: PromotionSortingInput,
$where: PromotionWhereInput) {
promotions(first: $first, sortBy: $sortBy, where: $where) {
totalCount
edges {
node {
id
events {
__typename
}
... | 66 | 1,143 |
openvino | tests/utils/path_utils.py | .py | #!/usr/bin/env python3
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
""" Common utilities for working with paths
"""
import argparse
import os
import sys
from pathlib import Path
# add utils folder to imports
UTILS_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(... | 56 | 1,592 |
saleor | saleor/thumbnail/signals.py | .py | from ..core.tasks import delete_from_storage_task
def delete_thumbnail_image(sender, instance, **kwargs):
if image := instance.image:
delete_from_storage_task.delay(image.name)
| 7 | 191 |
wagtail | wagtail/admin/views/pages/utils.py | .py | import swapper
from django.conf import settings
from django.urls import reverse
from django.utils.functional import cached_property
from wagtail.admin import messages
# Retain backwards compatibility for imports
from wagtail.admin.utils import ( # noqa: F401
get_latest_str,
get_valid_next_url_from_request,
)... | 93 | 3,208 |
beam | sdks/python/apache_beam/ml/transforms/handlers_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... | 635 | 22,307 |
loguru | tests/test_propagation.py | .py | import logging
import sys
from logging import StreamHandler
import pytest
from loguru import logger
from .conftest import make_logging_logger
class PropagateHandler(logging.Handler):
def emit(self, record):
logging.getLogger(record.name).handle(record)
def test_formatting(capsys):
fmt = (
... | 104 | 2,739 |
astropy | astropy/io/ascii/tdat.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""This package contains functions for reading and writing TDAT 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.
:Author: Daniel Giles (daniel.k.g... | 851 | 31,336 |
sqlmap | tests/test_encoding.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Core text<->bytes conversions (lib/core/convert.py): getBytes, getUnicode,
getText. (getOrds is covered in test_convert.py.)
These are called on essentially every request and respons... | 76 | 2,555 |
clearml | examples/frameworks/fire/fire_class_cmd.py | .py | # ClearML - Example of Python Fire integration, processing commands derived from a class
#
from clearml import Task
import fire
class BrokenCalculator:
def __init__(self, offset=1):
self._offset = offset
def add(self, x, y):
return x + y + self._offset
def multiply(self, x, y):
... | 22 | 480 |
sphinx | sphinx/domains/cpp/_ast.py | .py | from __future__ import annotations
import sys
import warnings
from typing import TYPE_CHECKING
from docutils import nodes
from sphinx import addnodes
from sphinx.domains.cpp._ids import (
_id_char_from_prefix,
_id_explicit_cast,
_id_fundamental_v1,
_id_fundamental_v2,
_id_operator_unary_v2,
_... | 4,750 | 163,954 |
wagtail | wagtail/embeds/wagtail_hooks.py | .py | from django.urls import include, path, reverse_lazy
from django.utils.translation import gettext_lazy as _
import wagtail.admin.rich_text.editors.draftail.features as draftail_features
from wagtail import hooks
from wagtail.embeds import urls
from wagtail.embeds.rich_text import MediaEmbedHandler
from wagtail.embeds.r... | 55 | 1,928 |
bazel | src/test/shell/unittest_test.py | .py | # Copyright 2020 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/LICENSE-2.0
#
# Unless required by applicable la... | 1,034 | 26,898 |
openvino | tests/layer_tests/pytorch_tests/test_is_nonzero.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
@pytest.mark.parametrize('input_tensor', (np.array([0.]), np.array([1.5]), np.array([False]), np.array([3])))
class TestIsNonZero(Pyto... | 32 | 935 |
astropy | astropy/cosmology/_src/tests/traits/test_trait_totalcomponent.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.cosmology._src.traits.totalcomponent import TotalComponent
class DummyTotal(TotalComponent):
@property
def Otot0(self):
return 1.0
def Otot(self, z, /):
z = np.asarray(z)
return np.ones_like(z... | 25 | 482 |
black | tests/data/cases/comments_non_breaking_space.py | .py | from .config import ( ConfigTypeAttributes, Int, Path, # String,
# DEFAULT_TYPE_ATTRIBUTES,
)
result = 1 # A simple comment
result = ( 1, ) # Another one
result = 1 # type: ignore
result = 1# This comment is talking about type: ignore
square = Square(4) # type: Optional[Square]
def function(a:in... | 45 | 994 |
onnx | onnx/reference/ops/aionnxml/_common_classifier.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
def compute_logistic(val: float) -> float:
v = 1.0 / (1.0 + np.exp(-np.abs(val)))
return (1.0 - v) if val < 0 else v
logistic = np.vectorize(compute_logistic)
def compute_softmax_zero(values: np.ndarray) -> np.nda... | 80 | 1,928 |
loguru | tests/test_remove.py | .py | import sys
import time
import pytest
from loguru import logger
class StopSinkError:
def write(self, message):
print(message, end="")
def stop(self):
raise OSError("Stop error")
def test_remove_all(tmp_path, writer, capsys):
file = tmp_path / "test.log"
logger.debug("This shouldn'... | 113 | 2,670 |
saleor | saleor/graphql/account/tests/utils.py | .py | from ...core.utils import snake_to_camel_case
def convert_dict_keys_to_camel_case(d):
"""Change dict fields from snake_case to camelCase.
Useful when dealing with dict data such as address that need to be parsed
into GraphQL input.
"""
data = {}
for k in d.keys():
new_key = snake_to_c... | 15 | 378 |
pyomo | doc/OnlineDocs/src/scripting/spy4Variables.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... | 38 | 1,182 |
pyomo | examples/pyomobook/overview-ch/wl_mutable.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... | 44 | 1,495 |
wagtail | wagtail/utils/text.py | .py | from bs4 import BeautifulSoup
from django.utils.encoding import force_str
def text_from_html(val):
# Return the unescaped text content of an HTML string
return BeautifulSoup(force_str(val), "html.parser").getText().strip()
| 8 | 233 |
django-cms | cms/test_utils/project/backwards_wizards/wizards.py | .py | from cms.test_utils.project.sampleapp.forms import SampleWizardForm
from cms.wizards.wizard_base import Wizard
class SampleWizard(Wizard):
pass
wizard = SampleWizard(
title="Sample",
weight=505,
form=SampleWizardForm,
description="Create something",
)
| 15 | 276 |
mlflow | mlflow/genai/datasets/evaluation_dataset.py | .py | from datetime import datetime
from typing import TYPE_CHECKING, Any
from mlflow.data import Dataset
from mlflow.data.pyfunc_dataset_mixin import PyFuncConvertibleDatasetMixin
from mlflow.entities.evaluation_dataset import (
EvaluationDataset as _EntityEvaluationDataset,
)
from mlflow.genai.datasets.databricks_eval... | 360 | 13,412 |
biopython | Tests/common_BioSQL_online.py | .py | # 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 storing biopython objects in a BioSQL relational db."""
import os
import platform
import tempfile
import time
import unittest
# Hide annoying ... | 129 | 4,388 |
wagtail | wagtail/embeds/finders/__init__.py | .py | from functools import lru_cache
from importlib import import_module
from django.conf import settings
from django.utils.module_loading import import_string
def import_finder_class(dotted_path):
"""
Imports a finder class from a dotted path. If the dotted path points to a
module, that module is imported an... | 49 | 1,336 |
probability | discussion/robust_inverse_graphics/nerf/rendering.py | .py | # Copyright 2024 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... | 398 | 12,794 |
textual | tests/test_pilot.py | .py | from string import punctuation
from typing import Type
import pytest
from textual import events, work
from textual._on import on
from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.containers import Center, Middle
from textual.css.errors import StylesheetError
from textual.pilo... | 453 | 15,523 |
wandb | wandb/sdk/artifacts/_generated/get_artifact_membership_file_urls.py | .py | # Generated by ariadne-codegen
# Source: tools/graphql_codegen/artifacts/
from __future__ import annotations
from typing import Literal
from pydantic import Field
from wandb._pydantic import GQLResult, Typename
from .fragments import FileWithUrlFragment, PageInfoFragment
class GetArtifactMembershipFileUrls(GQLRe... | 64 | 2,018 |
metrics | src/torchmetrics/functional/nominal/utils.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... | 147 | 5,745 |
luigi | examples/dynamic_requirements.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... | 111 | 3,733 |
pyomo | doc/OnlineDocs/src/data/table3.ul.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 24 | 839 |
black | tests/data/cases/backslash_before_indent.py | .py | # flags: --minimum-version=3.10
class Plotter:
\
pass
class AnotherCase:
\
"""Some
\
Docstring
"""
# output
class Plotter:
pass
class AnotherCase:
"""Some
\
Docstring
"""
| 25 | 219 |
beam | sdks/python/apache_beam/transforms/async_dofn_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... | 586 | 20,714 |
pyomo | pyomo/contrib/mpc/data/interval_data.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... | 201 | 8,188 |
beam | sdks/python/apache_beam/runners/portability/spark_java_job_server_test.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 66 | 2,695 |
hatch | tests/helpers/templates/wheel/standard_default_build_script_extra_dependencies.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 52 | 1,375 |
textual | docs/examples/widgets/progress_bar_gradient.py | .py | from textual.app import App, ComposeResult
from textual.color import Gradient
from textual.containers import Center, Middle
from textual.widgets import ProgressBar
class ProgressApp(App[None]):
"""Progress bar with a rainbow gradient."""
def compose(self) -> ComposeResult:
gradient = Gradient.from_co... | 35 | 868 |
mlflow | examples/demos/mlflow-3/ml.py | .py | # MLflow 3 Traditional ML Example
# In this example, we will first run a model training job, which is tracked as
# an MLflow Run, to produce a trained model, which is tracked as an MLflow Logged Model.
import pandas as pd
from sklearn.datasets import load_iris
from sklearn.linear_model import ElasticNet
from sklearn.me... | 114 | 4,450 |
onnxruntime | tools/python/remove_initializer_from_input.py | .py | import argparse
import onnx
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("--input", required=True, help="input model")
parser.add_argument("--output", required=True, help="output model")
args = parser.parse_args()
return args
def remove_initializer_from_input(model: on... | 38 | 994 |
openvino | tests/layer_tests/pytorch_tests/test_dot.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
class TestDot(PytorchLayerTest):
def _prepare_input(self, inputs, dtype, out=False):
import numpy as np
x = np.array(inputs[0]).ast... | 67 | 2,336 |
confluent-kafka-python | src/confluent_kafka/error.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... | 160 | 5,016 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_SplitV.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shape': [3], 'num_or_size_splits': [0, 2, 0, 1], 'axis': 0},
{'shape': [2, 3, 9], 'num_or_size_splits': [1, 2, 3, -1, 1], 'axis': 2},
{'shape': [3, 9, 5, 4], 'num_or_size_splits': [1, 2, 0, -... | 40 | 1,624 |
mlflow | mlflow/statsmodels/__init__.py | .py | """
The ``mlflow.statsmodels`` module provides an API for logging and loading statsmodels models.
This module exports statsmodels models with the following flavors:
statsmodels (native) format
This is the main flavor that can be loaded back into statsmodels, which relies on pickle
internally to serialize a mod... | 635 | 23,717 |
sqlmap | tests/test_request_basic.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Unit coverage for PURE functions in lib/request/basic.py.
These exercise getHeuristicCharEncoding (with its kb.cache.encoding memoization)
and decodePage's charset + HTML-entity deco... | 198 | 8,066 |
beam | sdks/python/apache_beam/runners/interactive/utils_test.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 402 | 15,411 |
beam | sdks/python/apache_beam/transforms/stats_test.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 "L... | 688 | 25,650 |
beam | sdks/python/apache_beam/io/aws/s3filesystem_test.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 "L... | 282 | 10,659 |
pyomo | doc/OnlineDocs/src/data/param7a.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 24 | 837 |
scikit-optimize | doc/sphinxext/custom_references_resolver.py | .py | """Adapted from
sphinx.transforms.post_transforms.ReferencesResolver.resolve_anyref
If 'py' is one of the domains and `py:class` is defined,
the Python domain will be processed before the 'std' domain.
License for Sphinx
==================
Copyright (c) 2007-2019 by the Sphinx team (see AUTHORS file).
All rights res... | 123 | 5,232 |
astropy | astropy/utils/state.py | .py | """
A simple class to manage a piece of global science state. See
:ref:`astropy:config-developer` for more details.
"""
__all__ = ["ScienceState"]
class _ScienceStateContext:
def __init__(self, parent, value):
self._value = value
self._parent = parent
def __enter__(self):
pass
... | 79 | 2,127 |
cvxpy | cvxpy/atoms/one_minus_pos.py | .py | """
Copyright 2018 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 in writing, software... | 111 | 3,084 |
saleor | saleor/graphql/channel/tests/mutations/test_channel_reorder_warehouses.py | .py | import uuid
import graphene
import pytest
from .....channel.error_codes import ChannelErrorCode
from .....warehouse.models import ChannelWarehouse
from ....tests.utils import get_graphql_content
CHANNEL_REORDER_WAREHOUSES = """
mutation ChannelReorderWarehouses($channelId: ID!, $moves: [ReorderInput!]!) {
... | 195 | 5,703 |
openvino | src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/file_utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import tarfile
from pathlib import Path, PurePath
from shutil import copyfile
from zipfile import ZipFile, is_zipfile
from urllib.parse import urlparse
from . import constants
from . import conformance_utils
# generates file... | 92 | 3,476 |
onnx | onnx/reference/ops/op_ceil.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 Ceil(OpRunUnaryNum):
def _run(self, x):
return (np.ceil(x),)
| 14 | 267 |
metrics | src/torchmetrics/functional/video/vmaf.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... | 143 | 6,979 |
luigi | test/hdfs_client_test.py | .py | import itertools
import threading
import unittest
from luigi.contrib.hdfs import get_autoconfig_client
class HdfsClientTest(unittest.TestCase):
def test_get_autoconfig_client_cached(self):
original_client = get_autoconfig_client()
for _ in range(100):
self.assertIs(original_client, ge... | 29 | 858 |
notebook | notebook/app.py | .py | """Jupyter notebook application."""
from __future__ import annotations
import os
import re
import typing as t
from pathlib import Path
from jupyter_client.utils import ensure_async # type:ignore[attr-defined]
from jupyter_core.paths import jupyter_config_dir
from jupyter_server.base.handlers import JupyterHandler
f... | 367 | 13,736 |
wandb | wandb/sdk/mailbox/response_handle.py | .py | from __future__ import annotations
import asyncio
import logging
import math
from collections.abc import Awaitable, Callable
from typing_extensions import override
from wandb.proto import wandb_server_pb2 as spb
from wandb.sdk.lib import asyncio_manager
from .mailbox_handle import HandleAbandonedError, MailboxHandl... | 134 | 3,972 |
sqlmap | extra/shutils/newlines.py | .py | #! /usr/bin/env python
from __future__ import print_function
import os
import sys
def check(filepath):
if filepath.endswith(".py"):
content = open(filepath, "rb").read()
pattern = "\n\n\n".encode("ascii")
if pattern in content:
index = content.find(pattern)
print(... | 31 | 903 |
coremltools | deps/protobuf/python/google/protobuf/internal/test_util.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 869 | 33,949 |
mlflow | tests/mcp/test_mcp.py | .py | import sys
from collections.abc import AsyncIterator
from unittest.mock import patch
import click
import pytest
import pytest_asyncio
from fastmcp import Client
from fastmcp.client.transports import StdioTransport
import mlflow
from mlflow.mcp import server
from mlflow.mcp.server import fn_wrapper
from mlflow.models ... | 214 | 6,307 |
metrics | tests/unittests/detection/test_modified_panoptic_quality.py | .py | # Copyright The PyTorch 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 i... | 194 | 7,792 |
kombu | examples/experimental/async_consume.py | .py | #!/usr/bin/env python3
from __future__ import annotations
from kombu import Connection, Consumer, Exchange, Producer, Queue
from kombu.asynchronous import Hub
hub = Hub()
exchange = Exchange('asynt')
queue = Queue('asynt', exchange, 'asynt')
def send_message(conn):
producer = Producer(conn)
producer.publis... | 32 | 746 |
sqlmap | thirdparty/colorama/__init__.py | .py | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
from .initialise import init, deinit, reinit, colorama_text, just_fix_windows_console
from .ansi import Fore, Back, Style, Cursor
from .ansitowin32 import AnsiToWin32
__version__ = '0.4.6'
| 8 | 266 |
onnxruntime | tools/ci_build/github/js/validate-npm-packages.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
import sys
# This is a script to validate NPM packages.
# If package version, publish tag and filename does not fulfill the requirement, an error will raise.
# arg.1 - Folder of extracted ar... | 186 | 8,828 |
confluent-kafka-python | tests/schema_registry/data/proto/test_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: test.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_data... | 31 | 1,743 |
pyomo | pyomo/contrib/pyros/tests/test_separation.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... | 662 | 26,302 |
textual | docs/examples/styles/border_title_align.py | .py | from textual.app import App
from textual.widgets import Label
class BorderTitleAlignApp(App):
CSS_PATH = "border_title_align.tcss"
def compose(self):
lbl = Label("My title is on the left.", id="label1")
lbl.border_title = "< Left"
yield lbl
lbl = Label("My title is centered",... | 25 | 583 |
textual | tests/input/test_input_key_modification_actions.py | .py | """Unit tests for Input widget value modification actions."""
from __future__ import annotations
from textual.app import App, ComposeResult
from textual.widgets import Input
TEST_INPUTS: dict[str | None, str] = {
"empty": "",
"multi-no-punctuation": "Curse your sudden but inevitable betrayal",
"multi-pun... | 182 | 7,229 |
structlog | tests/test_output.py | .py | # SPDX-License-Identifier: MIT OR Apache-2.0
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the MIT License. See the LICENSE file in the root of this
# repository for complete details.
import copy
import gc
import pickle
from io import BytesIO, StringIO
import pytest
from st... | 443 | 12,216 |
cvxpy | setup.py | .py | import builtins
import distutils.version
import os
import platform
import sys
import sysconfig
import setup.extensions as setup_extensions
# BEFORE importing setuptools, remove MANIFEST. Otherwise it may not be
# properly updated when the contents of directories change (true for distutils,
# not sure about setuptools... | 64 | 2,263 |
hypercorn | src/hypercorn/trio/statsd.py | .py | from __future__ import annotations
import trio
from ..config import Config
from ..statsd import StatsdLogger as Base
class StatsdLogger(Base):
def __init__(self, config: Config) -> None:
super().__init__(config)
self.address = tuple(config.statsd_host.rsplit(":", 1))
self.socket = trio.s... | 17 | 493 |
coremltools | coremltools/converters/mil/frontend/tensorflow/dialect_ops.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 coremltools.converters.mil.mil import Operation, types
from coremltools.converters.mil.mil.input... | 172 | 6,346 |
pyomo | pyomo/dae/tests/test_set_utils.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... | 419 | 15,330 |
pyomo | pyomo/neos/plugins/NEOS.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... | 58 | 2,501 |
coremltools | coremltools/test/sklearn_tests/test_categorical_imputer.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 unittest
import numpy as np
from packaging.version import Version
from ..utils import load_bost... | 78 | 2,569 |
onnx | onnx/reference/ops/op_atan.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 Atan(OpRunUnaryNum):
def _run(self, x):
return (np.arctan(x),)
| 14 | 269 |
mlflow | tests/genai/judges/adapters/test_gateway_adapter.py | .py | import json
from unittest import mock
import pydantic
import pytest
from mlflow.entities.trace import Trace
from mlflow.entities.trace_info import TraceInfo
from mlflow.entities.trace_location import TraceLocation
from mlflow.entities.trace_state import TraceState
from mlflow.exceptions import MlflowException
from ml... | 1,352 | 45,082 |
gunicorn | tests/docker/http2/conftest.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Pytest fixtures for HTTP/2 Docker integration tests."""
import subprocess
import time
from pathlib import Path
import pytest
# Directory containing this conftest.py
DOCKER_DIR = Path(__file__).parent
CERTS_DI... | 201 | 5,821 |
pyomo | doc/OnlineDocs/src/data/ABCD3.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... | 23 | 886 |
onnxruntime | tools/python/util/ort_format_model/utils.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import pathlib
import typing
from ..logger import get_logger
from .operator_type_usage_processors import OperatorTypeUsageManager
from .ort_model_processor import OrtFormatModelProcessor
log = get_logger("ort_format_model.u... | 62 | 2,534 |
wandb | wandb/integration/diffusers/__init__.py | .py | from .autologger import autolog
__all__ = ["autolog"]
| 4 | 55 |
saleor | saleor/graphql/tax/schema.py | .py | from collections import defaultdict
import graphene
from django_countries.fields import Country
from ...permission.auth_filters import AuthorizationFilters
from ...tax import models
from ..account.enums import CountryCodeEnum
from ..core import ResolveInfo
from ..core.connection import create_connection_slice, filter... | 185 | 6,826 |
beam | sdks/python/apache_beam/transforms/core_it_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... | 170 | 6,591 |
qutip | qutip/animation.py | .py | """
Functions to animate results of quantum dynamics simulations,
"""
__all__ = ['anim_wigner_sphere', 'anim_hinton', 'anim_sphereplot',
'anim_matrix_histogram', 'anim_fock_distribution', 'anim_wigner',
'anim_spin_distribution', 'anim_qubism', 'anim_schmidt',
'anim_qfunc']
from . impor... | 639 | 21,100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.