alimanfoo / anjl

A neighbour-joining library for Python.
https://alimanfoo.github.io/anjl
MIT License
0 stars 0 forks source link

Drop NA from leaf colour values before passing to np.unique() #38

Closed alimanfoo closed 1 week ago

alimanfoo commented 1 week ago

Calling np.unique() on data from a pandas DataFrame which contains a mix of string and NaN values generates an error:

malariagen_data/anoph/distance.py:530: in plot_njt
    fig = anjl.plot(
../../../.cache/pypoetry/virtualenvs/malariagen-data-XR4NpaW--py3.12/lib/python3.12/site-packages/anjl/_plot.py:79: in plot
    normalise_color_params(
../../../.cache/pypoetry/virtualenvs/malariagen-data-XR4NpaW--py3.12/lib/python3.12/site-packages/anjl/_plot.py:198: in normalise_color_params
    unique_color_values = np.unique(leaf_color_values)
../../../.cache/pypoetry/virtualenvs/malariagen-data-XR4NpaW--py3.12/lib/python3.12/site-packages/numpy/lib/_arraysetops_impl.py:289: in unique
    ret = _unique1d(ar, return_index, return_inverse, return_counts,
...
E           TypeError: '<' not supported between instances of 'float' and 'str'

Possible solution is to drop NA values before passing to numpy.