InsightSoftwareConsortium / InsightSoftwareConsortium/ITK
itk. array_from_vector_container fails for empty numpy array
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 748
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 64
Description
### Description
### Steps to Reproduce
```
import numpy as np
import itk
a1 = np.array([], dtype='uint64')
p1 = itk.vector_container_from_array(a1)
q1 = itk.array_from_vector_container(p1)
```
The above code fails with the following message:
```
Wrapping/Generators/Python/itk/itkPyVectorContainerPython.py", line 2580, in array_view_from_vector_container
memview = itkPyVectorContainerULUL._array_view_from_vector_container(vector_container)
ValueError: PyMemoryView_FromBuffer(): info->buf must not be NULL
```
And Following code works:
```
a1 = np.array([5], dtype='uint64')
p1 = itk.vector_container_from_array(a1)
q1 = itk.array_from_vector_container(p1)
print(q1.shape)
```
### Expected behavior
Output should be empty numpy array.
### Actual behavior
```
Wrapping/Generators/Python/itk/itkPyVectorContainerPython.py", line 2580, in array_view_from_vector_container
memview = itkPyVectorContainerULUL._array_view_from_vector_container(vector_container)
ValueError: PyMemoryView_FromBuffer(): info->buf must not be NULL
```
### Reproducibility
100%
### Versions
Linux ITK 5.3rc03
### Environment
Linux Ubuntu 20.04.2 LTS
### Additional Information
Contributor guide
Assessment
This issue has not been assessed yet.