dosma.core.numpy_routines.may_share_memory

dosma.core.numpy_routines.may_share_memory(a, b, max_work=None)[source]

Determine if two medical volumes may share memory.

This function implements numpy.may_share_memory() for MedicalVolume. Two volumes share memory if the pixel arrays and headers (if defined) may share memory.

Parameters
Returns

True if pixel arrays and headers (if defined) may share memory.

Return type

bool

Raises

numpy.TooHardError – Exceeded max_work.

Examples

>>> arr = np.random.rand(3,4,5)
>>> mv1 = MedicalVolume(arr, affine=np.eye(4))
>>> mv2 = MedicalVolume(arr, affine=np.eye(4))
>>> np.shares_memory(mv1, mv2)  # Compare medicalVolume with same array in memory
True
>>> mv3 = MedicalVolume(arr.copy(), affine=np.eye(4))
>>> np.shares_memory(mv1, mv2)  # Compare medicalVolume with different arrays in memory
False