repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
pyomo | examples/pyomobook/mpec-ch/ralph1.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... | 22 | 900 |
pyro | profiler/hmm.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import argparse
import os
import pickle
import re
import subprocess
import sys
from collections import defaultdict
from os.path import abspath, join
from numpy import median
from pyro.util import timed
EXAMPLES_DIR = join(abspat... | 86 | 2,834 |
biopython | Tests/test_SearchIO_interproscan_xml.py | .py | # This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Tests for SearchIO InterproscanIO parsers."""
import os
import unittest
from Bio.SearchIO import parse
# test case files are in the Blast directo... | 84 | 2,678 |
wagtail | wagtail/images/management/commands/wagtail_update_image_renditions.py | .py | import logging
from django.core.management.base import BaseCommand
from django.db import transaction
from wagtail.images import get_image_model
logger = logging.getLogger(__name__)
def progress_bar(current, total, bar_length=50):
fraction = current / total
arrow = int(fraction * bar_length - 1) * "-" + ">... | 101 | 3,451 |
hatch | tests/cli/dep/show/test_sources.py | .py | import pytest
from hatch.project.core import Project
from hatch.utils.structures import EnvVars
@pytest.fixture(scope="module", autouse=True)
def _terminal_width():
with EnvVars({"COLUMNS": "200"}):
yield
def test_no_sources(hatch, helpers, temp_dir, config_file):
config_file.model.template.plugins... | 92 | 2,818 |
probability | spinoffs/inference_gym/inference_gym/targets/radon_contextual_effects.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... | 459 | 18,877 |
readthedocs.org | readthedocs/subscriptions/tests/test_signals.py | .py | from unittest import mock
from django.contrib.auth.models import User
from django.test import TestCase
from django_dynamic_fixture import get
from djstripe import models as djstripe
from readthedocs.organizations.models import Organization
from readthedocs.payments.tests.utils import PaymentMixin
class TestSignals(... | 77 | 2,624 |
kafka | release/test_gh_actions.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... | 408 | 15,216 |
openvino | tests/layer_tests/onnx_tests/test_upsample.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import math
import os
import pytest
import torch
from common.layer_test_class import CommonLayerTest
from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model
class TestUpsample(OnnxRuntimeLayerTest):
def crea... | 194 | 7,283 |
metrics | src/torchmetrics/regression/minkowski.py | .py | # Copyright The PyTorch 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 i... | 123 | 4,603 |
openvino | tests/layer_tests/tensorflow_tests/test_tf_ScatterND.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import platform
import numpy as np
import pytest
from common.tf_layer_test_class import CommonTFLayerTest
rng = np.random.default_rng(475912)
class TestTFScatterND(CommonTFLayerTest):
def create_tf_scatternd_placeholder_const_net(... | 124 | 5,680 |
pyomo | examples/pyomobook/abstract-ch/set3.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 | 1,041 |
beam | sdks/python/apache_beam/transforms/enrichment_handlers/feast_feature_store_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... | 66 | 2,584 |
mlflow | tests/tracking/_model_registry/test_utils.py | .py | import io
import pickle
from unittest import mock
import pytest
from mlflow.environment_variables import MLFLOW_TRACKING_URI
from mlflow.store._unity_catalog.registry.rest_store import UcModelRegistryStore
from mlflow.store._unity_catalog.registry.uc_native_rest_store import UcNativeModelRegistryStore
from mlflow.sto... | 358 | 13,647 |
onnx | onnx/backend/test/case/node/optionalhaselement.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 optional_has_element_reference_implementation(
optional: np.ndarray ... | 94 | 3,381 |
astropy | astropy/units/tests/test_quantity_non_ufuncs.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import inspect
import itertools
from io import StringIO
from types import FunctionType, ModuleType
import numpy as np
import numpy.lib.recfunctions as rfn
import pytest
from numpy.testing import assert_allclose, assert_array_equal
from numpy.testing.over... | 2,924 | 100,316 |
mlflow | tests/test_runs.py | .py | import json
import logging
import os
import textwrap
from unittest import mock
from unittest.mock import patch
import pytest
from click.testing import CliRunner
import mlflow
from mlflow import experiments
from mlflow.exceptions import MlflowException
from mlflow.runs import create_run, link_traces, list_run
from mlf... | 597 | 19,179 |
pyro | pyro/contrib/oed/glmm/glmm.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import warnings
from collections import OrderedDict
from contextlib import ExitStack
from functools import partial
import torch
from torch.distributions import constraints
from torch.distributions.transforms import AffineTransform... | 468 | 16,376 |
loguru | tests/exceptions/source/diagnose/attributes.py | .py | # fmt: off
import sys
from loguru import logger
logger.remove()
logger.add(sys.stderr, format="", colorize=True, backtrace=False, diagnose=True)
class Obj:
@property
def forbidden(self):
raise RuntimeError
a = Obj()
a.b = "123"
def foo():
x = None
... + 1 + bar(a).b + a.forbidden + a.nop... | 29 | 430 |
omegaconf | tests/interpolation/built_in_resolvers/test_oc_deprecated.py | .py | import re
from typing import Any
from pytest import mark, param, raises, warns
from omegaconf import OmegaConf
from omegaconf.errors import InterpolationResolutionError
@mark.parametrize(
("cfg", "key", "expected_value", "expected_warning"),
[
param(
{"a": 10, "b": "${oc.deprecated: a}"}... | 108 | 3,245 |
coremltools | coremltools/converters/mil/mil/ops/defs/iOS15/pool.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 coremltools.converters.mil.mil import Operation, types
from coremltools.converters.mil.mil.block... | 265 | 9,304 |
mlflow | tests/sagemaker/conftest.py | .py | import pytest
from mlflow.store.artifact.s3_artifact_repo import _cached_get_s3_client
@pytest.fixture(autouse=True)
def reset_cached_get_s3_client():
# `_cached_get_s3_client` is a process-global lru_cache whose key does not include the
# resolved AWS credentials. Under pytest-xdist a worker runs many modul... | 14 | 657 |
textual | tests/snapshot_tests/snapshot_apps/horizontal_auto_width.py | .py | from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Static
class HorizontalAutoWidth(App):
"""
Checks that the auto width of the parent Horizontal is correct.
"""
def compose(self) -> ComposeResult:
yield Horizontal(
Sta... | 24 | 652 |
qutip | qutip/tests/solver/test_mcsolve.py | .py | import pytest
import numpy as np
import qutip
from copy import copy
from qutip.solver.mcsolve import mcsolve, MCSolver
def _return_constant(t, constant):
return constant
def _return_decay(t, constant, rate):
return constant * np.exp(-rate * t)
class callable_qobj:
def __init__(self, oper, coeff=None):... | 693 | 27,800 |
qutip | qutip/tests/core/test_energy_restricted.py | .py | import pytest
import itertools
import random
import numpy as np
import qutip
import scipy.sparse
from qutip.core.dimensions import flatten
from qutip.core.energy_restricted import EnrSpace, Space
def _n_enr_states(dimensions, n_excitations):
"""
Calculate the total number of distinct ENR states for a given s... | 384 | 13,752 |
mlflow | mlflow/store/artifact/databricks_artifact_repo_resources.py | .py | import posixpath
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from enum import Enum
from typing import Any, Callable
from mlflow.entities.file_info import FileInfo
from mlflow.protos.databricks_artifacts_pb2 import (
DatabricksMlflowArtifactsService,
GetCredentialsForLoggedModel... | 306 | 10,394 |
conda | conda/plugins/subcommands/doctor/health_checks/consistency.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Health check: Environment consistency (dependencies)."""
from __future__ import annotations
from typing import TYPE_CHECKING
from .....base.constants import OK_MARK, X_MARK
from .....base.context import context
from .....cli.install import... | 136 | 4,652 |
clearml | clearml/automation/cloud_driver.py | .py | import logging
from abc import ABC, abstractmethod
import os
from typing import List, Tuple, Any
import attr
from ..backend_api import Session
from ..backend_api.session.defs import ENV_AUTH_TOKEN
env_git_user = "CLEARML_AUTOSCALER_GIT_USER"
env_git_pass = "CLEARML_AUTOSCALER_GIT_PASSWORD"
bash_script_template = ""... | 236 | 6,905 |
sphinx | sphinx/domains/math.py | .py | """The math domain."""
from __future__ import annotations
from typing import TYPE_CHECKING
from docutils import nodes
from docutils.nodes import make_id
from sphinx.domains import Domain
from sphinx.locale import __
from sphinx.roles import XRefRole
from sphinx.util import logging
from sphinx.util.nodes import make... | 171 | 5,363 |
metrics | src/torchmetrics/functional/nominal/fleiss_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... | 100 | 4,226 |
saleor | saleor/tests/e2e/account/utils/customer_update.py | .py | from ...utils import get_graphql_content
CUSTOMER_UPDATE_MUTATION = """
mutation CustomerUpdate($id: ID!, $input: CustomerInput!) {
customerUpdate(id: $id, input: $input) {
errors {
field
message
code
}
user {
id
email
isActive
isConfirmed
isStaff
met... | 51 | 855 |
hydra | hydra/_internal/core_plugins/importlib_resources_config_source.py | .py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import zipfile
from importlib import resources
from typing import Any, List, Optional
from omegaconf import OmegaConf
from hydra.core.object_type import ObjectType
from hydra.plugins.config_source import ConfigLoadError, ConfigResult, Co... | 98 | 3,456 |
sqlmap | extra/dbwire/mysql.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 MySQL client/server protocol client (stdlib only).
Covers the whole MySQL-wire family (MySQL, MariaDB, TiDB, Aurora-MySQL, Percona, ...). Auth:
mysql_nati... | 373 | 15,958 |
saleor | saleor/tests/e2e/product/utils/product_query.py | .py | from ...utils import get_graphql_content
PRODUCT_QUERY = """
query Product($id: ID!, $channel: String) {
product(id: $id, channel: $channel) {
id
name
attributes {
attribute {
id
}
values {
name
}
}
pricing {
onSale
}
variants {
id
... | 90 | 1,377 |
onnx | onnx/backend/test/case/node/acos.py | .py | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class Acos(Base):
@staticmethod
def export() -> None:
node =... | 29 | 726 |
pymc | tests/model/test_fgraph.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... | 401 | 15,681 |
lemur | lemur/plugins/lemur_entrust/tests/test_entrust.py | .py | from unittest.mock import patch, Mock
import arrow
from cryptography import x509
from cryptography.x509 import CertificateSigningRequest, Extension, Extensions
from lemur.plugins.lemur_entrust import plugin
from freezegun import freeze_time
_base_config = {
"ENTRUST_API_CERT": "-----BEGIN CERTIFICATE-----abc-----... | 149 | 5,759 |
beam | sdks/python/apache_beam/internal/code_object_pickler_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... | 571 | 21,978 |
pyro | pyro/distributions/stable_log_prob.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import math
from functools import partial
import torch
value_near_zero_tolerance_alpha = 0.01
value_near_zero_tolerance_density = 0.1
alpha_near_one_tolerance = 0.05
finfo = torch.finfo(torch.float64)
MAX_LOG = math.log10(finfo.max... | 205 | 6,607 |
sphinx | tests/roots/test-ext-autodoc/target/slots.py | .py | class Foo:
"""docstring"""
__slots__ = ['attr']
class Bar:
"""docstring"""
__slots__ = {
'attr1': 'docstring of attr1',
'attr2': 'docstring of attr2',
'attr3': None,
}
__annotations__ = {'attr1': int}
def __init__(self):
self.attr2 = None #: docstring of... | 25 | 410 |
openvino | src/bindings/python/tests/test_graph/test_multinomial.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import openvino.opset13 as ops
from openvino import PartialShape, Type
@pytest.mark.parametrize(
(
"probs_shape", "num_samples_shape", "convert_type", "with_replacem... | 101 | 4,135 |
openvino | src/bindings/python/tests/utils/helpers.py | .py | # -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import io
from typing import Union
import os
import sys
import numpy as np
import base64
import re
from sys import platform
from pathlib import Path
import openvino
from openvino import Model, Core, Shape, Tens... | 342 | 12,347 |
readthedocs.org | readthedocs/api/v3/views.py | .py | import django_filters.rest_framework as filters
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.db.models import Exists
from django.db.models import OuterRef
from django.db.models import Prefetch
from rest_flex_fields import is_expanded
from rest_flex_f... | 758 | 25,743 |
astropy | astropy/io/ascii/cds.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""An extensible ASCII table reader and writer.
cds.py:
Classes to read CDS / Vizier table format
:Copyright: Smithsonian Astrophysical Observatory (2011)
:Author: Tom Aldcroft (aldcroft@head.cfa.harvard.edu)
"""
import fnmatch
import itertools
import... | 428 | 17,749 |
pyomo | pyomo/contrib/fme/fourier_motzkin_elimination.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... | 761 | 32,041 |
hatch | backend/src/hatchling/bridge/app.py | .py | from __future__ import annotations
import os
import sys
from typing import Any
class Application:
"""
The way output is displayed can be [configured](../config/hatch.md#terminal) by users.
!!! important
Never import this directly; Hatch judiciously decides if a type of plugin requires
th... | 112 | 3,890 |
beam | sdks/python/apache_beam/utils/proto_utils_test.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 68 | 2,453 |
pyomo | pyomo/gdp/plugins/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... | 156 | 6,419 |
python-prompt-toolkit | examples/choices/default.py | .py | from __future__ import annotations
from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.shortcuts import choice
def main() -> None:
result = choice(
message=HTML("<u>Please select a dish</u>:"),
options=[
("pizza", "Pizza with mushrooms"),
("salad", "Salad wi... | 22 | 467 |
pyomo | pyomo/gdp/tests/__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... | 13 | 571 |
beam | sdks/python/apache_beam/typehints/pandas_type_compatibility_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... | 237 | 8,323 |
onnxruntime | onnxruntime/test/testdata/transform/fusion/bias_gelu_matmul_gen.py | .py | import onnx
from onnx import TensorProto, helper
graph = helper.make_graph(
[ # nodes
# Add node before Gelu
helper.make_node("Add", ["A", "B"], ["add0_out"], "add0"),
# Gelu subgraph
helper.make_node("Div", ["add0_out", "div_const"], ["div_out"], "div"),
helper.make_node("... | 35 | 1,487 |
black | tests/data/cases/line_ranges_fmt_off.py | .py | # flags: --line-ranges=7-7 --line-ranges=17-23
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
# fmt: off
import os
def myfunc( ): # Intentionally unformatted.
pass
# fmt: on
def myfunc( ): # This will not be... | 50 | 1,373 |
mlflow | tests/evaluate/logging/test_evaluation.py | .py | from unittest import mock
from mlflow.entities import Metric
from mlflow.evaluation import Assessment, Evaluation
from mlflow.evaluation.assessment import AssessmentSource
from mlflow.evaluation.evaluation_tag import EvaluationTag
def test_evaluation_equality():
inputs = {"feature1": 1.0, "feature2": 2.0}
ou... | 247 | 8,548 |
wandb | wandb/sdk/lib/handler_util.py | .py | import wandb.data_types as data_types
def get_types():
classes = map(data_types.__dict__.get, data_types.__all__)
types = []
for cls in classes:
if hasattr(cls, "_log_type") and cls._log_type is not None:
types.append(cls._log_type)
# add table-file type because this is a special c... | 22 | 589 |
beam | sdks/python/apache_beam/examples/cookbook/bigquery_tornadoes_it_test.py | .py | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 77 | 2,753 |
loguru | tests/exceptions/source/others/assertionerror_without_traceback.py | .py | import sys
from loguru import logger
def test(diagnose, backtrace):
logger.remove()
logger.add(sys.stderr, format="", diagnose=diagnose, backtrace=backtrace, colorize=True)
try:
assert False
except AssertionError:
type_, value, _ = sys.exc_info()
logger.opt(exception=(type_, ... | 21 | 418 |
pyro | tests/contrib/funsor/test_named_handlers.py | .py | # Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
import logging
from collections import OrderedDict
import pytest
import torch
# put all funsor-related imports here, so test collection works without funsor
try:
import funsor
from funsor.tensor import Tensor
import pyro... | 159 | 5,329 |
textual | src/textual/driver.py | .py | from __future__ import annotations
import asyncio
import threading
from abc import ABC, abstractmethod
from contextlib import contextmanager
from pathlib import Path
from typing import TYPE_CHECKING, Any, BinaryIO, Iterator, Literal, TextIO
from textual import events, log, messages
from textual.events import MouseUp
... | 302 | 10,325 |
python-prompt-toolkit | examples/progress-bar/styled-tqdm-2.py | .py | #!/usr/bin/env python
"""
Styled similar to tqdm, another progress bar implementation in Python.
See: https://github.com/noamraph/tqdm
"""
import time
from prompt_toolkit.shortcuts import ProgressBar
from prompt_toolkit.shortcuts.progress_bar import formatters
from prompt_toolkit.styles import Style
style = Style.f... | 40 | 1,035 |
pyro | pyro/distributions/inverse_gamma.py | .py | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
from torch.distributions import constraints
from torch.distributions.transforms import PowerTransform
from pyro.distributions.torch import Gamma, TransformedDistribution
# DEPRECATED in favor of torch.distributions.InverseGamma.... | 49 | 1,489 |
luigi | test/target_test.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 357 | 11,076 |
probability | spinoffs/inference_gym/inference_gym/targets/ground_truth/convection_lorenz_bridge.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... | 306 | 7,766 |
mlflow | mlflow/gateway/providers/openrouter.py | .py | from mlflow.gateway.config import _OpenAICompatibleConfig
from mlflow.gateway.providers.openai_compatible import OpenAICompatibleProvider
class OpenRouterProvider(OpenAICompatibleProvider):
DISPLAY_NAME = "OpenRouter"
CONFIG_TYPE = _OpenAICompatibleConfig
DEFAULT_API_BASE = "https://openrouter.ai/api/v1"
| 9 | 320 |
voila | tests/app/notebooks_test.py | .py | # simply tests if some notebooks execute
import pytest
NOTEBOOK_PATH = "other_comms.ipynb"
@pytest.fixture
def notebook_other_comms_path(base_url):
return base_url + f"voila/render/{NOTEBOOK_PATH}"
@pytest.fixture
def voila_args(notebook_directory, voila_args_extra):
return ["--VoilaTest.root_dir=%r" % not... | 21 | 601 |
openvino | tests/layer_tests/jax_tests/test_erf.py | .py | # Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import jax
import numpy as np
import pytest
from jax import numpy as jnp
from jax_layer_test_class import JaxLayerTest
rng = np.random.default_rng(109734)
class TestErf(JaxLayerTest):
def _prepare_input(self):
# erf are m... | 40 | 1,148 |
saleor | saleor/graphql/attribute/utils/type_handlers.py | .py | import abc
import datetime
import re
from collections.abc import Sequence
from typing import TYPE_CHECKING
from django.core.exceptions import ValidationError
from django.db.models import Q
from django.utils.text import slugify
from graphql.error import GraphQLError
from text_unidecode import unidecode
from ....attrib... | 847 | 32,054 |
ipython | tests/test_macro.py | .py | """Tests for IPython.core.macro"""
import pickle
import pytest
from IPython.core.macro import Macro
def test_macro_stores_code_with_trailing_newline():
m = Macro("a = 1")
assert m.value == "a = 1\n"
def test_macro_multiline():
m = Macro("a = 1\nb = 2")
assert m.value == "a = 1\nb = 2\n"
def tes... | 108 | 2,514 |
mlflow | mlflow/data/huggingface_dataset_source.py | .py | from typing import TYPE_CHECKING, Any, Mapping, Sequence, Union
from packaging.version import Version
from mlflow.data.dataset_source import DatasetSource
if TYPE_CHECKING:
import datasets
class HuggingFaceDatasetSource(DatasetSource):
"""Represents the source of a Hugging Face dataset used in MLflow Track... | 117 | 4,554 |
probability | tensorflow_probability/python/optimizer/differential_evolution_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... | 243 | 8,598 |
mlflow | mlflow/store/db_migrations/versions/2b4d017a5e9b_add_model_registry_tables_to_db.py | .py | """add model registry tables to db
Create Date: 2019-10-14 12:20:12.874424
"""
import time
from alembic import op
from sqlalchemy import (
BigInteger,
Column,
ForeignKey,
Integer,
PrimaryKeyConstraint,
String,
orm,
)
from mlflow.entities.model_registry.model_version_stages import STAGE_... | 68 | 2,253 |
cvxpy | cvxpy/reductions/eliminate_pwl/eliminate_pwl.py | .py | """
Copyright 2017 Robin Verschueren
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, softw... | 38 | 1,451 |
cvxpy | cvxpy/reductions/dgp2dcp/canonicalizers/mulexpression_canon.py | .py | """
Copyright 2024 the CVXPY 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 law or agreed to in writing, so... | 42 | 1,469 |
probability | tensorflow_probability/python/internal/backend/numpy/gen/linear_operator_full_matrix.py | .py | # Copyright 2020 The TensorFlow Probability Authors. All Rights Reserved.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# THIS FILE IS AUTO-GENERATED BY `gen_linear_operators.py`.
# DO NOT MODIFY DIRECTLY.
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@... | 244 | 9,209 |
luigi | luigi/contrib/gcs.py | .py | # -*- coding: utf-8 -*-
#
# Copyright 2015 Twitter Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 511 | 18,557 |
conda | conda/_preview/__init__.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Private namespace for conda preview features.
This package contains opt-in preview features that are not yet part of the
stable conda API. Code here may change or be removed across any release without
deprecation notices.
Conventions
------... | 26 | 1,117 |
astropy | astropy/utils/tests/test_parsing.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import importlib
import secrets
from py_compile import compile
from textwrap import dedent
import pytest
from astropy.utils.parsing import _TAB_HEADER
def _docstring_canary():
"""Docstring that's here just to check for -OO."""
@pytest.mark.skipi... | 98 | 3,079 |
textual | src/textual/widgets/selection_list.py | .py | from textual.widgets._selection_list import (
MessageSelectionType,
Selection,
SelectionError,
SelectionType,
)
__all__ = ["MessageSelectionType", "Selection", "SelectionError", "SelectionType"]
| 9 | 212 |
metrics | tests/unittests/multimodal/test_clip_iqa.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... | 212 | 8,142 |
mlflow | tests/entities/test_gateway_endpoint.py | .py | from mlflow.entities import (
GatewayEndpoint,
GatewayEndpointBinding,
GatewayEndpointModelMapping,
GatewayModelDefinition,
GatewayModelLinkageType,
GatewayResourceType,
)
def test_model_definition_creation_full():
model_def = GatewayModelDefinition(
model_definition_id="model-def-... | 409 | 13,573 |
conda | conda/plugins/virtual_packages/freebsd.py | .py | # Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Detect whether this is FeeBSD."""
from __future__ import annotations
from typing import TYPE_CHECKING
from ...base.context import context
from .. import hookimpl
from ..types import CondaVirtualPackage
if TYPE_CHECKING:
from collectio... | 29 | 708 |
probability | tensorflow_probability/python/experimental/parallel_filter/parallel_kalman_filter_lib.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... | 716 | 32,022 |
coremltools | coremltools/optimize/torch/_utils/dist_utils.py | .py | # Copyright (c) 2024, 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 as _os
import torch as _torch
import torch.distributed as _dist
def ddp_setup(rank: int,... | 37 | 1,100 |
sqlmap | plugins/dbms/spanner/enumeration.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.data import logger
from lib.core.settings import SPANNER_DEFAULT_SCHEMA
from plugins.generic.enumeration import Enumeration as GenericEnumeration
class Enumeration(... | 51 | 1,506 |
cvxpy | cvxpy/tests/test_power_tools.py | .py | """
Copyright 2022, the CVXPY 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 law or agreed to in writing, s... | 161 | 6,249 |
saleor | saleor/checkout/tests/test_search_loaders.py | .py | from decimal import Decimal
from ...payment.models import Payment, TransactionItem
from ..search.loaders import load_checkout_data
def test_load_checkout_data(checkout_with_item, customer_user, address, address_usa):
# given
checkout_with_item.user = customer_user
checkout_with_item.billing_address = add... | 88 | 2,414 |
gunicorn | gunicorn/http2/stream.py | .py | # -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
HTTP/2 stream state management.
Each HTTP/2 stream represents a single request/response exchange.
"""
from enum import Enum, auto
from io import BytesIO
from .errors import HTTP2StreamE... | 365 | 10,993 |
django-cms | cms/admin/pageadmin.py | .py | from __future__ import annotations
import json
import re
from collections import defaultdict, namedtuple
import django
from django.conf import settings
from django.contrib import admin, messages
from django.contrib.admin.helpers import AdminForm
from django.contrib.admin.options import IS_POPUP_VAR
from django.contri... | 1,437 | 57,219 |
pymc | pymc/model/transform/__init__.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... | 45 | 1,349 |
readthedocs.org | readthedocs/projects/views/mixins.py | .py | """Mixin classes for project views."""
from urllib.parse import urlparse
import structlog
from celery import chain
from django.shortcuts import get_object_or_404
from readthedocs.core.resolver import Resolver
from readthedocs.core.utils import prepare_build
from readthedocs.projects.models import Project
log = str... | 141 | 4,549 |
readthedocs.org | readthedocs/search/api/v3/serializers.py | .py | from rest_framework import serializers
from readthedocs.search.api.v2.serializers import PageSearchSerializer as PageSearchSerializerBase
class PageSearchSerializer(PageSearchSerializerBase):
"""
Serializer for API V3.
This is very similar to the serializer from V2,
with the following changes:
... | 36 | 966 |
saleor | saleor/core/tests/test_weight.py | .py | import pytest
from measurement.measures import Weight
from ..units import WeightUnits
from ..weight import (
convert_weight,
convert_weight_to_default_weight_unit,
get_default_weight_unit,
)
def test_convert_weight():
# given
weight = Weight(kg=1)
expected_result = Weight(g=1000)
# when
... | 53 | 1,213 |
beam | sdks/python/apache_beam/examples/complete/game/hourly_team_score_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... | 59 | 2,107 |
astropy | astropy/io/fits/fitsrec.py | .py | # Licensed under a 3-clause BSD style license - see PYFITS.rst
import copy
import math
import warnings
import weakref
from contextlib import suppress
import numpy as np
from astropy.utils import lazyproperty
from astropy.utils.compat import chararray, get_chararray
from astropy.utils.exceptions import AstropyUserWar... | 1,589 | 65,612 |
pymc | tests/step_methods/hmc/test_quadpotential.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... | 300 | 10,206 |
mlflow | mlflow/pytorch/_pytorch_autolog.py | .py | import time
import mlflow
from mlflow.entities import Metric, Param
from mlflow.tracking import MlflowClient
from mlflow.utils.autologging_utils.metrics_queue import (
add_to_metrics_queue,
flush_metrics_queue,
)
def patched_add_hparams(original, self, hparam_dict, metric_dict, *args, **kwargs):
"""use a... | 51 | 1,874 |
saleor | saleor/graphql/shop/mutations/refund_reason_reference_type_clear.py | .py | import graphene
from ....permission.enums import SitePermissions
from ...core import ResolveInfo
from ...core.descriptions import ADDED_IN_322
from ...core.doc_category import DOC_CATEGORY_ORDERS
from ...core.mutations import BaseMutation
from ...core.types.common import RefundReasonReferenceTypeClearError
from ...sit... | 38 | 1,437 |
readthedocs.org | readthedocs/oauth/management/commands/sync_vcs_data.py | .py | import datetime
import json
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand
from django.utils import timezone
from readthedocs.oauth.tasks import sync_remote_repositories
class Command(BaseCommand):
help = "Sync OAuth RemoteRepository and RemoteOrganization"
... | 129 | 4,585 |
saleor | saleor/graphql/checkout/tests/mutations/test_checkout_customer_note_update.py | .py | from unittest.mock import ANY, patch
import pytest
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from .....checkout.actions import call_checkout_event
from .....core.models import EventDelivery
from .....product.models import ProductChannelListing, Produ... | 243 | 7,886 |
saleor | saleor/webhook/response_schemas/__init__.py | .py | from .payment import (
ListStoredPaymentMethodsSchema,
PaymentGatewayInitializeTokenizationSessionSchema,
PaymentMethodTokenizationFailedSchema,
PaymentMethodTokenizationPendingSchema,
PaymentMethodTokenizationSuccessSchema,
StoredPaymentMethodDeleteRequestedSchema,
)
from .shipping import Filte... | 127 | 3,900 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.