docs: def sum(x, weights=None):
      '''
      sum(x) yields either a potential-sum object if x is a potential function or the sum of x if x
        is not. If x is not a potential-field then it must be a vector.
      sum(x, weights=w) uses the given weights to produce a weighted sum.
      '''
      x = to_potential(x)
      if is_const_potential(x): return PotentialConstant(np.sum(x.c))
      else:                     return PotentialSum(x, weights=weights)