3 ms·
Well, you can do it this way: def kdtree(self): try: return self._kdtree except AttributeError: pass self._
by dietrichepp 11y ago
Well, you can do it this way:
def kdtree(self):
try:
return self._kdtree
except AttributeError:
pass
self._kdtree = scipy.spatial.KDTree(self.xi.T)
return self._kdtree
And, of course, you could do all of that with a decorator.