tskit-dev / pyslim

Tools for dealing with tree sequences coming to and from SLiM.
MIT License
27 stars 23 forks source link

annotate fails on empty tree sequence #167

Closed petrelharp closed 2 years ago

petrelharp commented 3 years ago

This is too bad, because sometimes one would want to put the metadata schema on the tables before building them.

>>> t = tskit.TableCollection()
>>> pyslim.annotate_tables(t, model_type='WF', tick=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/peter/projects/tskit-dev/pyslim/pyslim/methods.py", line 605, in annotate_tables
    _annotate_populations(tables)
  File "/home/peter/projects/tskit-dev/pyslim/pyslim/methods.py", line 705, in _annotate_populations
    num_pops = max(np.max(tables.nodes.population), np.max(do_pops)) + 1
  File "<__array_function__ internals>", line 5, in amax
  File "/usr/lib/python3/dist-packages/numpy/core/fromnumeric.py", line 2754, in amax
    return _wrapreduction(a, np.maximum, 'max', axis, None, out,
  File "/usr/lib/python3/dist-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: zero-size array to reduction operation maximum which has no identity