Closed chanokin closed 2 years ago
I'm happy to make this change, but I'm struggling to find values for which the current implementation fails (so I can write a regression test). Did you encounter a case where the exception is raised incorrectly?
I'm happy to make this change, but I'm struggling to find values for which the current implementation fails (so I can write a regression test). Did you encounter a case where the exception is raised incorrectly?
Hi, I think this was an extreme case where I one of my 2D populations ended up with a shape of [1, X]
(or [X, 1]
can't really remember). I'll try making a minimal script for this and let you know if I got it to behave unexpectedly.
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. https://github.com/NeuralEnsemble/PyNN/blob/4feecd79a216e41ad65d6399c2cc5fcd9fa0a7a0/pyNN/space.py#L245-L252I believe the comparison in line 248 should be changed to
not math.isclose(n % nx, 0)
with the precision of your choosing or just castnx
to an integer before the modulo operation is performed.