higra / Higra

Hierarchical Graph Analysis
Other
99 stars 19 forks source link

Saving tree issue without attribute #179

Closed fguiotte closed 4 years ago

fguiotte commented 4 years ago

There is an issue when saving a tree without attributes:

>>> hg.save_tree('/tmp/tree.hg', tree)
>>> hg.read_tree('/tmp/tree.hg')
RuntimeError                              Traceback (most recent call last)
<ipython-input-9-b3fdd0740c20> in <module>
      1 hg.save_tree('/tmp/tree.hg', tree)
----> 2 hg.read_tree('/tmp/tree.hg')

~/.local/lib/python3.8/site-packages/higra/io_utils/tree_io.py in read_tree(filename)
     22     :return: a pair (tree, attribute_map)
     23     """
---> 24     tree, attribute_map = hg.cpp._read_tree(filename)
     25 
     26     for k in attribute_map:

RuntimeError: read_tree in file /home/florent/Public/Higra/include/higra/io/tree_io.hpp(line:149): Incorrect or missing key NBATTR

It's ok with attribute:

>>> hg.save_tree('/tmp/tree.hg', tree, {'alt': alt})
>>> hg.read_tree('/tmp/tree.hg')
(<higra.higram.Tree at 0x7f61d69b6070>,
 {'alt': array([0.        , 0.        , 0.        , ..., 0.10424666, 0.06615742,
         0.        ])})