jonathf / numpoly

Numpy compatible polynomial representation
https://numpoly.readthedocs.io
BSD 2-Clause "Simplified" License
12 stars 5 forks source link

Problem with flatiter #90

Open simolon opened 2 years ago

simolon commented 2 years ago

I believe the flatiter might not be handled correctly.

import numpoly
X = numpoly.variable(6).reshape((3,2))
print('using flatten:')
for p in X.flatten():
    print(p)
print('using flat:')
for p in X.flat:
    print(p)

output:

using flatten:
q0
q1
q2
q3
q4
q5
using flat:
(1, 0, 0, 0, 0, 0)
(0, 1, 0, 0, 0, 0)
(0, 0, 1, 0, 0, 0)
(0, 0, 0, 1, 0, 0)
(0, 0, 0, 0, 1, 0)
(0, 0, 0, 0, 0, 1)
jonathf commented 2 years ago

Access to the real ndarray.flat isn't very simple as it needs to medle with the underlying implementation of np.flatiter object.

But I can easily mimic the behavior, so I did just that. Released in v1.2.4 now.