Skip to content

rate.py: Fix python3 syntax errors regarding handling of next()

Patrick Godwin requested to merge patrick.godwin/lalsuite:lal_rate_next into master

Description

Fix issue described in #305 (closed) with NDBins.randcoord() under python3 where an AttributeError would be raised:

Python 3.6.8 (default, Apr  1 2020, 10:29:41) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from lal.rate import LinearBins, LogarithmicBins, NDBins
>>> x = NDBins((LinearBins(1, 25, 3), LogarithmicBins(1, 25, 3)))
>>> next(x.randcoord())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.6/site-packages/lal/rate.py", line 1280, in randcoord
    coordgens = tuple(iter(binning.randcoord(n, domain = d)).next for binning, n, d in zip(self, ns, domain))
  File "/usr/lib64/python3.6/site-packages/lal/rate.py", line 1280, in <genexpr>
    coordgens = tuple(iter(binning.randcoord(n, domain = d)).next for binning, n, d in zip(self, ns, domain))
AttributeError: 'generator' object has no attribute 'next'

Also update some of the docstrings regarding the behavior of next() throughout rate.py.

Closes #305 (closed).

API Changes and Justification

Backwards Compatible Changes

  • This change introduces no API changes
  • This change adds new API calls

Backwards Incompatible Changes

  • This change modifies an existing API
  • This change removes an existing API

If any of the Backwards Incompatible check boxes are ticked please provide a justification why this change is necessary and why it needs to be done in a backwards incompatible way.

Review Status

N/A

Edited by LALSuite Bot

Merge request reports