pyccel: Using multi dimensional arrays with different orders to create another array, causes a semantics error
To Reproduce
if __name__ == "__main__":
import numpy as np
a = np.array([[1], [2], [4]], order="F")
b = np.array([[4], [5], [6]], order="C")
c = np.array([a, b], order="C")
a and b must be multi dimensional and of different orders to reproduce this bug.
Generates a semantics error
pyccel:
|fatal [semantic]: testbug.py [5,17]| Inhomogeneous lists are not supported by Pyccel. Please use a tuple ((a, b))
Expected behavior Should pass the semantics check.
Additional context As long as it passes the semantics check, Pyccel will be able to copy Python’s behaviour.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 23 (23 by maintainers)
If you have understood how it works then it would be great if you could add the docs about the “order”. That would also allow me to reread it and make sure you have understood correctly.
In Fortran the strides are not multiplied by the other dimensions. The ordering just tells us whether the indexing should be treated as column major or row major. (Someone needs to write a section in the developer docs about this)
Have a look at the Fortran translation of:
And see if you can see how it works
We talked about adding a language-specific semantic stage at some point. At the moment we try to keep the implementations as similar as possible and add any language-specific minor changes in the code printing stage.
In any case, just because you can do:
it doesn’t mean it will be efficient or a good idea. Sometimes pyccel restrictions are just a way of encouraging users to follow best practices which can also accelerate their code