TomographicImaging / CIL

A versatile python framework for tomographic imaging
https://tomographicimaging.github.io/CIL/
Apache License 2.0
98 stars 45 forks source link

Should `fill` return the data container? #1985

Open MargaretDuff opened 2 weeks ago

MargaretDuff commented 2 weeks ago

Description

The fill method, at least for VectorData, doesn't return anything; it just internally fills the array in the data container. When hacking with @bosschmidt, we realised that this behaviour wasn't very intuitive. I wonder if it should return, too. Or perhaps we should encourage people to use VectorData instead of allocating a random or zero DataContainer and filling it?

from cil.framework import VectorGeometry, VectorData
import numpy as np
from cil.utilities.display import show1D

#%%
n=50
b = np.random.randn(n)
vg = VectorGeometry(n)
b_cil = VectorData(b, geometry=vg)
print(b_cil)

#%%
b_cil2 = vg.allocate(0)
a=b_cil2.fill(b)

print(b_cil2)
print(a)

Gives the result Image

You can see that a is None.