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 |
|---|---|---|---|---|---|
pyro | pyro/contrib/autoname/autoname.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
from collections import defaultdict
from collections.abc import Iterable
from functools import singledispatch
import pyro
from pyro.poutine.handlers import _make_handler
from pyro.poutine.reentrant_messenger import ReentrantMessenger
... | 179 | 5,100 |
wagtail | wagtail/models/sites.py | .py | from collections import namedtuple
import swapper
from django.apps import apps
from django.conf import settings
from django.contrib.auth.models import Group, Permission
from django.core.cache import cache
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import Case,... | 332 | 11,401 |
python-prompt-toolkit | src/prompt_toolkit/input/vt100_parser.py | .py | """
Parser for VT100 input stream.
"""
from __future__ import annotations
import re
from collections.abc import Callable, Generator
from ..key_binding.key_processor import KeyPress
from ..keys import Keys
from .ansi_escape_sequences import ANSI_SEQUENCES
__all__ = [
"Vt100Parser",
]
# Regex matching any CPR r... | 251 | 8,410 |
openvino | tests/layer_tests/onnx_tests/test_split_concat.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
test_data_3D = [
dict(input_shape=[1, 50, 50], output_shapes=[[1, 50, 25], [1, 50, 25]], axis=2),
dict(input_shape=[2, 50, 50], output... | 596 | 22,576 |
python-prompt-toolkit | src/prompt_toolkit/input/typeahead.py | .py | r"""
Store input key strokes if we did read more than was required.
The input classes `Vt100Input` and `Win32Input` read the input text in chunks
of a few kilobytes. This means that if we read input from stdin, it could be
that we read a couple of lines (with newlines in between) at once.
This creates a problem: pote... | 79 | 2,545 |
beam | sdks/python/apache_beam/runners/portability/expansion_service_main.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... | 91 | 3,656 |
beam | sdks/python/apache_beam/internal/cloudpickle/__init__.py | .py | from . import cloudpickle
from .cloudpickle import * # noqa
__doc__ = cloudpickle.__doc__
__version__ = "3.1.1"
__all__ = [ # noqa
"__version__",
"Pickler",
"CloudPickler",
"dumps",
"loads",
"dump",
"load",
"register_pickle_by_value",
"unregister_pickle_by_value",
]
| 19 | 308 |
cvxpy | cvxpy/reductions/dcp2cone/canonicalizers/quad/quad_form_canon.py | .py | """
Copyright 2017 Robin Verschueren
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, softw... | 30 | 1,063 |
rq | rq/webhook.py | .py | from __future__ import annotations
import json
import logging
from dataclasses import asdict, dataclass
from typing import TYPE_CHECKING, Any, Literal
from urllib.parse import urlparse
from urllib.request import Request, urlopen
if TYPE_CHECKING:
from .job import Job
logger = logging.getLogger('rq.webhook')
@d... | 101 | 3,686 |
hypercorn | src/hypercorn/trio/lifespan.py | .py | from __future__ import annotations
import sys
import trio
from ..config import Config
from ..typing import AppWrapper, ASGIReceiveEvent, ASGISendEvent, LifespanScope, LifespanState
from ..utils import LifespanFailureError, LifespanTimeoutError
if sys.version_info < (3, 11):
from exceptiongroup import BaseExcept... | 109 | 3,942 |
conda | tests/plugins/test_types.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Tests for plugin type classes (CondaEnvironmentSpecifier and CondaEnvironmentExporter)."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from conda.env.specs.requirements import RequirementsSpec
from co... | 161 | 5,304 |
cvxpy | cvxpy/reductions/dcp2cone/canonicalizers/quad/power_canon.py | .py | """
Copyright 2017 Robin Verschueren
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, softw... | 42 | 1,515 |
biopython | Bio/SeqIO/TwoBitIO.py | .py | # Copyright 2020 by Michiel de Hoon
#
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been included as part of this
# package.
"""Bio.SeqIO support for UCSC's "twoBit" (.2bi... | 264 | 11,165 |
hydra | tests/test_apps/app_with_log_jobreturn_callback/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig
import hydra
@hydra.main(config_path=".", config_name="config")
def my_app(cfg: DictConfig) -> None:
val = 1 / cfg.divisor
print(f"val={val}")
if __name__ == "__main__":
my_app()
| 15 | 300 |
wandb | tests/unit_tests/test_wandb_logger_handler.py | .py | import logging
from unittest.mock import MagicMock
from wandb.sdk.lib.logger_capture import LoggerHandler
def _make_logger(name: str) -> logging.Logger:
"""Create a uniquely-named logger for test isolation."""
logger = logging.getLogger(f"{__name__}.{name}")
logger.setLevel(logging.DEBUG)
return logg... | 59 | 1,694 |
pyomo | pyomo/dataportal/plugins/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 21 | 735 |
mlflow | tests/utils/test_yaml_utils.py | .py | import codecs
import os
from mlflow.utils.yaml_utils import (
read_yaml,
safe_edit_yaml,
write_yaml,
)
from tests.helper_functions import random_file, random_int
def test_yaml_read_and_write(tmp_path):
temp_dir = str(tmp_path)
yaml_file = random_file("yaml")
long_value = 1
data = {
... | 77 | 2,134 |
mlflow | mlflow/dspy/save.py | .py | """Functions for saving DSPY models to MLflow."""
import json
import logging
import os
from pathlib import Path
from typing import Any
import cloudpickle
import yaml
from packaging.version import Version
import mlflow
from mlflow import pyfunc
from mlflow.dspy.constant import FLAVOR_NAME
from mlflow.dspy.wrapper imp... | 438 | 16,923 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_Binary.py | .py | import platform
import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
from common.utils.tflite_utils import parametrize_tests
test_ops = [
{'op_name': 'EQUAL', 'op_func': 'tf.math.equal'},
{'op_name': 'FLOOR_MOD', 'op_func': 'tf.math.floormod', 'kwargs_to_prepare_inp... | 57 | 2,679 |
python-prompt-toolkit | src/prompt_toolkit/data_structures.py | .py | from __future__ import annotations
from typing import NamedTuple
__all__ = [
"Point",
"Size",
]
class Point(NamedTuple):
x: int
y: int
class Size(NamedTuple):
rows: int
columns: int
| 19 | 212 |
cvxpy | cvxpy/tests/nlp_tests/test_ML_Gaussian_stress.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
... | 103 | 4,495 |
scikit-bio | skbio/stats/distance/tests/test_base.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.
# --------------------------------------------... | 2,239 | 80,274 |
coremltools | coremltools/converters/mil/mil/builder.py | .py | # Copyright (c) 2020, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
import numbers
from collections import defaultdict
from typing import Any, Callable, List, Optional, ... | 439 | 16,166 |
onnxruntime | orttraining/orttraining/python/training/amp/loss_scaler.py | .py | class LossScaler:
r"""Base class for implementing custom loss scaler strategies
Once the scaler is configured, no user intervention is needed to update loss scale during training.
Note:
This class should never be instantiated, but used as an abstract class for custom loss scaling strategy.
"""... | 121 | 4,654 |
cvxpy | cvxpy/atoms/log_sum_exp.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... | 98 | 2,807 |
luigi | luigi/execution_summary.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2015-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... | 507 | 20,201 |
astropy | astropy/timeseries/periodograms/lombscargle_multiband/implementations/main.py | .py | """
Main Lomb-Scargle Multiband Implementation
The ``lombscarglemultiband`` function here is essentially a switch
statement for the various implementations available in this submodule
"""
__all__ = ["available_methods", "lombscargle_multiband"]
from .mbfast_impl import lombscargle_mbfast
from .mbflex_impl import lom... | 74 | 1,826 |
probability | tensorflow_probability/python/experimental/mcmc/with_reductions_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... | 432 | 16,693 |
astropy | astropy/modeling/models/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Creates a common namespace for all pre-defined models.
"""
from astropy.modeling import math_functions as math
from astropy.modeling.core import custom_model, fix_inputs, hide_inverse
from astropy.modeling.functional_models import *
from astropy.mode... | 97 | 2,880 |
wandb | wandb/sdk/artifacts/_models/base_model.py | .py | from __future__ import annotations
from abc import ABC
from pydantic import ConfigDict
from wandb._pydantic import JsonableModel
# Abstract base class with a common default configuration that's shared by all
# pydantic classes in artifacts code (excluding GraphQL-generated types).
class ArtifactsBase(JsonableModel... | 21 | 761 |
pyomo | pyomo/core/base/util.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... | 54 | 1,642 |
pyro | tests/infer/reparam/test_projected_normal.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from torch.autograd import grad
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer.reparam import ProjectedNormalReparam
from tests.common import assert_close
from .util ... | 62 | 2,118 |
biopython | Tests/test_CAPS.py | .py | # Copyright 2001 by Iddo Friedberg. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Tests for CAPS module."""
import unittest
from Bio import CAPS
from Bio.Align import Ali... | 155 | 6,676 |
deap | doc/code/tutorials/part_3/3_8_algorithms.py | .py | ## 3.7 Variations
import random
from deap import base
from deap import creator
from deap import tools
## Data structure and initializer creation
creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", list, fitness=creator.FitnessMax)
toolbox = base.Toolbox()
toolbox.register("attr_f... | 36 | 1,050 |
lemur | lemur/plugins/base/manager.py | .py | """
.. module: lemur.plugins.base.manager
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson (kglisson@netflix.com)
"""
from flask import current_app
from lemur.common.managers import InstanceManager
# inspired by https:/... | 72 | 2,304 |
hatch | tests/cli/config/test_show.py | .py | def test_default_scrubbed(hatch, config_file, helpers, default_cache_dir, default_data_dir):
config_file.model.project = "foo"
config_file.model.publish["index"]["auth"] = "bar"
config_file.save()
result = hatch("config", "show")
default_cache_directory = str(default_cache_dir).replace("\\", "\\\\... | 111 | 2,644 |
onnxruntime | onnxruntime/python/tools/quantization/fusions/fusion.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from __fut... | 312 | 11,777 |
mlflow | tests/ai_commands/test_ai_command_utils.py | .py | import platform
from unittest import mock
import pytest
from mlflow.ai_commands import get_command, get_command_body, list_commands, parse_frontmatter
def test_parse_frontmatter_with_metadata():
content = """---
namespace: genai
description: Test command
---
# Command content
This is the body."""
metadata... | 283 | 7,863 |
pyro | tests/ops/test_contract.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import itertools
import numbers
from collections import OrderedDict
import opt_einsum
import pytest
import torch
import pyro.ops.jit
from pyro.distributions.util import logsumexp
from pyro.ops.contract import (
_partition_ter... | 836 | 26,142 |
lemur | lemur/certificates/service.py | .py | """
.. module: lemur.certificate.service
: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 re
import time
from collections import defaultdict
from itertools import group... | 1,488 | 54,159 |
textual | src/textual/css/transition.py | .py | from typing import NamedTuple
class Transition(NamedTuple):
duration: float = 1.0
easing: str = "linear"
delay: float = 0.0
def __str__(self) -> str:
duration, easing, delay = self
if delay:
return f"{duration:.1f}s {easing} {delay:.1f}"
elif easing != "linear":
... | 17 | 417 |
luigi | test/contrib/_webhdfs_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... | 66 | 2,104 |
mlflow | tests/store/tracking/test_rest_store_review_queues.py | .py | import json
from unittest import mock
import pytest
from mlflow.exceptions import MlflowException
from mlflow.protos import review_queues_pb2 as pb
from mlflow.store.tracking.rest_store import RestStore
from mlflow.utils.rest_utils import MlflowHostCreds
_CALL = "mlflow.store.tracking.rest_store.call_endpoint"
def... | 258 | 9,550 |
onnxruntime | onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/Attribute.py | .py | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: fbs
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class Attribute(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbu... | 338 | 10,850 |
mlflow | dev/clint/tests/rules/test_unused_disable_comment.py | .py | from pathlib import Path
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import Position, Range, lint_file
from clint.rules import UnusedDisableComment
def test_stale_disable_comment(index: SymbolIndex) -> None:
code = """
import os # clint: disable=lazy-import
"""
conf... | 90 | 3,032 |
astropy | astropy/convolution/convolve.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import warnings
from functools import partial
import numpy as np
from astropy import units as u
from astropy.modeling.convolution import Convolution
from astropy.modeling.core import SPECIAL_OPERATORS, CompoundModel
from astropy.nddata import support_nd... | 1,097 | 45,021 |
mlflow | mlflow/genai/judges/optimizers/__init__.py | .py | """MLflow GenAI Judge Optimizers."""
from mlflow.genai.judges.optimizers.gepa import GEPAAlignmentOptimizer
from mlflow.genai.judges.optimizers.memalign import MemAlignOptimizer
from mlflow.genai.judges.optimizers.simba import SIMBAAlignmentOptimizer
__all__ = [
"GEPAAlignmentOptimizer",
"MemAlignOptimizer",
... | 12 | 353 |
pymc | pymc/backends/report.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... | 93 | 3,135 |
saleor | saleor/tests/e2e/promotions/utils/promotion_delete.py | .py | from ...utils import get_graphql_content
PROMOTION_DELETE_MUTATION = """
mutation DeletePromotion($id:ID!) {
promotionDelete(id: $id) {
errors {
code
field
message
}
promotion {
id
}
}
}
"""
def delete_promotion(
staff_api_client,
promotion_id,
):
variables = {... | 35 | 587 |
clearml | clearml/utilities/plotlympl/mplexporter/tools.py | .py | """
Tools for matplotlib plot exporting
"""
def ipynb_vega_init() -> None:
"""Initialize the IPython notebook display elements
This function borrows heavily from the excellent vincent package:
http://github.com/wrobstory/vincent
"""
try:
from IPython.core.display import display, HTML
... | 56 | 1,734 |
wagtail | wagtail/admin/tests/test_admin_search.py | .py | """
Tests for the search box in the admin side menu, and the custom search hooks.
"""
from django.contrib.auth.models import Permission
from django.template import Context, Template
from django.test import RequestFactory, SimpleTestCase, TestCase
from django.urls import reverse
from wagtail.admin.auth import user_has... | 200 | 7,360 |
dirty-equals | tests/test_numeric.py | .py | import pytest
from dirty_equals import (
IsApprox,
IsFloat,
IsFloatInf,
IsFloatInfNeg,
IsFloatInfPos,
IsFloatNan,
IsInt,
IsNegative,
IsNegativeFloat,
IsNegativeInt,
IsNonNegative,
IsNonPositive,
IsPositive,
IsPositiveFloat,
IsPositiveInt,
)
@pytest.mark.par... | 146 | 3,726 |
mlflow | tests/spark/autologging/utils.py | .py | import os
import pyspark
from packaging.version import Version
from pyspark.sql import SparkSession
import mlflow
from mlflow.spark.autologging import _SPARK_TABLE_INFO_TAG_NAME
def _get_mlflow_spark_jar_path():
spark_dir = "spark_2.13" if Version(pyspark.__version__).major >= 4 else "spark_2.12"
jar_dir = ... | 43 | 1,566 |
kafka | tests/kafkatest/sanity_checks/test_console_consumer.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 ... | 71 | 3,354 |
hatch | src/hatch/utils/platform.py | .py | from __future__ import annotations
import os
import sys
from functools import cache
from importlib import import_module
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from collections.abc import Callable, Iterable, Sequence
from subprocess import CompletedProcess, Popen
from types import ModuleTy... | 307 | 11,399 |
lemur | lemur/tests/test_users.py | .py | import json
import pytest
from marshmallow import ValidationError
from lemur.tests.factories import UserFactory, RoleFactory
from lemur.users.schemas import UserInputSchema, UserCreateInputSchema
from lemur.users.views import * # noqa
from .vectors import (
VALID_ADMIN_API_TOKEN,
VALID_ADMIN_HEADER_TOKEN,
... | 238 | 5,920 |
readthedocs.org | readthedocs/sso/models.py | .py | """Single Sign On models."""
import uuid
from django.db import models
from readthedocs.projects.validators import validate_domain_name
class SSOIntegration(models.Model):
"""Single Sign-On integration for an Organization."""
PROVIDER_ALLAUTH = "allauth"
PROVIDER_EMAIL = "email"
PROVIDER_SAML = "sa... | 77 | 1,755 |
biopython | Tests/test_PQR.py | .py | # Copyright 2019-2020 by Konstantinos Zisis and Artemi Bendandi. All rights reserved.
#
# Converted by Konstantinos Zisis and Artemi Bendandi from an older unit test
# copyright 2009 by Eric Talevich.
#
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that sh... | 191 | 7,264 |
hatch | src/hatch/project/config.py | .py | from __future__ import annotations
import re
from copy import deepcopy
from functools import cached_property
from itertools import product
from os import environ
from typing import TYPE_CHECKING, Any, cast
from hatch.env.utils import ensure_valid_environment
from hatch.project.constants import DEFAULT_BUILD_DIRECTORY... | 802 | 32,263 |
mlflow | mlflow/gateway/cli.py | .py | import click
from mlflow.environment_variables import MLFLOW_GATEWAY_CONFIG
from mlflow.gateway.config import _validate_config
from mlflow.gateway.runner import run_app
from mlflow.telemetry.events import GatewayStartEvent
from mlflow.telemetry.track import _record_event
from mlflow.utils.annotations import deprecated... | 57 | 1,624 |
wagtail | wagtail/contrib/sitemaps/views.py | .py | import inspect
from django.contrib.sitemaps import views as sitemap_views
from .sitemap_generator import Sitemap
def index(request, sitemaps, **kwargs):
sitemaps = prepare_sitemaps(request, sitemaps)
return sitemap_views.index(request, sitemaps, **kwargs)
def sitemap(request, sitemaps=None, **kwargs):
... | 29 | 869 |
openvino | tests/layer_tests/pytorch_tests/test_quantized_convnd.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import pytest
import numpy as np
import torch
from pytorch_layer_test_class import PytorchLayerTest
class TestQuantizedConv2D(PytorchLayerTest):
def _prepare_input(self):
return (np.round(self.random.rand... | 89 | 3,464 |
readthedocs.org | readthedocs/gold/models.py | .py | """Django models for recurring donations aka Gold membership."""
import math
from django.contrib.auth.models import User
from django.db import models
from django.utils.translation import gettext_lazy as _
from readthedocs.projects.models import Project
#: The membership options that are currently available
LEVEL_C... | 62 | 1,691 |
openvino | tests/layer_tests/onnx_tests/test_gather.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
pytest.importorskip("openvino.tools.mo", reason="Ticket - 157136")
from common.layer_test_class import check_ir_version
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
fro... | 288 | 11,422 |
biopython | Bio/Phylo/PAML/_parse_yn00.py | .py | # Copyright (C) 2011, 2019 by Brandon Invergo (b.invergo@gmail.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.
"""Methods fo... | 155 | 6,820 |
beam | sdks/python/apache_beam/io/aws/clients/s3/client_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... | 228 | 7,543 |
onnxruntime | onnxruntime/contrib_ops/cuda/bert/flash_attention/update_kernels.py | .py | import os
base_dir = os.path.dirname(os.path.realpath(__file__))
dims = [32, 64, 96, 128, 192, 256]
types = ["fp16", "bf16"]
copyright_header = """/******************************************************************************
* Copyright (c) 2024, Tri Dao.
**********************************************************... | 78 | 2,825 |
django-cms | cms/test_utils/project/placeholderapp/exceptions.py | .py | class PlaceholderHookException(Exception):
"""
Simple exception to signal to the tests that a placeholder
hook has been run.
"""
pass
| 7 | 154 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_atan2.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# fill_const paddle model generator
#
import numpy as np
from save_model import saveModel
import paddle
import sys
def atan2(name , x , y):
paddle.enable_static()
with paddle.static.program_guard(paddle.static.Program(), padd... | 40 | 1,331 |
lemur | lemur/common/managers.py | .py | """
.. module: lemur.common.managers
:platform: Unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
from flask import current_app
from lemur.exceptions import InvalidConfiguration
# ins... | 78 | 2,162 |
saleor | saleor/graphql/core/__init__.py | .py | import graphene
from . import fields # noqa: F401
from .context import SaleorContext
__all__ = ["SaleorContext"]
class ResolveInfo(graphene.ResolveInfo):
context: SaleorContext
| 11 | 186 |
beam | sdks/python/apache_beam/examples/snippets/snippets_examples_wordcount_minimal.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");... | 119 | 3,664 |
probability | tensorflow_probability/python/sts/fitting.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... | 513 | 22,703 |
astropy | astropy/convolution/tests/test_discretize.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.convolution.utils import discretize_model
from astropy.modeling.functional_models import (
Box1D,
Box2D,
Gaussian1D,
Gaussian2D,
RickerWavelet1D,
... | 270 | 7,792 |
textual | src/textual/file_monitor.py | .py | from __future__ import annotations
import os
from pathlib import Path
from typing import Callable, Iterable, Sequence
import rich.repr
from textual._callback import invoke
@rich.repr.auto
class FileMonitor:
"""Monitors files for changes and invokes a callback when it does."""
_paths: set[Path]
def __... | 65 | 1,945 |
saleor | saleor/checkout/tests/test_checkout.py | .py | import datetime
from decimal import Decimal
from unittest.mock import Mock, patch
import graphene
import pytest
from django.utils import timezone
from django_countries.fields import Country
from freezegun import freeze_time
from prices import Money, TaxedMoney
from ...account.models import Address
from ...core.taxes ... | 1,964 | 63,609 |
beam | sdks/python/apache_beam/io/azure/blobstoragefilesystem_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... | 340 | 13,612 |
conda | conda/env/installers/conda.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Conda-flavored installer."""
from __future__ import annotations
import tempfile
from os.path import basename
from typing import TYPE_CHECKING
from ...base.constants import UpdateModifier
from ...base.context import context
from ...common.c... | 141 | 5,076 |
metrics | src/torchmetrics/regression/mape.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... | 136 | 5,094 |
probability | tensorflow_probability/python/experimental/linalg/linear_operator_psd_kernel.py | .py | # Copyright 2019 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 460 | 19,055 |
onnxruntime | onnxruntime/test/python/transformers/test_simplified_layernorm_fusion.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import os
import unittest
import numpy as np
import onnx
from onnx import TensorPr... | 243 | 9,113 |
metrics | src/torchmetrics/wrappers/minmax.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... | 173 | 6,922 |
pyro | docs/source/conf.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import os
import sys
# import pkg_resources
# -*- coding: utf-8 -*-
#
# Pyro documentation build configuration file, created by
# sphinx-quickstart on Thu Jun 15 17:16:14 2017.
#
# This file is execfile()d with the current direct... | 227 | 6,925 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_leakyrelu.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf2_layer_test_class import CommonTF2LayerTest
class TestKerasLeakyRelu(CommonTF2LayerTest):
def create_keras_leaky_relu_net(self, input_names, input_shapes, input_type, alpha, ir_... | 39 | 1,698 |
pyomo | pyomo/core/tests/unit/test_expr_numpy.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... | 109 | 4,696 |
mlflow | mlflow/ag2/__init__.py | .py | from mlflow.telemetry.events import AutologgingEvent
from mlflow.telemetry.track import _record_event
from mlflow.utils.autologging_utils import autologging_integration
FLAVOR_NAME = "ag2"
def autolog(
log_traces: bool = True,
disable: bool = False,
silent: bool = False,
):
"""
Enables (or disabl... | 60 | 2,367 |
probability | tensorflow_probability/python/distributions/pareto_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... | 378 | 13,800 |
saleor | saleor/product/search.py | .py | from collections import defaultdict
from collections.abc import Iterable
from typing import TYPE_CHECKING
from django.conf import settings
from django.db.models import Value, prefetch_related_objects
from ..attribute.models import AssignedProductAttributeValue, AttributeValue
from ..attribute.search import get_search... | 173 | 6,109 |
sqlmap | plugins/dbms/vertica/fingerprint.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.common import Backend
from lib.core.common import Format
from lib.core.data import conf
from lib.core.data import kb
from lib.core.data import logger
from lib.core.e... | 107 | 2,991 |
lemur | lemur/factory.py | .py | """
.. module: lemur.factory
:platform: Unix
:synopsis: This module contains all the needed functions to allow
the factory app creation.
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
... | 296 | 9,098 |
sphinx | tests/roots/test-copyright-multiline/conf.py | .py | copyright = (
'2006',
'2006-2009, Alice',
'2010-2013, Bob',
'2014-2017, Charlie',
'2018-2021, David',
'2022-2025, Eve',
)
html_theme = 'basic'
| 10 | 167 |
pyomo | pyomo/contrib/sensitivity_toolbox/pynumero.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... | 162 | 5,846 |
probability | tensorflow_probability/python/bijectors/unit_vector.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... | 135 | 4,469 |
mlflow | mlflow/genai/judges/prompts/tool_call_efficiency.py | .py | from typing import TYPE_CHECKING
from mlflow.genai.judges.utils.formatting_utils import (
format_available_tools,
format_tools_called,
)
from mlflow.genai.prompts.utils import format_prompt
if TYPE_CHECKING:
from mlflow.genai.utils.type import FunctionCall
from mlflow.types.chat import ChatTool
# NB:... | 84 | 2,804 |
onnxruntime | onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/SparseTensor.py | .py | # automatically generated by the FlatBuffers compiler, do not modify
# namespace: fbs
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class SparseTensor(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(fla... | 115 | 3,692 |
mlflow | mlflow/langchain/output_parsers.py | .py | from dataclasses import asdict
from typing import Any, AsyncIterator, Iterator
from uuid import uuid4
from langchain_core.messages.base import BaseMessage
from langchain_core.output_parsers.transform import BaseTransformOutputParser
from mlflow.models.rag_signatures import (
ChainCompletionChoice,
Message,
... | 153 | 5,270 |
probability | tensorflow_probability/examples/models/bayesian_vgg.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... | 103 | 3,601 |
saleor | saleor/webhook/tests/circuit_breaker/test_breaker_board_decorator.py | .py | import time
from unittest.mock import Mock, patch
from ....graphql.app.enums import CircuitBreakerState
from ....webhook.event_types import WebhookEventSyncType
from ....webhook.transport.synchronous import transport
from .utils import create_breaker_board
# The intention is to test whether BreakerBoard decorator is ... | 205 | 7,258 |
sqlmap | lib/core/common.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from __future__ import division
import binascii
import codecs
import contextlib
import copy
import functools
import getpass
import hmac
import hashlib
import inspect
import io
im... | 5,967 | 214,292 |
biopython | Tests/test_SearchIO_blast_xml.py | .py | # Copyright 2012 by Wibowo Arindrarto. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Tests for SearchIO BlastIO parsers."""
import os
import unittest
import warnings
from... | 4,068 | 172,918 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.