repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
dgasmith/opt_einsum | import itertools
from concurrent.futures import ProcessPoolExecutor
from typing import Any, Dict, List, Optional
import pytest
import opt_einsum as oe
from opt_einsum.testing import build_shapes, rand_equation
from opt_einsum.typing import ArrayIndexType, OptimizeKind, PathType, TensorShapeType
explicit_path_tests =... | 10 | assert | numeric_literal | opt_einsum/tests/test_paths.py | test_custom_random_greedy | 341 | null | |
dgasmith/opt_einsum | from typing import Any, List
import pytest
from opt_einsum import contract, contract_expression, contract_path
from opt_einsum.paths import _PATH_OPTIONS, linear_to_ssa, ssa_to_linear
from opt_einsum.testing import build_views, rand_equation
from opt_einsum.typing import OptimizeKind
np = pytest.importorskip("numpy"... | 728 | assert | numeric_literal | opt_einsum/tests/test_contract.py | test_printing | 184 | null | |
dgasmith/opt_einsum | from typing import Set
import pytest
from opt_einsum import backends, contract, contract_expression, sharing
from opt_einsum.contract import ArrayShaped, infer_backend, parse_backend
from opt_einsum.testing import build_views
tests = [
"ab,bc->ca",
"abc,bcd,dea",
"abc,def->fedcba",
"abc,bcd,df->fa",
... | ein) | pytest.approx | variable | opt_einsum/tests/test_backends.py | test_sparse | 373 | null | |
dgasmith/opt_einsum | from typing import Any, Tuple
import pytest
from opt_einsum import contract, contract_expression, contract_path
from opt_einsum.typing import PathType
np = pytest.importorskip("numpy")
def test_pathinfo_for_empty_contraction() -> None:
eq = "->"
arrays = (1.0,)
path: PathType = []
_, info = contract... | 1 | assert | numeric_literal | opt_einsum/tests/test_edge_cases.py | test_pathinfo_for_empty_contraction | 135 | null | |
dgasmith/opt_einsum | from typing import Set
import pytest
from opt_einsum import backends, contract, contract_expression, sharing
from opt_einsum.contract import ArrayShaped, infer_backend, parse_backend
from opt_einsum.testing import build_views
tests = [
"ab,bc->ca",
"abc,bcd,dea",
"abc,def->fedcba",
"abc,bcd,df->fa",
... | 0 | assert | numeric_literal | opt_einsum/tests/test_backends.py | test_tensorflow_with_sharing | 108 | null | |
dgasmith/opt_einsum | from typing import Any, Tuple
import pytest
from opt_einsum.parser import get_shape, get_symbol, parse_einsum_input
from opt_einsum.testing import build_arrays_from_tuples
def test_parse_einsum_input() -> None:
eq = "ab,bc,cd"
ops = build_arrays_from_tuples([(2, 3), (3, 4), (4, 5)])
input_subscripts, out... | eq | assert | variable | opt_einsum/tests/test_parser.py | test_parse_einsum_input | 26 | null | |
dgasmith/opt_einsum | from typing import Any
import pytest
from opt_einsum import contract, contract_path
from opt_einsum.testing import build_views
np = pytest.importorskip("numpy")
@pytest.mark.parametrize("contract_fn", [contract, contract_path])
def test_value_errors(contract_fn: Any) -> None:
with pytest.raises( | ValueError) | pytest.raises | variable | opt_einsum/tests/test_input.py | test_value_errors | 74 | null | |
dgasmith/opt_einsum | import itertools
from concurrent.futures import ProcessPoolExecutor
from typing import Any, Dict, List, Optional
import pytest
import opt_einsum as oe
from opt_einsum.testing import build_shapes, rand_equation
from opt_einsum.typing import ArrayIndexType, OptimizeKind, PathType, TensorShapeType
explicit_path_tests =... | 3 | assert | numeric_literal | opt_einsum/tests/test_paths.py | test_dp_edge_cases_dimension_1 | 220 | null | |
dgasmith/opt_einsum | import itertools
from concurrent.futures import ProcessPoolExecutor
from typing import Any, Dict, List, Optional
import pytest
import opt_einsum as oe
from opt_einsum.testing import build_shapes, rand_equation
from opt_einsum.typing import ArrayIndexType, OptimizeKind, PathType, TensorShapeType
explicit_path_tests =... | out | assert | variable | opt_einsum/tests/test_paths.py | test_custom_path_optimizer | 468 | null | |
dgasmith/opt_einsum | from typing import Any, Tuple
import pytest
from opt_einsum.parser import get_shape, get_symbol, parse_einsum_input
from opt_einsum.testing import build_arrays_from_tuples
def test_parse_einsum_input_shapes_error() -> None:
eq = "ab,bc,cd"
ops = build_arrays_from_tuples([(2, 3), (3, 4), (4, 5)])
with p... | ValueError) | pytest.raises | variable | opt_einsum/tests/test_parser.py | test_parse_einsum_input_shapes_error | 35 | null | |
dgasmith/opt_einsum | from typing import Any, Tuple
import pytest
from opt_einsum.parser import get_shape, get_symbol, parse_einsum_input
from opt_einsum.testing import build_arrays_from_tuples
@pytest.mark.parametrize(
"array, shape",
[
[[5], (1,)],
[[5, 5], (2,)],
[(5, 5), (2,)],
[[[[[[5, 2]]]]],... | shape | assert | variable | opt_einsum/tests/test_parser.py | test_get_shapes | 74 | null | |
dgasmith/opt_einsum | from typing import Set
import pytest
from opt_einsum import backends, contract, contract_expression, sharing
from opt_einsum.contract import ArrayShaped, infer_backend, parse_backend
from opt_einsum.testing import build_views
tests = [
"ab,bc->ca",
"abc,bcd,dea",
"abc,def->fedcba",
"abc,bcd,df->fa",
... | x1 | assert | variable | opt_einsum/tests/test_backends.py | test_jax_jit_gradient | 301 | null | |
dgasmith/opt_einsum | import itertools
import weakref
from collections import Counter
from typing import Any
import pytest
from opt_einsum import contract, contract_expression, contract_path, get_symbol, shared_intermediates
from opt_einsum.backends import to_cupy, to_torch
from opt_einsum.contract import _einsum
from opt_einsum.parser im... | expected | assert | variable | opt_einsum/tests/test_sharing.py | test_complete_sharing | 94 | null | |
dgasmith/opt_einsum | import itertools
from concurrent.futures import ProcessPoolExecutor
from typing import Any, Dict, List, Optional
import pytest
import opt_einsum as oe
from opt_einsum.testing import build_shapes, rand_equation
from opt_einsum.typing import ArrayIndexType, OptimizeKind, PathType, TensorShapeType
explicit_path_tests =... | 6 | assert | numeric_literal | opt_einsum/tests/test_paths.py | test_explicit_path | 134 | null | |
dgasmith/opt_einsum | import itertools
from concurrent.futures import ProcessPoolExecutor
from typing import Any, Dict, List, Optional
import pytest
import opt_einsum as oe
from opt_einsum.testing import build_shapes, rand_equation
from opt_einsum.typing import ArrayIndexType, OptimizeKind, PathType, TensorShapeType
explicit_path_tests =... | order | assert | variable | opt_einsum/tests/test_paths.py | test_path_scalar_cases | 190 | null | |
dgasmith/opt_einsum | from typing import Set
import pytest
from opt_einsum import backends, contract, contract_expression, sharing
from opt_einsum.contract import ArrayShaped, infer_backend, parse_backend
from opt_einsum.testing import build_views
tests = [
"ab,bc->ca",
"abc,bcd,dea",
"abc,def->fedcba",
"abc,bcd,df->fa",
... | cache | assert | variable | opt_einsum/tests/test_backends.py | test_tensorflow_with_sharing | 106 | null | |
dgasmith/opt_einsum | from typing import Any, Tuple
import pytest
from opt_einsum.parser import get_shape, get_symbol, parse_einsum_input
from opt_einsum.testing import build_arrays_from_tuples
def test_parse_einsum_input() -> None:
eq = "ab,bc,cd"
ops = build_arrays_from_tuples([(2, 3), (3, 4), (4, 5)])
input_subscripts, out... | "ad" | assert | string_literal | opt_einsum/tests/test_parser.py | test_parse_einsum_input | 27 | null | |
dgasmith/opt_einsum | from typing import Any, List
import pytest
from opt_einsum import contract, contract_expression, contract_path
from opt_einsum.paths import _PATH_OPTIONS, linear_to_ssa, ssa_to_linear
from opt_einsum.testing import build_views, rand_equation
from opt_einsum.typing import OptimizeKind
np = pytest.importorskip("numpy"... | linear_path | assert | variable | opt_einsum/tests/test_contract.py | test_linear_vs_ssa | 273 | null | |
dgasmith/opt_einsum | from typing import Set
import pytest
from opt_einsum import backends, contract, contract_expression, sharing
from opt_einsum.contract import ArrayShaped, infer_backend, parse_backend
from opt_einsum.testing import build_views
tests = [
"ab,bc->ca",
"abc,bcd,dea",
"abc,def->fedcba",
"abc,bcd,df->fa",
... | res_got2) | assert_* | variable | opt_einsum/tests/test_backends.py | test_torch_with_constants | 426 | null | |
dgasmith/opt_einsum | import itertools
from concurrent.futures import ProcessPoolExecutor
from typing import Any, Dict, List, Optional
import pytest
import opt_einsum as oe
from opt_einsum.testing import build_shapes, rand_equation
from opt_einsum.typing import ArrayIndexType, OptimizeKind, PathType, TensorShapeType
explicit_path_tests =... | width | assert | variable | opt_einsum/tests/test_paths.py | test_custom_dp_can_set_minimize | 287 | null | |
dgasmith/opt_einsum | from typing import Set
import pytest
from opt_einsum import backends, contract, contract_expression, sharing
from opt_einsum.contract import ArrayShaped, infer_backend, parse_backend
from opt_einsum.testing import build_views
tests = [
"ab,bc->ca",
"abc,bcd,dea",
"abc,def->fedcba",
"abc,bcd,df->fa",
... | opt) | assert_* | variable | opt_einsum/tests/test_backends.py | test_torch | 397 | null | |
dgasmith/opt_einsum | from typing import Any
import pytest
from opt_einsum import blas, contract
blas_tests = [
# DOT
((["k", "k"], "", set("k")), "DOT"), # DDOT
((["ijk", "ijk"], "", set("ijk")), "DOT"), # DDOT
# GEMV?
# GEMM
((["ij", "jk"], "ik", set("j")), "GEMM"), # GEMM N N
((["ijl", "jlk"], "ik", set(... | benchmark | assert | variable | opt_einsum/tests/test_blas.py | test_can_blas | 65 | null | |
dgasmith/opt_einsum | from typing import Any, List
import pytest
from opt_einsum import contract, contract_expression, contract_path
from opt_einsum.paths import _PATH_OPTIONS, linear_to_ssa, ssa_to_linear
from opt_einsum.testing import build_views, rand_equation
from opt_einsum.typing import OptimizeKind
np = pytest.importorskip("numpy"... | 2 | assert | numeric_literal | opt_einsum/tests/test_contract.py | test_contract_plain_types | 109 | null | |
dgasmith/opt_einsum | from typing import Any
import pytest
from opt_einsum import blas, contract
blas_tests = [
# DOT
((["k", "k"], "", set("k")), "DOT"), # DDOT
((["ijk", "ijk"], "", set("ijk")), "DOT"), # DDOT
# GEMV?
# GEMM
((["ij", "jk"], "ik", set("j")), "GEMM"), # GEMM N N
((["ijl", "jlk"], "ik", set(... | np.dot(a, b).dot(c)) | assert_* | func_call | opt_einsum/tests/test_blas.py | test_blas_out | 81 | null | |
dgasmith/opt_einsum | from typing import Any, Tuple
import pytest
from opt_einsum.parser import get_shape, get_symbol, parse_einsum_input
from opt_einsum.testing import build_arrays_from_tuples
def test_parse_einsum_input_shapes() -> None:
eq = "ab,bc,cd"
shapes = [(2, 3), (3, 4), (4, 5)]
input_subscripts, output_subscript, o... | operands | assert | variable | opt_einsum/tests/test_parser.py | test_parse_einsum_input_shapes | 45 | null | |
dgasmith/opt_einsum | import itertools
import weakref
from collections import Counter
from typing import Any
import pytest
from opt_einsum import contract, contract_expression, contract_path, get_symbol, shared_intermediates
from opt_einsum.backends import to_cupy, to_torch
from opt_einsum.contract import _einsum
from opt_einsum.parser im... | num_exprs_sharing | assert | variable | opt_einsum/tests/test_sharing.py | test_chain_sharing | 370 | null | |
dgasmith/opt_einsum | from typing import Any
import pytest
from opt_einsum import contract, contract_path
from opt_einsum.testing import build_views
np = pytest.importorskip("numpy")
def test_input_formats_shapes():
"""
Test that the shapes are the same for the bench and interleved input formats
"""
shape1 = (2, 3, 4)
... | interleved[0] | assert | complex_expr | opt_einsum/tests/test_input.py | test_input_formats_shapes | 162 | null | |
gao-lab/GLUE | import warnings
import anndata
import numpy as np
import pytest
import scglue
from ..utils import cmp_arrays
@pytest.mark.parametrize("rna_prob", ["NB"])
@pytest.mark.parametrize("atac_prob", ["NB", "ZINB"])
@pytest.mark.parametrize("model", ["SCGLUE", "PairedSCGLUE"])
@pytest.mark.parametrize("backed", [False, Tru... | ValueError) | pytest.raises | variable | tests/models/test_scglue.py | test_save_load | 64 | null | |
gao-lab/GLUE | import networkx as nx
import pytest
import scglue
from .utils import cmp_graphs
def test_bed(bed_file, fasta_file, fai_file):
bed = scglue.genomics.Bed.read_bed(bed_file)
bed.write_bed(bed_file)
assert bed.equals(scglue.genomics.Bed.read_bed(bed_file))
assert bed.equals(bed.expand(0, 0))
assert b... | ValueError) | pytest.raises | variable | tests/test_genomics.py | test_bed | 32 | null | |
gao-lab/GLUE | import networkx as nx
import numpy as np
import pandas as pd
import pytest
import scglue
import scglue.models.data
from ..utils import cmp_arrays
def test_array_dataset(rna, atac):
dataset = scglue.models.data.ArrayDataset(rna.X, atac.X)
assert dataset.size == max(dataset.sizes)
_ = dataset.random_split(... | ValueError) | pytest.raises | variable | tests/models/test_data.py | test_array_dataset | 32 | null | |
gao-lab/GLUE | import numpy as np
import pytest
import scglue
def test_sigmoid():
assert scglue.num.sigmoid(0) == | 0.5 | assert | numeric_literal | tests/test_num.py | test_sigmoid | 14 | null | |
gao-lab/GLUE | import numpy as np
import pytest
import scanpy as sc
import scglue
from .utils import cmp_arrays
def test_get_gene_annotation(rna, gtf_file):
with pytest.raises( | ValueError) | pytest.raises | variable | tests/test_data.py | test_get_gene_annotation | 22 | null | |
gao-lab/GLUE | import warnings
import anndata
import pytest
import scglue
from ..utils import cmp_arrays
@pytest.mark.parametrize("rna_prob", ["NB"])
@pytest.mark.parametrize("atac_prob", ["NB"])
@pytest.mark.parametrize("backed", [False, True])
def test_save_load(rna_pp, atac_pp, tmp_path, rna_prob, atac_prob, backed):
Acti... | ValueError) | pytest.raises | variable | tests/models/test_scclue.py | test_save_load | 52 | null | |
gao-lab/GLUE | import pytest
import scglue.check
def test_module_checker():
module_checker = scglue.check.ModuleChecker(
"numpy", vmin=None, install_hint="You may install via..."
)
module_checker.check()
module_checker = scglue.check.ModuleChecker(
"numpy", vmin="99.99.99", install_hint="You may ins... | RuntimeError) | pytest.raises | variable | tests/test_check.py | test_module_checker | 19 | null | |
gao-lab/GLUE | import pandas as pd
import pytest
import scglue
def test_configure_dataset(rna):
with pytest.raises( | ValueError) | pytest.raises | variable | tests/models/test_init.py | test_configure_dataset | 14 | null | |
gao-lab/GLUE | import numpy as np
import pytest
import scglue.metrics
def test_normalized_mutual_info(rna_pp):
normalized_mutual_info = scglue.metrics.normalized_mutual_info(
rna_pp.obsm["X_pca"], rna_pp.obs["ct"].to_numpy().ravel()
)
assert 0 <= | normalized_mutual_info | assert | variable | tests/test_metrics.py | test_normalized_mutual_info | 25 | null | |
gao-lab/GLUE | import numpy as np
import pytest
import scglue.metrics
def test_graph_connectivity(atac_pp):
graph_connectivity = scglue.metrics.graph_connectivity(
atac_pp.obsm["X_lsi"], atac_pp.obs["batch"].to_numpy().ravel()
)
assert 0 <= | graph_connectivity | assert | variable | tests/test_metrics.py | test_graph_connectivity | 39 | null | |
gao-lab/GLUE | import numpy as np
import pytest
import scanpy as sc
import scglue
from .utils import cmp_arrays
def test_aggregate_obs(rna_pp):
rna_agg = scglue.data.aggregate_obs(
rna_pp,
by="ct",
X_agg="sum",
obs_agg={"ct": "majority"},
obsm_agg={"X_pca": "mean"},
)
assert rna... | 3 | assert | numeric_literal | tests/test_data.py | test_aggregate_obs | 41 | null | |
gao-lab/GLUE | import pytest
import torch
import scglue
def test_base():
model = scglue.models.Model()
with pytest.raises( | RuntimeError) | pytest.raises | variable | tests/models/test_base.py | test_base | 13 | null | |
gao-lab/GLUE | import networkx as nx
import scglue
from .utils import cmp_graphs
def test_collapse_multigraph(composed_graph):
result = scglue.graph.collapse_multigraph(composed_graph)
result = scglue.graph.collapse_multigraph(
composed_graph, merge_fns={"dist": min, "weight": scglue.num.prob_or}
)
collapse... | 0 | assert | numeric_literal | tests/test_graph.py | test_collapse_multigraph | 61 | null | |
gao-lab/GLUE | import warnings
import anndata
import pytest
import scglue
from ..utils import cmp_arrays
@pytest.mark.parametrize("rna_prob", ["NB"])
@pytest.mark.parametrize("atac_prob", ["NB"])
@pytest.mark.parametrize("backed", [False, True])
def test_save_load(rna_pp, atac_pp, tmp_path, rna_prob, atac_prob, backed):
Acti... | RuntimeError) | pytest.raises | variable | tests/models/test_scclue.py | test_save_load | 63 | null | |
gao-lab/GLUE | import logging
import scglue
def test_get_rs():
rs1 = scglue.utils.get_rs(0)
rs2 = scglue.utils.get_rs(rs1)
assert rs1 is | rs2 | assert | variable | tests/test_utils.py | test_get_rs | 32 | null | |
gao-lab/GLUE | import networkx as nx
import numpy as np
import pandas as pd
import pytest
import scglue
import scglue.models.data
from ..utils import cmp_arrays
def test_array_dataset(rna, atac):
dataset = scglue.models.data.ArrayDataset(rna.X, atac.X)
assert dataset.size == | max(dataset.sizes) | assert | func_call | tests/models/test_data.py | test_array_dataset | 30 | null | |
gao-lab/GLUE | import warnings
import anndata
import numpy as np
import pytest
import scglue
from ..utils import cmp_arrays
@pytest.mark.parametrize("rna_prob", ["NB"])
@pytest.mark.parametrize("atac_prob", ["NB", "ZINB"])
@pytest.mark.parametrize("model", ["SCGLUE", "PairedSCGLUE"])
@pytest.mark.parametrize("backed", [False, Tru... | RuntimeError) | pytest.raises | variable | tests/models/test_scglue.py | test_save_load | 82 | null | |
gao-lab/GLUE | import networkx as nx
import numpy as np
import pandas as pd
import pytest
import scglue
import scglue.models.data
from ..utils import cmp_arrays
def test_parallel_dataloader():
pdl = scglue.models.data.ParallelDataLoader(
range(3), range(5), cycle_flags=[False, False]
)
for i, _ in enumerate(pdl... | 2 | assert | numeric_literal | tests/models/test_data.py | test_parallel_dataloader | 124 | null | |
gao-lab/GLUE | import numpy as np
import pytest
import scglue
def test_sigmoid():
assert scglue.num.sigmoid(0) == 0.5
assert 0 < | scglue.num.sigmoid(-1) | assert | func_call | tests/test_num.py | test_sigmoid | 15 | null | |
gao-lab/GLUE | import warnings
import anndata
import numpy as np
import pytest
import scglue
from ..utils import cmp_arrays
@pytest.mark.parametrize("model", ["SCGLUE", "PairedSCGLUE"])
def test_abnormal(rna_pp, atac_pp, guidance, tmp_path, model):
if model == "SCGLUE":
ActiveModel = scglue.models.SCGLUEModel
eli... | KeyError) | pytest.raises | variable | tests/models/test_scglue.py | test_abnormal | 292 | null | |
gao-lab/GLUE | import numpy as np
import pytest
import scglue.metrics
def test_mean_average_precision(rna_pp):
mean_average_precision = scglue.metrics.mean_average_precision(
rna_pp.obsm["X_pca"], rna_pp.obs["ct"].to_numpy().ravel()
)
assert 0 <= | mean_average_precision | assert | variable | tests/test_metrics.py | test_mean_average_precision | 18 | null | |
gao-lab/GLUE | import numpy as np
import pytest
import scglue.metrics
def test_avg_silhouette_width_batch(atac_pp):
avg_silhouette_width_batch = scglue.metrics.avg_silhouette_width_batch(
atac_pp.obsm["X_lsi"],
atac_pp.obs["ct"].to_numpy().ravel(),
atac_pp.obs["batch"].to_numpy().ravel(),
)
asse... | avg_silhouette_width_batch | assert | variable | tests/test_metrics.py | test_avg_silhouette_width_batch | 55 | null | |
gao-lab/GLUE | import numpy as np
def cmp_arrays(a, b, squeeze=False):
a, b = np.asarray(a), np.asarray(b)
if squeeze:
a, b = a.squeeze(), b.squeeze()
assert np.allclose(a, b)
def cmp_graphs(a, b):
set_a = set(
(e, tuple(sorted(p for p in a.get_edge_data(*e).items()))) for e in a.edges
)
set_... | set_b | assert | variable | tests/utils.py | cmp_graphs | 24 | null | |
gao-lab/GLUE | import numpy as np
import pytest
import scglue.metrics
def test_seurat_alignment_score(atac_pp):
seurat_alignment_score = scglue.metrics.seurat_alignment_score(
atac_pp.obsm["X_lsi"], atac_pp.obs["batch"].to_numpy().ravel()
)
assert 0 <= | seurat_alignment_score | assert | variable | tests/test_metrics.py | test_seurat_alignment_score | 46 | null | |
gao-lab/GLUE | import pytest
import torch
import scglue
def test_base():
model = scglue.models.Model()
with pytest.raises(RuntimeError):
_ = model.trainer
model.compile()
with pytest.raises( | NotImplementedError) | pytest.raises | variable | tests/models/test_base.py | test_base | 16 | null | |
gao-lab/GLUE | import numpy as np
import pytest
import scglue.metrics
def test_foscttm(rna_pp, atac_pp):
foscttm_x, foscttm_y = scglue.metrics.foscttm(
rna_pp.obsm["X_pca"], rna_pp.obsm["X_pca"]
)
assert np.all(foscttm_x == 0)
assert np.all(foscttm_y == 0)
foscttm_x, foscttm_y = scglue.metrics.foscttm(
... | ValueError) | pytest.raises | variable | tests/test_metrics.py | test_foscttm | 86 | null | |
gao-lab/GLUE | import numpy as np
import pytest
import scglue.metrics
def test_avg_silhouette_width(rna_pp):
avg_silhouette_width = scglue.metrics.avg_silhouette_width(
rna_pp.obsm["X_pca"], rna_pp.obs["ct"].to_numpy().ravel()
)
assert 0 <= | avg_silhouette_width | assert | variable | tests/test_metrics.py | test_avg_silhouette_width | 32 | null | |
gao-lab/GLUE | import numpy as np
import pytest
import scglue
def test_col_var(mat, spmat):
_ = scglue.num.col_var(mat)
_ = scglue.num.col_var(spmat)
_ = scglue.num.col_var(mat[:10, :2], spmat[:10, :][:, :2])
with pytest.raises( | ValueError) | pytest.raises | variable | tests/test_num.py | test_col_var | 22 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import math
import time
import hiro
import pytest
from flask import Flask
from limits.errors import ConfigurationError
from limits.storage import MemoryStorage
from limits.strategies import MovingWindowRateLimiter
from flask_limiter import Limiter
from flask_limiter.constants impor... | 429 | assert | numeric_literal | tests/test_configuration.py | test_constructor_arguments_over_config | 52 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import hiro
from flask_limiter import RateLimitExceeded
def test_static_limit(extension_factory):
app, limiter = extension_factory()
@app.route("/t1")
def t1():
with limiter.limit("1/second"):
resp = "ok"
try:
with limiter.limit(... | response.text | assert | complex_expr | tests/test_context_manager.py | test_static_limit | 26 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import hiro
from flask_limiter import RateLimitExceeded
def test_scoped_context_manager(extension_factory):
app, limiter = extension_factory()
@app.route("/t1/<int:param>")
def t1(param: int):
with limiter.limit("1/second", scope=param):
return "p1"... | cli.get("/t1/2").status_code | assert | func_call | tests/test_context_manager.py | test_scoped_context_manager | 60 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import hiro
from flask_limiter import RateLimitExceeded
def test_static_limit(extension_factory):
app, limiter = extension_factory()
@app.route("/t1")
def t1():
with limiter.limit("1/second"):
resp = "ok"
try:
with limiter.limit(... | cli.get("/t1").status_code | assert | func_call | tests/test_context_manager.py | test_static_limit | 27 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import json
from unittest.mock import patch
import hiro
from flask import make_response
from flask_limiter.constants import ConfigVars
def test_fallback_to_memory(extension_factory):
app, limiter = extension_factory(
config={ConfigVars.ENABLED: True},
default_l... | 429 | assert | numeric_literal | tests/test_error_handling.py | test_fallback_to_memory | 335 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import json
from unittest.mock import patch
import hiro
from flask import make_response
from flask_limiter.constants import ConfigVars
def test_custom_error_message(extension_factory):
app, limiter = extension_factory()
@app.errorhandler(429)
def ratelimit_handler(e):... | b"uno" | assert | string_literal | tests/test_error_handling.py | test_custom_error_message | 66 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import flask_restful
import hiro
import pytest
from flask import request
from flask.views import MethodView, View
def test_pluggable_views(extension_factory):
app, limiter = extension_factory(default_limits=["1/hour"])
class Va(View):
methods = ["GET", "POST"]
... | cli.get("/a").status_code | assert | func_call | tests/test_views.py | test_pluggable_views | 38 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import asyncio
import logging
from functools import wraps
from unittest import mock
import hiro
from flask import Blueprint, Flask, current_app, g, make_response, request
from werkzeug.exceptions import BadRequest
from flask_limiter import ExemptionScope, Limiter, RouteLimit
from f... | 3 | assert | numeric_literal | tests/test_decorators.py | test_invalid_decorated_dynamic_limits | 326 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import hiro
import pytest
def setup(redis_connection, memcached_connection, mongo_connection):
redis_connection.flushall()
memcached_connection.flush_all()
@pytest.mark.parametrize(
"storage_uri",
[
"memcached://localhost:31211",
"redis://localhost:4... | cli.get("/t1").status_code | assert | func_call | tests/test_storage.py | test_fixed_window | 38 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import datetime
import logging
import hiro
from flask import Blueprint, Flask, current_app
from flask_limiter import ExemptionScope, Limiter
from flask_limiter.util import get_remote_address
def test_invalid_decorated_static_limit_blueprint(caplog):
caplog.set_level(logging.IN... | 429 | assert | numeric_literal | tests/test_blueprints.py | test_invalid_decorated_static_limit_blueprint | 520 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import math
import time
import hiro
import pytest
from flask import Flask
from limits.errors import ConfigurationError
from limits.storage import MemoryStorage
from limits.strategies import MovingWindowRateLimiter
from flask_limiter import Limiter
from flask_limiter.constants impor... | str(math.ceil(time.time() + 1)) | assert | func_call | tests/test_configuration.py | test_header_names_config | 73 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import time
import hiro
from flask import Blueprint
from flask_limiter.constants import ConfigVars
def test_invalid_ratelimit_key(extension_factory):
app, limiter = extension_factory({ConfigVars.HEADERS_ENABLED: True})
def func(*a):
return None
@app.route("/t... | 429 | assert | numeric_literal | tests/test_regressions.py | test_invalid_ratelimit_key | 93 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import functools
import logging
import time
from collections import Counter
from unittest import mock
import hiro
from flask import Flask, abort, make_response, request
from werkzeug.exceptions import BadRequest
from flask_limiter import Limit, Limiter, MetaLimit
from flask_limiter... | 2 | assert | numeric_literal | tests/test_flask_ext.py | test_default_on_breach_callback | 724 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import math
import time
import hiro
import pytest
from flask import Flask
from limits.errors import ConfigurationError
from limits.storage import MemoryStorage
from limits.strategies import MovingWindowRateLimiter
from flask_limiter import Limiter
from flask_limiter.constants impor... | 200 | assert | numeric_literal | tests/test_configuration.py | test_constructor_arguments_over_config | 51 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import datetime
import logging
import hiro
from flask import Blueprint, Flask, current_app
from flask_limiter import ExemptionScope, Limiter
from flask_limiter.util import get_remote_address
def test_invalid_decorated_static_limit_blueprint(caplog):
caplog.set_level(logging.IN... | 200 | assert | numeric_literal | tests/test_blueprints.py | test_invalid_decorated_static_limit_blueprint | 519 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import datetime
import logging
import hiro
from flask import Blueprint, Flask, current_app
from flask_limiter import ExemptionScope, Limiter
from flask_limiter.util import get_remote_address
def test_invalid_decorated_dynamic_limits_blueprint(caplog):
caplog.set_level(logging.... | 3 | assert | numeric_literal | tests/test_blueprints.py | test_invalid_decorated_dynamic_limits_blueprint | 544 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import time
import hiro
from flask import Blueprint
from flask_limiter.constants import ConfigVars
def test_custom_key_prefix_with_headers(redis_connection, extension_factory):
app1, limiter1 = extension_factory(
key_prefix="moo", storage_uri="redis://localhost:46379",... | str(60) | assert | func_call | tests/test_regressions.py | test_custom_key_prefix_with_headers | 118 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import functools
import logging
import time
from collections import Counter
from unittest import mock
import hiro
from flask import Flask, abort, make_response, request
from werkzeug.exceptions import BadRequest
from flask_limiter import Limit, Limiter, MetaLimit
from flask_limiter... | 429 | assert | numeric_literal | tests/test_flask_ext.py | test_static_exempt | 64 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import time
import hiro
from flask import Blueprint
from flask_limiter.constants import ConfigVars
def test_invalid_ratelimit_key(extension_factory):
app, limiter = extension_factory({ConfigVars.HEADERS_ENABLED: True})
def func(*a):
return None
@app.route("/t... | 200 | assert | numeric_literal | tests/test_regressions.py | test_invalid_ratelimit_key | 90 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import asyncio
import logging
from functools import wraps
from unittest import mock
import hiro
from flask import Blueprint, Flask, current_app, g, make_response, request
from werkzeug.exceptions import BadRequest
from flask_limiter import ExemptionScope, Limiter, RouteLimit
from f... | 429 | assert | numeric_literal | tests/test_decorators.py | test_invalid_decorated_dynamic_limits | 324 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import hiro
import pytest
def setup(redis_connection, memcached_connection, mongo_connection):
redis_connection.flushall()
memcached_connection.flush_all()
@pytest.mark.parametrize(
"storage_uri",
[
"memcached://localhost:31211",
"redis://localhost:4... | cli.get("/t2").status_code | assert | func_call | tests/test_storage.py | test_fixed_window | 39 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import asyncio
import logging
from functools import wraps
from unittest import mock
import hiro
from flask import Blueprint, Flask, current_app, g, make_response, request
from werkzeug.exceptions import BadRequest
from flask_limiter import ExemptionScope, Limiter, RouteLimit
from f... | 1 | assert | numeric_literal | tests/test_decorators.py | test_on_breach_callback_swallow_errors | 724 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import math
import time
import hiro
import pytest
from flask import Flask
from limits.errors import ConfigurationError
from limits.storage import MemoryStorage
from limits.strategies import MovingWindowRateLimiter
from flask_limiter import Limiter
from flask_limiter.constants impor... | MovingWindowRateLimiter | assert | variable | tests/test_configuration.py | test_constructor_arguments_over_config | 40 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import math
import time
import hiro
import pytest
from flask import Flask
from limits.errors import ConfigurationError
from limits.storage import MemoryStorage
from limits.strategies import MovingWindowRateLimiter
from flask_limiter import Limiter
from flask_limiter.constants impor... | "1" | assert | string_literal | tests/test_configuration.py | test_header_names_config | 71 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import math
import time
import hiro
import pytest
from flask import Flask
from limits.errors import ConfigurationError
from limits.storage import MemoryStorage
from limits.strategies import MovingWindowRateLimiter
from flask_limiter import Limiter
from flask_limiter.constants impor... | ConfigurationError) | pytest.raises | variable | tests/test_configuration.py | test_invalid_strategy | 21 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import flask_restful
import hiro
import pytest
from flask import request
from flask.views import MethodView, View
@pytest.mark.xfail
def test_flask_restx_resource(extension_factory):
import flask_restx
app, limiter = extension_factory()
api = flask_restx.Api(app)
ns... | cli.post("/test/a").status_code | assert | func_call | tests/test_views.py | test_flask_restx_resource | 195 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import math
import time
import hiro
import pytest
from flask import Flask
from limits.errors import ConfigurationError
from limits.storage import MemoryStorage
from limits.strategies import MovingWindowRateLimiter
from flask_limiter import Limiter
from flask_limiter.constants impor... | "0" | assert | string_literal | tests/test_configuration.py | test_header_names_config | 72 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import functools
import logging
import time
from collections import Counter
from unittest import mock
import hiro
from flask import Flask, abort, make_response, request
from werkzeug.exceptions import BadRequest
from flask_limiter import Limit, Limiter, MetaLimit
from flask_limiter... | 0 | assert | numeric_literal | tests/test_flask_ext.py | test_retry_after | 460 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import functools
import logging
import time
from collections import Counter
from unittest import mock
import hiro
from flask import Flask, abort, make_response, request
from werkzeug.exceptions import BadRequest
from flask_limiter import Limit, Limiter, MetaLimit
from flask_limiter... | 1 | assert | numeric_literal | tests/test_flask_ext.py | test_logging | 245 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import flask_restful
import hiro
import pytest
from flask import request
from flask.views import MethodView, View
def test_flask_restful_resource(extension_factory):
app, limiter = extension_factory(default_limits=["1/hour"])
api = flask_restful.Api(app)
class Va(flask_... | cli.get("/d").status_code | assert | func_call | tests/test_views.py | test_flask_restful_resource | 158 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import flask_restful
import hiro
import pytest
from flask import request
from flask.views import MethodView, View
def test_pluggable_views(extension_factory):
app, limiter = extension_factory(default_limits=["1/hour"])
class Va(View):
methods = ["GET", "POST"]
... | cli.get("/b").status_code | assert | func_call | tests/test_views.py | test_pluggable_views | 41 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import flask_restful
import hiro
import pytest
from flask import request
from flask.views import MethodView, View
@pytest.mark.xfail
def test_flask_restx_resource(extension_factory):
import flask_restx
app, limiter = extension_factory()
api = flask_restx.Api(app)
ns... | cli.get("/test/a").status_code | assert | func_call | tests/test_views.py | test_flask_restx_resource | 193 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import time
import hiro
from flask import Blueprint
from flask_limiter.constants import ConfigVars
def test_redis_request_slower_than_fixed_window(redis_connection, extension_factory):
app, limiter = extension_factory(
{
ConfigVars.DEFAULT_LIMITS: "5 per se... | "5" | assert | string_literal | tests/test_regressions.py | test_redis_request_slower_than_fixed_window | 30 | null | |
alisaifee/flask-limiter | from __future__ import annotations
import functools
import logging
import time
from collections import Counter
from unittest import mock
import hiro
from flask import Flask, abort, make_response, request
from werkzeug.exceptions import BadRequest
from flask_limiter import Limit, Limiter, MetaLimit
from flask_limiter... | 200 | assert | numeric_literal | tests/test_flask_ext.py | test_static_exempt | 63 | null | |
gradio-app/daggr | import os
import tempfile
import pytest
from daggr.state import SessionState
def state():
with tempfile.NamedTemporaryFile(suffix=".db", delete=False) as f:
db_path = f.name
s = SessionState(db_path=db_path)
yield s
os.unlink(db_path)
def test_create_sheet(state):
sheet_id = state.create... | "user1" | assert | string_literal | tests/test_persistence.py | test_create_sheet | 24 | null | |
gradio-app/daggr | import pytest
from daggr import FnNode, Graph, InteractionNode
from daggr.port import ItemList, Port, ScatteredPort
class TestInteractionNode:
def test_custom_interaction_type(self):
node = InteractionNode(interaction_type="approve")
assert node._interaction_type == | "approve" | assert | string_literal | tests/test_nodes.py | test_custom_interaction_type | TestInteractionNode | 85 | null |
gradio-app/daggr | import pytest
import daggr
from daggr import FnNode, Graph
def test_edge_api_with_typed_ports():
def step_a(text: str) -> dict:
return {"output": text.upper()}
def step_b(data: str) -> dict:
return {"output": data + "!"}
node_a = FnNode(fn=step_a)
node_b = FnNode(fn=step_b)
ass... | dir(node_a) | assert | func_call | tests/test_basic.py | test_edge_api_with_typed_ports | 21 | null | |
gradio-app/daggr | import pytest
from daggr import FnNode, Graph, InteractionNode
from daggr.port import ItemList, Port, ScatteredPort
class TestFnNode:
def test_invalid_input_raises_error(self):
def process(text):
return {"out": text}
with pytest.raises( | ValueError) | pytest.raises | variable | tests/test_nodes.py | test_invalid_input_raises_error | TestFnNode | 63 | null |
gradio-app/daggr | import pytest
from daggr import FnNode, Graph, InteractionNode
from daggr.port import ItemList, Port, ScatteredPort
class TestGraphConstruction:
def test_persist_key_disabled(self):
graph = Graph(name="Test", persist_key=False)
assert graph.persist_key is | None | assert | none_literal | tests/test_nodes.py | test_persist_key_disabled | TestGraphConstruction | 149 | null |
gradio-app/daggr | import gradio as gr
from fastapi.testclient import TestClient
from daggr import FnNode, Graph
from daggr.server import DaggrServer
class TestWorkflowAPI:
def test_simple_two_node_workflow_api(self):
def double(x):
return x * 2
def add_ten(y):
return y + 10
node_a ... | 24 | assert | numeric_literal | tests/test_api.py | test_simple_two_node_workflow_api | TestWorkflowAPI | 49 | null |
gradio-app/daggr | import os
import tempfile
import pytest
from daggr.state import SessionState
def state():
with tempfile.NamedTemporaryFile(suffix=".db", delete=False) as f:
db_path = f.name
s = SessionState(db_path=db_path)
yield s
os.unlink(db_path)
def test_local_user_fallback(state, monkeypatch):
mon... | "myuser" | assert | string_literal | tests/test_persistence.py | test_local_user_fallback | 110 | null | |
gradio-app/daggr | import os
import tempfile
import pytest
from daggr.state import SessionState
def state():
with tempfile.NamedTemporaryFile(suffix=".db", delete=False) as f:
db_path = f.name
s = SessionState(db_path=db_path)
yield s
os.unlink(db_path)
def test_list_sheets_by_user(state):
state.create_she... | 2 | assert | numeric_literal | tests/test_persistence.py | test_list_sheets_by_user | 37 | null | |
gradio-app/daggr | import gradio as gr
from playwright.sync_api import Page, expect
from daggr import FnNode, Graph
from tests.ui.helpers import launch_daggr_server, wait_for_graph_load
def test_nodes_and_edges_render(page: Page, temp_db: str):
def double(x):
return x * 2
def add_ten(y):
return y + 10
node... | names | assert | variable | tests/ui/test_basic.py | test_nodes_and_edges_render | 40 | null | |
gradio-app/daggr | import pytest
from daggr import FnNode, Graph, InteractionNode
from daggr.port import ItemList, Port, ScatteredPort
class TestGraphConstruction:
def test_persist_key_derived_from_name(self):
graph = Graph(name="My Cool App!")
assert graph.persist_key == | "my_cool_app" | assert | string_literal | tests/test_nodes.py | test_persist_key_derived_from_name | TestGraphConstruction | 145 | null |
gradio-app/daggr | from pathlib import Path
from unittest.mock import patch
import pytest
from daggr import Graph
from daggr.server import DaggrServer
def server():
graph = Graph(name="test")
return DaggrServer(graph)
def test_file_to_url_converts_real_file_paths(server, tmp_path):
"""Verifies real filesystem paths are co... | result | assert | variable | tests/test_server.py | test_file_to_url_converts_real_file_paths | 35 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.