dosma.core.numpy_routines.shares_memory

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

Determine if two medical volumes share memory.

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

Parameters:
Returns:

True if pixel arrays and headers (if defined) 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