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 |
|---|---|---|---|---|---|
onnxruntime | onnxruntime/test/python/test_pep561_py_typed_marker.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Regression test for issue #23108: PEP 561 `py.typed` marker presence."""
from __future__ import annotations
import os
import unittest
import onnxruntime
class TestPep561Marker(unittest.TestCase):
def test_py_typed... | 26 | 719 |
wagtail | wagtail/admin/tests/test_navigation.py | .py | from django.contrib.auth import get_user_model
from django.test import TestCase
from wagtail.permission_policies.pages import PagePermissionPolicy
from wagtail.test.utils import PageFixturesMixin, WagtailTestUtils
class TestExplorablePages(PageFixturesMixin, WagtailTestUtils, TestCase):
"""
Test the way that... | 95 | 3,923 |
mlflow | mlflow/genai/datasets/entities.py | .py | from dataclasses import dataclass
from datetime import datetime, timedelta
def _format_datetime_for_repr(value: datetime) -> str:
formatted = value.isoformat(sep=" ", timespec="seconds")
if value.utcoffset() == timedelta(0):
return formatted.removesuffix("+00:00") + " UTC"
return formatted
@data... | 33 | 941 |
onnxruntime | onnxruntime/test/testdata/ort_github_issue_19590.py | .py | import onnx
from onnx import TensorProto, helper
# graph with a QDQ MatMul node unit where one input is and initializer -> DQ and the other is on a path that
# contains a supported node followed by an unsupported node followed by the DQ -> MatMul.
# The DQ of the initializer is prior to the unsupported node. If the pa... | 78 | 2,682 |
pyomo | pyomo/_archive/rangeset.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... | 13 | 646 |
kafka | tests/kafkatest/benchmarks/core/benchmark_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 use ... | 402 | 21,605 |
pyomo | examples/pyomo/draft/bpack.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... | 90 | 1,819 |
beam | sdks/python/apache_beam/io/gcp/datastore/v1new/query_splitter_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... | 264 | 9,624 |
kafka | tests/kafkatest/services/security/minikdc.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 ... | 140 | 6,683 |
openvino | tests/layer_tests/pytorch_tests/test_quantized_mul.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class quantized_mul(torch.nn.Module):
def __init__(self, scale, zero_point, dtype) -> None:
torch.nn.Modu... | 53 | 1,845 |
conda | tests/test_fetch.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import hashlib
import os
import re
from contextlib import nullcontext
from os.path import exists, isfile
from pathlib import Path
from tempfile import mktemp
from typing import TYPE_CHECKING
from unittest.mock... | 494 | 15,575 |
kafka | tests/kafkatest/sanity_checks/test_bounce.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 ... | 73 | 3,730 |
beam | sdks/python/apache_beam/runners/worker/bundle_processor.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... | 2,232 | 83,940 |
astropy | astropy/coordinates/angles/errors.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Custom angle errors and exceptions used in :mod:`astropy.coordinates.angles`."""
__all__ = [
"BoundsError",
"IllegalHourError",
"IllegalHourWarning",
"IllegalMinuteError",
"IllegalMinuteWarning",
"IllegalSecondError",
"Ille... | 174 | 3,928 |
wandb | wandb/_pydantic/utils.py | .py | """Internal utilities for working with Pydantic types and data."""
from __future__ import annotations
from functools import lru_cache
from typing import TYPE_CHECKING, Any
import pydantic_core
if TYPE_CHECKING:
from pydantic import BaseModel
@lru_cache
def gql_typename(cls: type[BaseModel]) -> str:
"""Get... | 50 | 1,584 |
mlflow | mlflow/server/graphql/graphql_custom_scalars.py | .py | import graphene
from graphql.language.ast import IntValueNode
class LongString(graphene.Scalar):
"""
LongString Scalar type to prevent truncation to max integer in JavaScript.
"""
description = "Long converted to string to prevent truncation to max integer in JavaScript"
@staticmethod
def se... | 25 | 579 |
saleor | saleor/graphql/tax/tests/mutations/test_tax_class_delete.py | .py | import graphene
from .....tax.models import TaxClass
from ....tests.utils import assert_no_permission, get_graphql_content
from ..fragments import TAX_CLASS_FRAGMENT
MUTATION = (
"""
mutation TaxClassDelete($id: ID!) {
taxClassDelete(id: $id) {
errors {
field
... | 70 | 1,755 |
onnxruntime | onnxruntime/test/python/onnxruntime_test_collective.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import unittest
import numpy as np
from mpi4py import MPI
from onnx import TensorProto, helper
from parameterized import parameterized
import onnxruntime as ort
class ORTBertPretrainTest(unittest.TestCase):
@staticmeth... | 394 | 16,257 |
onnx | onnx/backend/test/case/utils.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import importlib
import pkgutil
from typing import TYPE_CHECKING
import numpy as np
from onnx import ONNX_ML
if TYPE_CHECKING:
from types import ModuleType
all_numeric_dtypes = [
np.int8,
... | 46 | 1,040 |
biopython | Bio/PDB/mmtf/__init__.py | .py | # Copyright 2016 Anthony Bradley. 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.
"""Support for loading 3D ... | 54 | 1,568 |
hydra | examples/configure_hydra/job_name/with_config_file_override.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig
import hydra
from hydra.core.hydra_config import HydraConfig
@hydra.main(config_path=".", config_name="config")
def experiment(_cfg: DictConfig) -> None:
print(HydraConfig.get().job.name)
if __name__ == "__m... | 15 | 345 |
textual | tests/snapshot_tests/snapshot_apps/scroll_to_center.py | .py | from textual.app import App, ComposeResult
from textual.containers import HorizontalScroll, VerticalScroll
from textual.widgets import Label
class MyApp(App[None]):
AUTO_FOCUS = ""
CSS = """
VerticalScroll {
border: round $primary;
}
#vertical {
height: 21;
}
HorizontalScro... | 43 | 1,110 |
ipython | tests/test_handlers.py | .py | """Tests for input handlers."""
# -----------------------------------------------------------------------------
# Module imports
# -----------------------------------------------------------------------------
# our own packages
from IPython.core import autocall
from IPython.testing import tools as tt
import pytest
fr... | 80 | 2,954 |
textual | tests/test_containers.py | .py | """Test basic functioning of some containers."""
from textual.app import App, ComposeResult
from textual.containers import (
Center,
Horizontal,
HorizontalScroll,
Middle,
Vertical,
VerticalScroll,
)
from textual.widgets import Label
async def test_horizontal_vs_horizontalscroll_scrolling():
... | 122 | 3,692 |
probability | tensorflow_probability/python/internal/test_combinations_test.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... | 98 | 2,636 |
wagtail | wagtail/test/customuser/forms.py | .py | from django import forms
from wagtail.users.forms import UserCreationForm, UserEditForm
class CustomUserCreationForm(UserCreationForm):
country = forms.CharField(required=True, label="Country")
attachment = forms.FileField(required=True, label="Attachment")
class Meta(UserCreationForm.Meta):
fie... | 20 | 661 |
ipython | IPython/core/tips.py | .py | from __future__ import annotations
from datetime import datetime
import importlib.util
import os
import sys
from typing import Any
_tips: Any = {
# (month, day)
"every_year": {
(1, 1): "Happy new year!",
# European time:
# [2/8/25, 23:28:24] Fernando Perez: Hi! Yes, this was my first pu... | 136 | 6,907 |
pymc | benchmarks/benchmarks/benchmarks.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... | 314 | 11,082 |
gunicorn | tests/test_dirty_arbiter.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for dirty arbiter module."""
import asyncio
import os
import signal
import struct
import tempfile
import pytest
from gunicorn.config import Config
from gunicorn.dirty.arbiter import DirtyArbiter
from gun... | 1,430 | 42,883 |
mlflow | mlflow/store/artifact/artifact_repository_registry.py | .py | import warnings
from mlflow.exceptions import MlflowException
from mlflow.store.artifact.artifact_repo import ArtifactRepository
from mlflow.store.artifact.azure_blob_artifact_repo import AzureBlobArtifactRepository
from mlflow.store.artifact.azure_data_lake_artifact_repo import AzureDataLakeArtifactRepository
from ml... | 171 | 7,979 |
astropy | astropy/cosmology/_src/io/builtin/cosmology.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""|Cosmology| I/O, using |Cosmology.to_format| and |Cosmology.from_format|.
This module provides functions to transform a |Cosmology| object to and from another
|Cosmology| object. The functions are registered with ``convert_registry`` under the
format n... | 120 | 3,698 |
pymc | pymc/distributions/custom.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... | 875 | 32,654 |
loguru | tests/exceptions/source/modern/grouped_as_cause_and_context.py | .py | import sys
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="", diagnose=True, backtrace=True, colorize=False)
def a():
1 / 0
def b():
raise ValueError("Error")
@logger.catch
def main():
try:
a()
except Exception as err:
error_1 = err
try:
b()
... | 43 | 829 |
luigi | luigi/contrib/salesforce.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... | 684 | 26,833 |
coremltools | coremltools/converters/mil/mil/ops/tests/iOS14/test_elementwise_unary.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 itertools
import numpy as np
import pytest
import scipy
from coremltools.converters.mil.mil ... | 660 | 23,802 |
beam | sdks/python/apache_beam/examples/inference/run_inference_side_inputs.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... | 166 | 5,704 |
mlflow | mlflow/tracing/export/utils.py | .py | """
Utility functions for prompt linking in trace exporters.
"""
import logging
import threading
import uuid
from typing import Sequence
from mlflow.entities.model_registry import PromptVersion
from mlflow.tracing.client import TracingClient
_logger = logging.getLogger(__name__)
def try_link_prompts_to_trace(
... | 71 | 2,201 |
onnxruntime | onnxruntime/test/python/transformers/test_gqa_cpu_quantized.py | .py | # --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
"""Tests for CPU GroupQueryAttention with quantized KV cache (INT8/INT... | 1,035 | 38,210 |
probability | tensorflow_probability/python/distributions/linear_gaussian_ssm.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... | 2,088 | 92,859 |
beam | sdks/python/apache_beam/io/aws/clients/s3/fake_client.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... | 238 | 7,762 |
mkdocs | mkdocs/tests/search_tests.py | .py | #!/usr/bin/env python
import json
import unittest
from unittest import mock
from mkdocs.config.config_options import ValidationError
from mkdocs.contrib import search
from mkdocs.contrib.search import search_index
from mkdocs.structure.files import File
from mkdocs.structure.pages import Page
from mkdocs.structure.to... | 634 | 24,300 |
coremltools | coremltools/converters/mil/mil/ops/defs/iOS15/__init__.py | .py | # Copyright (c) 2022, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from coremltools.converters.mil._deployment_compatibility import \
AvailableTarget as target
_IOS... | 53 | 3,183 |
readthedocs.org | readthedocs/api/v2/views/model_views.py | .py | """Endpoints for listing Projects, Versions, Builds, etc."""
import json
from dataclasses import asdict
import structlog
from allauth.socialaccount.models import SocialAccount
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.db.models import BooleanField
from django.db.... | 587 | 21,942 |
astropy | astropy/visualization/scripts/tests/test_fits2bitmap.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from astropy.io import fits
from astropy.utils.compat.optional_deps import HAS_MATPLOTLIB
if HAS_MATPLOTLIB:
import matplotlib.image as mpimg
from astropy.visualization.scripts.fits2bitmap import fits2bitmap, ma... | 71 | 2,300 |
metrics | src/torchmetrics/functional/clustering/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... | 80 | 2,616 |
saleor | saleor/graphql/webhook/tests/mutations/test_webhook_trigger.py | .py | import datetime
import json
from unittest import mock
import graphene
import pytest
from freezegun import freeze_time
from .....core import EventDeliveryStatus
from .....graphql.tests.utils import get_graphql_content
from .....webhook.error_codes import WebhookTriggerErrorCode
from .....webhook.event_types import Web... | 438 | 14,480 |
biopython | Bio/SCOP/Des.py | .py | # Copyright 2001 by Gavin E. Crooks. 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.
"""Handle the SCOP DEScri... | 90 | 3,004 |
hatch | src/hatch/plugin/utils.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from hatch.env.collectors.plugin.interface import EnvironmentCollectorInterface
def load_plugin_from_script(
path: str, script_name: str, plugin_class: type[EnvironmentCollectorInterface], plugin_id: str
) -> type[Environm... | 47 | 1,472 |
wandb | tests/system_tests/test_functional/metaflow/flow_decoboth.py | .py | """Test Metaflow Flow integration"""
import os
import pathlib
import pandas as pd
import wandb
from metaflow import FlowSpec, Parameter, step
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
from wandb.integration.metaf... | 59 | 1,709 |
probability | tensorflow_probability/python/distributions/normal_conjugate_posteriors_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... | 235 | 9,900 |
clearml | clearml/task_parameters.py | .py | from typing import (
Optional,
Union,
Iterable,
List,
Callable,
Tuple,
Type,
Dict,
TYPE_CHECKING,
Any,
)
import attr
from attr import validators
if TYPE_CHECKING:
from clearml import Task
__all__ = ["range_validator", "param", "percent_param", "TaskParameters"]
def _cano... | 177 | 5,455 |
astropy | astropy/wcs/wcsapi/wrappers/__init__.py | .py | from .base import BaseWCSWrapper
from .sliced_wcs import *
| 3 | 59 |
astropy | astropy/visualization/wcsaxes/formatter_locator.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This file defines the AngleFormatterLocator class which is a class that
# provides both a method for a formatter and one for a locator, for a given
# label spacing. The advantage of keeping the two connected is that we need to
# make sure that the form... | 661 | 22,148 |
saleor | saleor/seo/models.py | .py | from django.core.validators import MaxLengthValidator
from django.db import models
from ..core.utils.translations import Translation
class SeoModel(models.Model):
seo_title = models.CharField(
max_length=70, blank=True, null=True, validators=[MaxLengthValidator(70)]
)
seo_description = models.Cha... | 48 | 1,293 |
mlflow | examples/mlflow-3/register_model.py | .py | import json
from sklearn.linear_model import LinearRegression
import mlflow
client = mlflow.MlflowClient()
with mlflow.start_run():
model = LinearRegression().fit([[1], [2]], [3, 4])
model_info = mlflow.sklearn.log_model(
model,
name="model",
params={
"alpha": 0.5,
... | 71 | 2,072 |
confluent-kafka-python | examples/oauth_oidc_ccloud_producer.py | .py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2020 Confluent Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | 124 | 4,965 |
openvino | src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import csv
import datetime
import heapq
import os
import shlex
import sys
import threading
from argparse import ArgumentParser
from hashlib import sha256
from pathlib import Path
from shutil import rmtree, copyfile
from subprocess import ... | 1,090 | 46,443 |
onnxruntime | onnxruntime/python/tools/transformers/models/llama/benchmark.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 a... | 701 | 26,594 |
gunicorn | gunicorn/app/base.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import importlib.util
import importlib.machinery
import os
import sys
import traceback
from gunicorn import util
from gunicorn.arbiter import Arbiter
from gunicorn.config import Config, get_default_config_file
from... | 236 | 7,370 |
lemur | lemur/plugins/bases/metric.py | .py | """
.. module: lemur.plugins.bases.metric
: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 lemur.plugins.base import Plugin
class MetricPlugin(Plugin):
type = "met... | 19 | 468 |
biopython | Bio/Phylo/_utils.py | .py | # Copyright (C) 2009 by Eric Talevich (eric.talevich@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.
"""Utilities for ... | 622 | 22,303 |
sqlmap | tests/test_brute.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Unit coverage for lib/utils/brute.py.
tableExists / columnExists are driven with conf.direct=True and the external
collaborators (inject.checkBooleanExpression, getFileItems, runThre... | 224 | 9,261 |
sphinx | tests/roots/test-ext-autosummary-imported_members/conf.py | .py | import sys
from pathlib import Path
sys.path.insert(0, str(Path.cwd().resolve()))
extensions = ['sphinx.ext.autosummary']
autosummary_generate = True
autosummary_imported_members = True
| 9 | 188 |
pyomo | pyomo/solvers/tests/mip/test_solver.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... | 73 | 2,314 |
textual | docs/examples/widgets/log.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Log
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its p... | 29 | 743 |
pyro | pyro/contrib/tracking/hashing.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import heapq
import itertools
from collections import defaultdict
from numbers import Number
import torch
class LSH:
"""
Implements locality-sensitive hashing for low-dimensional euclidean space.
Allows to efficien... | 220 | 7,266 |
jupytext | tests/functional/cli/test_synchronous_changes.py | .py | """
These tests ensure that Jupytext raises an error when a file loaded by Jupytext
changes while Jupytext is running.
To make the simultaneous change occur in the tests, we monkey-patch the function `create_prefix_dir`
which is called just before writing the file back to disk.
"""
from jupytext import cli
from jupyt... | 112 | 4,449 |
probability | tensorflow_probability/python/internal/assert_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... | 134 | 4,703 |
onnxruntime | onnxruntime/test/testdata/model_with_metadata.py | .py | import onnx
from onnx import TensorProto, helper
# Create a model with metadata to test ORT conversion
def GenerateModel(model_name): # noqa: N802
nodes = [
helper.make_node("Sigmoid", ["X"], ["Y"], "sigmoid"),
]
graph = helper.make_graph(
nodes,
"NNAPI_Internal_uint8_Test",
... | 38 | 977 |
pyomo | pyomo/gdp/tests/test_fix_disjuncts.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... | 188 | 6,781 |
pymc | scripts/slowest_tests/extract-slow-tests.py | .py | """Parse the GitHub action log for test times.
Taken from https://github.com/pymc-labs/pymc-marketing/tree/main/scripts/slowest_tests/extract-slow-tests.py
"""
import re
import sys
from pathlib import Path
start_pattern = re.compile(r"==== slow")
separator_pattern = re.compile(r"====")
time_pattern = re.compile(r"... | 81 | 1,847 |
textual | tests/snapshot_tests/snapshot_apps/markdown_component_classes_reloading.py | .py | from pathlib import Path
from textual.app import App, ComposeResult
from textual.widgets import Markdown
CSS_PATH = (Path(__file__) / "../markdown_component_classes_reloading.tcss").resolve()
CSS_PATH.write_text(
"""\
.code_inline,
.em,
.strong,
.s,
.markdown-table--header,
.markdown-table--lines,
{
color: y... | 51 | 751 |
probability | tensorflow_probability/python/distributions/autoregressive_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... | 335 | 13,646 |
pyomo | pyomo/solvers/tests/models/base.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... | 479 | 19,016 |
saleor | saleor/graphql/product/tests/queries/products_filtrations/test_over_references_collections.py | .py | import pytest
from ......attribute import AttributeEntityType, AttributeInputType, AttributeType
from ......attribute.models import Attribute, AttributeValue
from ......attribute.utils import associate_attribute_values_to_instance
from .....core.utils import to_global_id_or_none
from .....tests.utils import get_graphq... | 304 | 10,013 |
openvino | tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_simplernn.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 TestKerasSimpleRNN(CommonTF2LayerTest):
def create_keras_simplernn_net(self, input_names, input_shapes, input_type,
... | 127 | 6,927 |
onnx | onnx/backend/test/case/node/batchnorm.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
def _batchnorm_test_mode(x, s, bias, mean, var, epsilon=1e-5):
dims_x = ... | 138 | 4,732 |
mlflow | tests/sklearn/test_sklearn_model_export.py | .py | import json
import os
import pickle
import shutil
import tempfile
from pathlib import Path
from typing import Any, NamedTuple
from unittest import mock
import cloudpickle
import numpy as np
import pandas as pd
import pytest
import sklearn
import sklearn.linear_model as glm
import sklearn.naive_bayes as nb
import sklea... | 1,024 | 38,920 |
pyomo | pyomo/contrib/piecewise/transform/piecewise_to_mip_visitor.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... | 55 | 2,219 |
mlflow | mlflow/metrics/genai/metric_definitions.py | .py | from typing import Any
from mlflow.exceptions import MlflowException
from mlflow.metrics.genai.base import EvaluationExample
from mlflow.metrics.genai.genai_metric import make_genai_metric
from mlflow.metrics.genai.utils import _MIGRATION_GUIDE, _get_latest_metric_version
from mlflow.models import EvaluationMetric
fro... | 457 | 23,122 |
beam | sdks/python/apache_beam/examples/inference/runinference_metrics/pipeline/transformations.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... | 95 | 4,018 |
wandb | tests/unit_tests/test_launch/test_runner/conftest.py | .py | import asyncio
from typing import Any
from unittest.mock import MagicMock
import pytest
from wandb.sdk.launch.agent.agent import LaunchAgent
from wandb.sdk.launch.runner.kubernetes_monitor import LaunchKubernetesMonitor
class MockDict(dict):
# use a dict to mock an object
__getattr__ = dict.get
__setattr... | 198 | 5,980 |
pyfilesystem2 | fs/opener/tarfs.py | .py | # coding: utf-8
"""`TarFS` opener definition.
"""
from __future__ import absolute_import, print_function, unicode_literals
import typing
from .base import Opener
from .errors import NotWriteable
from .registry import registry
if typing.TYPE_CHECKING:
from typing import Text
from ..tarfs import TarFS # noq... | 41 | 925 |
pdm | src/pdm/environments/base.py | .py | from __future__ import annotations
import abc
import os
import re
import shutil
import subprocess
import sys
import tempfile
import weakref
from collections.abc import Generator
from contextlib import contextmanager
from functools import cached_property
from pathlib import Path
from typing import TYPE_CHECKING
from p... | 327 | 12,564 |
pyomo | pyomo/contrib/incidence_analysis/tests/test_scc_solver.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... | 521 | 21,186 |
coremltools | coremltools/converters/mil/mil/ops/defs/iOS15/control_flow.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 copy
import numpy as np
from coremltools import _logger as logger
from coremltools.converter... | 860 | 29,691 |
metrics | src/torchmetrics/functional/classification/cohen_kappa.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... | 272 | 11,633 |
saleor | saleor/graphql/product/tests/queries/products_filtrations/shared.py | .py | PRODUCTS_WHERE_QUERY = """
query($where: ProductWhereInput!, $channel: String) {
products(first: 10, where: $where, channel: $channel) {
edges {
node {
id
name
slug
}
}
}
}
"""
PRODUCTS_FILTER_QUERY = """
query($where: Produ... | 27 | 541 |
beam | sdks/python/apache_beam/dataframe/transforms.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... | 627 | 22,840 |
textual | docs/examples/widgets/collapsible.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Collapsible, Footer, Label, Markdown
LETO = """\
# Duke Leto I Atreides
Head of House Atreides."""
JESSICA = """
# Lady Jessica
Bene Gesserit and concubine of Leto, and mother of Paul and Alia.
"""
PAUL = """
# Paul Atreides
Son of Leto and Je... | 47 | 1,157 |
returns | tests/test_io/test_ioresult_container/test_ioresult_values.py | .py | import pytest
from returns.io import IO, IOFailure, IOSuccess
from returns.primitives.exceptions import UnwrapFailedError
def test_ioresult_value_or():
"""Ensures that ``value_or`` works correctly."""
assert IOSuccess(1).value_or(0) == IO(1)
assert IOFailure(1).value_or(0) == IO(0)
def test_unwrap_iosu... | 44 | 1,249 |
mlflow | mlflow/tracing/enablement.py | .py | """
Trace enablement functionality for MLflow to enable tracing to Databricks Storage.
"""
import logging
import mlflow
from mlflow.entities.trace_location import UCSchemaLocation
from mlflow.exceptions import MlflowException
from mlflow.utils.uri import is_databricks_uri
from mlflow.version import IS_TRACING_SDK_ONL... | 161 | 5,949 |
mlflow | tests/pyfunc/sample_code/func_code_with_config.py | .py | from mlflow.models import ModelConfig, set_model
def predict(model_input: list[str]):
model_config = ModelConfig(development_config="tests/pyfunc/sample_code/config.yml")
timeout = model_config.get("timeout")
return f"This was the input: {model_input[0]}, timeout {timeout}"
set_model(predict)
| 11 | 310 |
sphinx | tests/test_util/test_util_fileutil.py | .py | """Tests sphinx.util.fileutil functions."""
from __future__ import annotations
import re
from pathlib import Path
from typing import TYPE_CHECKING
from unittest import mock
import pytest
from sphinx._cli.util.errors import strip_escape_sequences
from sphinx.jinja2glue import BuiltinTemplateLoader
from sphinx.util.f... | 172 | 6,236 |
eve | tests/methods/common.py | .py | import time
from collections import OrderedDict # noqa
from datetime import datetime
from random import shuffle
import simplejson as json
from bson import ObjectId, decimal128
from bson.dbref import DBRef
from eve.methods.common import normalize_dotted_fields, serialize, sort_per_resource
from eve.utils import confi... | 776 | 29,165 |
mlflow | mlflow/server/workspace_helpers.py | .py | from __future__ import annotations
import logging
import os
from flask import Response, request
from mlflow.entities import Workspace
from mlflow.environment_variables import (
MLFLOW_ENABLE_WORKSPACES,
MLFLOW_WORKSPACE_STORE_URI,
)
from mlflow.exceptions import MlflowException
from mlflow.protos import data... | 156 | 5,455 |
saleor | saleor/tests/e2e/account/utils/token_create.py | .py | from ...utils import get_graphql_content
TOKEN_CREATE_MUTATION = """
mutation TokenCreate($email: String!, $password: String!) {
tokenCreate(email: $email, password: $password) {
errors {
field
message
code
}
token
refreshToken
user {
id
email
isActive
is... | 60 | 1,132 |
pyfilesystem2 | tests/test_fscompat.py | .py | from __future__ import unicode_literals
import six
import unittest
from fs._fscompat import fsdecode, fsencode, fspath
class PathMock(object):
def __init__(self, path):
self._path = path
def __fspath__(self):
return self._path
class BrokenPathMock(object):
def __init__(self, path):
... | 62 | 1,563 |
sqlmap | lib/core/target.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import functools
import os
import re
import subprocess
import sys
import tempfile
import time
from lib.core.common import Backend
from lib.core.common import getSafeExString
from... | 832 | 38,276 |
onnxruntime | orttraining/orttraining/python/training/optim/fused_adam.py | .py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# fused_adam.py
# This file has been adapted from microsoft/DeepSpeed
"""
Copyright 2020 The Microsoft DeepSpeed Team
Copyright NVIDIA/apex
This file is adapted from fused adam in NVIDIA/apex, commit a109f85
"""
import warn... | 293 | 12,791 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.