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 |
|---|---|---|---|---|---|
mlflow | dev/clint/src/clint/rules/invalid_abstract_method.py | .py | import ast
from clint.resolver import Resolver
from clint.rules.base import Rule
class InvalidAbstractMethod(Rule):
def _message(self) -> str:
return (
"Abstract method should only contain a single statement/expression, "
"and it must be `pass`, `...`, or a docstring."
)
... | 51 | 1,684 |
coremltools | coremltools/converters/mil/backend/nn/passes/handle_return_unused_inputs.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 Builder as mb
from coremltools.converters.mil.mil.passes.g... | 60 | 2,086 |
wandb | tests/assets/wandb/offline-run-20210216_154407-g9dvvkua/files/code/standalone_tests/code-toad.py | .py | import os
import wandb
os.environ["WANDB_CODE_DIR"] = "."
wandb.init(project="code-toad")
# wandb.run.log_code()
| 10 | 117 |
metrics | src/torchmetrics/utilities/__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... | 38 | 1,205 |
onnxruntime | onnxruntime/python/tools/transformers/onnx_model_unet.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import logging
from fusion_attention_unet import FusionAttentionUnet
f... | 259 | 9,255 |
gunicorn | gunicorn/debug.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""The debug module contains utilities and functions for better
debugging Gunicorn."""
import sys
import linecache
import re
import inspect
__all__ = ['spew', 'unspew']
_token_spliter = re.compile(r'\W+')
clas... | 69 | 2,263 |
mlflow | tests/genai/scorers/online/test_session_processor.py | .py | import json
import uuid
from unittest.mock import MagicMock, patch
import pytest
from mlflow.entities import Trace, TraceData, TraceInfo
from mlflow.entities.assessment import Assessment
from mlflow.entities.trace_location import (
MlflowExperimentLocation,
TraceLocation,
TraceLocationType,
)
from mlflow.... | 726 | 27,472 |
django-cms | cms/tests/settings.py | .py | """Django settings module for running the django CMS test suite with pytest.
This mirrors the configuration that ``manage.py`` builds dynamically and passes
to ``settings.configure()``. It is exposed as an importable settings module so
that ``pytest`` (via ``pytest-django``) and ``django-admin`` can pick it up
through... | 328 | 10,309 |
cvxpy | cvxpy/tests/nlp_tests/test_power_flow.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
... | 117 | 4,918 |
hatch | tests/cli/python/test_show.py | .py | from rich.box import ASCII_DOUBLE_HEAD
from rich.console import Console
from rich.table import Table
from hatch.python.resolve import get_compatible_distributions
def render_table(title, rows):
console = Console(force_terminal=False, no_color=True, legacy_windows=False)
table = Table(title=title, show_lines=... | 140 | 4,474 |
mlflow | mlflow/protos/unity_catalog_prompt_service_pb2.py | .py |
import google.protobuf
from packaging.version import Version
if Version(google.protobuf.__version__).major >= 5:
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: unity_catalog_prompt_service.proto
# Protobuf Python Version: 5.26.0
"""Generated protocol buffer code.... | 165 | 29,407 |
black | tests/data/cases/raw_docstring_no_string_normalization.py | .py | # flags: --skip-string-normalization
def do_not_touch_this_prefix():
R"""There was a bug where docstring prefixes would be normalized even with -S."""
def do_not_touch_this_prefix2():
FR'There was a bug where docstring prefixes would be normalized even with -S.'
def do_not_touch_this_prefix3():
u'''Ther... | 12 | 394 |
astropy | astropy/io/fits/hdu/compressed/tests/conftest.py | .py | import itertools
import numpy as np
import pytest
COMPRESSION_TYPES = [
"GZIP_1",
"GZIP_2",
"RICE_1",
"HCOMPRESS_1",
"PLIO_1",
"NOCOMPRESS",
]
def fitsio_param_to_astropy_param(param):
# Convert fitsio kwargs to astropy kwargs
_map = {"qlevel": "quantize_level", "qmethod": "quantize_... | 115 | 2,911 |
wandb | tests/system_tests/test_functional/keras/test_keras.py | .py | import pathlib
import subprocess
def test_eval_tables_builder(wandb_backend_spy):
script_path = pathlib.Path(__file__).parent / "keras_eval_tables_builder.py"
subprocess.check_call(["python", str(script_path)])
with wandb_backend_spy.freeze() as snapshot:
run_ids = snapshot.run_ids()
asse... | 69 | 2,396 |
textual | src/textual/render.py | .py | from __future__ import annotations
from rich.cells import cell_len
from rich.console import Console, RenderableType
from rich.protocol import rich_cast
def measure(
console: Console,
renderable: RenderableType,
default: int,
*,
container_width: int | None = None,
) -> int:
"""Measure a rich r... | 42 | 1,135 |
sqlmap | tamper/infoschema2innodb.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.NORMAL
def dependencies():
pass
def tamper(payload, **kwargs):
"""
Rewrites MySQL table-enume... | 51 | 2,131 |
jupytext | tests/data/notebooks/outputs/ipynb_to_percent/frozen_cell.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %%
# This is an unfrozen cell. Works as usual.
print("I'm a regular cell so I run and print!")
# %% deletable=false editable=false run_control={"frozen": true}
# # This is an frozen cell
# print("I'm froze... | 16 | 346 |
wagtail | wagtail/test/utils/wagtail_factories/__init__.py | .py | from .blocks import * # noqa: F403
from .factories import * # noqa: F403
| 3 | 75 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_reshape.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# reshape paddle model generator
#
import numpy as np
from save_model import saveModel
import sys
data_type = 'float32'
def reshape(name : str, x, out_shape):
import paddle
paddle.enable_static()
with paddle.static.prog... | 88 | 2,791 |
pyomo | pyomo/contrib/mindtpy/tests/from_proposal.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,755 |
python-prompt-toolkit | tests/test_style.py | .py | from __future__ import annotations
from prompt_toolkit.styles import Attrs, Style, SwapLightAndDarkStyleTransformation
def test_style_from_dict():
style = Style.from_dict(
{
"a": "#ff0000 bold underline strike italic",
"b": "bg:#00ff00 blink reverse",
}
)
# Lookup... | 293 | 7,143 |
pyomo | pyomo/contrib/pynumero/algorithms/solvers/tests/test_pyomo_ext_cyipopt.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... | 329 | 14,443 |
dirty-equals | dirty_equals/_base.py | .py | import io
from abc import ABCMeta
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any, Generic, Optional, Protocol, TypeVar
try:
from _pytest._io.pprint import PrettyPrinter
except ImportError:
# support for pytest 7.4.4
from pprint import PrettyPrinter # type: ignore
from ._utils... | 263 | 8,354 |
django-cms | cms/models/pluginmodel.py | .py | from __future__ import annotations
import os
import re
import warnings
from datetime import date
from functools import cache, cached_property
from django.core.exceptions import ObjectDoesNotExist
from django.db import connection, connections, models, router
from django.db.models import QuerySet
from django.db.models.... | 503 | 19,547 |
pymc | tests/logprob/test_checks.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... | 102 | 3,938 |
beam | sdks/python/apache_beam/ml/rag/ingestion/qdrant_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... | 327 | 10,501 |
wagtail | wagtail/models/preview.py | .py | from io import StringIO
from urllib.parse import urlsplit
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.handlers.base import BaseHandler
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import validate_host
from django.template.respo... | 290 | 11,207 |
saleor | saleor/graphql/shipping/tests/queries/test_shipping_zone.py | .py | from unittest.mock import Mock
import graphene
from django.contrib.sites.models import Site
from measurement.measures import Weight
from .....channel.models import Channel
from .....core.db.connection import allow_writer
from .....core.units import WeightUnits
from .....tests import race_condition
from ....shipping.r... | 268 | 8,407 |
saleor | saleor/graphql/page/mutations/page_type_create.py | .py | from collections import defaultdict
from typing import TYPE_CHECKING
import graphene
from django.core.exceptions import ValidationError
from ....attribute import AttributeType
from ....page import models
from ....page.error_codes import PageErrorCode
from ....permission.enums import PageTypePermissions
from ...core i... | 108 | 3,685 |
slimit | docs/source/conf.py | .py | # -*- coding: utf-8 -*-
#
# SlimIt documentation build configuration file, created by
# sphinx-quickstart on Mon May 2 11:51:24 2011.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All ... | 220 | 7,033 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_reduce_sum.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# reduce_sum paddle model generator
#
import numpy as np
import sys
from save_model import saveModel
def reduce_sum(name : str, x, axis=None, keepdim=False):
import paddle
paddle.enable_static()
with paddle.static.progr... | 47 | 1,475 |
probability | tensorflow_probability/python/bijectors/rayleigh_cdf.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... | 148 | 5,386 |
saleor | saleor/tests/e2e/checkout/utils/checkout_shipping_address_update.py | .py | from ... import DEFAULT_ADDRESS
from ...utils import assert_address_data, get_graphql_content
CHECKOUT_SHIPPING_ADDRESS_UPDATE_MUTATION = """
mutation CheckoutShippingAddressUpdate(
$shippingAddress: AddressInput!, $checkoutId: ID!
) {
checkoutShippingAddressUpdate(
shippingAddress: $shippingAddress
id: $c... | 72 | 1,611 |
mlflow | examples/langchain/simple_chain.py | .py | import os
from langchain.chains import LLMChain
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
import mlflow
# Ensure the OpenAI API key is set in the environment
assert "OPENAI_API_KEY" in os.environ, "Please set the OPENAI_API_KEY environment variable."
# Initialize the OpenAI mode... | 31 | 979 |
pyomo | pyomo/core/kernel/piecewise_library/transforms_nd.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... | 397 | 14,168 |
beam | sdks/python/apache_beam/utils/thread_pool_executor.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... | 135 | 4,067 |
clearml | clearml/backend_api/services/v2_23/events.py | .py | """
events service
Provides an API for running tasks to report events collected by the system.
"""
from typing import List, Optional, Any
import six
import enum
from clearml.backend_api.session import (
Request,
BatchRequest,
Response,
NonStrictDataModel,
CompoundRequest,
schema_property,
S... | 5,809 | 194,568 |
pdm | src/pdm/models/specifiers.py | .py | from __future__ import annotations
import dataclasses
import importlib.resources
import itertools
import json
import re
import warnings
from collections.abc import Iterable
from functools import lru_cache
from operator import attrgetter
from re import Match
from typing import Any, cast
from dep_logic.specifiers impor... | 269 | 9,926 |
confluent-kafka-python | src/confluent_kafka/kafkatest/verifiable_client.py | .py | # Copyright 2016 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... | 117 | 3,569 |
wandb | tests/unit_tests/test_wandb_agent/test_pyagent.py | .py | """Unit tests for sweep agent behavior without a live backend."""
from __future__ import annotations
import contextlib
import io
import threading
import pytest
import wandb
from wandb.sdk.launch.sweeps import SweepNotFoundError
from wandb.sdk.lib.service.service_connection import WandbApiFailedError
from .conftest ... | 224 | 7,185 |
probability | tensorflow_probability/python/distributions/power_spherical.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... | 475 | 19,473 |
saleor | saleor/graphql/account/tests/mutations/staff/test_user_avatar_delete.py | .py | from ......thumbnail.models import Thumbnail
from .....tests.utils import assert_no_permission, get_graphql_content
USER_AVATAR_DELETE_MUTATION = """
mutation userAvatarDelete {
userAvatarDelete {
user {
avatar {
url
}
}
}
... | 45 | 1,096 |
pyomo | examples/dae/Optimal_Control.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... | 59 | 1,495 |
pyfilesystem2 | tests/test_imports.py | .py | import sys
import unittest
class TestImports(unittest.TestCase):
def test_import_path(self):
"""Test import fs also imports other symbols."""
restore_fs = sys.modules.pop("fs")
sys.modules.pop("fs.path")
try:
import fs
fs.path
fs.Seek
... | 20 | 422 |
coveragepy | tests/__init__.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
"""Automated tests. Run with pytest."""
| 5 | 198 |
probability | tensorflow_probability/python/experimental/__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... | 97 | 4,177 |
textual | docs/examples/styles/align_all.py | .py | from textual.app import App, ComposeResult
from textual.containers import Container
from textual.widgets import Label
class AlignAllApp(App):
"""App that illustrates all alignments."""
CSS_PATH = "align_all.tcss"
def compose(self) -> ComposeResult:
yield Container(Label("left top"), id="left-top... | 25 | 894 |
probability | spinoffs/fun_mc/fun_mc/using_jax.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... | 26 | 1,014 |
biopython | Tests/test_BioSQL_mysql_connector_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.
"""Run BioSQL tests using MySQL."""
import unittest
import requires_internet
# Really do want "import *" to get all the test classes:
from common_Bi... | 35 | 1,031 |
pyomo | pyomo/contrib/preprocessing/plugins/induced_linearity.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... | 402 | 16,416 |
saleor | saleor/checkout/tests/webhooks/subscriptions/test_calculate_taxes.py | .py | import json
from unittest.mock import ANY
import pytest
from freezegun import freeze_time
from .....discount.models import PromotionRule
from .....graphql.core.utils import to_global_id_or_none
from .....tax import TaxableObjectDiscountType
from .....webhook.event_types import WebhookEventSyncType
from .....webhook.m... | 576 | 18,206 |
saleor | saleor/graphql/checkout/tests/mutations/test_checkout_customer_attach.py | .py | from unittest.mock import ANY, patch
import graphene
import pytest
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from .....account.tests.fixtures.user import dangerously_create_test_user
from .....checkout.actions import call_checkout_event
from .....che... | 426 | 14,092 |
astropy | astropy/extern/ply/ctokens.py | .py | # ----------------------------------------------------------------------
# ctokens.py
#
# Token specifications for symbols in ANSI C and C++. This file is
# meant to be used as a library in other tokenizers.
# ----------------------------------------------------------------------
# Reserved words
tokens = [
# Li... | 128 | 3,155 |
onnx | onnx/backend/test/case/node/sinh.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 Sinh(Base):
@staticmethod
def export() -> None:
node =... | 29 | 770 |
onnxruntime | onnxruntime/test/testdata/transform/cast_elimination.py | .py | import onnx
from onnx import OperatorSetIdProto, TensorProto, helper
X1 = helper.make_tensor_value_info("x1", TensorProto.INT64, [4, 4])
X2 = helper.make_tensor_value_info("x2", TensorProto.INT64, [4, 1])
X3 = helper.make_tensor_value_info("x3", TensorProto.INT64, [4, 1])
Y = helper.make_tensor_value_info("output", Te... | 46 | 1,960 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/top_smallest.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");... | 53 | 1,575 |
mlflow | mlflow/utils/exception_utils.py | .py | import traceback
def get_stacktrace(error):
msg = repr(error)
try:
tb = traceback.format_exception(error)
return (msg + "".join(tb)).strip()
except Exception:
return msg
| 11 | 208 |
wagtail | wagtail/sites/views.py | .py | from django.utils.translation import gettext_lazy as _
from wagtail.admin.ui.tables import Column, StatusFlagColumn, TitleColumn
from wagtail.admin.views import generic
from wagtail.admin.viewsets.model import ModelViewSet
from wagtail.models import Site
from wagtail.sites.forms import SiteForm
class IndexView(gener... | 75 | 2,147 |
biopython | Bio/GenBank/utils.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.
#
"""Useful utilities for helping in parsing GenBank files."""
class FeatureValueCleaner:
r"""Provide specialized capabilities for cleaning up va... | 67 | 2,229 |
astropy | astropy/coordinates/representation/geodetic.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import erfa
import numpy as np
from astropy import units as u
from astropy.coordinates.angles import Latitude, Longitude
from astropy.utils.decorators import format_doc
from .base import BaseRepresentation
from .cartesian import CartesianRepresentation
... | 193 | 6,893 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_relu6.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# relu6 paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle
import sys
def relu6(name: str, x, threshold: float = 6.0, data_type='float32'):
paddle.enable_static()
with paddle.static.pr... | 47 | 1,300 |
httpie | httpie/status.py | .py | from enum import IntEnum, unique
@unique
class ExitStatus(IntEnum):
"""Program exit status code constants."""
SUCCESS = 0
ERROR = 1
ERROR_TIMEOUT = 2
# See --check-status
ERROR_HTTP_3XX = 3
ERROR_HTTP_4XX = 4
ERROR_HTTP_5XX = 5
ERROR_TOO_MANY_REDIRECTS = 6
PLUGIN_ERROR = 7
... | 41 | 987 |
wagtail | wagtail/api/v2/serializers.py | .py | from collections import OrderedDict
from django.urls.exceptions import NoReverseMatch
from modelcluster.models import get_all_child_relations
from rest_framework import relations, serializers
from rest_framework.fields import Field, SkipField
from taggit.managers import _TaggableManager
from wagtail import fields as ... | 442 | 13,203 |
deap | doc/code/tutorials/part_2/2_3_2_grid.py | .py | ## 2.3.2 Grid
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", list, fitness=creator.FitnessMin)
IND_SIZE = 20
toolbox = base.Toolbox()
toolbox.register("attr_float", random.random)
toolbox.re... | 25 | 658 |
beam | infra/security/log_analyzer.py | .py | # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use ... | 334 | 12,827 |
hatch | tests/helpers/helpers.py | .py | from __future__ import annotations
import importlib
import json
import os
import re
import sys
from datetime import datetime, timezone
from functools import lru_cache
from textwrap import dedent as _dedent
from typing import TYPE_CHECKING
from unittest.mock import call
import tomli_w
from hatch.config.user import Ro... | 185 | 6,358 |
beam | sdks/python/apache_beam/transforms/enrichment_handlers/vertex_ai_feature_store_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... | 58 | 2,245 |
astropy | astropy/stats/nanfunctions.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
The functions in this module provide faster versions of np.nan*
functions using the optional bottleneck package if it is installed. If
bottleneck is not installed, then the np.nan* functions are used.
"""
import functools
from collections.abc import C... | 153 | 5,202 |
biopython | Tests/test_Chi2.py | .py | # Copyright (C) 2011 by Brandon Invergo (b.invergo@gmail.com)
# 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.
"""Tests for Chi2 module."""
import unittest
from Bio.Phylo.PAML import chi2
class Mod... | 32 | 1,160 |
hydra | tools/configen/tests/test_generate.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from difflib import unified_diff
from pathlib import Path
from textwrap import dedent
from typing import Any
from configen.config import ConfigenConf, Flags, ModuleConf
from hydra.test_utils.test_utils import chdir_hydra_root, run_python_script
fro... | 295 | 8,544 |
mlflow | mlflow/genai/utils/enum_utils.py | .py | from enum import Enum, EnumMeta
class MetaEnum(EnumMeta):
"""Metaclass for Enum classes that allows to check if a value is a valid member of the Enum."""
def __contains__(cls, item):
try:
cls(item)
except ValueError:
return False
return True
class StrEnum(str... | 24 | 635 |
structlog | src/structlog/stdlib.py | .py | # 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.
"""
Processors and helpers specific to the :mod:`logging` module from the `Python
standard library <https://docs.python.org/>`_.
See also... | 1,259 | 42,119 |
astropy | astropy/constants/tests/test_constant.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import copy
import pytest
import astropy.units as u
from astropy.constants import Constant
def test_c():
from astropy.constants import c
# c is an exactly defined constant, so it shouldn't be changing
assert c.value == 2.99792458e8 # def... | 162 | 4,713 |
beam | learning/tour-of-beam/learning-content/core-transforms/branching/python-example/task.py | .py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); y... | 54 | 1,965 |
confluent-kafka-python | tests/integration/consumer/test_incremental_assign.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... | 91 | 3,235 |
scikit-bio | skbio/diversity/alpha/__init__.py | .py | r"""Alpha diversity measures (:mod:`skbio.diversity.alpha`)
=======================================================
.. currentmodule:: skbio.diversity.alpha
This package provides implementations of various alpha diversity [1]_ metrics,
including measures of richness, diversity, evenness, dominance, and coverage.
Som... | 229 | 4,804 |
onnx | onnx/tools/replace_constants.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx import (
AttributeProto,
FunctionProto,
GraphProto,
ModelProto,
NodeProto,
SparseTensorProto,
TensorProto,
)
from onnx.helper import (
make_a... | 422 | 14,993 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_IdentityN.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
class TestIdentityN(CommonTFLayerTest):
def create_identityn_net(self, value_shape, size_splits_values, axis_value):
tf.compat.v... | 44 | 1,959 |
openvino | tools/commit_slider/utils/common_mode.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from abc import ABC
import utils.helpers as util
from utils.subscription import SubscriptionManager
from utils.break_validator import validateBMOutput
from utils.break_validator import BmValidationError
import json
import os
from enum im... | 538 | 21,000 |
saleor | saleor/tests/e2e/orders/discounts/test_order_products_on_fixed_promotion.py | .py | import pytest
from .....product.tasks import recalculate_discounted_price_for_products_task
from ... import DEFAULT_ADDRESS
from ...product.utils.preparing_product import prepare_product
from ...promotions.utils import create_promotion, create_promotion_rule
from ...shop.utils.preparing_shop import prepare_default_sho... | 141 | 5,554 |
wagtail | wagtail/api/v3/schemas/sites.py | .py | from ninja import Field, Schema
class SiteSchema(Schema):
id: int
hostname: str
port: int
site_name: str
root_page_id: int
is_default_site: bool
class SiteInputSchema(Schema):
hostname: str
port: int = 80
site_name: str = ""
# Accept root_page_id in the input schema for consi... | 21 | 492 |
pyomo | pyomo/util/components.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 131 | 4,565 |
beam | sdks/python/apache_beam/typehints/typehints.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,641 | 56,944 |
saleor | saleor/discount/tests/test_utils/test_create_voucher_discount_object_for_order.py | .py | from decimal import Decimal
import graphene
from ....core.prices import Money, quantize_price
from ....core.taxes import zero_money
from ....order import OrderStatus
from ....order.calculations import fetch_order_prices_if_expired
from ... import DiscountType, DiscountValueType, VoucherType
from ...models import Orde... | 1,086 | 41,443 |
probability | tensorflow_probability/python/mcmc/sample_annealed_importance_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... | 214 | 7,849 |
returns | returns/primitives/exceptions.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from returns.interfaces.unwrappable import Unwrappable # noqa: WPS433
class UnwrapFailedError(Exception):
"""Raised when a container can not be unwrapped into a meaningful value."""
__slots__ = ('halted_container',)
... | 48 | 1,386 |
cvxpy | cvxpy/constraints/constraint.py | .py | """
Copyright 2013 Steven Diamond
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | 371 | 10,729 |
mlflow | mlflow/entities/document.py | .py | from copy import deepcopy
from dataclasses import asdict, dataclass, field
from typing import Any
@dataclass
class Document:
"""
An entity used in MLflow Tracing to represent retrieved documents in a RETRIEVER span.
Args:
page_content: The content of the document.
metadata: A dictionary o... | 49 | 1,372 |
astropy | astropy/timeseries/periodograms/lombscargle/utils.py | .py | import numpy as np
NORMALIZATIONS = ["standard", "psd", "model", "log"]
def compute_chi2_ref(y, dy=None, center_data=True, fit_mean=True):
"""Compute the reference chi-square for a particular dataset.
Note: this is not valid center_data=False and fit_mean=False.
Parameters
----------
y : array-... | 105 | 3,082 |
lemur | lemur/api_keys/models.py | .py | """
.. module: lemur.api_keys.models
:platform: Unix
:synopsis: This module contains all of the models need to create an api key within Lemur.
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Eric Coan <kungfury@instructure.com>... | 32 | 1,071 |
returns | returns/pointfree/__init__.py | .py | from returns.pointfree.alt import alt as alt
from returns.pointfree.apply import apply as apply
from returns.pointfree.bimap import bimap as bimap
from returns.pointfree.bind import bind as bind
from returns.pointfree.bind_async import bind_async as bind_async
from returns.pointfree.bind_async_context_future_result imp... | 44 | 2,164 |
saleor | saleor/core/jwt.py | .py | import datetime
from collections.abc import Iterable
from typing import Any
import graphene
import jwt
from django.conf import settings
from ..account.models import User
from ..app.models import App, AppExtension
from ..permission.enums import (
get_permission_names,
get_permissions_from_codenames,
get_pe... | 238 | 7,225 |
sqlmap | tamper/symboliclogical.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.HIGHEST
def dependencies():
pass
def tamper(payload, **kwargs):
"""
Replaces AND and OR logic... | 31 | 590 |
metrics | src/torchmetrics/functional/multimodal/__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... | 24 | 1,019 |
sqlmap | tests/test_texthelpers.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Text-processing helpers in lib/core/common.py:
normalizeUnicode (accent folding), filterStringValue (charset whitelist),
parseFilePaths (absolute-path harvesting from error pages -> k... | 90 | 3,674 |
beam | sdks/python/apache_beam/transforms/timeutil.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... | 132 | 4,546 |
saleor | saleor/graphql/translations/mutations/menu_item_translate.py | .py | import graphene
from ....menu import models as menu_models
from ....permission.enums import SitePermissions
from ...core import ResolveInfo
from ...core.context import ChannelContext
from ...core.enums import LanguageCodeEnum
from ...core.types import TranslationError
from ...menu.types import MenuItem
from .utils imp... | 43 | 1,574 |
coveragepy | coverage/disposition.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
"""Simple value objects for tracking what to do with files."""
from __future__ import annotations
from typing import TYPE_CHECKING
from coverage.types import T... | 60 | 1,897 |
wagtail | wagtail/users/views/bulk_actions/user_bulk_action.py | .py | from django.contrib.auth import get_user_model
from django.db.models import Q
from wagtail.admin.views.bulk_action import BulkAction
from wagtail.admin.views.generic.permissions import PermissionCheckedMixin
from wagtail.search.backends import get_search_backend
from wagtail.search.index import class_is_indexed
User ... | 33 | 1,266 |
pymc | tests/model/transform/test_conditioning.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... | 381 | 12,143 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.