Compute function maximum/minimum on subdomains

I’ve tried to change this function to get the maximum but it doesn’t seem to be working :confused:
Do you know what I’ve done wrong ?

def maximum(f, subdomains, subd_id):
    '''Maximum of f over subdomains cells marked with subd_id'''
    V = f.function_space()
    dm = V.dofmap()
    subd_dofs = np.unique(np.hstack(
        [dm.cell_dofs(c.index()) for c in SubsetIterator(subdomains, subd_id)]))
    return np.max(f.vector().get_local()[subd_dofs])

The error message is:
index -2147483648 is out of bounds for axis 0 with size 10201