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
pyranges/pyranges
from io import StringIO import numpy as np import pandas as pd import pytest import pyranges as pr def string_to_df(c): return pd.read_csv( StringIO(c), sep=r"\s+", dtype={ "Chromosome": "category", "Start": np.int32, "End": np.int32, "Start...
result_k_nearest_first2)
assert_*
variable
tests/unit/k_nearest.py
test_k_nearest_first
151
null
pyranges/pyranges
import pickle from pandas.testing import assert_frame_equal import pyranges as pr def test_pickle(): gr = pr.data.f1() pickle.dump(gr, open("hi", "wb+")) gr2 = pickle.load(open("hi", "rb")) assert_frame_equal(gr.df,
gr2.df)
assert_*
complex_expr
tests/unit/test_pickle.py
test_pickle
12
null
pyranges/pyranges
from pandas.testing import assert_series_equal import pyranges as pr def test_join_without_reordering(): f1 = pr.from_dict( { "Chromosome": ["chr1", "chr1", "chr1"], "Start": [3, 8, 5], "End": [6, 9, 7], "Name": ["interval1", "interval3", "interval2"], ...
["-1", "-1", "b", "a"]
assert
collection
tests/unit/join/test_join.py
test_join_without_reordering
36
null
pyranges/pyranges
import pandas as pd import pyranges as pr by_to_id = {"gene": "gene_id", "transcript": "transcript_id"} def compute_introns_single(df, by): id_column = by_to_id[by] df = df.sort_values("Start End".split()) g = df[df.Feature == by] x = pr.PyRanges(df[df.Feature == "exon"]).merge(by=id_column, strand=F...
list(actual.Start)
assert
func_call
tests/unit/test_genomicfeatures.py
test_introns_single
114
null
pyranges/pyranges
from pandas.testing import assert_series_equal import pyranges as pr def test_join_without_reordering(): f1 = pr.from_dict( { "Chromosome": ["chr1", "chr1", "chr1"], "Start": [3, 8, 5], "End": [6, 9, 7], "Name": ["interval1", "interval3", "interval2"], ...
["interval1", "interval3", "interval2", "-1"]
assert
collection
tests/unit/join/test_join.py
test_join_without_reordering
35
null
pyranges/pyranges
import os import numpy as np import pandas as pd from natsort import natsorted # type: ignore import pyranges as pr ray = None def get_n_args(f): import inspect nparams = len(inspect.signature(f).parameters) return nparams def call_f(f, nparams, df, odf, kwargs): if nparams == 3: return f...
["same", "opposite", False, None]
assert
collection
pyranges/multithreaded.py
pyrange_apply
204
null
pyranges/pyranges
import numpy as np import pyranges as pr from tests.helpers import assert_df_equal a = """Chromosome Start End Strand chr1 6 12 + chr1 10 20 + chr1 22 27 - chr1 24 30 -""" b = """Chromosome Start End Strand chr1 12 32 + chr1 14 30 +""" c = """Chromosome Start End Strand chr1 8 ...
expected_result.df)
assert_*
complex_expr
tests/unit/test_count_overlaps.py
test_strand_vs_strand_same
45
null
pyranges/pyranges
import pandas as pd import pyranges as pr by_to_id = {"gene": "gene_id", "transcript": "transcript_id"} def compute_introns_single(df, by): id_column = by_to_id[by] df = df.sort_values("Start End".split()) g = df[df.Feature == by] x = pr.PyRanges(df[df.Feature == "exon"]).merge(by=id_column, strand=F...
list(expected.End)
assert
func_call
tests/unit/test_genomicfeatures.py
_introns_correct
85
null
pyranges/pyranges
import pyranges as pr def assert_equal_length_before_after(gr1, gr2): print("in test") l1 = len(gr1) l2 = len(gr2) c = pr.concat([gr1, gr2]) if not gr1.stranded or not gr2.stranded: assert not c.stranded lc = len(c) assert l1 + l2 == lc def test_concat_unstranded_unstranded(f1, f...
f2.unstrand())
assert_*
func_call
tests/unit/test_concat.py
test_concat_unstranded_unstranded
24
null
pyranges/pyranges
import numpy as np import pyranges as pr np.random.seed(0) def test_stranded(): cpg = pr.data.cpg() exons = pr.data.exons() j = cpg.join(exons) assert j.stranded j.Strand = "." assert not j.stranded j.Strand = np.random.choice("+ -".split(), size=len(j)) assert j.stranded f...
1
assert
numeric_literal
tests/unit/test_stranded.py
test_stranded
25
null
pyranges/pyranges
import numpy as np from pandas.testing import assert_frame_equal import pyranges as pr ensembl_gtf = "tests/unit/test_data/ensembl.gtf" def test_read_gtf(): gr = pr.read_gtf(ensembl_gtf, full=True) assert len(gr.columns) == 26 df = gr.df transcript = df.iloc[1] assert transcript["tag"] ==
"basic"
assert
string_literal
tests/unit/test_io.py
test_read_gtf
16
null
pyranges/pyranges
from io import StringIO import numpy as np import pandas as pd import pytest import pyranges as pr def string_to_df(c): return pd.read_csv( StringIO(c), sep=r"\s+", dtype={ "Chromosome": "category", "Start": np.int32, "End": np.int32, "Start...
result_k_nearest_different)
assert_*
variable
tests/unit/k_nearest.py
test_k_nearest_different
80
null
pyranges/pyranges
import subprocess # nosec import tempfile from io import StringIO import numpy as np import pandas as pd import pytest from hypothesis import reproduce_failure # noqa: F401 from hypothesis import HealthCheck, given, settings from natsort import natsorted # type: ignore import pyranges as pr from tests.helpers impo...
expected.drop("Cluster", axis=1))
assert_*
func_call
tests/property_based/test_unary.py
test_cluster_by
199
null
pyranges/pyranges
from itertools import product import numpy as np import pytest from hypothesis import HealthCheck, given, settings from tests.property_based.hypothesis_helper import deadline, dfs_no_min, max_examples strandedness = [False, "same", "opposite"] binary_methods = [ "set_union", "set_intersect", "overlap", ...
np.int64
assert
complex_expr
tests/property_based/test_do_not_error.py
test_three_in_a_row
61
null
pyranges/pyranges
import subprocess # nosec import tempfile from io import StringIO import numpy as np import pandas as pd import pytest from hypothesis import reproduce_failure # noqa: F401 from hypothesis import HealthCheck, given, settings from natsort import natsorted # type: ignore import pyranges as pr from tests.helpers impo...
result.df.empty
assert
complex_expr
tests/property_based/test_unary.py
test_merge
88
null
pyranges/pyranges
from io import StringIO import pandas as pd import pytest import pyranges as pr def expected_result(): c = """Chromosome Start End Name Score Strand 0 chr1 0 10 interval1 0 + 1 chr1 0 10 interval3 0 + 2 chr1 0 10 interval2 0 -""" ...
[10200, 10400, 51400, 51600, 51800]
assert
collection
tests/unit/windows/test_windows.py
test_windows2
55
null
pyranges/pyranges
import subprocess # nosec import tempfile from io import StringIO import numpy as np import pandas as pd import pytest from hypothesis import reproduce_failure # noqa: F401 from hypothesis import HealthCheck, given, settings from natsort import natsorted # type: ignore import pyranges as pr from tests.helpers impo...
expected)
assert_*
variable
tests/property_based/test_unary.py
test_merge_by
224
null
pyranges/pyranges
from io import StringIO import pandas as pd import pytest import pyranges as pr def expected_result(): c = """Chromosome Start End Name Score Strand 0 chr1 0 10 interval1 0 + 1 chr1 0 10 interval3 0 + 2 chr1 0 10 interval2 0 -""" ...
[2, 4, 8, 4, 6]
assert
collection
tests/unit/windows/test_windows.py
test_windows
32
null
pyranges/pyranges
import pandas as pd import pyranges as pr by_to_id = {"gene": "gene_id", "transcript": "transcript_id"} def compute_introns_single(df, by): id_column = by_to_id[by] df = df.sort_values("Start End".split()) g = df[df.Feature == by] x = pr.PyRanges(df[df.Feature == "exon"]).merge(by=id_column, strand=F...
list(actual.End)
assert
func_call
tests/unit/test_genomicfeatures.py
test_introns_single
115
null
pyranges/pyranges
from io import StringIO import numpy as np import pandas as pd import pytest import pyranges as pr def string_to_df(c): return pd.read_csv( StringIO(c), sep=r"\s+", dtype={ "Chromosome": "category", "Start": np.int32, "End": np.int32, "Start...
result_k_nearest_last2)
assert_*
variable
tests/unit/k_nearest.py
test_k_nearest_last
211
null
pyranges/pyranges
from io import StringIO import pandas as pd import pytest import pyranges as pr def expected_result(): c = """Chromosome Start End Name Score Strand 0 chr1 0 10 interval1 0 + 1 chr1 0 10 interval3 0 + 2 chr1 0 10 interval2 0 -""" ...
[4, 6, 10, 6, 8]
assert
collection
tests/unit/windows/test_windows.py
test_windows
33
null
pyranges/pyranges
import numpy as np from pandas.testing import assert_frame_equal import pyranges as pr ensembl_gtf = "tests/unit/test_data/ensembl.gtf" def test_read_gtf(): gr = pr.read_gtf(ensembl_gtf, full=True) assert len(gr.columns) ==
26
assert
numeric_literal
tests/unit/test_io.py
test_read_gtf
12
null
pyranges/pyranges
import pandas as pd import pyranges as pr by_to_id = {"gene": "gene_id", "transcript": "transcript_id"} def compute_introns_single(df, by): id_column = by_to_id[by] df = df.sort_values("Start End".split()) g = df[df.Feature == by] x = pr.PyRanges(df[df.Feature == "exon"]).merge(by=id_column, strand=F...
list(expected.Start)
assert
func_call
tests/unit/test_genomicfeatures.py
_introns_correct
84
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake from snake.solver import PathSolver def test_shortest(): m = Map(7, 7) m.create_food(Pos(5, 5)) s = Snake( m, Direc.RIGHT, [Pos(2, 3), Pos(2, 2), Pos(2, 1)], [PointType.HEAD_R, PointType.BODY_HOR, PointType.BODY_HOR], ...
5
assert
numeric_literal
tests/solver/test_path.py
test_shortest
21
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake def test_init(): m = Map(5, 5) s = Snake( m, Direc.RIGHT, [Pos(1, 3), Pos(1, 2), Pos(1, 1)], [PointType.HEAD_R, PointType.BODY_HOR, PointType.BODY_HOR], ) assert not s.dead assert s.direc is Direc.RIGHT ass...
Pos(1, 2)
assert
func_call
tests/base/test_snake.py
test_init
16
null
chuyangliu/snake
import numpy as np import pytest from snake.util.sumtree import SumTree def test_sumtree(): tree = SumTree(8) data = ( ("a", 3), ("b", 10), ("c", 12), ("d", 4), ("e", 1), ("f", 2), ("g", 8), ("h", 2), ) for dat in data: tree.inser...
1
assert
numeric_literal
tests/util/test_sumtree.py
test_sumtree
24
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake from snake.solver import PathSolver def test_shortest(): m = Map(7, 7) m.create_food(Pos(5, 5)) s = Snake( m, Direc.RIGHT, [Pos(2, 3), Pos(2, 2), Pos(2, 1)], [PointType.HEAD_R, PointType.BODY_HOR, PointType.BODY_HOR], ...
expect_path[i]
assert
complex_expr
tests/solver/test_path.py
test_shortest
20
null
chuyangliu/snake
import pytest from snake.base import Map, PointType, Pos def test_init(): with pytest.raises(
TypeError)
pytest.raises
variable
tests/base/test_map.py
test_init
7
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake def test_move_eat(): m = Map(5, 5) s = Snake( m, Direc.RIGHT, [Pos(1, 2), Pos(1, 1)], [PointType.HEAD_R, PointType.BODY_HOR] ) assert s.len() == 2 m.create_food(Pos(1, 3)) assert m.has_food() s.move(Direc.RIGHT) assert not...
PointType.HEAD_L
assert
complex_expr
tests/base/test_snake.py
test_move_eat
46
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake def test_move_eat(): m = Map(5, 5) s = Snake( m, Direc.RIGHT, [Pos(1, 2), Pos(1, 1)], [PointType.HEAD_R, PointType.BODY_HOR] ) assert s.len() == 2 m.create_food(Pos(1, 3)) assert m.has_food() s.move(Direc.RIGHT) assert not...
PointType.HEAD_R
assert
complex_expr
tests/base/test_snake.py
test_move_eat
36
null
chuyangliu/snake
import pytest from snake.base import Map, PointType, Pos def test_copy(): m = Map(5, 5) m.point(Pos(1, 1)).type = PointType.FOOD m_copy = m.copy() assert id(m) !=
id(m_copy)
assert
func_call
tests/base/test_map.py
test_copy
24
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake def test_move_eat(): m = Map(5, 5) s = Snake( m, Direc.RIGHT, [Pos(1, 2), Pos(1, 1)], [PointType.HEAD_R, PointType.BODY_HOR] ) assert s.len() == 2 m.create_food(Pos(1, 3)) assert m.has_food() s.move(Direc.RIGHT) assert not...
PointType.HEAD_D
assert
complex_expr
tests/base/test_snake.py
test_move_eat
41
null
chuyangliu/snake
import numpy as np import pytest from snake.util.sumtree import SumTree def test_sumtree(): tree = SumTree(8) data = ( ("a", 3), ("b", 10), ("c", 12), ("d", 4), ("e", 1), ("f", 2), ("g", 8), ("h", 2), ) for dat in data: tree.inser...
2
assert
numeric_literal
tests/util/test_sumtree.py
test_sumtree
62
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake def test_copy(): m = Map(5, 5) s = Snake( m, Direc.RIGHT, [Pos(1, 3), Pos(1, 2), Pos(1, 1)], [PointType.HEAD_R, PointType.BODY_HOR, PointType.BODY_HOR], ) s.move(Direc.DOWN) s.move(Direc.LEFT) s_copy, _ = s...
s_copy.bodies[i]
assert
complex_expr
tests/base/test_snake.py
test_copy
203
null
chuyangliu/snake
import pytest from snake.base import Map, PointType, Pos def test_copy(): m = Map(5, 5) m.point(Pos(1, 1)).type = PointType.FOOD m_copy = m.copy() assert id(m) != id(m_copy) assert m.num_rows ==
m_copy.num_rows
assert
complex_expr
tests/base/test_map.py
test_copy
25
null
chuyangliu/snake
import pytest from snake.base import Map, PointType, Pos def test_food(): m = Map(5, 5) assert not m.has_food() m.create_food(Pos(1, 1)) assert m.has_food() m.rm_food() assert not m.has_food() food = m.create_rand_food() assert m.has_food() assert m.point(food).type == PointType.FO...
PointType.EMPTY
assert
complex_expr
tests/base/test_map.py
test_food
73
null
chuyangliu/snake
from snake.base import Direc def test_opposite(): assert Direc.opposite(Direc.UP) == Direc.DOWN assert Direc.opposite(Direc.DOWN) == Direc.UP assert Direc.opposite(Direc.LEFT) == Direc.RIGHT assert Direc.opposite(Direc.RIGHT) ==
Direc.LEFT
assert
complex_expr
tests/base/test_direc.py
test_opposite
8
null
chuyangliu/snake
import pytest from snake.base import Map, PointType, Pos def test_copy(): m = Map(5, 5) m.point(Pos(1, 1)).type = PointType.FOOD m_copy = m.copy() assert id(m) != id(m_copy) assert m.num_rows == m_copy.num_rows assert m.num_cols == m_copy.num_cols assert m.capacity ==
m_copy.capacity
assert
complex_expr
tests/base/test_map.py
test_copy
27
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake def test_copy(): m = Map(5, 5) s = Snake( m, Direc.RIGHT, [Pos(1, 3), Pos(1, 2), Pos(1, 1)], [PointType.HEAD_R, PointType.BODY_HOR, PointType.BODY_HOR], ) s.move(Direc.DOWN) s.move(Direc.LEFT) s_copy, _ = s...
id(s_copy)
assert
func_call
tests/base/test_snake.py
test_copy
197
null
chuyangliu/snake
from snake.base import Direc def test_opposite(): assert Direc.opposite(Direc.UP) ==
Direc.DOWN
assert
complex_expr
tests/base/test_direc.py
test_opposite
5
null
chuyangliu/snake
import numpy as np import pytest from snake.util.sumtree import SumTree def test_sumtree(): tree = SumTree(8) data = ( ("a", 3), ("b", 10), ("c", 12), ("d", 4), ("e", 1), ("f", 2), ("g", 8), ("h", 2), ) for dat in data: tree.inser...
42
assert
numeric_literal
tests/util/test_sumtree.py
test_sumtree
22
null
chuyangliu/snake
from snake.base import Direc, Pos def test_adj(): p = Pos(0, 0) adjs = p.all_adj() assert len(adjs) == 4 hit = [False] * 4 assert hit.count(False) == 4 for adj in adjs: if adj == Pos(-1, 0): assert p.direc_to(adj) == Direc.UP hit[0] = True elif adj == Pos...
Direc.DOWN
assert
complex_expr
tests/base/test_pos.py
test_adj
45
null
chuyangliu/snake
from snake.base import Direc def test_opposite(): assert Direc.opposite(Direc.UP) == Direc.DOWN assert Direc.opposite(Direc.DOWN) ==
Direc.UP
assert
complex_expr
tests/base/test_direc.py
test_opposite
6
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake def test_init(): m = Map(5, 5) s = Snake( m, Direc.RIGHT, [Pos(1, 3), Pos(1, 2), Pos(1, 1)], [PointType.HEAD_R, PointType.BODY_HOR, PointType.BODY_HOR], ) assert not s.dead assert s.direc is Direc.RIGHT ass...
Pos(1, 3)
assert
func_call
tests/base/test_snake.py
test_init
15
null
chuyangliu/snake
import pytest from snake.base import Map, PointType, Pos def test_food(): m = Map(5, 5) assert not m.has_food() m.create_food(Pos(1, 1)) assert m.has_food() m.rm_food() assert not m.has_food() food = m.create_rand_food() assert m.has_food() assert m.point(food).type ==
PointType.FOOD
assert
complex_expr
tests/base/test_map.py
test_food
69
null
chuyangliu/snake
from snake.base import Direc, Pos def test_dist(): p1 = Pos(-5, 20) p2 = Pos(10, 8) assert Pos.manhattan_dist(p1, p2) ==
27
assert
numeric_literal
tests/base/test_pos.py
test_dist
31
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake from snake.solver import HamiltonSolver def test_cycle(): m = Map(6, 6) s = Snake( m, Direc.RIGHT, [Pos(1, 2), Pos(1, 1)], [PointType.HEAD_R, PointType.BODY_HOR] ) solver = HamiltonSolver(s, False) table = solver.table cnt = 0 ...
table[head.x][head.y].idx
assert
complex_expr
tests/solver/test_hamilton.py
test_cycle
16
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake from snake.solver import PathSolver def test_shortest(): m = Map(7, 7) m.create_food(Pos(5, 5)) s = Snake( m, Direc.RIGHT, [Pos(2, 3), Pos(2, 2), Pos(2, 1)], [PointType.HEAD_R, PointType.BODY_HOR, PointType.BODY_HOR], ...
solver.table[5][5].dist
assert
complex_expr
tests/solver/test_path.py
test_shortest
22
null
chuyangliu/snake
import numpy as np import pytest from snake.util.sumtree import SumTree def test_sumtree(): tree = SumTree(8) data = ( ("a", 3), ("b", 10), ("c", 12), ("d", 4), ("e", 1), ("f", 2), ("g", 8), ("h", 2), ) for dat in data: tree.inser...
20
assert
numeric_literal
tests/util/test_sumtree.py
test_sumtree
61
null
chuyangliu/snake
from snake.base import Direc, Pos def test_init(): p = Pos(-5, 5) assert p ==
Pos(-5, 5)
assert
func_call
tests/base/test_pos.py
test_init
6
null
chuyangliu/snake
from snake.base import Direc, Pos def test_arithmetic(): p1 = Pos(-5, 10) p2 = Pos(5, -10) p3 = p1 + p2 p4 = p1 - p2 p5 = p2 - p1 assert p3 == Pos(0, 0) assert p3 - p1 ==
p2
assert
variable
tests/base/test_pos.py
test_arithmetic
20
null
chuyangliu/snake
import pytest from snake.base import Map, PointType, Pos def test_copy(): m = Map(5, 5) m.point(Pos(1, 1)).type = PointType.FOOD m_copy = m.copy() assert id(m) != id(m_copy) assert m.num_rows == m_copy.num_rows assert m.num_cols ==
m_copy.num_cols
assert
complex_expr
tests/base/test_map.py
test_copy
26
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake from snake.solver import PathSolver def test_shortest(): m = Map(7, 7) m.create_food(Pos(5, 5)) s = Snake( m, Direc.RIGHT, [Pos(2, 3), Pos(2, 2), Pos(2, 1)], [PointType.HEAD_R, PointType.BODY_HOR, PointType.BODY_HOR], ...
len(expect_path)
assert
func_call
tests/solver/test_path.py
test_shortest
18
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake def test_move_eat(): m = Map(5, 5) s = Snake( m, Direc.RIGHT, [Pos(1, 2), Pos(1, 1)], [PointType.HEAD_R, PointType.BODY_HOR] ) assert s.len() ==
2
assert
numeric_literal
tests/base/test_snake.py
test_move_eat
28
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake from snake.solver import PathSolver def test_longest(): m = Map(6, 6) m.create_food(Pos(4, 4)) s = Snake( m, Direc.RIGHT, [Pos(1, 3), Pos(1, 2), Pos(1, 1)], [PointType.HEAD_R, PointType.BODY_HOR, PointType.BODY_HOR], ...
PointType.BODY_HOR
assert
complex_expr
tests/solver/test_path.py
test_longest
55
null
chuyangliu/snake
import pytest from snake.base import Map, PointType, Pos def test_init(): with pytest.raises(TypeError): m = Map(5, 1.5) with pytest.raises(
ValueError)
pytest.raises
variable
tests/base/test_map.py
test_init
9
null
chuyangliu/snake
from snake.base import Point, PointType def test_init(): p = Point() assert p.type == PointType.EMPTY p.type = PointType.FOOD assert p.type ==
PointType.FOOD
assert
complex_expr
tests/base/test_point.py
test_init
8
null
chuyangliu/snake
from snake.base import Direc, Pos def test_adj(): p = Pos(0, 0) adjs = p.all_adj() assert len(adjs) == 4 hit = [False] * 4 assert hit.count(False) == 4 for adj in adjs: if adj == Pos(-1, 0): assert p.direc_to(adj) == Direc.UP hit[0] = True elif adj == Pos...
0
assert
numeric_literal
tests/base/test_pos.py
test_adj
55
null
chuyangliu/snake
from snake.base import Direc, Pos def test_adj(): p = Pos(0, 0) adjs = p.all_adj() assert len(adjs) ==
4
assert
numeric_literal
tests/base/test_pos.py
test_adj
37
null
chuyangliu/snake
import numpy as np import pytest from snake.util.sumtree import SumTree def test_sumtree(): tree = SumTree(8) data = ( ("a", 3), ("b", 10), ("c", 12), ("d", 4), ("e", 1), ("f", 2), ("g", 8), ("h", 2), ) for dat in data: tree.inser...
12
assert
numeric_literal
tests/util/test_sumtree.py
test_sumtree
23
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake def test_init(): m = Map(5, 5) s = Snake( m, Direc.RIGHT, [Pos(1, 3), Pos(1, 2), Pos(1, 1)], [PointType.HEAD_R, PointType.BODY_HOR, PointType.BODY_HOR], ) assert not s.dead assert s.direc is
Direc.RIGHT
assert
complex_expr
tests/base/test_snake.py
test_init
13
null
chuyangliu/snake
from snake.base import Direc, Map, PointType, Pos, Snake def test_init(): m = Map(5, 5) s = Snake( m, Direc.RIGHT, [Pos(1, 3), Pos(1, 2), Pos(1, 1)], [PointType.HEAD_R, PointType.BODY_HOR, PointType.BODY_HOR], ) assert not s.dead assert s.direc is Direc.RIGHT ass...
Pos(1, 1)
assert
func_call
tests/base/test_snake.py
test_init
17
null
nipunsadvilkar/pySBD
import pytest from pysbd.languages import LANGUAGE_CODES, Language def test_lang_code2instance_mapping(): for code, language_module in LANGUAGE_CODES.items(): assert Language.get_language_code(code) ==
language_module
assert
variable
tests/test_languages.py
test_lang_code2instance_mapping
7
null
nipunsadvilkar/pySBD
import pytest import pysbd from pysbd.utils import TextSpan def test_segmenter_doesnt_mutate_input(pysbd_default_en_no_clean_no_span_fixture, text='My name is Jonas E. Smith. Please turn to p. 55.'): segments = pysbd_default_en_no_clean_no_span_fixture.segment(text) segme...
'My name is Jonas E. Smith. Please turn to p. 55.'
assert
string_literal
tests/test_segmenter.py
test_segmenter_doesnt_mutate_input
22
null
nipunsadvilkar/pySBD
import pytest GOLDEN_AR_RULES_TEST_CASES = [ ("سؤال وجواب: ماذا حدث بعد الانتخابات الايرانية؟ طرح الكثير من التساؤلات غداة ظهور نتائج الانتخابات الرئاسية الايرانية التي أججت مظاهرات واسعة واعمال عنف بين المحتجين على النتائج ورجال الامن. يقول معارضو الرئيس الإيراني إن الطريقة التي اعلنت بها النتائج كانت مثيرة للاست...
expected_sents
assert
variable
tests/lang/test_arabic.py
test_ar_sbd
24
null
nipunsadvilkar/pySBD
import pytest import pysbd from pysbd.utils import TextSpan def test_exception_with_doc_type_pdf_and_clean_false(): """ Test to force clean=True when doc_type="pdf" """ with pytest.raises(ValueError) as e: seg = pysbd.Segmenter(language="en", clean=False, doc_type='pdf') assert str(e.value...
"`doc_type='pdf'` should have `clean=True` & " "`char_span` should be False since original" "text will be modified."
assert
string_literal
tests/test_segmenter.py
test_exception_with_doc_type_pdf_and_clean_false
80
null
nipunsadvilkar/pySBD
import pytest GOLDEN_NL_RULES_TEST_CASES = [ ("Hij schoot op de JP8-brandstof toen de Surface-to-Air (sam)-missiles op hem af kwamen. 81 procent van de schoten was raak.", ["Hij schoot op de JP8-brandstof toen de Surface-to-Air (sam)-missiles op hem af kwamen.", "81 procent van de schoten was raak."]), ("...
expected_sents
assert
variable
tests/lang/test_dutch.py
test_nl_sbd
17
null
nipunsadvilkar/pySBD
import pytest GOLDEN_EN_RULES_TEST_CASES = [ ("Hello World. My name is Jonas.", ["Hello World.", "My name is Jonas."]), ("What is your name? My name is Jonas.", ["What is your name?", "My name is Jonas."]), ("There it is! I found it.", ["There it is!", "I found it."]), ("My name is Jonas E. Smith.", ["...
expected_sents
assert
variable
tests/lang/test_english.py
test_en_sbd
170
null
nipunsadvilkar/pySBD
import pytest GOLDEN_UR_RULES_TEST_CASES = [ ("کیا حال ہے؟ ميرا نام ___ ەے۔ میں حالا تاوان دےدوں؟", ["کیا حال ہے؟", "ميرا نام ___ ەے۔", "میں حالا تاوان دےدوں؟"]), ] @pytest.mark.parametrize('text,expected_sents', GOLDEN_UR_RULES_TEST_CASES) def test_ur_sbd(ur_default_fixture, text, expected_sents): """Urdu langu...
expected_sents
assert
variable
tests/lang/test_urdu.py
test_ur_sbd
14
null
nipunsadvilkar/pySBD
import pytest GOLDEN_HY_RULES_TEST_CASES = [ ("Ի՞նչ ես մտածում: Ոչինչ:", ["Ի՞նչ ես մտածում:", "Ոչինչ:"]), ("Ապրիլի 24-ին սկսեց անձրևել...Այդպես էի գիտեի:", ["Ապրիլի 24-ին սկսեց անձրևել...Այդպես էի գիտեի:"]), ("Այսպիսով` մոտենում ենք ավարտին: Տրամաբանությյունը հետևյալն է. պարզություն և աշխատանք:...
expected_sents
assert
variable
tests/lang/test_armenian.py
test_hy_sbd
87
null
nipunsadvilkar/pySBD
import pytest GOLDEN_SK_RULES_TEST_CASES = [ ("Ide o majiteľov firmy ABTrade s. r. o., ktorí stoja aj za ďalšími spoločnosťami, napr. XYZCorp a.s.", ["Ide o majiteľov firmy ABTrade s. r. o., ktorí stoja aj za ďalšími spoločnosťami, napr. XYZCorp a.s."]), ("„Prieskumy beriem na ľahkú váhu. V podstate ma to...
expected_sents
assert
variable
tests/lang/test_slovak.py
test_pl_sbd
23
null
nipunsadvilkar/pySBD
import pytest from pysbd.cleaner import Cleaner from pysbd.languages import Language TEST_TOBE_CLEANED_DATA = [ ("It was a cold \nnight in the city.", "It was a cold night in the city."), ("This is the U.S. Senate my friends. <em>Yes.</em> <em>It is</em>!", "This is the U.S. Senate my friends. Yes. It is!"...
"It was a cold \nnight in the city."
assert
string_literal
tests/test_cleaner.py
test_cleaner_doesnt_mutate_input
19
null
nipunsadvilkar/pySBD
import pytest import pysbd from pysbd.utils import TextSpan def test_same_sentence_different_char_span(en_no_clean_with_span_fixture): """Test same sentences with different char offsets & check for non-destruction""" text = """From the AP comes this story : President Bush on Tuesday nominated two individuals t...
"".join([seg.sent for seg in segments_w_spans])
assert
string_literal
tests/test_segmenter.py
test_same_sentence_different_char_span
64
null
nipunsadvilkar/pySBD
import pytest GOLDEN_PL_RULES_TEST_CASES = [ ("To słowo bałt. jestskrótem.", ["To słowo bałt. jestskrótem."]), ] @pytest.mark.parametrize('text,expected_sents', GOLDEN_PL_RULES_TEST_CASES) def test_pl_sbd(pl_default_fixture, text, expected_sents): """Polish language SBD tests""" segments = pl_default_fixture...
expected_sents
assert
variable
tests/lang/test_polish.py
test_pl_sbd
14
null
nipunsadvilkar/pySBD
import pytest GOLDEN_HI_RULES_TEST_CASES = [ ("सच्चाई यह है कि इसे कोई नहीं जानता। हो सकता है यह फ़्रेन्को के खिलाफ़ कोई विद्रोह रहा हो, या फिर बेकाबू हो गया कोई आनंदोत्सव।", ["सच्चाई यह है कि इसे कोई नहीं जानता।", "हो सकता है यह फ़्रेन्को के खिलाफ़ कोई विद्रोह रहा हो, या फिर बेकाबू हो गया कोई आनंदोत्सव।"]) ] ...
expected_sents
assert
variable
tests/lang/test_hindi.py
test_hi_sbd
14
null
nipunsadvilkar/pySBD
import pytest from pysbd.languages import LANGUAGE_CODES, Language def test_exception_on_no_lang_code_provided(): with pytest.raises(ValueError) as e: Language.get_language_code('') assert "Provide valid language ID i.e. ISO code." in
str(e.value)
assert
func_call
tests/test_languages.py
test_exception_on_no_lang_code_provided
12
null
nipunsadvilkar/pySBD
import pytest from pysbd.cleaner import Cleaner from pysbd.languages import Language TEST_TOBE_CLEANED_DATA = [ ("It was a cold \nnight in the city.", "It was a cold night in the city."), ("This is the U.S. Senate my friends. <em>Yes.</em> <em>It is</em>!", "This is the U.S. Senate my friends. Yes. It is!"...
expected_cleaned_sents
assert
variable
tests/test_cleaner.py
test_cleaner
15
null
nipunsadvilkar/pySBD
import pytest from pysbd.cleaner import Cleaner from pysbd.languages import Language TEST_TOBE_CLEANED_DATA = [ ("It was a cold \nnight in the city.", "It was a cold night in the city."), ("This is the U.S. Senate my friends. <em>Yes.</em> <em>It is</em>!", "This is the U.S. Senate my friends. Yes. It is!"...
text
assert
variable
tests/test_cleaner.py
test_cleaner_none_input
23
null
nipunsadvilkar/pySBD
import pytest GOLDEN_RU_RULES_TEST_CASES = [ ("Объем составляет 5 куб.м.", ["Объем составляет 5 куб.м."]), ("Маленькая девочка бежала и кричала: «Не видали маму?».", ["Маленькая девочка бежала и кричала: «Не видали маму?»."]), ("Сегодня 27.10.14", ["Сегодня 27.10.14"]) ] RU_MORE_TEST_CASES = [("Маленькая девочка бе...
expected_sents
assert
variable
tests/lang/test_russian.py
test_ru_sbd
97
null
nipunsadvilkar/pySBD
import pytest GOLDEN_KK_RULES_TEST_CASES = [ ("Мұхитқа тікелей шыға алмайтын мемлекеттердің ішінде Қазақстан - ең үлкені.", ["Мұхитқа тікелей шыға алмайтын мемлекеттердің ішінде Қазақстан - ең үлкені."]), ("Оқушылар үйі, Достық даңғылы, Абай даналығы, ауыл шаруашылығы – кім? не?", ["Оқушылар үйі, Достық даңғылы, Аба...
expected_sents
assert
variable
tests/lang/test_kazakh.py
test_kk_sbd
40
null
nipunsadvilkar/pySBD
import pytest GOLDEN_FA_RULES_TEST_CASES = [ ("خوشبختم، آقای رضا. شما کجایی هستید؟ من از تهران هستم.", ["خوشبختم، آقای رضا.", "شما کجایی هستید؟", "من از تهران هستم."]) ] @pytest.mark.parametrize('text,expected_sents', GOLDEN_FA_RULES_TEST_CASES) def test_fa_sbd(fa_default_fixture, text, expected_sents): ...
expected_sents
assert
variable
tests/lang/test_persian.py
test_fa_sbd
15
null
nipunsadvilkar/pySBD
import pytest GOLDEN_ZH_RULES_TEST_CASES = [ ("安永已聯繫周怡安親屬,協助辦理簽證相關事宜,周怡安家屬1月1日晚間搭乘東方航空班機抵達上海,他們步入入境大廳時神情落寞、不發一語。周怡安來自台中,去年剛從元智大學畢業,同年9月加入安永。", ["安永已聯繫周怡安親屬,協助辦理簽證相關事宜,周怡安家屬1月1日晚間搭乘東方航空班機抵達上海,他們步入入境大廳時神情落寞、不發一語。", "周怡安來自台中,去年剛從元智大學畢業,同年9月加入安永。"]), ("我们明天一起去看《摔跤吧!爸爸》好吗?好!", ["我们明天一起去看《摔跤吧!爸爸》好吗?", "好!"...
expected_sents
assert
variable
tests/lang/test_chinese.py
test_zsh_sbd
16
null
nipunsadvilkar/pySBD
import pytest import pysbd GOLDEN_ES_RULES_TEST_CASES = [ ("¿Cómo está hoy? Espero que muy bien.", ["¿Cómo está hoy?", "Espero que muy bien."]), ("¡Hola señorita! Espero que muy bien.", ["¡Hola señorita!", "Espero que muy bien."]), ("Hola Srta. Ledesma. Buenos días, soy el Lic. Naser Pastoriza, y...
expected_sents
assert
variable
tests/lang/test_spanish.py
test_es_sbd
102
null
nipunsadvilkar/pySBD
import pytest GOLDEN_BG_RULES_TEST_CASES = [ ("В първата половина на ноември т.г. ще бъде свикан Консултативният съвет за национална сигурност, обяви държавният глава.", ["В първата половина на ноември т.г. ще бъде свикан Консултативният съвет за национална сигурност, обяви държавният глава."]), ("Компютърът е устрой...
expected_sents
assert
variable
tests/lang/test_bulgarian.py
test_bg_sbd
20
null
nipunsadvilkar/pySBD
import pytest import pysbd from pysbd.utils import TextSpan @pytest.mark.parametrize('text,expected', [('My name is Jonas E. Smith. Please turn to p. 55.', [ ('My name is Jonas E. Smith. ', 0, 27), ('Pl...
"".join([seg.sent for seg in segments])
assert
string_literal
tests/test_segmenter.py
test_sbd_char_span
38
null
nipunsadvilkar/pySBD
import pytest import pysbd from pysbd.utils import TextSpan def test_no_input(pysbd_default_en_no_clean_no_span_fixture, text=""): segments = pysbd_default_en_no_clean_no_span_fixture.segment(text) assert segments ==
[]
assert
collection
tests/test_segmenter.py
test_no_input
8
null
nipunsadvilkar/pySBD
import pytest import pysbd from pysbd.utils import TextSpan @pytest.mark.parametrize('text,expected', [('My name is Jonas E. Smith. Please turn to p. 55.', [ ('My name is Jonas E. Smith. ', 0, 27), ('Pl...
expected_text_spans
assert
variable
tests/test_segmenter.py
test_sbd_char_span
36
null
nipunsadvilkar/pySBD
import pytest import pysbd from pysbd.utils import TextSpan TEST_ISSUE_DATA = [ ('#27', "This new form of generalized PDF in (9) is generic and suitable for all the fading models presented in Table I withbranches MRC reception. In section III, (9) will be used in the derivations of the unified ABER and ACC express...
"".join([seg.sent for seg in segments])
assert
string_literal
tests/regression/test_issues.py
test_issues_with_char_spans
97
null
nipunsadvilkar/pySBD
import pytest import pysbd from pysbd.utils import TextSpan def test_exception_with_both_clean_and_span_true(): """Test to not allow clean=True and char_span=True """ with pytest.raises(
ValueError)
pytest.raises
variable
tests/test_segmenter.py
test_exception_with_both_clean_and_span_true
69
null
nipunsadvilkar/pySBD
import pytest GOLDEN_IT_RULES_TEST_CASES = [ ("Salve Sig.ra Mengoni! Come sta oggi?", ["Salve Sig.ra Mengoni!", "Come sta oggi?"]), ("Una lettera si può iniziare in questo modo «Il/la sottoscritto/a.».", ["Una lettera si può iniziare in questo modo «Il/la sottoscritto/a.»."]), ("La casa costa 170.500.000,00€!", ["L...
expected_sents
assert
variable
tests/lang/test_italian.py
test_it_sbd
87
null
nipunsadvilkar/pySBD
import pytest GOLDEN_EL_RULES_TEST_CASES = [ ("Με συγχωρείτε· πού είναι οι τουαλέτες; Τις Κυριακές δε δούλευε κανένας. το κόστος του σπιτιού ήταν £260.950,00.", ["Με συγχωρείτε· πού είναι οι τουαλέτες;", "Τις Κυριακές δε δούλευε κανένας.", "το κόστος του σπιτιού ήταν £260.950,00."]), ] @pytest.mark.parametrize('text...
expected_sents
assert
variable
tests/lang/test_greek.py
test_el_sbd
14
null
nipunsadvilkar/pySBD
import pytest import pysbd from pysbd.utils import TextSpan TEST_ISSUE_DATA = [ ('#27', "This new form of generalized PDF in (9) is generic and suitable for all the fading models presented in Table I withbranches MRC reception. In section III, (9) will be used in the derivations of the unified ABER and ACC express...
" ".join(segments)
assert
string_literal
tests/regression/test_issues.py
test_issue
86
null
nipunsadvilkar/pySBD
import pytest import pysbd from pysbd.utils import TextSpan TEST_ISSUE_DATA = [ ('#27', "This new form of generalized PDF in (9) is generic and suitable for all the fading models presented in Table I withbranches MRC reception. In section III, (9) will be used in the derivations of the unified ABER and ACC express...
expected_sents
assert
variable
tests/regression/test_issues.py
test_issue
84
null
nipunsadvilkar/pySBD
import pytest import pysbd from pysbd.utils import TextSpan TEST_ISSUE_DATA = [ ('#27', "This new form of generalized PDF in (9) is generic and suitable for all the fading models presented in Table I withbranches MRC reception. In section III, (9) will be used in the derivations of the unified ABER and ACC express...
expected_text_spans
assert
variable
tests/regression/test_issues.py
test_issues_with_char_spans
95
null
nipunsadvilkar/pySBD
import pytest GOLDEN_MR_RULES_TEST_CASES = [ ("आज दसरा आहे. आज खूप शुभ दिवस आहे.", ["आज दसरा आहे.", "आज खूप शुभ दिवस आहे."]), ("ढग खूप गर्जत होते; पण पाऊस पडत नव्हता.", ["ढग खूप गर्जत होते; पण पाऊस पडत नव्हता."]), ("रमाची परीक्षा कधी आहे? अवकाश आहे अजून.", ["रमाची परीक्षा कधी आहे?", "अवकाश आ...
expected_sents
assert
variable
tests/lang/test_marathi.py
test_mr_sbd
22
null
nipunsadvilkar/pySBD
import pytest GOLDEN_JA_RULES_TEST_CASES = [ ("これはペンです。それはマーカーです。", ["これはペンです。", "それはマーカーです。"]), ("それは何ですか?ペンですか?", ["それは何ですか?", "ペンですか?"]), ("良かったね!すごい!", ["良かったね!", "すごい!"]), ("自民党税制調査会の幹部は、「引き下げ幅は3.29%以上を目指すことになる」と指摘していて、今後、公明党と合意したうえで、30日に決定する与党税制改正大綱に盛り込むことにしています。2%台後半を目指すとする方向で最終調整に入りました。", ["自民党税制調査会の幹部は、「引...
expected_sents
assert
variable
tests/lang/test_japanese.py
test_ja_sbd
20
null
descriptinc/audiotools
import os import random import tempfile import numpy as np import pytest import torch from audiotools import util from audiotools.core.audio_signal import AudioSignal def test_sample_dist(): state = util.random_state(0) v1 = state.uniform(0.0, 1.0) v2 = util.sample_from_dist(("uniform", 0.0, 1.0), 0) ...
1.0
assert
numeric_literal
tests/core/test_util.py
test_sample_dist
97
null
descriptinc/audiotools
import numpy as np import pytest import torch import torchaudio import audiotools from audiotools import AudioSignal from audiotools import metrics from audiotools.core import audio_signal def test_stoi(): audio_path = "tests/audio/spk/f10_script4_produced.wav" x = AudioSignal.excerpt(audio_path, duration=1,...
loss_val_identity
assert
variable
tests/metrics/test_quality.py
test_stoi
26
null
descriptinc/audiotools
import os import random import tempfile import numpy as np import pytest import torch from audiotools import util from audiotools.core.audio_signal import AudioSignal def test_check_random_state(): # seed is None rng_type = type(np.random.RandomState(10)) rng = util.random_state(None) assert type(rng...
ValueError)
pytest.raises
variable
tests/core/test_util.py
test_check_random_state
29
null
descriptinc/audiotools
import os import random import tempfile import numpy as np import pytest import torch from audiotools import util from audiotools.core.audio_signal import AudioSignal def test_whisper_features(): audio_path = "tests/audio/spk/f10_script4_produced.wav" signal = AudioSignal(audio_path, offset=10, duration=10) ...
torch.float32
assert
complex_expr
tests/core/test_whisper.py
test_whisper_features
19
null