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 |
|---|---|---|---|---|---|
saleor | saleor/csv/utils/product_headers.py | .py | from collections import ChainMap
from django.conf import settings
from django.db.models import Value as V
from django.db.models.functions import Concat
from ...attribute.models import Attribute
from ...channel.models import Channel
from ...warehouse.models import Warehouse
from . import ProductExportFields
def get_... | 155 | 4,942 |
mlflow | docs/scripts/build-all.py | .py | import os
import shutil
import subprocess
from pathlib import Path
import click
import mlflow
mlflow_version = mlflow.version.VERSION
def build_docs(package_manager, version):
env = os.environ.copy()
# ensure it ends with a "/"
base_url = env.get("DOCS_BASE_URL", "/docs/").rstrip("/") + "/"
api_re... | 93 | 2,366 |
pyomo | pyomo/core/expr/__init__.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 212 | 5,115 |
hatch | src/hatch/utils/ci.py | .py | import os
def running_in_ci() -> bool:
return any(os.environ.get(env_var) in {"true", "1"} for env_var in ("CI", "GITHUB_ACTIONS"))
| 6 | 138 |
pyro | pyro/ops/newton.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
from torch.autograd import grad
from pyro.ops.linalg import eig_3d, rinverse
from pyro.util import warn_if_nan
def newton_step(loss, x, trust_radius=None):
"""
Performs a Newton update step to minimize loss ... | 247 | 9,520 |
astropy | astropy/constants/codata2018.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Astronomical and physics constants in SI units. See :mod:`astropy.constants`
for a complete listing of constants defined in Astropy.
"""
import math
from .constant import Constant, EMConstant
# PHYSICAL CONSTANTS
# https://en.wikipedia.org/wiki/201... | 156 | 3,794 |
saleor | saleor/core/editorjs/tests/test_lists.py | .py | import pytest
from ...editorjs import editorjs_to_text
@pytest.mark.parametrize(
("_case", "input_data", "expected_output"),
[
("Missing items", {}, ""),
("Missing null items", {"items": None}, ""),
("Empty list", {"items": []}, ""),
("List with 1 item", {"items": ["Item 1"]},... | 98 | 2,992 |
coremltools | coremltools/models/datatypes.py | .py | # Copyright (c) 2017, 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
"""
Basic Data Types.
"""
import numpy as _np
from coremltools import proto
class _DatatypeBase:
... | 246 | 6,823 |
qutip | qutip/solver/__init__.py | .py | from .result import *
from .multitrajresult import *
from .options import *
import qutip.solver.integrator as integrator
from .integrator import IntegratorException
from .sesolve import *
from .mesolve import *
from .mcsolve import *
from .nm_mcsolve import *
from .propagator import *
from .scattering import *
from .co... | 23 | 603 |
pymc | pymc/distributions/moments/means.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... | 451 | 12,553 |
mlflow | tests/utils/test_validation.py | .py | import copy
import socket
import time
from unittest.mock import patch
import pytest
from mlflow.entities import Metric, Param, RunTag
from mlflow.environment_variables import MLFLOW_ARTIFACT_LOCATION_MAX_LENGTH
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VA... | 784 | 26,931 |
textual | tests/test_file_monitor.py | .py | import os
from pathlib import Path
from textual.file_monitor import FileMonitor
def test_repr() -> None:
file_monitor = FileMonitor([Path(".")], lambda: None)
assert "FileMonitor" in repr(file_monitor)
def test_file_never_found():
path = "doesnt_exist.tcss"
file_monitor = FileMonitor([Path(path)], ... | 59 | 1,711 |
pymc | pymc/distributions/continuous.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... | 4,266 | 128,630 |
mlflow | mlflow/tracing/client.py | .py | import json
import logging
import time
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor
from contextlib import nullcontext
from typing import TYPE_CHECKING, Sequence
import mlflow
if TYPE_CHECKING:
from mlflow.genai.label_schemas.label_schemas import (
InputCategorical... | 1,104 | 44,937 |
mlflow | examples/transformers/load_components.py | .py | import transformers
import mlflow
pipeline = transformers.pipeline(
task="fill-mask",
model=transformers.AutoModelForMaskedLM.from_pretrained("distilbert-base-uncased"),
tokenizer=transformers.AutoTokenizer.from_pretrained("distilbert-base-uncased"),
)
with mlflow.start_run():
model_info = mlflow.tra... | 32 | 861 |
pyomo | examples/gdp/eight_process/eight_proc_verbose_model.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... | 211 | 7,753 |
clearml | examples/frameworks/tensorflow/tensorboard_toy.py | .py | # ClearML - Example of tensorboard with tensorflow (without any actual training)
#
import os
import tensorflow as tf
import numpy as np
from tempfile import gettempdir
from PIL import Image
from clearml import Task
def generate_summary(k, step):
# Make a normal distribution, with a shifting mean
mean_moving_... | 77 | 3,227 |
pyomo | pyomo/contrib/sensitivity_toolbox/examples/HIV_Transmission.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... | 334 | 9,696 |
onnxruntime | onnxruntime/python/tools/microbench/conv.py | .py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
from dataclasses import dataclass
import numpy as np
fr... | 63 | 2,049 |
mlflow | tests/langchain/sample_code/simple_runnable.py | .py | from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import PromptTemplate
from langchain_openai import ChatOpenAI
import mlflow
prompt = PromptTemplate(
input_variables=["product"],
template="What is {product}?",
)
llm = ChatOpenAI(temperature=0.1, stream_usage=True)
chain = ... | 15 | 385 |
openvino | tests/layer_tests/tensorflow_lite_tests/test_tfl_SelectV2.py | .py | import pytest
import tensorflow as tf
from common.tflite_layer_test_class import TFLiteLayerTest
test_params = [
{'shape': [2, 3, 1, 2, 2], 'condition': [True, False]},
{'shape': [4, 3, 1, 2], 'condition': [False, True]},
{'shape': [3, 3, 3, 3], 'condition': [True, True, False]},
{'shape': [3, 3, 3], ... | 37 | 1,406 |
rq | tests/test_queue_unique.py | .py | """Tests for Queue unique job enqueue behavior."""
from datetime import datetime, timedelta, timezone
from rq import Queue
from rq.exceptions import DuplicateJobError
from rq.job import JobStatus
from rq.rate_limit import RateLimit
from tests import RQTestCase
from tests.fixtures import say_hello
class TestEnqueueJ... | 76 | 3,013 |
gunicorn | gunicorn/__main__.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.app.wsgiapp import run
if __name__ == "__main__":
# see config.py - argparse defaults to basename(argv[0]) == "__main__.py"
# todo: let runpy.run_module take care of argv[0] rewriting
run... | 11 | 338 |
wagtail | wagtail/admin/views/generic/__init__.py | .py | from .base import ( # noqa: F401
BaseListingView,
BaseObjectMixin,
BaseOperationView,
WagtailAdminTemplateMixin,
)
from .history import HistoryView # noqa: F401
from .mixins import ( # noqa: F401
BeforeAfterHookMixin,
CreateEditViewOptionalFeaturesMixin,
HookResponseMixin,
IndexViewOp... | 33 | 805 |
biopython | Bio/phenotype/__init__.py | .py | # Copyright 2014-2016 by Marco Galardini. 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.
r"""phenotype data... | 245 | 8,353 |
readthedocs.org | readthedocs/api/v3/apps.py | .py | from django.apps import AppConfig
class V3Config(AppConfig):
name = "readthedocs.api.v3"
| 6 | 95 |
astropy | astropy/io/fits/hdu/compressed/tests/test_compressed.py | .py | # Licensed under a 3-clause BSD style license - see PYFITS.rst
import io
import math
import os
import pickle
import re
import time
import warnings
from io import BytesIO
import numpy as np
import pytest
from hypothesis import given
from hypothesis.extra.numpy import basic_indices
from numpy.testing import assert_allc... | 1,636 | 59,455 |
jupytext | src/jupytext/__main__.py | .py | """Main for Jupytext
Call with (e.g.)::
python -m jupytext my_notebook.ipynb --to Rmd
"""
import sys
from .cli import jupytext
if __name__ == "__main__":
sys.exit(jupytext())
| 14 | 188 |
beam | sdks/python/apache_beam/ml/inference/utils.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 164 | 6,260 |
scikit-optimize | skopt/utils.py | .py | from copy import deepcopy
from functools import wraps
from sklearn.utils import check_random_state
import numpy as np
from scipy.optimize import OptimizeResult
from scipy.optimize import minimize as sp_minimize
from sklearn.base import is_regressor
from sklearn.ensemble import GradientBoostingRegressor
from joblib impo... | 796 | 27,455 |
coveragepy | coverage/files.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
"""File wrangling."""
from __future__ import annotations
import abc
import hashlib
import ntpath
import os
import os.path
import posixpath
import re
import sys
... | 586 | 20,279 |
probability | spinoffs/inference_gym/inference_gym/targets/neals_funnel.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... | 149 | 5,089 |
textual | src/textual/_import_app.py | .py | from __future__ import annotations
import os
import runpy
import shlex
import sys
from pathlib import Path
from typing import TYPE_CHECKING, cast
if TYPE_CHECKING:
from textual.app import App
class AppFail(Exception):
pass
def shebang_python(candidate: Path) -> bool:
"""Does the given file look like i... | 127 | 3,609 |
beam | sdks/python/apache_beam/ml/inference/xgboost_inference_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... | 540 | 19,804 |
tqdm | tqdm/contrib/bells.py | .py | """
Even more features than `tqdm.auto` (all the bells & whistles):
- `tqdm.auto`
- `tqdm.tqdm.pandas`
- `tqdm.contrib.slack`
+ uses `${TQDM_SLACK_TOKEN}` and `${TQDM_SLACK_CHANNEL}`
- `tqdm.contrib.telegram`
+ uses `${TQDM_TELEGRAM_TOKEN}` and `${TQDM_TELEGRAM_CHAT_ID}`
- `tqdm.contrib.discord`
+ uses `${... | 29 | 921 |
sqlmap | tests/test_graphql.py | .py | #!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
Offline, deterministic tests for the GraphQL injection engine. Mock oracles stand in for the
HTTP/GraphQL layer so endpoint detection, introspection parsing, slot enumeration, query
c... | 1,004 | 46,892 |
django-cms | cms/cms_config.py | .py | from collections.abc import Iterable
from functools import cached_property
from logging import getLogger
from django.core.exceptions import ImproperlyConfigured
from cms.app_base import CMSAppConfig, CMSAppExtension
from cms.cms_wizards import cms_page_wizard, cms_subpage_wizard
from cms.models import PageContent
fro... | 88 | 3,652 |
mlflow | mlflow/agent/cli.py | .py | """`mlflow agent` CLI group.
Wires per-subcommand modules under :mod:`mlflow.agent`. To add a new
subcommand, drop a package under ``mlflow/agent/<name>/`` and register it
here with ``commands.add_command``.
"""
from __future__ import annotations
import click
from mlflow.agent.setup.cli import setup
@click.group(... | 21 | 435 |
gunicorn | tests/requests/valid/rfc9110_field_value_htab_trim_01.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# RFC 9110 section 5.5: OWS around field-value is optional and not part
# of the value; leading and trailing HTAB must be stripped.
request = {
"method": "GET",
"uri": uri("/foo"),
"version": (1, 1),
... | 17 | 422 |
openvino | tests/layer_tests/pytorch_tests/test_take_along_dim.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
class TestTakeAlongDim(PytorchLayerTest):
def _prepare_input(self, m, n, max_val, out=False, flattenize=False):
import numpy as np
... | 57 | 2,255 |
biopython | Bio/Align/phylip.py | .py | # Copyright 2006-2016 by Peter Cock. 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.
"""Bio.Align support fo... | 182 | 6,401 |
deap | deap/base.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 ... | 359 | 14,167 |
openvino | src/bindings/python/src/openvino/properties/__init__.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# Enums
from openvino._pyopenvino.properties import CompatibilityCheck
from openvino._pyopenvino.properties import CacheMode
from openvino._pyopenvino.properties import WorkloadType
# Properties
import openvino._... | 23 | 755 |
pyomo | pyomo/solvers/tests/checks/test_BARON.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... | 99 | 3,445 |
textual | docs/examples/styles/grid_columns.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Label
class MyApp(App):
CSS_PATH = "grid_columns.tcss"
def compose(self):
yield Grid(
Label("1fr"),
Label("width = 16"),
Label("2fr"),
Label("1fr"),
... | 27 | 556 |
mlflow | examples/pyfunc/infer_model_code_paths.py | .py | from typing import Any
from custom_code import iris_classes
import mlflow
class CustomPredict(mlflow.pyfunc.PythonModel):
"""Custom pyfunc class used to create customized mlflow models"""
def predict(self, context, model_input, params: dict[str, Any] | None = None):
prediction = [x % 3 for x in mod... | 24 | 666 |
mlflow | tests/openai/mock_openai.py | .py | import argparse
import base64
import json
from typing import Any
import fastapi
from pydantic import BaseModel
from starlette.responses import StreamingResponse
from mlflow.types.chat import ChatCompletionRequest
EMPTY_CHOICES = "EMPTY_CHOICES"
LIST_CONTENT = "LIST_CONTENT"
AZURE_ANNOTATIONS = "AZURE_ANNOTATIONS"
a... | 548 | 15,860 |
wandb | tools/perf/scripts/test_case_helper.py | .py | import logging
import time
from pathlib import Path
from typing import Literal
from .bench_run_log import Experiment
from .process_sar_helper import capture_sar_metrics, process_sar_files
logger = logging.getLogger(__name__)
def run_perf_tests(
loop_count: int,
num_steps_options: list[int],
num_metrics_... | 72 | 2,570 |
textual | tests/test_app_focus_blur.py | .py | """Test the workings of reacting to AppFocus and AppBlur."""
from textual.app import App, ComposeResult
from textual.events import AppBlur, AppFocus
from textual.widgets import Input
class FocusBlurApp(App[None]):
AUTO_FOCUS = "#input-4"
def compose(self) -> ComposeResult:
for n in range(10):
... | 80 | 2,840 |
saleor | saleor/core/editorjs/converters.py | .py | import logging
from typing import overload
import pydantic_core
from django.core.exceptions import ValidationError
from django.utils.html import strip_tags
from .models import EditorJSDocumentModel
logger = logging.getLogger(__name__)
def parse_editorjs(data: dict, *, for_django: bool = True) -> EditorJSDocumentMo... | 92 | 3,514 |
openvino | tests/e2e_tests/test_utils/pytorch_loaders.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import importlib
import os
import sys
import torch
from huggingface_hub import snapshot_download
class LoadPyTorchModel:
def __init__(self, module: str, args: dict, inputs: dict):
self.module = module
self.args = a... | 110 | 3,216 |
astropy | astropy/cosmology/_src/tests/traits/test_trait_tcmb.py | .py | import pytest
import astropy.units as u
from astropy.cosmology._src.traits.tcmb import TemperatureCMB
from astropy.tests.helper import assert_quantity_allclose
class DummyTcmb(TemperatureCMB):
Tcmb0 = 2.7 * u.K
@pytest.fixture
def dummy_tcmb():
return DummyTcmb()
def test_tcmb_behavior_and_signature(dumm... | 23 | 496 |
textual | tests/snapshot_tests/snapshot_apps/tree_clearing.py | .py | from textual.app import App, ComposeResult
from textual.widgets import Tree
class TreeClearingSnapshotApp(App[None]):
CSS = """
Screen {
layout: horizontal;
}
"""
@staticmethod
def _populate(tree: Tree) -> Tree:
for n in range(5):
branch = tree.root.add(str(n))
... | 31 | 805 |
conda | conda/auxlib/type_coercion.py | .py | """Collection of functions to coerce conversion of types with an intelligent guess."""
from __future__ import annotations
from collections.abc import Mapping
from enum import Enum
from itertools import chain
from re import IGNORECASE, compile
from typing import TYPE_CHECKING
from ..deprecations import deprecated
fro... | 273 | 8,936 |
metrics | src/torchmetrics/retrieval/reciprocal_rank.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... | 161 | 6,557 |
readthedocs.org | readthedocs/projects/tests/test_domain_views.py | .py | from unittest import mock
import dns.resolver
from django.contrib.auth.models import User
from django.contrib.messages import get_messages
from django.test import TestCase, override_settings
from django.urls import reverse
from django_dynamic_fixture import get
from readthedocs.organizations.models import Organizatio... | 238 | 9,319 |
jupyterlab | jupyterlab/labapp.py | .py | """A tornado based Jupyter lab server."""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import dataclasses
import json
import os
import sys
from collections.abc import Sequence
from jupyter_core.application import JupyterApp, NoStart, base_aliases, base_flags
fr... | 964 | 34,834 |
conda | conda/_preview/env_setup/cli/main_create.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""CLI implementation for `conda create` — env-setup preview stub.
This module is part of the ``env-setup`` preview feature. It intercepts
``conda create`` when the preview is enabled and raises ``OperationNotAllowed``
until a functional implem... | 35 | 1,040 |
clearml | clearml/utilities/requests_toolbelt/multipart/__init__.py | .py | """
requests_toolbelt.multipart
===========================
See https://toolbelt.readthedocs.io/ for documentation
:copyright: (c) 2014 by Ian Cordasco and Cory Benfield
:license: Apache v2.0, see LICENSE for more details
"""
from .encoder import MultipartEncoder, MultipartEncoderMonitor
from .decoder import Multipa... | 32 | 854 |
textual | docs/examples/styles/outline_all.py | .py | from textual.app import App
from textual.containers import Grid
from textual.widgets import Label
class AllOutlinesApp(App):
CSS_PATH = "outline_all.tcss"
def compose(self):
yield Grid(
Label("ascii", id="ascii"),
Label("blank", id="blank"),
Label("dashed", id="das... | 32 | 886 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_Resample_pattern_new.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from common.tf_layer_test_class import CommonTFLayerTest
class TestResamplePattern(CommonTFLayerTest):
def _prepare_input(self, inputs_dict):
for input in inputs_dict.keys():
inp... | 53 | 1,990 |
saleor | saleor/webhook/tests/test_utils.py | .py | import pytest
from django.utils import timezone
from ...app.models import App
from ..event_types import WebhookEventAsyncType, WebhookEventSyncType
from ..models import Webhook
from ..observability.exceptions import (
ApiCallTruncationError,
EventDeliveryAttemptTruncationError,
TruncationError,
)
from ..ob... | 461 | 13,741 |
astropy | astropy/timeseries/tests/test_common.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
from numpy.testing import assert_equal
from astropy import units as u
from astropy.table import QTable, Table, join, vstack
from astropy.time import Time
from astropy.timeseries.binned import BinnedTimeSeries
from astropy.timeseries.sampled... | 101 | 3,288 |
hydra | examples/plugins/example_configsource_plugin/tests/test_example_config_source.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from pytest import mark
from hydra.core.plugins import Plugins
from hydra.plugins.config_source import ConfigSource
from hydra.test_utils.config_source_common_tests import ConfigSourceTestSuite
from hydra_plugins.example_configsource_plugin.examp... | 24 | 759 |
mlflow | tests/telemetry/test_events.py | .py | from unittest.mock import Mock
import pandas as pd
import pytest
from mlflow.entities.evaluation_dataset import DatasetGranularity, EvaluationDataset
from mlflow.entities.gateway_budget_policy import (
BudgetAction,
BudgetDuration,
BudgetDurationUnit,
BudgetTargetScope,
BudgetUnit,
)
from mlflow.e... | 1,025 | 33,162 |
beam | sdks/python/apache_beam/ml/rag/ingestion/milvus_search_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... | 159 | 6,474 |
django-cms | cms/test_utils/project/sampleapp/urls_excluded.py | .py | from django.urls import include, re_path
urlpatterns = [
re_path(r'^excluded/', include('cms.test_utils.project.sampleapp.urls_example', namespace="excluded")),
re_path(r'^not_excluded/', include('cms.test_utils.project.sampleapp.urls_example', namespace="not_excluded")),
]
| 7 | 284 |
mlflow | tests/tracking/test_artifact_utils.py | .py | import os
from unittest import mock
from unittest.mock import ANY
from uuid import UUID
import pytest
import mlflow
from mlflow.exceptions import MlflowException
from mlflow.tracking.artifact_utils import (
_download_artifact_from_uri,
_upload_artifact_to_uri,
_upload_artifacts_to_databricks,
)
def test... | 151 | 6,173 |
probability | spinoffs/fun_mc/fun_mc/dynamic/backend_tensorflow/util.py | .py | # Copyright 2021 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 515 | 14,414 |
clearml | clearml/backend_api/services/v2_20/workers.py | .py | """
workers service
Provides an API for worker machines, allowing workers to report status and get tasks for execution
"""
from typing import List, Optional, Any
import six
from datetime import datetime
import enum
from dateutil.parser import parse as parse_datetime
from clearml.backend_api.session import (
Reques... | 2,478 | 86,857 |
saleor | saleor/payment/gateways/stripe/webhooks.py | .py | import logging
from typing import cast
import stripe
from django.core.exceptions import ValidationError
from django.db.models import Prefetch
from django.http import HttpResponse
from stripe.error import SignatureVerificationError
from stripe.stripe_object import StripeObject
from ....checkout.calculations import cal... | 559 | 18,290 |
wandb | hatch_build.py | .py | import dataclasses
import importlib.util
import os
import pathlib
import platform
import re
import shutil
import sys
import sysconfig
from typing import Any
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from typing_extensions import override
# A small hack to allow importing build scripts f... | 324 | 10,929 |
coremltools | coremltools/test/neural_network/test_model.py | .py | # Copyright (c) 2017, 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 os
import tempfile
import unittest
import numpy as np
import PIL.Image
import coremltools
from ... | 590 | 23,297 |
biopython | Bio/Seq.py | .py | # Copyright 2000 Andrew Dalke.
# Copyright 2000-2002 Brad Chapman.
# Copyright 2004-2005, 2010 by M de Hoon.
# Copyright 2007-2023 by Peter Cock.
# 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".
#... | 3,279 | 114,965 |
probability | spinoffs/inference_gym/inference_gym/internal/datasets/synthetic_plasma_spectroscopy.py | .py | # Copyright 2021 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 1,777 | 28,308 |
wandb | wandb/proto/wandb_server_pb2.py | .py | import google.protobuf
protobuf_version = google.protobuf.__version__[0]
if protobuf_version == "5":
from wandb.proto.v5.wandb_server_pb2 import *
elif protobuf_version == "6":
from wandb.proto.v6.wandb_server_pb2 import *
elif protobuf_version == "7":
from wandb.proto.v7.wandb_server_pb2 import *
| 11 | 313 |
pyro | examples/scanvi/scanvi.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
"""
We use a semi-supervised deep generative model of transcriptomics data to propagate labels
from a small set of labeled cells to a larger set of unlabeled cells. In particular we
use a dataset of peripheral blood mononuclear cells (... | 442 | 16,794 |
mlflow | tests/tracing/export/test_uc_table_exporter.py | .py | import time
from concurrent.futures import ThreadPoolExecutor
from unittest import mock
import pytest
from mlflow.entities.span import Span
from mlflow.tracing.export.uc_table import DatabricksUCTableSpanExporter
from mlflow.tracing.trace_manager import InMemoryTraceManager
from mlflow.tracing.utils import generate_t... | 270 | 10,352 |
pyro | pyro/poutine/trace_messenger.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import sys
from typing import TYPE_CHECKING, Callable, Generic, Literal, Optional, TypeVar
from typing_extensions import ParamSpec, Self
from pyro.poutine.messenger import Messenger
from pyro.poutine.trace_struct import Trace
fro... | 218 | 7,701 |
clearml | clearml/backend_interface/task/log.py | .py | import json
import sys
from typing import List, Any
from pathlib2 import Path
from logging import (
LogRecord,
getLogger,
basicConfig,
getLevelName,
INFO,
WARNING,
Formatter,
makeLogRecord,
warning,
)
from logging.handlers import BufferingHandler
from .development.worker import Dev... | 369 | 14,153 |
astropy | astropy/units/function/units.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package defines units that can also be used as functions of other units.
If called, their arguments are used to initialize the corresponding function
unit (e.g., ``u.mag(u.ct/u.s)``). Note that the prefixed versions cannot be
called, as it would ... | 120 | 3,477 |
openvino | tests/conditional_compilation/test_utils.py | .py | #!/usr/bin/env python3
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
""" Utility functions for work with json test configuration file.
"""
import os
import json
import multiprocessing
import sys
from inspect import getsourcefile
from pathlib import Path
from install_pkg import get_... | 93 | 3,237 |
scikit-bio | skbio/io/tests/test_format_imports.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.
# --------------------------------------------... | 150 | 5,565 |
deap | examples/ga/mo_rhv.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 ... | 193 | 7,038 |
beam | sdks/python/apache_beam/typehints/typecheck_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... | 305 | 10,903 |
marshmallow | tests/test_exceptions.py | .py | import pytest
from marshmallow.exceptions import ValidationError
class TestValidationError:
def test_stores_message_in_list(self):
err = ValidationError("foo")
assert err.messages == ["foo"]
def test_can_pass_list_of_messages(self):
err = ValidationError(["foo", "bar"])
asser... | 43 | 1,416 |
wandb | tests/system_tests/test_artifacts/test_model_workflows.py | .py | from __future__ import annotations
from pathlib import Path
import wandb
from pytest import raises
from wandb import env
class FakeArtifact:
def wait(self):
pass
def is_draft(self):
return False
def test_offline_link_artifact(user):
with wandb.init(mode="offline") as run:
with... | 94 | 2,962 |
wagtail | wagtail/users/tests/test_api_tokens_admin.py | .py | import re
from unittest.mock import patch
from django.contrib.auth import get_user_model
from django.test import SimpleTestCase, TestCase
from django.urls import reverse
from django.utils import timezone
from freezegun import freeze_time
from wagtail.log_actions import registry as log_registry
from wagtail.models imp... | 410 | 16,670 |
biopython | Bio/SearchIO/HHsuiteIO/hhsuite2_text.py | .py | # Copyright 2019 by Jens Thomas. 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.
"""Bio.SearchIO parser for HH... | 237 | 9,354 |
slimit | src/slimit/lextab.py | .py | # coding=utf-8
# lextab.py. This file automatically created by PLY (version 3.11). Don't edit!
_tabversion = '3.10'
_lextokens = set(('AND', 'ANDEQUAL', 'BAND', 'BLOCK_COMMENT', 'BNOT', 'BOR', 'BREAK', 'BXOR', 'CASE', 'CATCH', 'CLASS', 'COLON', 'COMMA', 'CONDOP', 'CONST', 'CONTINUE', 'DEBUGGER', 'DEFAULT', 'DELETE... | 12 | 18,320 |
astropy | astropy/coordinates/tests/test_formatting.py | .py | """
Tests the Angle string formatting capabilities. SkyCoord formatting is in
test_sky_coord
"""
import numpy as np
import pytest
from astropy import units as u
from astropy.coordinates import Angle
def test_to_string_precision():
# There are already some tests in test_api.py, but this is a regression
# te... | 219 | 7,790 |
coremltools | coremltools/converters/mil/mil/passes/defs/optimize_linear.py | .py | # Copyright (c) 2023, 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 Block
from coremltools.converters.mil.... | 413 | 15,021 |
qutip | qutip/core/environment.py | .py | """
Classes that describe environments of open quantum systems
"""
# Required for Sphinx to follow autodoc_type_aliases
from __future__ import annotations
__all__ = ['BosonicEnvironment',
'DrudeLorentzEnvironment',
'UnderDampedEnvironment',
'OhmicEnvironment',
'ExponentialB... | 3,039 | 100,827 |
sphinx | tests/test_extensions/test_ext_duration.py | .py | """Test sphinx.ext.duration extension."""
from __future__ import annotations
import json
import re
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from sphinx.testing.util import SphinxTestApp
@pytest.mark.sphinx(
'dummy',
testroot='basic',
confoverrides={... | 163 | 4,285 |
wagtail | wagtail/test/settings_ui.py | .py | from .settings import * # noqa: F403
# Settings meant to run the test suite with Django’s development server, for integration tests.
DATABASES["default"]["NAME"] = "ui_tests.db" # noqa: F405
INSTALLED_APPS += [ # noqa: F405
"pattern_library",
]
TEMPLATES[0]["OPTIONS"]["builtins"] = ["pattern_library.loader_t... | 33 | 991 |
beam | sdks/python/apache_beam/utils/python_callable.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... | 127 | 4,340 |
loguru | tests/exceptions/source/ownership/string_source.py | .py | import sys
from loguru import logger
def test(*, backtrace, colorize, diagnose):
logger.remove()
logger.add(sys.stderr, format="", colorize=colorize, backtrace=backtrace, diagnose=diagnose)
def foo():
1 / 0
try:
exec("foo()")
except ZeroDivisionError:
logger.exception(""... | 24 | 586 |
saleor | saleor/graphql/giftcard/mutations/gift_card_add_note.py | .py | import graphene
from django.core.exceptions import ValidationError
from ....giftcard import events
from ....giftcard.error_codes import GiftCardErrorCode
from ....permission.enums import GiftcardPermissions
from ....webhook.event_types import WebhookEventAsyncType
from ...app.dataloaders import get_app_promise
from ..... | 82 | 3,051 |
python-prompt-toolkit | examples/prompts/rprompt.py | .py | #!/usr/bin/env python
"""
Example of a right prompt. This is an additional prompt that is displayed on
the right side of the terminal. It will be hidden automatically when the input
is long enough to cover the right side of the terminal.
This is similar to RPROMPT is Zsh.
"""
from prompt_toolkit import prompt
from pr... | 55 | 1,517 |
mlflow | mlflow/store/tracking/gateway/abstract_mixin.py | .py | from typing import Any
from mlflow.entities import (
FallbackConfig,
GatewayEndpoint,
GatewayEndpointBinding,
GatewayEndpointModelConfig,
GatewayEndpointModelMapping,
GatewayEndpointTag,
GatewayModelDefinition,
GatewaySecretInfo,
RoutingStrategy,
)
from mlflow.entities.gateway_budge... | 692 | 23,815 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.