human
I am working on the file "100 Numpy exercises.ipynb".
The first task is:
85. Create a 2D array subclass such that Z[i,j] == Z[j,i] (★★★)
Can you write Python program for it?
 Can you provide a the Python program you requested?
assistant
#Here is the Python program you requested.

# Author: Eric O. Lebigot
# Note: only works for 2d array and value setting using indices

class Symetric(np.ndarray):
    def __setitem__(self, index, value):
        i,j = index
        super(Symetric, self).__setitem__((i,j), value)
        super(Symetric, self).__setitem__((j,i), value)

def symetric(Z):
    return np.asarray(Z + Z.T - np.diag(Z.diagonal())).view(Symetric)

S = symetric(np.random.randint(0,10,(5,5)))
S[2,3] = 42
print(S)