When computing the shape of a Grid2D, the number of x units, nx, comes from a floating-point operation. Checking if it's equal to 0 will often return false (e.g. 1e-100 != 0) even if the value should be interpreted as 0.
|
def calculate_size(self, n): |
|
"""docstring goes here""" |
|
nx = math.sqrt(n * self.aspect_ratio) |
|
if n % nx != 0: |
|
raise Exception("Invalid size: n=%g, nx=%d" % (n, nx)) |
|
nx = int(round(nx)) |
|
ny = n // nx |
|
return nx, ny |
I believe the comparison in line 248 should be changed to not math.isclose(n % nx, 0) with the precision of your choosing or just cast nx to an integer before the modulo operation is performed.
When computing the shape of a
Grid2D, the number of x units,nx, comes from a floating-point operation. Checking if it's equal to 0 will often return false (e.g.1e-100 != 0) even if the value should be interpreted as 0.PyNN/pyNN/space.py
Lines 245 to 252 in 4feecd7
I believe the comparison in line 248 should be changed to
not math.isclose(n % nx, 0)with the precision of your choosing or just castnxto an integer before the modulo operation is performed.