spacepy.toolbox.isview¶
- spacepy.toolbox.isview(array1, array2=None)[source]¶
Returns if an object is a view of another object. More precisely if one array argument is specified True is returned is the arrays owns its data. If two arrays arguments are specified a tuple is returned of if the first array owns its data and the the second if they point at the same memory location
- Parameters:
- array1numpy.ndarray
array to query if it owns its data
- Returns:
- outbool or tuple
If one array is specified bool is returned, True is the array owns its data. If two arrays are specified a tuple where the second element is a bool of if the array point at the same memory location
- Other Parameters:
- array2object (optional)
array to query if array1 is a view of this object at the specified memory location
Examples
import numpy import spacepy.toolbox as tb a = numpy.arange(100) b = a[0:10] tb.isview(a) # False tb.isview(b) # True tb.isview(b, a) # (True, True) tb.isview(b, b) # (True, True) # the conditions are met and numpy cannot tell this