donovan-h-parks / PhyloRank

Assign taxonomic ranks based on evolutionary divergence.
GNU General Public License v3.0
21 stars 4 forks source link

TypeError: read_from_tree() got an unexpected keyword argument 'warnings' #2

Closed xvazquezc closed 6 years ago

xvazquezc commented 6 years ago

Hi @dparks1134,

I'm "playing around" with Phylorank and I get errors from most commands. e.g. with phylorank outliers

TypeError: read_from_tree() got an unexpected keyword argument 'warnings'

This causes the program to terminate, but can be solved by removing the two warnings=False options in outliers.py. After this, the command goes further but still crashes with this

Unexpected error: <type 'exceptions.TypeError'>
Traceback (most recent call last):
  File "/home/xabi/anaconda2/envs/phylorank/bin/phylorank", line 336, in <module>
    parser.parse_options(args)
  File "/home/xabi/anaconda2/envs/phylorank/lib/python2.7/site-packages/phylorank/main.py", line 421, in parse_options
    self.outliers(options)
  File "/home/xabi/anaconda2/envs/phylorank/lib/python2.7/site-packages/phylorank/main.py", line 82, in outliers
    options.verbose_table)
  File "/home/xabi/anaconda2/envs/phylorank/lib/python2.7/site-packages/phylorank/outliers.py", line 1007, in run
    plot_file)
  File "/home/xabi/anaconda2/envs/phylorank/lib/python2.7/site-packages/phylorank/outliers.py", line 326, in _distribution_plot
    mpld3.save_html(self.fig, plot_file[0:plot_file.rfind('.')] + '.html')
  File "/home/xabi/anaconda2/envs/phylorank/lib/python2.7/site-packages/mpld3/_display.py", line 432, in save_html
    fileobj.write(fig_to_html(fig, **kwargs))
  File "/home/xabi/anaconda2/envs/phylorank/lib/python2.7/site-packages/mpld3/_display.py", line 236, in fig_to_html
    figure_json=json.dumps(figure_json),
  File "/home/xabi/anaconda2/envs/phylorank/lib/python2.7/json/__init__.py", line 244, in dumps
    return _default_encoder.encode(obj)
  File "/home/xabi/anaconda2/envs/phylorank/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/home/xabi/anaconda2/envs/phylorank/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/home/xabi/anaconda2/envs/phylorank/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: array([1.]) is not JSON serializable

PS: I installed the program through pip, not from source

donovan-h-parks commented 6 years ago

Hello. Thank you for bringing this to my attention. I have fixed the "warnings" issue. If you update PhyloRank to v0.0.35, it should install that latest version of biolib (v0.0.46) which fixes this issue. I have seen the issue regarding JSON serialization before. It appears to be specific to Anaconda. I assume you are on OS X? I haven't been able to reproduce this issue on Linux and am not sure what is causing the problem. Any insights you might have would be appreciated.

xvazquezc commented 6 years ago

Hi, Just updated to v0.0.36 but the JSON issue remains. I use Ubuntu 16.04 and tried it within Anaconda and outside the conda environment in the main Python installation with no luck... Initially I had installed the dependencies with conda install so I remove them and added them again via pip. Same error. I tried in the HPC (CentOS) in Anaconda and after installing phylorank it runs with no error. I went through the 3 environments and check the Python libraries with pip freeze comparing those in the HPC to the others... long story short: matplotlib versions are different and downgrading it to matplotlib==2.0.0 fixes the problem. It works in my local Anaconda environment without error. As a double-check I upgraded matplotlib in the HPC and it stops working. Right now matplotlib==2.1.2 does not work for some reason.

donovan-h-parks commented 6 years ago

Hello. Thank you for investigating this. I believe this is actually a mpld3 limitation and only indirectly related to PhyloRank. Perhaps the latest version of mpld3 works with the later versions of matplotlib? Anyway, this is excellent to know so I can direct people accordingly.