Centurion incompatible with Py3
Opened this issue · 0 comments
bredeson commented
Hi Devs,
I'm reporting this just in case you intend Centurion to be Py3-compatible.
I'm getting the following error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-19-152081d3bb39> in <module>
1 centromeres = centromeres_calls.centromeres_calls(
2 counts, lengths,
----> 3 resolution=10000)
~/.conda/envs/centurion/lib/python3.6/site-packages/centurion/centromeres_calls.py in centromeres_calls(counts, lengths, resolution, init, n_candidate, sigma, verbose, filter_candidates, normalize)
21 if init is None:
22 counts_40kb, lengths_40kb = utils.downsample_resolution(
---> 23 counts, lengths, coefficient=coef)
24
25 if normalize:
~/.conda/envs/centurion/lib/python3.6/site-packages/centurion/utils.py in downsample_resolution(counts, lengths, coefficient)
41 sub_target_counts = target_counts[target_begin_i:target_end_i,
42 target_begin_j:target_end_j]
---> 43 for start in range(coefficient):
44 s = sub_counts[start::coefficient, start::coefficient]
45 sub_target_counts[:s.shape[0], :s.shape[1]] += s
TypeError: 'float' object cannot be interpreted as an integer
because centromeres_calls.centromeres_calls()
attempts division without flooring:
if sigma is None:
sigma = 80000 / resolution
coef = 40000 / resolution
In Py3, division (even between two integers) yields a float
, which could be avoided instead by using floor division (which returns an int
):
if sigma is None:
sigma = 80000 // resolution
coef = 40000 // resolution
In order to make Centurion Py3-compatible, floor division should be used everywhere an integer is expected to be returned.
Thanks!