Is an array a view of another?

0 votes
Do numpy arrays keep track of their "view status"?

import numpy
a = numpy.arange(100)
b = a[0:10]
b[0] = 100
print a[0]
# 100 comes out as it is a view
b is a[0:10]
# False (hmm how to ask?)
 

 I am looking for numpy.isview()  and I want this for code profiling to be sure that I am doing things correctly and getting views when I think I am.
Apr 23, 2019 in Python by ana1504.k
• 7,890 points
75 views

1 answer to this question.

0 votes
The array has a base attribute, as follows:

a = np.arange(10)
print a.base
None

b = a[2:9]
print b.base is a
True

c = b[:2]
print c.base is b
True
print c.base is a
False
answered Apr 23, 2019 by SDeb
• 13,250 points

Related Questions In Python

0 votes
1 answer

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Hello @kartik, Since different users might have different ...READ MORE

answered Jun 15 in Python by Niroj
• 66,420 points
3,814 views
0 votes
1 answer

how do I check the length of an array in a python program?

lets say we have a list mylist = ...READ MORE

answered Mar 12, 2019 in Python by Mohammad
• 3,210 points
234 views
+4 votes
7 answers
+1 vote
7 answers

Count the frequency of an item in a python list

To count the number of appearances: from collections ...READ MORE

answered Oct 18, 2018 in Python by tinitales
12,008 views
+1 vote
2 answers

View onto a numpy array?

 just index it as you normally would. ...READ MORE

answered Oct 18, 2018 in Python by roberto
116 views
0 votes
1 answer
0 votes
1 answer

Printing a large numpy array

numpy.set_printoptions(threshold='nan') READ MORE

answered Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
379 views
0 votes
1 answer

Is arr.__len__() the preferred way to get the length of an array in Python?

my_list = [1,2,3,4,5,6,7] len(my_list) # 7 The same works for ...READ MORE

answered Oct 8, 2018 in Python by SDeb
• 13,250 points
197 views
0 votes
1 answer

Return a list inside a for loop while iterating over the elements of another list

The print() is getting called multiple times ...READ MORE

answered Sep 21, 2018 in Python by SDeb
• 13,250 points
217 views