1d array, column of fortran array, with F and C contiguity, raises error for not being C-contiguous.
See original GitHub issueThank you for this great and useful library 😃
I have noticed that functions like the following foo do not compile:
from numba import njit
import numpy as np
@njit('f8[::1](f8[::1])')
def foo2(b):
return b
@njit('f8[::1](f8[::1,:])')
def foo(a):
return foo2(a[:, 0])
The following error is raised:
TypingError: Invalid use of type(CPUDispatcher(<function foo2 at 0x000001759D4C7550>)) with parameters (array(float64, 1d, F))
Known signatures:
* (array(float64, 1d, C),) -> array(float64, 1d, C)
During: resolving callee type: type(CPUDispatcher(<function foo2 at 0x000001759D4C7550>))
It indicates that the input argument given to function foo2 is not C-contiguous.
However, by checking the flags of fortran-arrays columns, we can see that they present both contiguities, e.g.:
arr = np.array([[1.0, 2.0], [3.0, 4.0]], order='F')
print(f'{arr[:, 0].flags}\n{arr[:, 1].flags}')
C_CONTIGUOUS : True
F_CONTIGUOUS : True
OWNDATA : False
WRITEABLE : True
ALIGNED : True
WRITEBACKIFCOPY : False
UPDATEIFCOPY : False
C_CONTIGUOUS : True
F_CONTIGUOUS : True
OWNDATA : False
WRITEABLE : True
ALIGNED : True
WRITEBACKIFCOPY : False
UPDATEIFCOPY : False
I think this is related to #5967. There a similiar problem appeared when using empty arrays with F-order.
Numba version: 0.56.3 (latest as of today).
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
ValueError: When changing to a larger dtype, its size must be ...
When you try to change the dtype of a Fortran-order array, a warning is raised: DeprecationWarning: Changing the shape of an F-contiguous ......
Read more >Using Arrays Efficiently
The array temporary is created because the passed array may not be contiguous and the receiving (explicit-shape) array requires a contiguous array. When...
Read more >Using F2PY bindings in Python — NumPy v1.12 Manual
Fortran -contiguous arrays when data is stored column-wise, i.e. indexing of data as stored in memory starts from the lowest dimension; · C-contiguous...
Read more >Using F2PY bindings in Python — NumPy v1.9 Manual
Fortran -contiguous arrays when data is stored column-wise, i.e. indexing of data as stored in memory starts from the lowest dimension;; C-contiguous or...
Read more >2. Creating Numpy Arrays | Numerical Programming
NumPy tutorial: Creating basic array structures and manipulating arrays. ... 'F' if the object 'obj' is Fortran contiguous, 'C' otherwise.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

No problem. Typically signatures are not needed as type inference just “works it out”, but those options above present the methods of describing just about anything within the type system if needed.
That’s really helpful, thanks again!, and my bad for not realising that I could have used that kind of type signature.