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 |
|---|---|---|---|---|---|
pyomo | pyomo/solvers/plugins/solvers/CONOPT.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... | 164 | 6,005 |
biopython | BioSQL/DBUtils.py | .py | # Copyright 2002 by Andrew Dalke. All rights reserved.
# Revisions 2007-2010 copyright by Peter Cock. All rights reserved.
# Revisions 2009 copyright by Brad Chapman. All rights reserved.
# Revisions 2013 copyright by Tiago Antao. All rights reserved.
#
# This file is part of the Biopython distribution and governed... | 154 | 4,657 |
biopython | Bio/PDB/StructureBuilder.py | .py | # Copyright (C) 2002, Thomas Hamelryck (thamelry@binf.ku.dk)
# 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.
"""Consumer class that builds a Structure object.
This is used by the PDBParser and MMCIF... | 322 | 12,137 |
coremltools | coremltools/proto/MIL_pb2.py | .py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: MIL.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from g... | 491 | 29,190 |
beam | sdks/python/apache_beam/transforms/managed_iceberg_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... | 94 | 3,229 |
deap | doc/code/tutorials/part_2/2_2_5_particle.py | .py | ## 2.2.6 Particle
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMax", base.Fitness, weights=(1.0, 1.0))
creator.create("Particle", list, fitness=creator.FitnessMax, speed=None,
smin=None, smax=None, best=None)
def initParticle(pcls, size, pm... | 22 | 679 |
probability | tensorflow_probability/python/experimental/joint_distribution_layers/layers.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... | 404 | 11,769 |
sqlmap | thirdparty/chardet/compat.py | .py | ######################## BEGIN LICENSE BLOCK ########################
# Contributor(s):
# Dan Blanchard
# Ian Cordasco
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# versi... | 37 | 1,200 |
openvino | tests/model_hub_tests/jax/jax_utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import flax
import jax
import numpy as np
from models_hub_common.test_convert_model import TestConvertModel
from openvino import convert_model
def flattenize_pytree(outputs):
leaves, _ = jax.tree_util.tree_flatten(outputs)
retu... | 41 | 1,293 |
structlog | tests/processors/test_renderers.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.
from __future__ import annotations
import datetime
import json
import pickle
import pytest
... | 627 | 18,374 |
biopython | Bio/PopGen/GenePop/__init__.py | .py | # Copyright 2007 by Tiago Antao. All rights reserved.
# 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.
"""Code to work with GenePop... | 225 | 7,462 |
mlflow | mlflow/ai_commands/ai_command_utils.py | .py | """Core module for managing MLflow commands."""
import os
import re
from pathlib import Path
from typing import Any
import yaml
def parse_frontmatter(content: str) -> tuple[dict[str, Any], str]:
"""Parse frontmatter from markdown content.
Args:
content: Markdown content with optional YAML frontmatt... | 118 | 3,329 |
ipython | IPython/utils/encoding.py | .py | """
Utilities for dealing with text encodings
"""
from __future__ import annotations
# -----------------------------------------------------------------------------
# Copyright (C) 2008-2012 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING... | 92 | 3,452 |
probability | tensorflow_probability/python/experimental/mcmc/weighted_resampling_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 ... | 370 | 15,667 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/enrichment.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");... | 401 | 13,953 |
onnxruntime | onnxruntime/test/python/quantization/test_qoperator_adjust_int32_bias.py | .py | import os
import tempfile
import unittest
import numpy as np
import onnx
from op_test_utils import TestDataFeeds, check_model_correctness
from onnxruntime.quantization import QuantFormat, QuantType, quantize_static
class TestAdjustWeightScaleForInt32BiasQOperator(unittest.TestCase):
@classmethod
def setUpCl... | 106 | 4,687 |
kombu | t/unit/asynchronous/http/test_curl.py | .py | from __future__ import annotations
from io import BytesIO
from unittest.mock import ANY, Mock, call, patch
import pytest
import t.skip
from kombu.asynchronous.http.curl import READ, WRITE, CurlClient
pytest.importorskip('pycurl')
@t.skip.if_pypy
@pytest.mark.usefixtures('hub')
class test_CurlClient:
class Cl... | 158 | 5,728 |
biopython | Tests/test_CodonTable.py | .py | # Copyright 2008 by Peter Cock.
# Revision copyright 2017 by Markus Piotrowski.
# 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 CodonTable module."""
import unitt... | 822 | 35,447 |
textual | tests/test_widget_child_moving.py | .py | from __future__ import annotations
import pytest
from textual.app import App
from textual.widget import Widget, WidgetError
async def test_move_child_no_direction() -> None:
"""Test moving a widget in a child list."""
async with App().run_test() as pilot:
child = Widget()
await pilot.app.mou... | 192 | 6,602 |
beam | sdks/python/apache_beam/examples/snippets/transforms/aggregation/combineperkey_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 "License");... | 135 | 4,315 |
hatch | tests/helpers/templates/new/basic.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from ..licenses import MIT
def get_files(**kwargs):
return [
File(
Path("LICENSE.txt"),
MIT.replace("<year>", f"{kwargs['year']}-present", 1).replace(
"<copyright holders>", f"{kwargs['author']} <{kwar... | 99 | 2,825 |
wandb | wandb/sdk/lib/run_messages.py | .py | """Echoing messages from wandb-core to the terminal."""
from __future__ import annotations
import asyncio
import contextlib
import logging
from wandb.errors import term
from wandb.proto import wandb_internal_pb2 as pb
from wandb.sdk.interface.interface import InterfaceBase
from wandb.sdk.lib import asyncio_compat, a... | 122 | 4,053 |
wagtail | wagtail/bin/wagtail.py | .py | #!/usr/bin/env python
import fileinput
import fnmatch
import os
import re
import sys
from argparse import ArgumentParser
from difflib import unified_diff
from django.core.management import ManagementUtility
CURRENT_PYTHON = sys.version_info[:2]
REQUIRED_PYTHON = (3, 10)
if CURRENT_PYTHON < REQUIRED_PYTHON:
sys.s... | 452 | 14,376 |
rq | tests/test_webhooks.py | .py | import json
from datetime import datetime, timedelta, timezone
from unittest.mock import ANY, patch
from rq.job import Job, JobStatus, Retry
from rq.queue import Queue
from rq.registry import StartedJobRegistry
from rq.webhook import Webhook
from rq.worker import SimpleWorker
from tests import RQTestCase
from .fixtur... | 373 | 17,062 |
sphinx | tests/test_pycode/test_pycode_ast.py | .py | """Test pycode.ast"""
from __future__ import annotations
import ast
import pytest
from sphinx.pycode.ast import unparse as ast_unparse
@pytest.mark.parametrize(
('source', 'expected'),
[
('a + b', 'a + b'), # Add
('a and b', 'a and b'), # And
... | 76 | 3,622 |
wagtail | wagtail/api/v2/tests/test_pages.py | .py | import collections
import json
import unittest
from io import StringIO
from unittest import mock
import swapper
from django.contrib.auth.models import Group
from django.contrib.contenttypes.models import ContentType
from django.core import management
from django.test import TestCase, TransactionTestCase, tag
from djan... | 2,192 | 82,675 |
biopython | Bio/Restriction/__init__.py | .py | #!/usr/bin/env python
#
# Restriction Analysis Libraries.
# Copyright (C) 2004. Frederic Sohm.
#
# 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.
#
"""Restriction Digest Enzymes.
Examples
--... | 193 | 7,846 |
omegaconf | omegaconf/version.py | .py | import sys # pragma: no cover
# Managed by bump-my-version; see pyproject.toml for bump commands.
__version__ = "2.4.0.dev16"
msg = """OmegaConf 2.4 and above is compatible with Python 3.10 and newer.
You have the following options:
1. Upgrade to Python 3.10 or newer.
This is highly recommended. new features will... | 16 | 519 |
gunicorn | examples/frameworks/django/testing/testing/apps/someapp/middleware.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from multiprocessing import Process, Queue
import requests
def child_process(queue):
while True:
print(queue.get())
requests.get('http://requestb.in/15s95oz1')
class GunicornSubProcessTestMi... | 28 | 725 |
metrics | tests/unittests/segmentation/test_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... | 284 | 11,210 |
astropy | astropy/units/tests/test_quantity_decorator.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# STDLIB
import typing
# THIRD PARTY
import numpy as np
import pytest
# LOCAL
from astropy import units as u
# list of pairs (target unit/physical type, input unit)
x_inputs = [
(u.arcsec, u.deg),
("angle", u.deg),
(u.kpc / u.Myr, u.km / u.... | 490 | 12,358 |
readthedocs.org | readthedocs/rtd_tests/tests/projects/test_version_sorting.py | .py | from django.test import TestCase
from django_dynamic_fixture import get
from readthedocs.builds.constants import BRANCH, LATEST
from readthedocs.builds.models import Version
from readthedocs.projects.constants import REPO_TYPE_GIT
from readthedocs.projects.models import Project
from readthedocs.projects.templatetags.p... | 141 | 4,379 |
black | tests/data/cases/prefer_rhs_split_reformatted.py | .py | # Test cases separate from `prefer_rhs_split.py` that contains unformatted source.
# Left hand side fits in a single line but will still be exploded by the
# magic trailing comma.
first_value, (m1, m2,), third_value = xxxxxx_yyyyyy_zzzzzz_wwwwww_uuuuuuu_vvvvvvvvvvv(
arg1,
arg2,
)
# Make when when the left sid... | 72 | 2,119 |
conda | tests/cli/test_startup_benchmarks.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Startup performance benchmarks.
Measures the cost of conda's startup phases. Runs locally with
``pytest -m benchmark tests/cli/test_startup_benchmarks.py``.
Import benchmarks use ``benchmark.pedantic`` with a setup function that
scrubs cach... | 260 | 8,171 |
textual | docs/examples/guide/styles/screen.py | .py | from textual.app import App
class ScreenApp(App):
def on_mount(self) -> None:
self.screen.styles.background = "darkblue"
self.screen.styles.border = ("heavy", "white")
if __name__ == "__main__":
app = ScreenApp()
app.run()
| 13 | 255 |
textual | docs/examples/app/question02.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Button, Label
class QuestionApp(App[str]):
CSS_PATH = "question02.tcss"
def compose(self) -> ComposeResult:
yield Label("Do you love Textual?", id="question")
yield Button("Yes", id="yes", variant="primary")
yield ... | 21 | 551 |
probability | tensorflow_probability/python/sts/internal/missing_values_util.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... | 198 | 7,986 |
mlflow | tests/tracking/context/test_system_environment_context.py | .py | from mlflow.tracking.context.system_environment_context import SystemEnvironmentContext
def test_system_environment_context_in_context(monkeypatch):
monkeypatch.setenv("MLFLOW_RUN_CONTEXT", '{"A": "B"}')
assert SystemEnvironmentContext().in_context()
monkeypatch.delenv("MLFLOW_RUN_CONTEXT", raising=True)
... | 14 | 570 |
sphinx | tests/roots/test-epub-anchor-id/conf.py | .py | def setup(app):
app.add_crossref_type(directivename='setting', rolename='setting')
| 3 | 87 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/tests/test_utils.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_equal
from astropy.timeseries.periodograms.lombscargle._testing import (
assert_not_strictly_equal,
)
from astropy.timeseries.periodograms.lombscargle.implementations.utils import (
bitceil,
extirpolate,
jn,
trig_sum... | 122 | 3,378 |
probability | tensorflow_probability/python/bijectors/fill_triangular_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... | 98 | 3,595 |
saleor | saleor/warehouse/webhooks/channel_stock_events.py | .py | import json
from collections import defaultdict
from functools import partial
from typing import TYPE_CHECKING
import graphene
from ...account.models import User
from ...app.models import App
from ...webhook.event_types import WebhookEventAsyncType
from ...webhook.transport.asynchronous.transport import (
Webhook... | 135 | 4,076 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_conv2d_s.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import paddle
import numpy as np
import os
import sys
from save_model import saveModel
if paddle.__version__ >= '2.6.0':
import paddle.base as fluid
else:
from paddle import fluid
paddle.enable_static()
inp_blob = np.random.r... | 37 | 1,326 |
qutip | qutip/distributions.py | .py | """
This module provides classes and functions for working with spatial
distributions, such as Wigner distributions, etc.
.. note::
Experimental.
"""
__all__ = ['Distribution', 'HarmonicOscillatorWaveFunction',
'HarmonicOscillatorProbabilityFunction']
import numpy as np
from numpy.typing import Arra... | 533 | 18,209 |
pyomo | examples/pyomo/quadratic/example3.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... | 40 | 1,283 |
attrs | tests/test_compat.py | .py | # SPDX-License-Identifier: MIT
import types
from typing import Protocol
import pytest
import attr
from attr._compat import _IS_GENERATOR_RESULTS, _lazy_is_generator
@pytest.fixture(name="mp")
def _mp():
return types.MappingProxyType({"x": 42, "y": "foo"})
class TestMetadataProxy:
"""
Ensure propert... | 101 | 2,570 |
pyomo | pyomo/core/tests/unit/test_numpy_expr.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... | 316 | 10,352 |
beam | sdks/python/apache_beam/utils/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... | 61 | 2,287 |
coveragepy | ci/comment_on_fixes.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
"""Add a release comment to all the issues mentioned in the latest release."""
import re
import sys
from scriv.scriv import Scriv
from session import get_sessi... | 61 | 2,001 |
pyomo | pyomo/repn/tests/test_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... | 484 | 18,098 |
hydra | hydra/types.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from enum import Enum
from typing import TYPE_CHECKING, Any, Callable
TaskFunction = Callable[[Any], Any]
if TYPE_CHECKING:
from hydra._internal.callbacks import Callbacks
from hydra.core.config_loader im... | 66 | 2,183 |
onnxruntime | onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/InferenceSession.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 InferenceSession(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get... | 89 | 3,037 |
saleor | saleor/graphql/account/types.py | .py | from functools import partial
from typing import cast
import graphene
from django.contrib.auth import get_user_model
from graphene import relay
from promise import Promise
from ...account import models
from ...attribute import models as attribute_models
from ...checkout.utils import get_user_checkout
from ...core.exc... | 1,358 | 50,683 |
hatch | backend/src/hatchling/cli/__init__.py | .py | import argparse
from hatchling.cli.build import build_command
from hatchling.cli.dep import dep_command
from hatchling.cli.metadata import metadata_command
from hatchling.cli.version import version_command
def hatchling() -> int:
parser = argparse.ArgumentParser(prog="hatchling", allow_abbrev=False)
subparse... | 29 | 730 |
mlflow | tests/openai/test_genai_semconv_converter.py | .py | import importlib.metadata
import json
import openai
import pytest
from packaging.version import Version
import mlflow
from mlflow.openai.genai_semconv_converter import _convert_content, _convert_message
from tests.tracing.helper import capture_otel_export, reset_autolog_state # noqa: F401
MODEL = "gpt-4o-mini"
_o... | 316 | 11,080 |
mlflow | dev/pyproject.py | .py | from __future__ import annotations
import re
import subprocess
import sys
from collections import Counter
from enum import Enum
from pathlib import Path
from typing import Any, cast
import toml
import yaml
from packaging.version import Version
from pydantic import BaseModel, Field, RootModel
class PackageType(Enum)... | 536 | 20,602 |
black | tests/data/cases/comments2.py | .py | from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
MyLovelyCompanyTeamProjectComponent # NOT DRY
)
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
MyLovelyCompanyTeamProjectComponent as component # DRY
)
# Please keep __all__ alph... | 345 | 7,640 |
bazel | src/test/py/bazel/runfiles_test.py | .py | # pylint: disable=g-bad-file-header
# Copyright 2017 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
... | 584 | 21,557 |
kombu | kombu/utils/debug.py | .py | """Debugging support."""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from vine.utils import wraps
from kombu.log import get_logger
if TYPE_CHECKING:
from logging import Logger
from types import TracebackType
from typing import Any, Callable
from kombu.transpo... | 89 | 2,355 |
saleor | saleor/app/validators.py | .py | import re
from django.core.validators import URLValidator
from .error_codes import AppErrorCode
class AppURLValidator(URLValidator):
validator = URLValidator
host_re = "(" + validator.hostname_re + validator.domain_re + "|localhost)"
regex = re.compile(
r"^(?:[a-z0-9.+-]*)://" # scheme is valid... | 26 | 758 |
jupytext | tests/data/notebooks/outputs/ipynb_to_hydrogen/jupyter_again.py | .py | # ---
# jupyter:
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %%
c = '''
title: "Quick test"
output:
ioslides_presentation:
widescreen: true
smaller: true
editor_options:
chunk_output_type console
'''
# %%
import yaml
print(yaml.dump(yaml.load(c)))
# ... | 26 | 329 |
ipython | IPython/core/macro.py | .py | """Support for interactive macros in IPython"""
from __future__ import annotations
#*****************************************************************************
# Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
#
# Distributed under the terms of the BSD License. The full license is in
# the file... | 49 | 1,632 |
pyomo | pyomo/util/tests/test_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... | 121 | 5,053 |
astropy | astropy/logger.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""This module defines a logging class based on the built-in logging module.
.. note::
This module is meant for internal ``astropy`` usage. For use in other
packages, we recommend implementing your own logger instead.
"""
import inspect
import ... | 611 | 20,014 |
biopython | Tests/test_SearchIO_hmmer2_text_index.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 hmmer2-text indexing."""
import os
import unittest
from search_tes... | 512 | 23,810 |
mlflow | tests/store/tracking/sqlalchemy_store/test_sqlalchemy_store_scorers.py | .py | import json
import math
import time
import uuid
from unittest import mock
import pytest
from opentelemetry import trace as trace_api
from opentelemetry.sdk.resources import Resource as _OTelResource
from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan
from mlflow.entities import (
AssessmentSource... | 1,546 | 57,156 |
pdm | tests/test_plugin.py | .py | import importlib.metadata
import sys
from unittest import mock
import pytest
from pdm.cli.commands.base import BaseCommand
from pdm.project.config import ConfigItem
from pdm.utils import cd
class HelloCommand(BaseCommand):
def add_arguments(self, parser) -> None:
parser.add_argument("-n", "--name", help... | 164 | 5,181 |
confluent-kafka-python | src/confluent_kafka/_util/conversion_util.py | .py | # Copyright 2022 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... | 40 | 1,481 |
beam | infra/enforcement/test_sending.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 ... | 104 | 4,192 |
probability | tensorflow_probability/python/distributions/batch_concat_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... | 417 | 17,610 |
luigi | test/instance_wrap_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... | 100 | 2,989 |
omegaconf | omegaconf/typing.py | .py | from typing import TypeAlias
from .vendor.antlr4.ParserRuleContext import ParserRuleContext
# The antlr4 class `ParserRulerContext` is not a valid type for static type checkers
# for a number of reasons, including lack of strict typing in antlr4-python3-runtime
# and dynamically generated attributes that can only be ... | 14 | 734 |
astropy | astropy/units/quantity_helper/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Helper functions for Quantity.
In particular, this implements the logic that determines scaling and result
units for a given ufunc, given input units.
"""
from .converters import *
# isort: split
# By importing helpers, all the unit conversion functi... | 17 | 588 |
scikit-optimize | skopt/learning/tests/test_forest.py | .py | import numpy as np
import pytest
from scipy import stats
from numpy.testing import assert_equal
from numpy.testing import assert_array_equal
from numpy.testing import assert_almost_equal
from skopt.learning import ExtraTreesRegressor, RandomForestRegressor
def truth(X):
return 0.5 * np.sin(1.75*X[:, 0])
@pyt... | 103 | 3,418 |
beam | sdks/python/apache_beam/runners/pipeline_utils.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... | 260 | 10,261 |
openvino | src/frontends/tensorflow/tests/test_models/gen_scripts/generate_model_with_assert.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# model with Assert node generator
#
import os
import sys
import numpy as np
import tensorflow as tf
def main():
tf.compat.v1.reset_default_graph()
# Create the graph and model
with tf.compat.v1.Session() as sess:
... | 39 | 1,135 |
openvino | tests/layer_tests/pytorch_tests/conftest.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import inspect
import os
from pytorch_layer_test_class import get_params
def _patch_cia_ops_cache():
"""Cache _collect_all_valid_cia_ops to speed up run_decompositions.
PyTorch's run_decompositions() calls _collect_all_valid_... | 44 | 1,527 |
astropy | astropy/utils/tests/test_compat.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Just deprecation tests, the rest is tested throughout astropy.
"""
import pytest
from astropy.utils.exceptions import AstropyPendingDeprecationWarning
def test_copy_if_needed_deprecation():
with pytest.warns(AstropyPendingDeprecationWarning, ma... | 19 | 617 |
probability | tensorflow_probability/python/bijectors/composition.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... | 865 | 37,368 |
pyfilesystem2 | examples/count_py.py | .py | """
Display how much storage is used in your Python files.
Usage:
python count_py.py <PATH or FS URL>
"""
import sys
from fs import open_fs
from fs.filesize import traditional
fs_url = sys.argv[1]
count = 0
with open_fs(fs_url) as fs:
for _path, info in fs.walk.info(filter=["*.py"], namespaces=["details"]... | 22 | 415 |
scikit-bio | skbio/sequence/_nucleotide_mixin.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.
# --------------------------------------------... | 377 | 10,986 |
metrics | examples/image/spatial_correlation_coef.py | .py | """
Spatial Correlation Coefficient
===============================
The Spatial Correlation Coefficient can be applied to compare the spatial structure of two images, which can be valuable in various domains such as medical imaging, remote sensing, and quality assessment in manufacturing or design processes.
Let's co... | 59 | 2,372 |
conda | tests/cli/test_main_create.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Tests for `conda create` help text."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from conda.cli.main_create import epilog as create_epilog
from conda.plugins import hookimpl
from conda.plugins.types... | 94 | 3,144 |
metrics | src/torchmetrics/retrieval/_deprecated.py | .py | from typing import Any, Optional
from torchmetrics.retrieval.average_precision import RetrievalMAP
from torchmetrics.retrieval.fall_out import RetrievalFallOut
from torchmetrics.retrieval.hit_rate import RetrievalHitRate
from torchmetrics.retrieval.ndcg import RetrievalNormalizedDCG
from torchmetrics.retrieval.precisi... | 279 | 9,222 |
pyro | pyro/distributions/zero_inflated.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.distributions import constraints
from torch.distributions.utils import (
broadcast_all,
lazy_property,
logits_to_probs,
probs_to_logits,
)
from torch.nn.functional import softplus
from pyro.... | 204 | 6,893 |
pymc | pymc/initial_point.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... | 368 | 14,535 |
probability | tensorflow_probability/python/vi/csiszar_divergence_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... | 1,209 | 42,456 |
saleor | saleor/graphql/tax/tests/mutations/test_tax_country_configuration_update.py | .py | import graphene
import pytest
from .....tax.error_codes import TaxCountryConfigurationUpdateErrorCode
from .....tax.models import TaxClass, TaxClassCountryRate
from ....tests.utils import assert_no_permission, get_graphql_content
from ..fragments import TAX_COUNTRY_CONFIGURATION_FRAGMENT
MUTATION = (
"""
muta... | 285 | 8,790 |
readthedocs.org | readthedocs/builds/querysets.py | .py | """Build and Version QuerySet classes."""
import datetime
import structlog
from django.db import models
from django.db.models import Q
from django.utils import timezone
from readthedocs.builds.constants import BUILD_STATE_CANCELLED
from readthedocs.builds.constants import BUILD_STATE_FINISHED
from readthedocs.builds... | 321 | 10,896 |
saleor | saleor/graphql/page/tests/queries/pages_with_where/test_with_where_attributes_numeric.py | .py | import pytest
from ......attribute.utils import associate_attribute_values_to_instance
from .....tests.utils import get_graphql_content
from .shared import QUERY_PAGES_WITH_WHERE
@pytest.mark.parametrize(
("numeric_input", "expected_count"),
[
({"slug": "num-slug", "value": {"numeric": {"eq": 1.2}}},... | 88 | 2,912 |
pyro | pyro/contrib/autoname/named.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
The ``pyro.contrib.named`` module is a thin syntactic layer on top of Pyro. It
allows Pyro models to be written to look like programs with operating on Python
data structures like ``latent.x.sample_(...)``, rather than program... | 255 | 8,625 |
textual | tests/suggester/test_input_suggestions.py | .py | import string
import pytest
from textual.app import App, ComposeResult
from textual.suggester import SuggestFromList
from textual.widgets import Input
class SuggestionsApp(App[ComposeResult]):
def __init__(self, suggestions):
self.suggestions = suggestions
self.input = Input(suggester=SuggestFro... | 102 | 3,050 |
beam | sdks/python/apache_beam/examples/snippets/transforms/elementwise/runinference.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");... | 98 | 3,498 |
sphinx | sphinx/environment/collectors/title.py | .py | """The title collector components for sphinx.environment."""
from __future__ import annotations
from typing import TYPE_CHECKING
from docutils import nodes
from sphinx.environment.collectors import EnvironmentCollector
from sphinx.transforms import SphinxContentsFilter
if TYPE_CHECKING:
from collections.abc im... | 70 | 2,335 |
onnx | onnx/backend/test/case/node/reducesumsquare.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 ReduceSumSquare(Base):
@staticmethod
def export_do_not_keepdim... | 195 | 5,558 |
wagtail | wagtail/users/tests/test_utils.py | .py | from typing import Any
from django.contrib.auth import get_user_model
from django.test import TestCase, override_settings
from wagtail.test.utils import WagtailTestUtils
from wagtail.users.utils import (
get_gravatar_url,
get_manageable_token_owners,
user_can_manage_token,
)
User: Any = get_user_model()
... | 138 | 5,755 |
sphinx | sphinx/ext/apidoc/__main__.py | .py | """Command-line interface for the apidoc extension."""
from __future__ import annotations
import sys
from sphinx.ext.apidoc._cli import main
raise SystemExit(main(sys.argv[1:]))
| 10 | 182 |
pymc | pymc/step_methods/compound.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... | 427 | 14,604 |
clearml | clearml/storage/hashing.py | .py | import json
from typing import Optional, Union, Dict, Tuple
from zlib import crc32
from clearml.debugging.log import LoggerRoot
from clearml.utilities.hashing import (
safe_hash,
sha256_safe_hash,
StrHashFunction,
)
STR_HASH_FUNCTIONS = {"md5", "sha256", "sha384", "sha512"}
DICT_HASH_FUNCTIONS = {"crc32",... | 140 | 4,588 |
pyomo | pyomo/repn/tests/ampl/test_ampl_nl.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... | 423 | 15,106 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.