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 |
|---|---|---|---|---|---|
probability | spinoffs/autobnn/autobnn/training_util_test.py | .py | # Copyright 2023 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 215 | 6,635 |
pyomo | pyomo/contrib/pynumero/sparse/tests/test_block_matrix.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... | 900 | 32,257 |
cvxpy | cvxpy/atoms/lambda_sum_largest.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... | 92 | 3,141 |
mlflow | tests/entities/test_run_info.py | .py | from mlflow.entities import RunInfo
def _check(
ri,
run_id,
experiment_id,
user_id,
status,
start_time,
end_time,
lifecycle_stage,
artifact_uri,
):
assert isinstance(ri, RunInfo)
assert ri.run_id == run_id
assert ri.experiment_id == experiment_id
assert ri.user_id =... | 115 | 2,453 |
astropy | astropy/wcs/wcsapi/conftest.py | .py | import numpy as np
import pytest
from astropy.coordinates import SkyCoord
from astropy.units import Quantity
from astropy.wcs import WCS
from astropy.wcs.wcsapi import BaseLowLevelWCS
@pytest.fixture
def spectral_1d_fitswcs():
wcs = WCS(naxis=1)
wcs.wcs.ctype = ("FREQ",)
wcs.wcs.cunit = ("Hz",)
wcs.w... | 186 | 4,405 |
pyomo | pyomo/scripting/plugins/build_ext.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... | 94 | 3,154 |
httpie | httpie/cli/argtypes.py | .py | import argparse
import getpass
import os
import sys
from copy import deepcopy
from typing import List, Optional, Union
from .constants import DEFAULT_FORMAT_OPTIONS, SEPARATOR_CREDENTIALS
from ..sessions import VALID_SESSION_NAME_PATTERN
class KeyValueArg:
"""Base key-value pair parsed from CLI."""
def __in... | 276 | 7,991 |
beam | sdks/python/apache_beam/examples/inference/anomaly_detection/write_data_to_pubsub_pipeline/pipeline/options.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... | 63 | 2,317 |
mlflow | tests/anthropic/test_anthropic_autolog.py | .py | import asyncio
import re
from typing import Any
from unittest.mock import ANY, patch
import anthropic
import pytest
from anthropic.types import Message, TextBlock, ToolUseBlock, Usage
import mlflow.anthropic
from mlflow.entities import SpanLogLevel
from mlflow.entities.span import SpanType
from mlflow.tracing.constan... | 499 | 16,785 |
pyomo | pyomo/contrib/pynumero/examples/parallel_matvec.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... | 52 | 1,727 |
metrics | tests/unittests/classification/test_hinge.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... | 252 | 10,042 |
saleor | saleor/graphql/giftcard/tests/mutations/test_gift_card_unassign_user.py | .py | import graphene
from .....giftcard import GiftCardEvents
from .....giftcard.error_codes import GiftCardErrorCode
from .....giftcard.utils import assign_gift_card_to_user
from .....permission.enums import AccountPermissions
from ....tests.utils import assert_no_permission, get_graphql_content
MUTATION = """
mutati... | 133 | 4,288 |
wandb | wandb/sdk/wandb_metric.py | .py | """metric."""
from __future__ import annotations
import logging
from collections.abc import Callable, Sequence
from wandb.proto import wandb_internal_pb2 as pb
logger = logging.getLogger("wandb")
class Metric:
"""Metric object."""
_callback: Callable[[pb.MetricRecord], None] | None
_name: str
_st... | 115 | 3,320 |
mamba | libmambapy/tests/test_utils.py | .py | import copy
import pytest
import libmambapy
def test_import_submodule():
import libmambapy.utils as utils
# Dummy execution
_p = utils.TextEmphasis
def test_import_recursive():
import libmambapy as mamba
# Dummy execution
_p = mamba.utils.TextEmphasis
def test_TextEmphasis():
TextE... | 112 | 3,292 |
openvino | tests/llm/accuracy_conformance.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import gc
import logging
import os
import shutil
import tempfile
import pytest
from huggingface_hub import snapshot_download
from optimum.intel.openvino import (OVModelForCausalLM,
OVWeightQuantizatio... | 259 | 10,510 |
mlflow | mlflow/genai/optimize/optimizers/base.py | .py | from abc import ABC, abstractmethod
from typing import Any, Callable
from mlflow.genai.optimize.types import EvaluationResultRecord, PromptOptimizerOutput
# The evaluation function that takes candidate prompts as a dict
# (prompt template name -> prompt template) and a dataset as a list of dicts,
# and returns a list... | 39 | 1,700 |
onnxruntime | onnxruntime/python/tools/transformers/models/bart/utils/onnx_inference.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 ... | 96 | 3,497 |
pdm | src/pdm/builders/base.py | .py | from __future__ import annotations
import functools
import logging
import os
import shutil
import subprocess
import textwrap
import threading
from collections.abc import Iterable
from logging import Logger
from pathlib import Path
from typing import TYPE_CHECKING, Any, ClassVar, cast
from pyproject_hooks import (
... | 346 | 12,713 |
mlflow | tests/sagemaker/test_sagemaker_deployment_client.py | .py | import json
import os
import re
import time
from functools import wraps
from io import BytesIO
from typing import NamedTuple
from unittest import mock
import boto3
import botocore
import numpy as np
import pandas as pd
import pytest
from click.testing import CliRunner
from moto.core import DEFAULT_ACCOUNT_ID
from skle... | 1,707 | 65,165 |
onnxruntime | docs/python/examples/plot_profiling.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
.. _l-example-profiling:
Profile the execution of a simple model
=======================================
*ONNX Runtime* can profile the execution of the model.
This example shows how to interpret the results.
"""
impo... | 70 | 1,900 |
probability | tensorflow_probability/python/math/special_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... | 1,480 | 54,059 |
onnxruntime | onnxruntime/test/python/contrib_ops/profile_matmul_block_scaled.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
"""
Accuracy and latency harness for the CUDA MatMulBlockQuantizedFp8Wei... | 507 | 20,344 |
mlflow | mlflow/langchain/retriever_chain.py | .py | """Chain for wrapping a retriever."""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
import yaml
from pydantic import ConfigDict, Field
from mlflow.langchain._compat import (
import_async_callback_manager_for_chain_run,
import_base_retriever,
import_callba... | 167 | 5,649 |
beam | sdks/python/apache_beam/internal/test_data/module_1_function_added.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... | 34 | 1,129 |
openvino | tests/e2e_tests/test_utils/test_utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import csv
import logging as log
import os
import re
import shutil
import sys
from pathlib import Path
from typing import Union
from filelock import FileLock
from contextlib import contextmanager
from datetime import datetime
import cop... | 494 | 19,251 |
saleor | saleor/graphql/product/tests/mutations/test_product_type_update.py | .py | import json
from unittest import mock
from unittest.mock import patch
import graphene
import pytest
from django.utils.functional import SimpleLazyObject
from freezegun import freeze_time
from .....core.utils.json_serializer import CustomJsonEncoder
from .....product.error_codes import ProductErrorCode
from .....produ... | 534 | 16,566 |
loguru | tests/exceptions/source/backtrace/frame_values_forward.py | .py | import sys
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="", colorize=False, backtrace=True, diagnose=False)
k = 2
def a(n):
1 / n
def b(n):
a(n - 1)
@logger.catch
def c(n):
b(n - 1)
c(k)
| 25 | 237 |
readthedocs.org | readthedocs/builds/version_slug.py | .py | """
Contains logic for handling version slugs.
Handling slugs for versions is not too straightforward. We need to allow some
characters which are uncommon in usual slugs. They are dots and underscores.
Usually we want the slug to be the name of the tag or branch corresponding VCS
version. However we need to strip url-... | 129 | 4,236 |
pyfilesystem2 | examples/rm_pyc.py | .py | """
Remove all pyc files in a directory.
Usage:
python rm_pyc.py <PATH or FS URL>
"""
import sys
from fs import open_fs
with open_fs(sys.argv[1]) as fs:
count = fs.glob("**/*.pyc").remove()
print(f"{count} .pyc files remove")
| 17 | 240 |
deap | doc/code/tutorials/part_1/1_where_to_start.py | .py | ## 1.1 Types
from deap import base, creator
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", list, fitness=creator.FitnessMin)
## 1.2 Initialization
import random
from deap import tools
IND_SIZE = 10
toolbox = base.Toolbox()
toolbox.register("attribute", random.random)
toolbox... | 68 | 2,147 |
scikit-bio | skbio/diversity/_block.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.
# --------------------------------------------... | 357 | 11,279 |
django-cms | cms/test_utils/project/sampleapp/forms.py | .py | from django import forms
from django.contrib.auth.forms import AuthenticationForm
from cms.test_utils.project.sampleapp.models import Category
class LoginForm(AuthenticationForm):
pass
class LoginForm2(AuthenticationForm):
pass
class LoginForm3(AuthenticationForm):
def __init__(self, request=None, *a... | 25 | 493 |
mlflow | mlflow/store/model_registry/sqlalchemy_store.py | .py | import logging
import threading
import urllib
import uuid
from typing import Any
import sqlalchemy
from sqlalchemy import select
from sqlalchemy.orm import Session
from mlflow.entities.model_registry.model_version_stages import (
ALL_STAGES,
DEFAULT_STAGES_FOR_GET_LATEST_VERSIONS,
STAGE_ARCHIVED,
STAG... | 1,794 | 74,257 |
metrics | src/torchmetrics/functional/clustering/adjusted_mutual_info_score.py | .py | # Copyright The Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 122 | 4,470 |
gunicorn | examples/dirty_example/test_worker_integration.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
#!/usr/bin/env python
"""
Integration test demonstrating DirtyWorker execution.
This test demonstrates how the DirtyWorker loads apps and handles requests
without actually forking processes (suitable for a quick t... | 278 | 8,671 |
mlflow | tests/cli/test_scorers.py | .py | import json
from typing import Any
from unittest.mock import patch
import pytest
from click.testing import CliRunner
import mlflow
from mlflow.cli.scorers import commands
from mlflow.exceptions import MlflowException
from mlflow.genai.scorers import get_all_scorers, list_scorers, scorer
from mlflow.utils.string_utils... | 773 | 23,142 |
onnxruntime | onnxruntime/core/flatbuffers/ort_flatbuffers_py/fbs/Checkpoint.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 Checkpoint(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatb... | 126 | 4,217 |
clearml | examples/automation/toy_base_task.py | .py | # This Task is the base task that we will be executing as a second step (see task_piping.py)
# In order to make sure this experiment is registered in the platform, you must execute it once.
from clearml import Task
# Initialize the task pipe's first task used to start the task pipe
task = Task.init('examples', 'Toy B... | 20 | 675 |
wandb | tests/unit_tests/test_asyncio_manager.py | .py | import threading
import unittest.mock
import pytest
from wandb.sdk.lib import asyncio_manager
class _TestError(Exception):
"""Intentional error raised in a test."""
async def _return_value(value: str) -> str:
return value
async def _raise_test_error() -> None:
raise _TestError
def test_run_returns_... | 110 | 2,360 |
probability | discussion/neutra/__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... | 20 | 766 |
wandb | tests/unit_tests/test_launch/test_cli/test_job_create.py | .py | import pytest
from wandb.cli import cli
def test_parse_service_config_valid_single():
"""Test parsing a single valid service configuration."""
result = cli.parse_service_config(None, None, ["test_service=always"])
assert result == {"test_service": "always"}
def test_parse_service_config_valid_multiple()... | 90 | 3,547 |
saleor | saleor/product/tests/test_managers.py | .py | from ...product.models import ProductVariant
def test_available_quantity_with_no_allocations(variant, allocations):
stocks = variant.stocks.first()
stocks.allocations.all().delete()
assert stocks.quantity == 15
assert stocks.allocations.count() == 0
# No allocations have been made, so available_q... | 61 | 2,241 |
biopython | Tests/test_Phylo_CDAO.py | .py | # Copyright (C) 2013 by Ben Morris (ben@bendmorris.com)
# based on code by Eric Talevich (eric.talevich@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.
"""Unit tests for the CDAO and CDAOIO... | 108 | 3,270 |
coremltools | coremltools/converters/mil/mil/types/__init__.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 .annotate import annotate, apply_delayed_types, class_annotate, delay_type
from .get_type_info i... | 94 | 2,170 |
pyomo | pyomo/core/tests/unit/test_block.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... | 3,793 | 130,502 |
openvino | tests/e2e_tests/common/postprocessors/filters.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
from .provider import ClassProvider
class FilterByLabels(ClassProvider):
__action_name__ = 'classes_filter'
def __init__(self, config):
self.classes = config.get("classes", [])
def apply(self, d... | 90 | 3,120 |
pdm | src/pdm/models/requirements.py | .py | from __future__ import annotations
import dataclasses
import functools
import inspect
import json
import os
import posixpath
import re
import secrets
import urllib.parse as urlparse
from collections.abc import Sequence
from importlib.metadata import Distribution
from pathlib import Path
from typing import TYPE_CHECKIN... | 540 | 20,124 |
onnxruntime | onnxruntime/python/tools/quantization/fusions/fusion_layernorm.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... | 147 | 6,000 |
hydra | hydra/core/plugins.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import importlib
import importlib.util
import inspect
import pkgutil
import sys
import warnings
from collections import defaultdict
from dataclasses import dataclass, field
from timeit import default_timer as timer
from typing import Any, Dict, List... | 277 | 10,607 |
kafka | tests/kafkatest/services/trogdor/network_partition_fault_spec.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 ... | 40 | 1,816 |
kafka | tests/kafkatest/services/trogdor/produce_bench_workload.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 ... | 57 | 2,442 |
mlflow | mlflow/server/security_utils.py | .py | """
Shared security utilities for MLflow server middleware.
This module contains common functions used by both Flask and FastAPI
security implementations.
"""
import fnmatch
from urllib.parse import urlparse
from mlflow.environment_variables import (
MLFLOW_SERVER_ALLOWED_HOSTS,
MLFLOW_SERVER_CORS_ALLOWED_OR... | 171 | 5,294 |
mlflow | examples/gateway/huggingface/example.py | .py | from mlflow.deployments import get_deploy_client
def main():
client = get_deploy_client("http://localhost:7000")
print(f"Hugging Face TGI endpoints: {client.list_endpoints()}\n")
print(
f"Hugging Face completions endpoint info: {client.get_endpoint(endpoint='completions')}\n"
)
# Complet... | 26 | 645 |
clearml | clearml/utilities/requests_toolbelt/_compat.py | .py | """Private module full of compatibility hacks.
Primarily this is for downstream redistributions of requests that unvendor
urllib3 without providing a shim.
.. warning::
This module is private. If you use it, and something breaks, you were
warned
"""
import sys
import requests
try:
from requests.package... | 328 | 9,956 |
onnx | tests/python/tools_test.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from numpy.testing import assert_allclose
import onnx
from onnx import TensorProto, helper, numpy_helper
from onnx.defs import onnx_opset_version
from onnx.reference import ReferenceE... | 322 | 13,407 |
saleor | saleor/graphql/attribute/tests/test_utils.py | .py | import datetime
from collections import defaultdict
import graphene
import pytest
from django.conf import settings
from django.core.exceptions import ValidationError
from graphql import GraphQLError
from ....attribute import AttributeInputType
from ....attribute.models import AttributeValue
from ....attribute.utils i... | 2,975 | 92,498 |
wagtail | wagtail/test/snippets/models.py | .py | from django.db import models
from modelcluster.fields import ParentalKey
from modelcluster.models import ClusterableModel
from wagtail.admin.panels import FieldPanel, InlinePanel
from wagtail.fields import RichTextField
from wagtail.models import TranslatableMixin
from wagtail.search import index
from wagtail.snippets... | 123 | 2,836 |
coremltools | coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/constant_propagation.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 gc
import tensorflow as tf
from packaging.version import Version
from coremltools import _lo... | 164 | 6,849 |
hypercorn | tests/protocol/test_ws_stream.py | .py | from __future__ import annotations
import asyncio
from typing import Any, cast
from unittest.mock import AsyncMock, call, Mock
import pytest
import pytest_asyncio
from wsproto.events import BytesMessage, TextMessage
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.asyncio.worker_context import Worke... | 552 | 18,061 |
black | tests/data/cases/context_managers_38.py | .py | with \
make_context_manager1() as cm1, \
make_context_manager2() as cm2, \
make_context_manager3() as cm3, \
make_context_manager4() as cm4 \
:
pass
with \
make_context_manager1() as cm1, \
make_context_manager2(), \
make_context_manager3() as cm3, \
make_context_manager4()... | 55 | 1,140 |
kafka | tests/kafkatest/services/security/listener_security_config.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 ... | 44 | 2,747 |
onnxruntime | tools/python/convert_onnx_models_to_ort.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# This script is a stub that uses the model conversion script from the util subdirectory.
# We do it this way so we can use relative imports in that script, which makes it easy to include
# in the ORT p... | 22 | 956 |
coveragepy | coverage/env.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
"""Determine facts about the environment."""
from __future__ import annotations
import os
import platform
import sys
import sysconfig
from collections.abc impor... | 143 | 5,273 |
pyomo | pyomo/environ/tests/test_environ.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... | 257 | 9,032 |
pymc | tests/test_printing.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... | 571 | 23,421 |
wandb | wandb/proto/wandb_api_pb2.py | .py | import google.protobuf
protobuf_version = google.protobuf.__version__[0]
if protobuf_version == "5":
from wandb.proto.v5.wandb_api_pb2 import *
elif protobuf_version == "6":
from wandb.proto.v6.wandb_api_pb2 import *
elif protobuf_version == "7":
from wandb.proto.v7.wandb_api_pb2 import *
else:
raise ... | 17 | 528 |
coveragepy | coverage/control.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
"""Central control stuff for coverage.py."""
from __future__ import annotations
import atexit
import collections
import contextlib
import datetime
import os
imp... | 1,520 | 56,025 |
django-cms | cms/test_utils/project/second_urls_for_apphook_tests.py | .py | from django.conf import settings
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
from django.urls import include, re_path
from django.views.i18n import JavaScriptCatalog
from django.views.static import serve
from cms.utils.conf import get_cms_setting
admin.autodiscover()
urlpatterns ... | 25 | 807 |
astropy | astropy/io/votable/converters.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module handles the conversion of various VOTABLE datatypes
to/from TABLEDATA_ and BINARY_ formats.
"""
# STDLIB
import re
import struct
import sys
from math import prod
# THIRD-PARTY
import numpy as np
from numpy import ma
# ASTROPY
from astrop... | 1,552 | 45,735 |
pyro | pyro/poutine/substitute_messenger.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import warnings
from typing import TYPE_CHECKING, Dict, Set
from typing_extensions import Self
from pyro import params
from pyro.poutine.messenger import Messenger
from pyro.poutine.util import is_validation_enabled
if TYPE_CHEC... | 95 | 3,295 |
conda | conda/cli/main_env_remove.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""CLI implementation for `conda-env remove`.
Removes the specified conda environment.
"""
from argparse import (
ArgumentParser,
_SubParsersAction,
)
def configure_parser(sub_parsers: _SubParsersAction, **kwargs) -> ArgumentParser:
... | 72 | 1,504 |
mlflow | tests/data/test_code_dataset_source.py | .py | from mlflow.data.code_dataset_source import CodeDatasetSource
def test_code_dataset_source_from_path():
tags = {
"mlflow_source_type": "NOTEBOOK",
"mlflow_source_name": "some_random_notebook_path",
}
code_datasource = CodeDatasetSource(tags)
assert code_datasource.to_dict() == {
... | 17 | 435 |
wagtail | wagtail/__init__.py | .py | # PLEASE NOTE: If you edit this file (other than updating the version number), please
# also update scripts/nightly/get_version.py as well as that needs to generate a new
# version of this file from a template for nightly builds
from wagtail.utils.version import get_semver_version, get_version
# major.minor.patch.rel... | 26 | 724 |
openvino | docs/articles_en/assets/snippets/ov_dynamic_shapes.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
from utils import get_dynamic_model
#! [import]
import openvino as ov
#! [import]
model = get_dynamic_model()
#! [reshape_undefined]
core = ov.Core()
# Set first dimension to be dynamic while keeping others static
... | 119 | 3,139 |
cvxpy | cvxpy/atoms/elementwise/maximum.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... | 135 | 4,170 |
textual | src/textual/_styles_cache.py | .py | from __future__ import annotations
from functools import lru_cache
from typing import TYPE_CHECKING, Callable, Iterable, Sequence
import rich.repr
from rich.segment import Segment
from rich.style import Style as RichStyle
from rich.terminal_theme import TerminalTheme
from textual import log
from textual._ansi_theme ... | 524 | 19,197 |
metrics | src/torchmetrics/functional/regression/log_mse.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... | 77 | 2,598 |
conda | conda/_private/shards/misc.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""
Miscellaneous utility functions for sharded repodata processing.
This module contains utility functions that don't fit cleanly into other modules:
- URL handling
- Package name parsing
- Data transformation helpers
- Threading utilities
"""... | 220 | 7,461 |
saleor | saleor/plugins/tests/utils.py | .py | def get_config_value(
field_name: str, configuration: list[dict[str, str | bool]]
) -> str | bool | None:
for elem in configuration:
if elem["name"] == field_name:
return elem["value"]
return None
| 8 | 229 |
biopython | Tests/test_SCOP_Des.py | .py | # Copyright 2001 by Gavin E. Crooks. 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.
"""Unit test for Des."""
import unittest
from Bio.SCOP import Des
class DesTests(unittes... | 55 | 1,874 |
beam | sdks/python/apache_beam/testing/benchmarks/cloudml/cloudml_benchmark_constants_lib.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... | 30 | 1,089 |
mlflow | mlflow/protos/issues_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: issues.proto
# Protobuf Python Version: 5.26.0
"""Generated protocol buffer code."""
from google.prot... | 192 | 12,576 |
textual | src/textual/layouts/vertical.py | .py | from __future__ import annotations
from fractions import Fraction
from typing import TYPE_CHECKING
from textual._resolve import resolve_box_models
from textual.geometry import NULL_OFFSET, Region, Size
from textual.layout import ArrangeResult, Layout, WidgetPlacement
if TYPE_CHECKING:
from textual.geometry impor... | 125 | 3,913 |
scikit-bio | skbio/tree/_me.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.
# --------------------------------------------... | 1,734 | 61,848 |
sphinx | sphinx/config.py | .py | """Build configuration file handling."""
from __future__ import annotations
import time
import traceback
import types
from contextlib import chdir
from os import getenv
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal, NamedTuple
from sphinx.errors import ConfigError, ExtensionError
from sphin... | 915 | 34,669 |
saleor | saleor/graphql/product/mutations/product_type/product_type_delete.py | .py | import graphene
from django.db.models import Q
from django.db.models.expressions import Exists, OuterRef
from .....attribute import AttributeInputType
from .....attribute import models as attribute_models
from .....core.tracing import traced_atomic_transaction
from .....order import OrderStatus
from .....order import ... | 79 | 3,091 |
astropy | astropy/io/fits/tests/test_util.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import gzip
import os
import signal
import sys
import threading
import numpy as np
import pytest
from numpy.testing import assert_equal
from astropy.io.fits import util
from astropy.io.fits.util import _rstrip_inplace, ignore_sigint
from astropy.utils.c... | 202 | 7,079 |
hatch | tests/helpers/templates/wheel/standard_default_build_script_force_include.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 52 | 1,410 |
saleor | saleor/graphql/order/tests/benchmark/test_order_bulk_create.py | .py | from decimal import Decimal
import graphene
import pytest
from django.utils import timezone
from ....discount.enums import DiscountValueTypeEnum
from ....tests.utils import get_graphql_content
from ..mutations.test_order_bulk_create import ( # noqa: F401
ORDER_BULK_CREATE,
order_bulk_input,
order_bulk_in... | 90 | 2,408 |
deap | examples/pso/basic.py | .py | # This file is part of DEAP.
#
# DEAP 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 version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 92 | 3,352 |
saleor | saleor/order/tests/test_base_order_total.py | .py | from decimal import ROUND_HALF_UP, Decimal
from prices import Money
from ...core.taxes import zero_money
from ...discount import DiscountType, DiscountValueType
from .. import base_calculations
def test_base_order_total(order_with_lines):
# given
order = order_with_lines
lines = order.lines.all()
sh... | 625 | 20,427 |
onnxruntime | onnxruntime/python/tools/transformers/optimizer.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# Convert Bert ONNX model converted from TensorFlow or exported from Py... | 622 | 25,163 |
onnx | onnx/backend/test/case/node/split.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 Split(Base):
@staticmethod
def export_1d_opset13() -> None:
... | 379 | 11,845 |
django-cms | cms/middleware/utils.py | .py | from cms.utils import apphook_reload
class ApphookReloadMiddleware:
"""
If the URLs are stale, reload them.
"""
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
apphook_reload.ensure_urlconf_is_up_to_date()
return self.get_res... | 18 | 478 |
biopython | Bio/SeqUtils/ProtParamData.py | .py | # Copyright 2003 Yair Benita. 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.
"""Indices to be used with ProtP... | 391 | 18,172 |
saleor | saleor/giftcard/tests/test_events.py | .py | from decimal import Decimal
from .. import GiftCardEvents
from ..events import (
gift_card_assigned_event,
gift_card_balance_adjusted_event,
gift_card_unassigned_event,
)
def test_gift_card_balance_adjusted_event(gift_card, staff_user):
# given
old_current = Decimal("50.00")
old_initial = Dec... | 59 | 1,974 |
mlflow | examples/langchain/retrieval_qa_chain.py | .py | import os
import tempfile
from langchain.chains import RetrievalQA
from langchain.document_loaders import TextLoader
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.llms import OpenAI
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import FAISS
import mlfl... | 47 | 1,696 |
wandb | tests/unit_tests/test_launch/test_runner/test_local_process.py | .py | import shlex
from unittest.mock import MagicMock
import pytest
from wandb.sdk.launch._project_spec import EntryPoint
from wandb.sdk.launch.runner.local_process import LocalProcessRunner
@pytest.fixture
def mock_launch_project():
"""Mock the launch project for testing."""
project = MagicMock()
project.ove... | 99 | 3,257 |
pyomo | examples/mpec/linear1.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... | 25 | 840 |
luigi | test/task_register_test.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2017 VNG Corporation
#
# 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... | 56 | 1,760 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.