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 |
|---|---|---|---|---|---|
ipython | IPython/utils/capture.py | .py | """IO capturing utilities."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
from __future__ import annotations
import sys
from io import StringIO
from types import TracebackType
from typing import Any
#-----------------------------------------------------------... | 178 | 5,448 |
clearml | clearml/utilities/pigar/reqs.py | .py | # -*- coding: utf-8 -*-
from __future__ import print_function, division, absolute_import
import ast
import collections
import doctest
import fnmatch
import functools
import importlib
import json
import os
import sys
from typing import Tuple, Set, Optional, Callable, Union, Dict, Any
import six
from pathlib2 import P... | 512 | 19,663 |
mlflow | examples/sktime/score_model.py | .py | import pandas as pd
import requests
from sktime.datasets import load_longley
from sktime.forecasting.model_selection import temporal_train_test_split
y, X = load_longley()
y_train, y_test, X_train, X_test = temporal_train_test_split(y, X)
# Define local host and endpoint url
host = "127.0.0.1"
url = f"http://{host}:5... | 35 | 1,253 |
readthedocs.org | readthedocs/core/utils/__init__.py | .py | """Common utility functions."""
import re
import structlog
from django.conf import settings
from django.core.mail import EmailMessage
from django.core.mail import EmailMultiAlternatives
from django.template.loader import render_to_string
from django.utils.functional import keep_lazy
from django.utils.safestring impor... | 483 | 16,878 |
probability | tensorflow_probability/python/math/root_search.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... | 652 | 29,229 |
hypercorn | compliance/autobahn/summarise.py | .py | import json
import sys
with open('reports/servers/index.json') as file_:
report = json.load(file_)
failures = sum(value['behavior'] == 'FAILED' for value in report['websockets'].values())
if failures > 0:
sys.exit(1)
else:
sys.exit(0)
| 13 | 250 |
cvxpy | cvxpy/lin_ops/lin_utils.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... | 833 | 19,938 |
pyomo | pyomo/opt/parallel/manager.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... | 241 | 7,540 |
kafka | tests/unit/version/check_version.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 ... | 33 | 1,257 |
textual | src/textual/_xterm_parser.py | .py | from __future__ import annotations
import os
import re
from functools import lru_cache
from typing import Any, Generator, Iterable
from typing_extensions import Final
from textual import constants, events, messages
from textual._ansi_sequences import ANSI_SEQUENCES_KEYS, IGNORE_SEQUENCE
from textual._keyboard_protoc... | 469 | 18,334 |
hydra | tests/instantiate/test_positional.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from textwrap import dedent
from typing import Any
from pytest import mark, param, raises
from hydra.errors import InstantiationException
from hydra.utils import UNSAFE_ALLOW_ALL_TARGETS, instantiate
from tests.instantiate import ArgsClass
def u... | 292 | 8,549 |
onnxruntime | onnxruntime/test/python/transformers/benchmark_gqa_cpu_flash.py | .py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Benchmark CPU GroupQueryAttention: Flash Attention vs Naive (full materialization).
Runs the actual GQA operator via InferenceSession, toggling between flash and
naive paths using the ORT_GQA_DISAB... | 403 | 14,252 |
returns | tests/test_result/test_result_unwrap.py | .py | import pytest
from returns.primitives.exceptions import UnwrapFailedError
from returns.result import Failure, Success
def test_unwrap_success():
"""Ensures that unwrap works for Success container."""
assert Success(5).unwrap() == 5
def test_unwrap_failure():
"""Ensures that unwrap works for Failure con... | 27 | 752 |
luigi | test/batch_notifier_test.py | .py | # coding=utf-8
import unittest
from smtplib import SMTPServerDisconnected
import mock
import luigi.batch_notifier
BATCH_NOTIFIER_DEFAULTS = {
"error_lines": 0,
"error_messages": 0,
"group_by_error_messages": False,
}
class BatchNotifier(luigi.batch_notifier.BatchNotifier):
"""BatchNotifier class wi... | 456 | 19,945 |
beam | sdks/python/apache_beam/pipeline.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 1,771 | 72,531 |
mlflow | tests/genai/utils/test_display_utils.py | .py | from unittest import mock
import mlflow
from mlflow.genai.utils import display_utils
from mlflow.store.tracking.rest_store import RestStore
from mlflow.tracking.client import MlflowClient
from mlflow.utils.mlflow_tags import MLFLOW_DATABRICKS_WORKSPACE_URL
def test_display_outputs_jupyter(monkeypatch):
mock_stor... | 81 | 3,188 |
openvino | src/frontends/tensorflow/tests/test_models/gen_scripts/generate_partitioned_call_with_conv.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import numpy as np
import tensorflow.compat.v1 as tf
def main():
'''
This test model aims to test that the conversion for the body graphs is performed with set input shapes
that allows to get more opti... | 39 | 1,304 |
pymc | pymc/backends/ndarray.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... | 243 | 8,456 |
openvino | tests/model_hub_tests/models_hub_common/multiprocessing_utils.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging as log
import os
import signal
import sys
import traceback
from multiprocessing import Process, Queue, TimeoutError, ProcessError
from queue import Empty as QueueEmpty
from typing import Union
from collections.abc import C... | 95 | 3,666 |
wandb | tests/unit_tests/test_lib/test_progress.py | .py | from collections.abc import Generator
import pytest
from wandb.proto import wandb_internal_pb2 as pb
from wandb.sdk.lib import printer as p
from wandb.sdk.lib import progress
from tests.fixtures.emulated_terminal import EmulatedTerminal
from tests.fixtures.mock_wandb_log import MockWandbLog
@pytest.fixture()
def dy... | 310 | 9,236 |
mkdocs | mkdocs/contrib/search/search_index.py | .py | from __future__ import annotations
import json
import logging
import os
import re
import subprocess
from html.parser import HTMLParser
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mkdocs.structure.pages import Page
from mkdocs.structure.toc import AnchorLink, TableOfContents
try:
from lunr imp... | 226 | 7,945 |
textual | tests/toggles/test_radioset.py | .py | from __future__ import annotations
from textual.app import App, ComposeResult
from textual.widgets import RadioButton, RadioSet
class RadioSetApp(App[None]):
def __init__(self):
super().__init__()
self.events_received = []
def compose(self) -> ComposeResult:
with RadioSet(id="from_bu... | 184 | 6,980 |
qutip | qutip/core/data/extract.py | .py | from . import Dense, CSR, Dia
from .dispatch import Dispatcher as _Dispatcher
from ._scipy_sparse import csr_as_matrix, dia_as_matrix
import inspect as _inspect
__all__ = ["extract"]
def extract_dense(matrix, format=None, copy=True):
"""
Return an array representation of the Dense data object.
Paramete... | 146 | 4,691 |
hydra | tools/configen/tests/test_modules/default_flags/both.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# Generated by configen, do not edit.
# See https://github.com/hydra-ecosystem/hydra/tree/main/tools/configen
# fmt: off
# isort:skip_file
# flake8: noqa
from dataclasses import dataclass, field
@dataclass
class EmptyConf:
_target_: str = "te... | 16 | 400 |
hydra | tests/test_completion.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import re
import shutil
import subprocess
import sys
from pathlib import Path
from typing import List
from packaging import version
from pytest import mark, param, skip, xfail
from hydra._internal.config_loader_impl import ConfigLoaderIm... | 552 | 17,906 |
probability | tensorflow_probability/python/bijectors/discrete_cosine_transform.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,667 |
wagtail | wagtail/embeds/exceptions.py | .py | class EmbedException(Exception):
pass
class EmbedUnsupportedProviderException(EmbedException):
pass
class EmbedNotFoundException(EmbedException):
pass
| 11 | 167 |
clearml | clearml/utilities/proxy_object.py | .py | import itertools
import json
from copy import copy
from logging import getLogger
from typing import Callable, Union, Optional, Mapping, Tuple, Dict, Any
import yaml
class ProxyDictPostWrite(dict):
"""Dictionary wrapper that updates an arguments instance on any item set in the dictionary"""
def __init__(
... | 537 | 17,487 |
probability | tensorflow_probability/python/experimental/auto_batching/instructions.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,519 | 56,518 |
beam | sdks/python/apache_beam/dataframe/expressions.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... | 417 | 14,945 |
conda | tests/test_features.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from conda.testing.integration import package_is_installed
if TYPE_CHECKING:
from pathlib import Path
from conda.testing.fixtures import CondaCLIFixtu... | 104 | 3,752 |
returns | tests/test_curry/test_curry.py | .py | from inspect import getdoc
import pytest
from returns.curry import curry
def test_docstring():
"""Ensures that we preserve docstrings from curried function."""
@curry
def factory(arg: int, other: int) -> None:
"""Some docstring."""
assert getdoc(factory) == 'Some docstring.'
def test_imm... | 195 | 4,754 |
sqlmap | extra/dbwire/firebird.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
"""
Minimal pure-python Firebird wire-protocol client (stdlib only, no firebirdsql).
Speaks the Firebird v13-17 protocol (Firebird 3/4/5): op_connect, SRP-256 authentication, Cha... | 871 | 32,808 |
coremltools | coremltools/converters/mil/frontend/torch/torch_op_registry.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 typing import Callable
import torch
from coremltools import _logger as logger
from coremltools... | 167 | 6,223 |
jupyterlab | jupyterlab/tests/conftest.py | .py | # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import pytest
from jupyterlab import __version__
from jupyterlab.handlers.announcements import (
CheckForUpdate,
CheckForUpdateHandler,
NewsHandler,
check_update_handler_path,
news_handler_path,
)
... | 48 | 1,327 |
jupytext | tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/Notebook_with_R_magic.py | .py | # ---
# jupyter:
# jupytext:
# cell_markers: region,endregion
# kernelspec:
# display_name: Python 2
# language: python
# name: python2
# ---
# # A notebook with R cells
#
# This notebook shows the use of R cells to generate plots
# %load_ext rpy2.ipython
# region language="R"
# suppressMessages(... | 30 | 742 |
pyomo | pyomo/gdp/plugins/hull.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... | 2,046 | 88,859 |
openvino | src/bindings/python/docs/examples/openvino/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore # mypy issue #1422
| 6 | 207 |
wandb | wandb/sdk/artifacts/artifact_download_logger.py | .py | """Artifact download logger."""
from __future__ import annotations
import multiprocessing.dummy
import time
from collections.abc import Callable
from wandb.errors.term import termlog
class ArtifactDownloadLogger:
def __init__(
self,
nfiles: int,
clock_for_testing: Callable[[], float] = ... | 46 | 1,546 |
pymc | pymc/_deprecations.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... | 130 | 4,668 |
coremltools | deps/protobuf/python/google/protobuf/reflection.py | .py | # Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redi... | 96 | 3,779 |
pyomo | pyomo/_archive/component_set.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 | 662 |
metrics | src/torchmetrics/functional/regression/r2.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... | 175 | 6,613 |
pyomo | pyomo/solvers/tests/models/MILP_discrete_var_bounds.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... | 79 | 2,881 |
wagtail | wagtail/snippets/tests/test_unschedule_view.py | .py | import datetime
from django.contrib.admin.utils import quote
from django.contrib.auth.models import Permission
from django.test import TestCase
from django.urls import reverse
from django.utils.timezone import now
from wagtail.log_actions import registry as log_registry
from wagtail.models import Revision
from wagtai... | 166 | 5,812 |
onnxruntime | onnxruntime/python/tools/transformers/fusion_attention_vae.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
from logging import getLogger
import numpy as np
from fusion_base impor... | 301 | 12,079 |
onnxruntime | onnxruntime/python/tools/transformers/models/gpt2/__init__.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import os.path
import sys
sys.path.append(os.path.dirname(__file__))
t... | 13 | 483 |
gunicorn | tests/docker/per_app_allocation/gunicorn_conf.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Gunicorn configuration for per-app worker allocation e2e tests.
Configuration:
- 4 dirty workers total
- LightweightApp: loads on ALL 4 workers (workers=None)
- HeavyApp: loads on 2 workers (via class attribut... | 39 | 934 |
sqlmap | plugins/dbms/presto/takeover.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.exception import SqlmapUnsupportedFeatureException
from plugins.generic.takeover import Takeover as GenericTakeover
class Takeover(GenericTakeover):
def osCmd(s... | 29 | 970 |
pyomo | examples/doc/samples/scripts/s1/script.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... | 29 | 905 |
sqlmap | plugins/dbms/hana/filesystem.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.exception import SqlmapUnsupportedFeatureException
from plugins.generic.filesystem import Filesystem as GenericFilesystem
class Filesystem(GenericFilesystem):
d... | 19 | 675 |
cvxpy | cvxpy/reductions/solvers/compr_matrix.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... | 110 | 3,749 |
wagtail | wagtail/images/tests/test_management_commands.py | .py | import re
import warnings
from io import StringIO
from django.core import management
from django.test import TestCase, override_settings
from ..management.commands.wagtail_update_image_renditions import progress_bar
from .utils import Image, get_test_image_file
# note .utils.Image already does get_image_model()
Rend... | 141 | 5,712 |
hydra | tests/test_apps/defaults_in_schema_missing/my_app.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from dataclasses import dataclass
from typing import Any, List
from omegaconf import MISSING, DictConfig, OmegaConf
import hydra
from hydra.core.config_store import ConfigStore
@dataclass
class DBConfig:
driver: str = MISSING
host: str =... | 44 | 909 |
saleor | saleor/graphql/account/tests/fixtures/benchmark.py | .py | import pytest
from prices import Money, TaxedMoney
from .....account.models import CustomerEvent, User
from .....giftcard.models import GiftCard
from .....order.models import Order
from .utils import (
create_permission_groups,
prepare_events_for_user,
prepare_gift_cards_for_user,
)
@pytest.fixture
def u... | 58 | 1,820 |
pyfilesystem2 | tests/test_errors.py | .py | from __future__ import unicode_literals
import multiprocessing
import unittest
from six import text_type
from fs import errors
from fs.errors import CreateFailed
class TestErrors(unittest.TestCase):
def test_str(self):
err = errors.FSError("oh dear")
repr(err)
self.assertEqual(text_type(... | 65 | 1,910 |
beam | sdks/python/apache_beam/runners/interactive/interactive_beam.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 1,112 | 43,739 |
textual | src/textual/renderables/bar.py | .py | from __future__ import annotations
from rich.console import Console, ConsoleOptions, RenderResult
from rich.style import Style, StyleType
from rich.text import Text
from textual.color import Gradient
class Bar:
"""Thin horizontal bar with a portion highlighted.
Args:
highlight_range: The range to h... | 156 | 5,112 |
pyro | examples/vae/utils/custom_mlp.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from inspect import isclass
import torch
import torch.nn as nn
from pyro.distributions.util import broadcast_shape
class Exp(nn.Module):
"""
a custom module for exponentiation of tensors
"""
def __init__(self):... | 204 | 6,871 |
hatch | tests/helpers/templates/wheel/standard_editable_pth_extra_dependencies.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.default import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
metadata_direc... | 50 | 1,419 |
pymc | pymc/gp/mean.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... | 104 | 2,486 |
sqlmap | tests/test_checks.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Unit tests for lib/controller/checks.py driven with a MOCKED HTTP layer.
checks.py is the injection-detection controller; almost everything in it goes
through the network seam (lib.r... | 501 | 21,238 |
ipython | tests/test_cve.py | .py | """
Test that CVEs stay fixed.
"""
from IPython.utils.tempdir import TemporaryDirectory, TemporaryWorkingDirectory
from pathlib import Path
import random
import sys
import os
import string
import subprocess
def test_cve_2022_21699():
"""
Here we test CVE-2022-21699.
We create a temporary directory, cd i... | 67 | 1,999 |
mlflow | tests/genai/discovery/test_utils.py | .py | import time
from unittest import mock
import pytest
from mlflow.entities.issue import Issue, IssueStatus
from mlflow.entities.trace import Trace
from mlflow.entities.trace_data import TraceData
from mlflow.entities.trace_info import TraceInfo
from mlflow.entities.trace_location import TraceLocation
from mlflow.entiti... | 377 | 12,016 |
mlflow | tests/store/tracking/sqlalchemy_store/test_sqlalchemy_store_experiments.py | .py | import json
import time
import uuid
from pathlib import Path
import pytest
from mlflow import entities
from mlflow.entities import (
Experiment,
ExperimentTag,
LoggedModelStatus,
RunStatus,
TraceState,
ViewType,
)
from mlflow.environment_variables import MLFLOW_TRACKING_URI
from mlflow.excepti... | 956 | 38,781 |
mlflow | mlflow/genai/labeling/__init__.py | .py | """
Databricks Agent Labeling Python SDK. For more details see Databricks Agent Evaluation:
<https://docs.databricks.com/en/generative-ai/agent-evaluation/index.html>
The API docs can be found here:
<https://api-docs.databricks.com/python/databricks-agents/latest/databricks_agent_eval.html#review-app>
"""
from typing... | 134 | 4,360 |
beam | learning/tour-of-beam/learning-content/core-transforms/motivating-challenge-3/python-challenge/task.py | .py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); y... | 82 | 2,624 |
mlflow | tests/gateway/providers/test_sap_ai_core.py | .py | from typing import Any
from unittest import mock
import pytest
from mlflow.exceptions import MlflowException
from mlflow.gateway.config import EndpointConfig
from mlflow.gateway.providers.sap_ai_core import (
SapAiCoreAdapter,
SapAiCoreConfig,
SapAiCoreProvider,
)
def _make_endpoint_config(model_name: s... | 371 | 12,817 |
scikit-optimize | skopt/tests/test_callbacks.py | .py | import pytest
import numpy as np
import os
from collections import namedtuple
from skopt import dummy_minimize
from skopt import gp_minimize
from skopt.benchmarks import bench1
from skopt.benchmarks import bench3
from skopt.callbacks import TimerCallback
from skopt.callbacks import DeltaYStopper
from skopt.callbacks ... | 123 | 3,735 |
deap | examples/ga/nsga2.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 ... | 145 | 5,160 |
sphinx | sphinx/builders/changes.py | .py | """Changelog builder."""
from __future__ import annotations
import html
from typing import TYPE_CHECKING
from sphinx import package_dir
from sphinx._cli.util.colour import bold
from sphinx.builders import Builder
from sphinx.locale import _, __
from sphinx.theming import HTMLThemeFactory
from sphinx.util import logg... | 200 | 7,190 |
openvino | src/frontends/paddle/tests/test_models/gen_scripts/generate_grid_sampler.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# grid_sampler paddle model generator
#
import paddle
import numpy as np
from save_model import saveModel
import sys
def grid_sampler(name: str, x, grid, mode="bilinear", padding_mode="zeros", align_corners=True, not_empty=True,
... | 62 | 2,555 |
django-cms | cms/plugin_processors.py | .py | from django.utils.safestring import mark_safe
def plugin_meta_context_processor(instance, placeholder, context):
return {
'plugin': {
'counter': instance._render_meta.index + 1,
'counter0': instance._render_meta.index,
'revcounter': instance._render_meta.total - instanc... | 22 | 883 |
sphinx | tests/roots/test-ext-viewcode/conf.py | .py | import sys
from pathlib import Path
from sphinx.ext.linkcode import add_linkcode_domain
sys.path.insert(0, str(Path.cwd().resolve()))
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
exclude_patterns = ['_build']
if 'test_linkcode' in tags: # NoQA: F821 (tags is injected into conf.py)
extensions.rem... | 31 | 972 |
beam | sdks/python/apache_beam/ml/anomaly/detectors/robust_zscore.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... | 117 | 4,313 |
coremltools | deps/kmeans1d/setup.py | .py | import os
import setuptools
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
class BuildExt(build_ext):
"""A custom build extension for adding -stdlib arguments for clang++."""
def build_extensions(self):
# '-std=c++11' is added to `extra_compile_args` so the... | 68 | 2,502 |
hatch | tests/backend/version/source/test_code.py | .py | import pytest
from hatchling.version.source.code import CodeSource
def test_no_path(isolation):
source = CodeSource(str(isolation), {})
with pytest.raises(ValueError, match="option `path` must be specified"):
source.get_version_data()
def test_path_not_string(isolation):
source = CodeSource(st... | 128 | 3,696 |
metrics | src/torchmetrics/regression/nrmse.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... | 281 | 10,852 |
jupytext | tests/external/simple_external_notebooks/test_read_simple_quarto.py | .py | import pytest
from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook
import jupytext
from jupytext.compare import compare, compare_notebooks
@pytest.mark.requires_quarto
def test_qmd_to_ipynb(
qmd="""Some text
```{python}
1 + 1
```
""",
nb=new_notebook(
cells=[
new... | 38 | 914 |
mlflow | mlflow/entities/logged_model_tag.py | .py | from mlflow.entities._mlflow_object import _MlflowObject
from mlflow.protos import service_pb2 as pb2
class LoggedModelTag(_MlflowObject):
"""Tag object associated with a Model."""
def __init__(self, key, value):
self._key = key
self._value = value
def __eq__(self, other):
if typ... | 34 | 850 |
biopython | Bio/PDB/qcprot.py | .py | # Copyright (C) 2022, Joao Rodrigues (j.p.g.l.m.rodrigues@gmail.com
# Anuj Sharma (anuj.sharma80@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 ... | 364 | 12,295 |
coremltools | deps/pybind11/tests/test_const_name.py | .py | from __future__ import annotations
import pytest
from pybind11_tests import const_name as m
@pytest.mark.parametrize("func", [m.const_name_tests, m.underscore_tests])
@pytest.mark.parametrize(
("selector", "expected"),
enumerate(
(
"",
"A",
"Bd",
"Cef"... | 32 | 629 |
saleor | saleor/tests/e2e/checkout/taxes/test_checkout_with_click_and_collect_calculate_simple_taxes_based_on_shipping_address.py | .py | import pytest
from ... import ADDRESS_DE
from ...product.utils.preparing_product import prepare_product
from ...shop.utils import prepare_shop
from ...taxes.utils import update_country_tax_rates
from ...utils import assign_permissions
from ...warehouse.utils import update_warehouse
from ..utils import (
checkout_b... | 329 | 10,181 |
gunicorn | tests/requests/valid/rfc9110_body_framing_http10_cl_01.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# RFC 9112 section 6.1: Content-Length is the only framing option for
# HTTP/1.0 bodies (chunked was added in HTTP/1.1).
request = {
"method": "POST",
"uri": uri("/foo"),
"version": (1, 0),
"headers... | 17 | 422 |
bazel | tools/build_defs/pkg/build_tar.py | .py | # Copyright 2015 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
#
# Unless required by applicable la... | 122 | 3,478 |
voila | tests/server/no_strip_sources_test.py | .py | import os
import pytest
BASE_DIR = os.path.dirname(__file__)
@pytest.fixture
def jupyter_server_args_extra():
return ["--VoilaConfiguration.strip_sources=False"]
async def test_hello_world(http_server_client, print_notebook_url):
response = await http_server_client.fetch(print_notebook_url)
assert res... | 19 | 496 |
tablib | src/tablib/formats/_df.py | .py | """ Tablib - DataFrame Support.
"""
try:
from pandas import DataFrame
except ImportError:
DataFrame = None
class DataFrameFormat:
title = 'df'
extensions = ('df',)
@classmethod
def detect(cls, stream):
"""Returns True if given stream is a DataFrame."""
if DataFrame is None:
... | 42 | 1,112 |
pyomo | examples/performance/misc/diag1_100000.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... | 32 | 1,003 |
pyomo | examples/pyomobook/python-ch/pythonconditional.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... | 24 | 791 |
beam | sdks/python/apache_beam/transforms/environments_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 "Lic... | 147 | 6,068 |
onnx | onnx/backend/test/case/model/__init__.py | .py | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import sys
from typing import TYPE_CHECKING
from onnx.backend.test.case.test_case import TestCase
from onnx.backend.test.case.utils import import_recursive
if TYPE_CHECKING:
from collections.abc im... | 82 | 2,191 |
confluent-kafka-python | examples/avro_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... | 174 | 6,340 |
hatch | backend/src/hatchling/builders/plugin/hooks.py | .py | from __future__ import annotations
import typing
from hatchling.builders.app import AppBuilder
from hatchling.builders.binary import BinaryBuilder
from hatchling.builders.custom import CustomBuilder
from hatchling.builders.sdist import SdistBuilder
from hatchling.builders.wheel import WheelBuilder
from hatchling.plug... | 19 | 617 |
coremltools | coremltools/converters/mil/backend/mil/passes/adjust_io_to_supported_types.py | .py | # Copyright (c) 2021, 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 typing import Set, Tuple
from coremltools import _logger as logger
from coremltools.converters.... | 242 | 11,489 |
pyomo | examples/pyomobook/abstract-ch/param4.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 | 842 |
qutip | qutip/core/tensor.py | .py | """
Module for the creation of composite quantum objects via the tensor product.
"""
__all__ = [
'tensor', 'super_tensor', 'composite', 'tensor_swap', 'tensor_contract',
'expand_operator'
]
from collections.abc import Iterable
from functools import partial
from typing import TypeVar, overload
import numpy as ... | 518 | 17,164 |
pyro | tests/infer/mcmc/test_mcmc_api.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import os
from functools import partial
import pytest
import torch
import pyro
import pyro.distributions as dist
from pyro import poutine
from pyro.infer.mcmc import HMC, NUTS
from pyro.infer.mcmc.api import MCMC, StreamingMCMC, ... | 414 | 12,719 |
pdm | src/pdm/cli/commands/info.py | .py | import argparse
import json
from rich import print_json
from pdm.cli.commands.base import BaseCommand
from pdm.cli.options import ArgumentGroup, venv_option
from pdm.cli.utils import check_project_file
from pdm.project import Project
class Command(BaseCommand):
"""Show the project information"""
def add_ar... | 84 | 3,473 |
coremltools | coremltools/converters/mil/mil/ops/defs/iOS15/normalization.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 numpy as np
from coremltools.converters.mil.mil import (DefaultInputs, InputSpec,
... | 382 | 12,601 |
mlflow | mlflow/genai/judges/adapters/base_adapter.py | .py | from __future__ import annotations
import logging
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any
import pydantic
if TYPE_CHECKING:
from mlflow.entities.trace import Trace
from mlflow.types.llm import ChatMessage
from mlflow.entities.assessment imp... | 178 | 6,300 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.