code: def optimize(self):
          
  
          def te(weights, r, proxies):
              """Helper func.  `pyfinance.tracking_error` doesn't work here."""
              if isinstance(weights, list):
                  weights = np.array(weights)
              proxy = np.sum(proxies * weights, axis=1)
              te = np.std(proxy - r)  # not anlzd...
              return te
  
          ew = utils.equal_weights(n=self.n, sumto=self.sumto)
          bnds = tuple((0, 1) for x in range(self.n))
          cons = {"type": "eq", "fun": lambda x: np.sum(x) - self.sumto}
  
          xs = []
          funs = []
          for i, j in zip(self._r, self._proxies):
              opt = sco.minimize(
                  te,
                  x0=ew,
                  args=(i, j),
                  method="SLSQP",
                  bounds=bnds,
                  constraints=cons,
              )
              x, fun = opt["x"], opt["fun"]
              xs.append(x)
              funs.append(fun)
          self._xs = np.array(xs)
          self._funs = np.array(funs)
  
          return self
docs: Analogous to `sklearn`'s fit.  Returns `self` to enable chaining.