Closed SimonGreenhill closed 2 years ago
So, I think a combination of 1 and 3 and 4 is probably the best?
Hm. I think, I'll start with a failing test
def test_roundtrip(examples):
nex = NexusReader(examples.joinpath('example2.nex'))
_ = NexusReader.from_string(nex.write())
:)
@SimonGreenhill please have a look at #27. This seems to be the smallest change to make this work. It doesn't touch the bug, where the 'data'
block is a CharacterHandler
. But I don't think we should fix this. We don't demand (or enforce) much of anything regarding whether NexusReader
s can be used to modify data - e.g. whether it's ok to assign to NexusReader.blocks
after object initialization. So there is no real principle we could claim to follow for such a change.
It's not the worst thing that python-nexus
gets some exercise now with phlorest :)
...which means the resulting nexus can't be read. Example here.
...which means:
This is because of this:
https://github.com/dlce-eva/python-nexus/blob/071aaca665cc9bfde15201a31c836c6587d04483/src/nexus/reader.py#L80-L81
(which, I admit, I implemented as cheap way to always have a
data
block rather than looking fordata
orcharacters
).What's the best solution here @xrotwang ?
NexusWriter
to check for duplicate blocks, and perhaps allow writing of specific blocks only (nex.write(filename, blocks=['data'])The fact that the moved block still thinks of itself as a characters block rather than a data block is a bug.