lingpy / lingpy

@@ -16,45 +16,45 @@
Loading
16 16
    assert 'Height:  200' in output
17 17
18 18
19 -
def test_alignments(tmppath, capsys, test_data):
19 +
def test_alignments(tmp_path, capsys, test_data):
20 20
    def cmd(i, rem=''):
21 -
        return 'alignments -i {0} -c cogid -o {1} {2}'.format(i, tmppath / 'alignments', rem)
21 +
        return 'alignments -i {0} -c cogid -o {1} {2}'.format(i, tmp_path / 'alignments', rem)
22 22
23 23
    run(capsys, cmd(test_data / 'KSL.qlc'))
24 24
    run(capsys, cmd(test_data / 'KSL3.qlc', ' --format html --use-logodds'))
25 25
26 26
27 -
def test_ortho_profile(tmppath, capsys, test_data):
27 +
def test_ortho_profile(tmp_path, capsys, test_data):
28 28
    run(capsys,
29 -
        'profile -i ' + str(test_data / 'KSL.qlc') + ' --column ipa -o ' + str(tmppath / 'ortho'))
29 +
        'profile -i ' + str(test_data / 'KSL.qlc') + ' --column ipa -o ' + str(tmp_path / 'ortho'))
30 30
31 31
32 -
def test_multiple(capsys, test_data, tmppath):
32 +
def test_multiple(capsys, test_data, tmp_path):
33 33
    # first test, align string, no output, no input
34 34
    output = run(capsys, 'multiple -s woldemort waldemar walter')
35 35
    assert 'w\ta\tl\tt\te\t-\t-\tr\t-' in output
36 36
37 37
    # second test, test output as file, no input, vary method as sca
38 38
    _ = run(capsys, 'multiple', '-s', 'woldemort', 'waldemar',
39 -
             'walter', '--method', 'sca', '--output-file', str(tmppath / 'out.msa'))
39 +
             'walter', '--method', 'sca', '--output-file', str(tmp_path / 'out.msa'))
40 40
41 41
    # third test, test output and input
42 42
    # second test, test output as file, no input, vary method as sca
43 43
    mlt = main('multiple', '-i', str(test_data / 'harryp.msa'),
44 44
               '--method', 'sca', '--output-file',
45 -
               str(tmppath / 'out2.msa'), '--align-method',
45 +
               str(tmp_path / 'out2.msa'), '--align-method',
46 46
               'library')
47 47
    assert len(mlt[0]) == 7
48 48
49 49
    # fourth test, test output and input with method=basic
50 50
    mlt = main('multiple', '-i', str(test_data / 'harryp.msa'),
51 51
               '--method', 'basic', '--output-file',
52 -
               str(tmppath / 'out2.msa'))
52 +
               str(tmp_path / 'out2.msa'))
53 53
    assert len(mlt[0]) == 7
54 54
    assert len([x for x in mlt[1][-1] if x != '-']) == 4
55 55
56 56
57 -
def test_pairwise(capsys, tmppath, test_data):
57 +
def test_pairwise(capsys, tmp_path, test_data):
58 58
    # first test, align string, no output, no input
59 59
    output = run(capsys, 'pairwise -s woldemort waldemar')
60 60
    assert [line.split('\t') for line in output.split('\n')][:2] == \
@@ -64,14 +64,14 @@
Loading
64 64
        ]
65 65
66 66
    # second test, test output as file, no input, vary method as sca
67 -
    tmp = tmppath / 'test1'
67 +
    tmp = tmp_path / 'test1'
68 68
    run(capsys, 'pairwise -s woldemort waldemar --method sca -o {0}'
69 69
                 ' --distance'.format(tmp))
70 70
    assert tmp.exists()
71 71
72 72
    # third test, test output and input
73 73
    # second test, test output as file, no input, vary method as sca
74 -
    tmp = tmppath / 'test2'
74 +
    tmp = tmp_path / 'test2'
75 75
    run(capsys, 'pairwise -i {0} --method sca -o {1} -m overlap'.format(
76 76
        test_data / 'harry_potter.psa', tmp))
77 77
    #
@@ -81,7 +81,7 @@
Loading
81 81
    assert tmp.parent.joinpath(tmp.name + '.psa').exists()
82 82
83 83
    # fourth test, test output and input with method=basic
84 -
    tmp = tmppath / 'test3'
84 +
    tmp = tmp_path / 'test3'
85 85
    run(capsys, 'pairwise -i {0} --method basic -o {1}'.format(
86 86
        test_data / 'harry_potter.psa', tmp))
87 87
    assert tmp.parent.joinpath(tmp.name + '.psa').exists()
@@ -94,10 +94,10 @@
Loading
94 94
    assert 'lexstat_threshold' in output
95 95
96 96
97 -
def test_lexstat(test_data, tmppath):
97 +
def test_lexstat(test_data, tmp_path):
98 98
    # TODO check with other python versions
99 99
    cogs = main('lexstat', '-i', str(test_data / 'KSL.qlc'),
100 -
                '--output-file', str(tmppath / 'lexstat'))
100 +
                '--output-file', str(tmp_path / 'lexstat'))
101 101
    print(cogs)
102 102
    assert cogs in [1080, 1081]
103 103

@@ -10,17 +10,17 @@
Loading
10 10
from lingpy.util import write_text_file
11 11
12 12
13 -
def test_output(tmppath, test_data):
14 -
    fpsa = tmppath / 'test.psa'
13 +
def test_output(tmp_path, test_data):
14 +
    fpsa = tmp_path / 'test.psa'
15 15
    write_text_file(fpsa, '\n')
16 16
    psa = PSA(str(fpsa))
17 -
    fname = str(tmppath / 'test')
17 +
    fname = str(tmp_path / 'test')
18 18
    psa.output(fileformat='psa', filename=fname)
19 19
20 -
    psq = tmppath / 'test.psq'
20 +
    psq = tmp_path / 'test.psq'
21 21
    write_text_file(psq, '\n')
22 22
    psa = PSA(str(psq))
23 -
    fname = str(tmppath / 'test')
23 +
    fname = str(tmp_path / 'test')
24 24
    psa.output(fileformat='psq', filename=fname)
25 25
26 26
    psa = PSA(str(test_data / 'harry_potter.psa'))
@@ -29,12 +29,12 @@
Loading
29 29
    psa.output(fileformat="psq", filename=fname)
30 30
31 31
32 -
def test_output2(test_data, tmppath):
32 +
def test_output2(test_data, tmp_path):
33 33
    msa = MSA(str(test_data / 'harry.msa'))
34 34
    msa.ipa2cls()
35 35
    # well. it is a list, but the code apparently wants a dict ...
36 36
    msa.merge = {'a': 'x', 'b': 'x'}
37 -
    fname = str(tmppath / 'test')
37 +
    fname = str(tmp_path / 'test')
38 38
    for fmt in 'msa psa msq html tex'.split():
39 39
        for s, u in product([True, False], [True, False]):
40 40
            msa.output(fileformat=fmt, filename=fname, sorted_seqs=s, unique_seqs=u)
@@ -95,19 +95,19 @@
Loading
95 95
         alm.get_list(language="Turkish", entry="tokens", flat=True)]
96 96
97 97
98 -
def test_get_confidence(test_data, alm, tmppath):
98 +
def test_get_confidence(test_data, alm, tmp_path):
99 99
    lex = LexStat(str(test_data / 'KSL3.qlc'))
100 100
    tmp_dict = dict([(k, lex[k, 'numbers']) for k in lex])
101 101
    alm.add_entries('numbers', tmp_dict, lambda x: x)
102 102
    # Run get_confidence to populate the output variable.
103 103
    # TODO: Check and document side-effects of this.
104 104
    _ = alm.get_confidence(lex.rscorer, ref='cogid')
105 -
    alm.output('html', filename=str(tmppath / 'alm'), confidence=True)
105 +
    alm.output('html', filename=str(tmp_path / 'alm'), confidence=True)
106 106
107 107
108 -
def test_output3(alm, tmppath):
109 -
    alm.output('tsv', filename=str(tmppath / 'test'))
110 -
    alm.output('html', filename=str(tmppath / 'test'))
108 +
def test_output3(alm, tmp_path):
109 +
    alm.output('tsv', filename=str(tmp_path / 'test'))
110 +
    alm.output('html', filename=str(tmp_path / 'test'))
111 111
112 112
113 113
def test_get_consensus2():

@@ -4,7 +4,7 @@
Loading
4 4
from lingpy.evaluate.apa import EvalPSA, EvalMSA
5 5
6 6
7 -
def test_EvalPSA(test_data, tmppath):
7 +
def test_EvalPSA(test_data, tmp_path):
8 8
    obj = EvalPSA(
9 9
        PSA(str(test_data / 'harry_potter.psa')),
10 10
        PSA(str(test_data / 'harry_potter_misaligned.psa')))
@@ -12,7 +12,7 @@
Loading
12 12
    obj.r_score()
13 13
    obj.sp_score()
14 14
    obj.jc_score()
15 -
    obj.diff(filename=str(tmppath / 'test_EvalPSA.diff'))
15 +
    obj.diff(filename=str(tmp_path / 'test_EvalPSA.diff'))
16 16
17 17
18 18
def test_EvalMSA(test_data):

@@ -68,15 +68,15 @@
Loading
68 68
                    "((((Xiamen,Taibei),Shantou,Haikou),Fuzhou),Jian’ou));"
69 69
70 70
71 -
def test_plots(mocker, Plt, Sch, gls, tree, scenarios, tmppath, test_data):
71 +
def test_plots(mocker, Plt, Sch, gls, tree, scenarios, tmp_path, test_data):
72 72
    mocker.patch('lingpy.convert.plot.mpl', new=mocker.MagicMock())
73 73
    mocker.patch('lingpy.convert.plot.plt', new=Plt)
74 74
    mocker.patch('lingpy.convert.plot.sch', new=Sch)
75 75
76 -
    plot_gls(gls, tree, filename=str(tmppath / 'test'))
77 -
    plot_tree(tree, filename=str(tmppath / 'test'))
78 -
    plot_concept_evolution(scenarios, tree, filename=str(tmppath / 'test'))
76 +
    plot_gls(gls, tree, filename=str(tmp_path / 'test'))
77 +
    plot_tree(tree, filename=str(tmp_path / 'test'))
78 +
    plot_concept_evolution(scenarios, tree, filename=str(tmp_path / 'test'))
79 79
80 80
    wl = Wordlist(str(test_data /'KSL.qlc'))
81 81
    wl.calculate('tree')
82 -
    plot_heatmap(wl, filename=str(tmppath / 'test'), ref="cogid", refB="cogid", steps=1)
82 +
    plot_heatmap(wl, filename=str(tmp_path / 'test'), ref="cogid", refB="cogid", steps=1)

@@ -1,12 +1,12 @@
Loading
1 1
from lingpy import util
2 2
3 3
4 -
def test_write_text_file(tmppath):
4 +
def test_write_text_file(tmp_path):
5 5
    def lines_generator(n):
6 6
        for i in range(n):
7 7
            yield 'line%s' % i
8 8
9 -
    path = tmppath / 'test'
9 +
    path = tmp_path / 'test'
10 10
    util.write_text_file(path, 'test')
11 11
    assert util.read_text_file(path) == 'test'
12 12
@@ -17,8 +17,8 @@
Loading
17 17
    assert len(util.read_text_file(path, lines=True)) == 5
18 18
19 19
20 -
def test_TextFile(tmppath):
21 -
    path = tmppath / 'test'
20 +
def test_TextFile(tmp_path):
21 +
    path = tmp_path / 'test'
22 22
    with util.TextFile(path) as fp:
23 23
        fp.writelines(['line1\n', 'line2\n'])
24 24
    assert len(util.read_text_file(path, lines=True)) == 2

@@ -37,12 +37,12 @@
Loading
37 37
    assert res == pytest.approx((1.0, 1.0, 1.0))
38 38
39 39
40 -
def test_diff(lex, tmppath):
40 +
def test_diff(lex, tmp_path):
41 41
    res = diff(lex, test='cogid', tofile=False, pprint=False)
42 42
    assert res == (pytest.approx((1.0, 1.0, 1.0)), pytest.approx((1.0, 1.0, 1.0)))
43 43
    lex.add_entries('cugid', 'cogid', lambda x: x + 1 if x % 2 else x * x)
44 44
45 -
    fname = str(tmppath / 'test_acd')
45 +
    fname = str(tmp_path / 'test_acd')
46 46
    _ = diff(lex, gold='cogid', test='cogid', filename=fname, pprint=False)
47 47
    d2 = diff(lex, gold='cugid', test='cogid', filename=fname, pprint=False, tofile=False)
48 48
    _ = diff(lex, gold='cugid', test='cogid', filename=fname, pprint=False, tofile=True)

@@ -18,7 +18,7 @@
Loading
18 18
    return colx._get_colexifications(wordlist)
19 19
20 20
21 -
def test_colexification_network(test_data, tmppath):
21 +
def test_colexification_network(test_data, tmp_path):
22 22
    graph = colexification_network(Wordlist(str(test_data / 'colexification.tsv')))
23 23
    assert "hand" in graph and "arm" in graph
24 24
@@ -28,7 +28,7 @@
Loading
28 28
    _ = colexification_network(
29 29
        Wordlist(str(test_data / 'colexification.tsv')),
30 30
        output="gml",
31 -
        filename=str(tmppath / "test"))
31 +
        filename=str(tmp_path / "test"))
32 32
33 33
34 34
def test__get_colexifications(cols):
@@ -63,7 +63,7 @@
Loading
63 63
    assert matrix[0][0] == 0
64 64
65 65
66 -
def test_evaluate_colexifications(cols, tmppath):
66 +
def test_evaluate_colexifications(cols, tmp_path):
67 67
    graph = colx._make_graph(cols)
68 68
    _, _ = colx.evaluate_colexifications(graph, weight='wordWeight')
69 -
    colx.evaluate_colexifications(graph, weight='wordWeight', outfile=str(tmppath / 'test'))
69 +
    colx.evaluate_colexifications(graph, weight='wordWeight', outfile=str(tmp_path / 'test'))

@@ -40,8 +40,8 @@
Loading
40 40
    _ = read_qlc(str(test_data / 'read_qlc.qlc'))
41 41
42 42
43 -
def test_read_qlc_complex(tmppath):
44 -
    p = tmppath / 'test.qlc'
43 +
def test_read_qlc_complex(tmp_path):
44 +
    p = tmp_path / 'test.qlc'
45 45
    p.write_text("""\
46 46
<json id="x">
47 47
{"y": 5}

@@ -3,11 +3,6 @@
Loading
3 3
import pytest
4 4
5 5
6 -
@pytest.fixture
7 -
def tmppath(tmpdir):
8 -
    return pathlib.Path(str(tmpdir))
9 -
10 -
11 6
@pytest.fixture
12 7
def test_data():
13 8
    return pathlib.Path(__file__).parent / 'test_data'

@@ -12,13 +12,13 @@
Loading
12 12
    log._logger = None
13 13
14 14
15 -
def test_Logging_context_manager(capsys, tmppath, fresh_logger):
15 +
def test_Logging_context_manager(capsys, tmp_path, fresh_logger):
16 16
    # Note: We must make sure to acquire a fresh logger *within* the capture
17 17
    # all context, because otherwise, stderr redirection won't work. Thus,
18 18
    # we have to initialize the logger and call one of its logging methods
19 19
    # within one function which we will then pass to capture_all.
20 20
    def _log(method='debug', with_context_manager=False, level=logging.DEBUG):
21 -
        logger = log.get_logger(test=True, force_default_config=True, config_dir=tmppath)
21 +
        logger = log.get_logger(test=True, force_default_config=True, config_dir=tmp_path)
22 22
        method = getattr(logger, method)
23 23
24 24
        if with_context_manager:
@@ -34,13 +34,13 @@
Loading
34 34
    assert 'WARN' in _log(method='warning', with_context_manager=True, level=logging.WARN)
35 35
36 36
37 -
def test_new_config(fresh_logger, tmppath):
38 -
    new_cfg = log.get_logger(config_dir=tmppath, test=True)
37 +
def test_new_config(fresh_logger, tmp_path):
38 +
    new_cfg = log.get_logger(config_dir=tmp_path, test=True)
39 39
    assert hasattr(new_cfg, 'info')
40 40
41 41
42 -
def test_default_config(fresh_logger, tmppath):
43 -
    default_cfg = log.get_logger(config_dir=tmppath, force_default_config=True)
42 +
def test_default_config(fresh_logger, tmp_path):
43 +
    default_cfg = log.get_logger(config_dir=tmp_path, force_default_config=True)
44 44
    assert hasattr(default_cfg, 'info')
45 45
46 46

@@ -103,16 +103,16 @@
Loading
103 103
    return str(test_data / 'phybo.qlc')
104 104
105 105
106 -
def test_utils(mocker, SPS, ifile, tmppath):
106 +
def test_utils(mocker, SPS, ifile, tmp_path):
107 107
    try:
108 108
        import scipy.stats
109 109
    except ImportError:  # pragma: no cover
110 110
        return
111 111
112 112
    mocker.patch('lingpy.compare._phylogeny.utils.sps', new=SPS)
113 -
    phy = PhyBo(ifile, output_dir=str(tmppath))
113 +
    phy = PhyBo(ifile, output_dir=str(tmp_path))
114 114
    phy.analyze()
115 115
    get_acs(phy, phy.best_model)
116 116
    tstats(phy, phy.best_model, return_dists=True)
117 117
118 -
    check_stats([phy.best_model], phy, filename=str(tmppath / 'test'), pprint=False)
118 +
    check_stats([phy.best_model], phy, filename=str(tmp_path / 'test'), pprint=False)

@@ -23,9 +23,9 @@
Loading
23 23
24 24
25 25
@pytest.fixture
26 -
def lextstat_factory(tmppath):
26 +
def lextstat_factory(tmp_path):
27 27
    def make(*args, **kw):
28 -
        kw.setdefault('errors', str(tmppath / 'errors.log'))
28 +
        kw.setdefault('errors', str(tmp_path / 'errors.log'))
29 29
        return LexStat(*args, **kw)
30 30
    return make
31 31
@@ -46,7 +46,7 @@
Loading
46 46
    return dict(runs=10, rands=10, limit=100)
47 47
48 48
49 -
def test_init(lextstat_factory, test_data, mocker, log, tmppath):
49 +
def test_init(lextstat_factory, test_data, mocker, log, tmp_path):
50 50
    lextstat_factory({0: ['ID', 'doculect', 'concept', 'IPA'],
51 51
                    1: ['1', 'deu', 'hand', 'hant']}, model='sca')
52 52
    ls = lextstat_factory({0: ['ID', 'doculect', 'concept', 'IPA'],
@@ -61,7 +61,7 @@
Loading
61 61
    mocker.patch('lingpy.compare.lexstat.log', log)
62 62
    lextstat_factory(str(test_data / 'KSL.qlc'), check=True)
63 63
    assert log.info.called
64 -
    error_log = tmppath / 'errors'
64 +
    error_log = tmp_path / 'errors'
65 65
    mocker.patch('lingpy.util.confirm', mocker.Mock(return_value=True))
66 66
    lex = lextstat_factory(
67 67
        {
@@ -190,9 +190,9 @@
Loading
190 190
    assert isinstance(w, float)
191 191
192 192
193 -
def test_output(lex, tmppath):
194 -
    lex.output('csv', filename=str(tmppath /'test_lexstat'))
195 -
    lex.output('scorer', filename=str(tmppath / 'test_lexstat'))
193 +
def test_output(lex, tmp_path):
194 +
    lex.output('csv', filename=str(tmp_path /'test_lexstat'))
195 +
    lex.output('scorer', filename=str(tmp_path / 'test_lexstat'))
196 196
197 197
198 198
def test_correctness(lextstat_factory):

@@ -126,8 +126,8 @@
Loading
126 126
        assert abs(key) in paps
127 127
128 128
129 -
def test_output(tmppath, wordlist):
130 -
    fn = str(tmppath / 'test')
129 +
def test_output(tmp_path, wordlist):
130 +
    fn = str(tmp_path / 'test')
131 131
    for fmt in 'tsv taxa tre dst starling paps.nex paps.csv' \
132 132
               'separated multistate.nex groups'.split():
133 133
        kw = {'ref': 'word'} if fmt == 'starling' else {}
@@ -143,8 +143,8 @@
Loading
143 143
                                 rows=dict(ID=" > 10"), **kw)
144 144
145 145
146 -
def test_export(tmppath, wordlist):
147 -
    fn = str(tmppath / 'test')
146 +
def test_export(tmp_path, wordlist):
147 +
    fn = str(tmp_path / 'test')
148 148
    for fmt in 'txt tex html'.split():
149 149
        wordlist.export(fmt, filename=fn)
150 150

@@ -6,21 +6,21 @@
Loading
6 6
7 7
8 8
@pytest.fixture
9 -
def config_factory(tmppath):
9 +
def config_factory(tmp_path):
10 10
    def make(**kw):
11 -
        return Config('test', config_dir=tmppath / CFG_NAME, **kw)
11 +
        return Config('test', config_dir=tmp_path / CFG_NAME, **kw)
12 12
    return make
13 13
14 14
15 -
def test_new_config(config_factory, tmppath):
16 -
    assert not tmppath.joinpath(CFG_NAME).exists()
15 +
def test_new_config(config_factory, tmp_path):
16 +
    assert not tmp_path.joinpath(CFG_NAME).exists()
17 17
    cfg = config_factory()
18 -
    assert tmppath.joinpath(CFG_NAME).exists()
18 +
    assert tmp_path.joinpath(CFG_NAME).exists()
19 19
20 20
21 -
def test_existing_config(config_factory, tmppath):
22 -
    tmppath.joinpath(CFG_NAME).mkdir()
23 -
    tmppath.joinpath(CFG_NAME, 'test.ini').write_text(
21 +
def test_existing_config(config_factory, tmp_path):
22 +
    tmp_path.joinpath(CFG_NAME).mkdir()
23 +
    tmp_path.joinpath(CFG_NAME, 'test.ini').write_text(
24 24
        """\
25 25
[section]
26 26
option = 12

@@ -167,10 +167,10 @@
Loading
167 167
168 168
169 169
@pytest.fixture
170 -
def nexus_factory(wordlist, tmppath):
170 +
def nexus_factory(wordlist, tmp_path):
171 171
    def f(**kw):
172 172
        # Use missing="X" parameter to avoid \? in the assertRegex calls below
173 -
        return write_nexus(wordlist, missing="X", filename=str(tmppath / 'test'), **kw)
173 +
        return write_nexus(wordlist, missing="X", filename=str(tmp_path / 'test'), **kw)
174 174
    return f
175 175
176 176

@@ -1,8 +1,8 @@
Loading
1 1
from lingpy import cache
2 2
3 3
4 -
def test_cache(tmppath):
4 +
def test_cache(tmp_path):
5 5
    d = {'a': 123}
6 6
    filename = 'lingpy_test.CSV'
7 -
    cache.dump(d, filename, d=tmppath / 'cache')
8 -
    assert cache.load(filename, d=tmppath / 'cache') == d
7 +
    cache.dump(d, filename, d=tmp_path / 'cache')
8 +
    assert cache.load(filename, d=tmp_path / 'cache') == d

@@ -10,7 +10,6 @@
Loading
10 10
from pathlib import Path
11 11
12 12
from tqdm import tqdm
13 -
from clldutils.path import path_component
14 13
from clldutils import clilib
15 14
from clldutils.misc import slug
16 15
@@ -91,7 +90,7 @@
Loading
91 90
92 91
    Parameters
93 92
    ----------
94 -
    path : {text_type, Path}
93 +
    path : {str, Path}
95 94
        A fs path either as Path instance or as text_type.
96 95
    mkdir : bool (default=False)
97 96
        If True, create the directories within the path.
@@ -101,7 +100,7 @@
Loading
101 100
    path : text_type
102 101
        The path as text_type.
103 102
    """
104 -
    res = Path(path_component(path))
103 +
    res = Path(path)
105 104
    if mkdir and res.parent and not res.parent.exists():
106 105
        res.parent.mkdir(parents=True)
107 106
    return res.as_posix()
@@ -112,7 +111,7 @@
Loading
112 111
113 112
    Parameters
114 113
    ----------
115 -
    path : str
114 +
    path : {str, Path}
116 115
        File-system path of the file.
117 116
    content : str
118 117
        The text content to be written.

@@ -49,9 +49,9 @@
Loading
49 49
    assert wl.cols[28] == 'wallisian'
50 50
51 51
52 -
def test_load_cldf_and_write(test_data, tmppath):
52 +
def test_load_cldf_and_write(test_data, tmp_path):
53 53
    wl = Wordlist.from_cldf(
54 54
        str(test_data / 'cldf/test-metadata.json'),
55 55
        col="Language_ID".lower(),
56 56
        row="Parameter_ID".lower())
57 -
    wl.output('tsv', filename=str(tmppath / 'lingpycldf'))
57 +
    wl.output('tsv', filename=str(tmp_path / 'lingpycldf'))

@@ -48,8 +48,8 @@
Loading
48 48
        for revert in [True, False]:
49 49
            fuzzy(0.5, matrix, taxa, method=method, revert=revert)
50 50
51 -
def test_matrix2tree(tmppath, matrix, taxa):
52 -
    newick = tmppath / 't'
51 +
def test_matrix2tree(tmp_path, matrix, taxa):
52 +
    newick = tmp_path / 't'
53 53
    matrix2tree(matrix, taxa, filename=str(newick))
54 54
    assert newick.parent.joinpath(newick.name + '.nwk').exists()
55 55
    matrix2tree(matrix, taxa, tree_calc='upgma')

@@ -2,7 +2,7 @@
Loading
2 2
from lingpy.convert.cldf import to_cldf
3 3
4 4
5 -
def test_from_cldf(test_data, tmppath):
5 +
def test_from_cldf(test_data, tmp_path):
6 6
    wl = from_cldf(str(test_data / 'cldf/test-metadata.json'), language='Name',
7 7
                   concept='Name', concepticon="Concepticon_ID",
8 8
                   glottocode='glottocode')
@@ -13,5 +13,5 @@
Loading
13 13
    assert wl.cols[0] == 'Anuta'
14 14
    assert wl.cols[28] == 'Vaeakau-Taumako'
15 15
16 -
    to_cldf(wl, path=tmppath)
17 -
    assert tmppath.joinpath('Wordlist-metadata.json').exists()
16 +
    to_cldf(wl, path=tmp_path)
17 +
    assert tmp_path.joinpath('Wordlist-metadata.json').exists()

@@ -5,8 +5,8 @@
Loading
5 5
6 6
7 7
@pytest.fixture
8 -
def cache_dir(tmppath):
9 -
    d = tmppath / '_test'
8 +
def cache_dir(tmp_path):
9 +
    d = tmp_path / '_test'
10 10
    d.mkdir()
11 11
    d.joinpath('converter').write_text("""\
12 12
p : p, ɸ, p͡f

@@ -8,14 +8,14 @@
Loading
8 8
    assert len(set(crang)) == len(crang)
9 9
10 10
11 -
def test_alm2html(test_data, tmppath):
12 -
    alm2html(str(test_data / 'alm.alm'), filename=str(tmppath / 'alm'))
11 +
def test_alm2html(test_data, tmp_path):
12 +
    alm2html(str(test_data / 'alm.alm'), filename=str(tmp_path / 'alm'))
13 13
14 14
15 -
def test_msa2html(test_data, tmppath):
15 +
def test_msa2html(test_data, tmp_path):
16 16
    msa = MSA(str(test_data / 'harry.msq'))
17 17
    msa.prog_align()
18 -
    msa.output('html', filename=str(tmppath / 'alm'))
18 +
    msa.output('html', filename=str(tmp_path / 'alm'))
19 19
20 20
21 21
def test_strings_and_tokens2html():
@@ -27,6 +27,6 @@
Loading
27 27
    string2html('English', list('hary'), tax_len=20)
28 28
29 29
30 -
def test_psa2html(test_data, tmppath):
31 -
    psa2html(str(test_data / 'harry_potter.psa'), filename=str(tmppath / 'alm'))
32 -
    psa2html(str(test_data / 'harry_potter_bad.psa'), filename=str(tmppath / 'alm'))
30 +
def test_psa2html(test_data, tmp_path):
31 +
    psa2html(str(test_data / 'harry_potter.psa'), filename=str(tmp_path / 'alm'))
32 +
    psa2html(str(test_data / 'harry_potter_bad.psa'), filename=str(tmp_path / 'alm'))

@@ -49,12 +49,12 @@
Loading
49 49
    assert dst[0][2] == 1
50 50
51 51
52 -
def test_wl2qlc(tmppath, test_data, wordlist):
52 +
def test_wl2qlc(tmp_path, test_data, wordlist):
53 53
    stamp = 'test-stamp'
54 -
    out = tmppath / 'test'
54 +
    out = tmp_path / 'test'
55 55
56 56
    wl2qlc(wordlist.header, wordlist._data, filename=str(out), stamp=stamp)
57 -
    out = tmppath / 'test.qlc'
57 +
    out = tmp_path / 'test.qlc'
58 58
    assert out.read_text(encoding='utf8').endswith(stamp)
59 59
60 60
    # load a worldist with alignments and otuput it as string with msapairs
@@ -74,8 +74,8 @@
Loading
74 74
           stamp='stampo', ignore=[], formatter="doculect")
75 75
76 76
77 -
def test_tsv2triple(tmppath, wordlist):
78 -
    out = tmppath / 'test'
77 +
def test_tsv2triple(tmp_path, wordlist):
78 +
    out = tmp_path / 'test'
79 79
    triples = tsv2triple(wordlist, str(out))
80 80
    assert isinstance(triple2tsv(str(out)), list)
81 81
    assert isinstance(triple2tsv(triples, output='dict'), dict)

@@ -38,11 +38,11 @@
Loading
38 38
    return str(test_data / 'phybo.qlc')
39 39
40 40
41 -
def test_get_GLS(inputfile, tmppath, test_data):
42 -
    phy = PhyBo(inputfile, output_dir=str(tmppath))
43 -
    _ = PhyBo(str(test_data / 'phybo2.qlc'), output_dir=str(tmppath),
41 +
def test_get_GLS(inputfile, tmp_path, test_data):
42 +
    phy = PhyBo(inputfile, output_dir=str(tmp_path))
43 +
    _ = PhyBo(str(test_data / 'phybo2.qlc'), output_dir=str(tmp_path),
44 44
              tree=str(test_data / 'phylogeny.tre'))
45 -
    _ = PhyBo(str(test_data / 'phybo2.qlc'), output_dir=str(tmppath))
45 +
    _ = PhyBo(str(test_data / 'phybo2.qlc'), output_dir=str(tmp_path))
46 46
47 47
    # test default scenario
48 48
    phy.get_GLS()
@@ -69,7 +69,7 @@
Loading
69 69
    phy.get_stats(glm)
70 70
71 71
72 -
def test_plot(inputfile, mocker, Bmp, Sp, Plt, tmppath):
72 +
def test_plot(inputfile, mocker, Bmp, Sp, Plt, tmp_path):
73 73
    mocker.patch('lingpy.compare.phylogeny.mpl', new=mocker.MagicMock())
74 74
    mocker.patch('lingpy.compare.phylogeny.gls2gml', new=mocker.MagicMock())
75 75
    mocker.patch('lingpy.compare.phylogeny.plot_tree', new=mocker.MagicMock())
@@ -77,7 +77,7 @@
Loading
77 77
    mocker.patch('lingpy.compare.phylogeny.plt', new=Plt)
78 78
    mocker.patch('lingpy.compare.phylogeny.sp', new=Sp)
79 79
80 -
    phy = PhyBo(inputfile, output_dir=str(tmppath))
80 +
    phy = PhyBo(inputfile, output_dir=str(tmp_path))
81 81
    phy.get_GLS()
82 82
    glm = list(phy.stats.keys())[0]
83 83
    phy.plot_GLS(glm)
Files Coverage
src/lingpy 87.60%
tests 98.86%
Project Totals (123 files) 89.26%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading