brettc / partitionfinder

PartitionFinder discovers optimal partitioning schemes for DNA sequences.
Other
60 stars 42 forks source link

Fix: call scipy.misc.comb with exact=True #125

Closed hdetering closed 7 years ago

hdetering commented 7 years ago

I got an error running PartitionFinder with SciPy 0.19.0:

[...]
INFO     | 2017-05-22 16:31:39,021 |    ***Greedy algorithm step 1***
Traceback (most recent call last):
  File "/home/sereina/src/partitionfinder/PartitionFinder.py", line 23, in <module>
    sys.exit(main.main("PartitionFinder", "DNA"))
  File "/home/sereina/src/partitionfinder/partfinder/main.py", line 399, in main
    run_analysis(cfg, options)
  File "/home/sereina/src/partitionfinder/partfinder/main.py", line 333, in run_analysis
    results = anal.analyse()
  File "/home/sereina/src/partitionfinder/partfinder/analysis.py", line 93, in analyse
    self.do_analysis()
  File "/home/sereina/src/partitionfinder/partfinder/logtools.py", line 159, in indented_fn
    fn(*args, **kwargs)
  File "/home/sereina/src/partitionfinder/partfinder/analysis_method.py", line 193, in do_analysis
    subsets, the_config, cutoff, d_matrix)
  File "/home/sereina/src/partitionfinder/partfinder/neighbour.py", line 127, in get_N_closest_subsets
    ranked_subset_groupings = get_ranked_list(distance_matrix, subsets, N)
  File "/home/sereina/src/partitionfinder/partfinder/neighbour.py", line 38, in get_ranked_list
    closest = distance_matrix.argsort()[:N]
TypeError: slice indices must be integers or None or have an __index__ method

which seems to be due to the fact that the return value of scipy.misc.comb is passed on to be used as an index later on in neighbour.py::get_ranked_list(). The error log is attached to this PR: parfi.e60266.txt

A quick fix is to call scipy.misc.comb with parameter exact=True, so that the return value will be an integer (works for SciPy 0.19.0 as well as SciPy 0.13.0).

roblanf commented 7 years ago

Thanks for the heads up and the PR. Much appreciated!

I'll do the merge and run the tests next week, then make a new release.