Example #1
0
 def test(self):
     beastling_format = load_data(data_path("basic.csv"))
     cldf_format = load_data(data_path("cldf.csv"))
     explicit_cldf_format = load_data(data_path("cldf.csv"),
                                      file_format='cldf')
     tabbed_cldf_format = load_data(data_path("cldf.tsv"))
     tabbed_explicit_cldf_format = load_data(data_path("cldf.tsv"),
                                             file_format='cldf')
     assert set(list(beastling_format.keys())) == set(
         list(cldf_format.keys()))
     assert set(list(beastling_format.keys())) == set(
         list(explicit_cldf_format.keys()))
     assert set(list(beastling_format.keys())) == set(
         list(tabbed_cldf_format.keys()))
     assert set(list(beastling_format.keys())) == set(
         list(tabbed_explicit_cldf_format.keys()))
     for key in beastling_format:
         self.assertEqual(set(beastling_format[key].items()),
                          set(cldf_format[key].items()))
         self.assertEqual(set(beastling_format[key].items()),
                          set(explicit_cldf_format[key].items()))
         self.assertEqual(set(beastling_format[key].items()),
                          set(tabbed_cldf_format[key].items()))
         self.assertEqual(set(beastling_format[key].items()),
                          set(tabbed_explicit_cldf_format[key].items()))
Example #2
0
def test_load_data_2(data_dir, fname, kw):
    beastling_format, x = load_data(data_dir / "basic.csv")
    format, _ = load_data(data_dir / fname, **kw)

    assert set(list(beastling_format.keys())) == set(list(format.keys()))
    for key in beastling_format:
        assert set(beastling_format[key].items()), set(format[key].items())
Example #3
0
 def test(self):
     beastling_format = load_data(data_path("basic.csv"))
     cldf_format = load_data(data_path("cldf.csv"))
     assert set(list(beastling_format.keys())) == set(list(cldf_format.keys()))
     for key in beastling_format:
         beastling_format[key].pop("iso")
         self.assertEqual(
             set(beastling_format[key].items()), set(cldf_format[key].items()))
Example #4
0
def test_load_cldf_data_from_stdin(mocker, data_dir):
    filename = data_dir / 'cldf.csv'
    mocker.patch(
        'beastling.fileio.datareaders.sys.stdin',
        StringIO(
            filename.read_text(encoding='utf8').replace('Feature_ID', 'x')))

    with pytest.raises(ValueError):
        load_data('stdin')
Example #5
0
 def test_load_data(self):
     for p in data_path().iterdir():
         if p.suffix == '.csv':
             if p.stem in ['duplicated_iso', 'no_iso', 'nonstandard_lang_col']:
                 self.assertRaises(ValueError, load_data, p)
             else:
                 data = load_data(p)
                 self.assertNotEqual(len(data), 0)
Example #6
0
def test_load_data(data_dir):
    for p in data_dir.iterdir():
        if p.suffix == '.csv':
            if p.stem in ['duplicated_iso', 'no_iso', 'nonstandard_lang_col']:
                with pytest.raises(ValueError):
                    load_data(p)
            elif p.stem in ['forms', 'cognatesets']:
                # Metadata-free CLDF Wordlist has no default value column
                continue
            else:
                if p.stem == "cldf_value_col":
                    data, x = load_data(p,
                                        file_format='cldf-legacy',
                                        value_column="Cognate_Set")
                else:
                    data, x = load_data(p)
                assert len(data) != 0
Example #7
0
 def test_load_data(self):
     for p in data_path().iterdir():
         if p.suffix == '.csv':
             if p.stem in [
                     'duplicated_iso', 'no_iso', 'nonstandard_lang_col'
             ]:
                 self.assertRaises(ValueError, load_data, p)
             elif p.stem in ['forms', 'cognatesets']:
                 # Metadata-free CLDF Wordlist has no default value column
                 continue
             else:
                 if p.stem == "cldf_value_col":
                     data = load_data(p,
                                      file_format='cldf-legacy',
                                      value_column="Cognate_Set")
                 else:
                     data = load_data(p)
                 self.assertNotEqual(len(data), 0)
Example #8
0
 def test_load_data(self):
     for p in data_path().iterdir():
         if p.suffix == '.csv':
             if p.stem in [
                     'duplicated_iso', 'no_iso', 'nonstandard_lang_col'
             ]:
                 self.assertRaises(ValueError, load_data, p)
             else:
                 data = load_data(p)
                 self.assertNotEqual(len(data), 0)
Example #9
0
 def test(self):
     beastling_format = load_data(data_path("basic.csv"))
     cldf_format = load_data(data_path("cldf.csv"))
     explicit_cldf_format = load_data(data_path("cldf.csv"),
                                      file_format='cldf-legacy')
     nonstandard_value_cldf_format = load_data(
         data_path("cldf_value_col.csv"),
         file_format='cldf-legacy',
         value_column="Cognate_Set")
     tabbed_cldf_format = load_data(data_path("cldf.tsv"))
     tabbed_explicit_cldf_format = load_data(data_path("cldf.tsv"),
                                             file_format='cldf-legacy')
     assert set(list(beastling_format.keys())) == set(
         list(cldf_format.keys()))
     assert set(list(beastling_format.keys())) == set(
         list(explicit_cldf_format.keys()))
     assert set(list(beastling_format.keys())) == set(
         list(nonstandard_value_cldf_format.keys()))
     assert set(list(beastling_format.keys())) == set(
         list(tabbed_cldf_format.keys()))
     assert set(list(beastling_format.keys())) == set(
         list(tabbed_explicit_cldf_format.keys()))
     for key in beastling_format:
         self.assertEqual(set(beastling_format[key].items()),
                          set(cldf_format[key].items()))
         self.assertEqual(set(beastling_format[key].items()),
                          set(explicit_cldf_format[key].items()))
         self.assertEqual(set(beastling_format[key].items()),
                          set(nonstandard_value_cldf_format[key].items()))
         self.assertEqual(set(beastling_format[key].items()),
                          set(tabbed_cldf_format[key].items()))
         self.assertEqual(set(beastling_format[key].items()),
                          set(tabbed_explicit_cldf_format[key].items()))
Example #10
0
def test_load_data_from_stdin(mocker, data_dir):
    filename = data_dir / 'basic.csv'
    mocker.patch('beastling.fileio.datareaders.sys.stdin',
                 StringIO(filename.read_text(encoding='utf8')))
    assert load_data('stdin') == load_data(filename)