From 4803fc991c83fcf1b8be3e4451195ef83de71f45 Mon Sep 17 00:00:00 2001 From: Jeffrey Guo Date: Thu, 17 Mar 2016 17:00:14 +0800 Subject: [PATCH 1/2] vector's squared attribute may be the dot point --- birch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/birch.py b/birch.py index b3ec33b..19ba7f8 100644 --- a/birch.py +++ b/birch.py @@ -528,7 +528,7 @@ def length(self): @property def squared(self): if not self._squared: - self._squared = self % self + self._squared = self.__mod__(self, self) # maybe here needs dot production return self._squared def distance(self,other): @@ -602,4 +602,4 @@ def distance(self,other): time = datetime.now()-start # Stop measuring the computing time print "took %s (%.2fms per point)" % (time,(time.seconds*1000+time.microseconds/1000.0)/totalpoints) - print "splitcount: %s, nodecount: %s, entrycount: %s, leafcount: %s" % (splitcount, nodecount, entrycount, leafcount) \ No newline at end of file + print "splitcount: %s, nodecount: %s, entrycount: %s, leafcount: %s" % (splitcount, nodecount, entrycount, leafcount) From d303997c0bfddc87731ba89287c53ff6f1edeb99 Mon Sep 17 00:00:00 2001 From: Jeffrey Guo Date: Thu, 17 Mar 2016 17:34:09 +0800 Subject: [PATCH 2/2] Update birch.py --- birch.py | 1 + 1 file changed, 1 insertion(+) diff --git a/birch.py b/birch.py index 19ba7f8..b842541 100644 --- a/birch.py +++ b/birch.py @@ -93,6 +93,7 @@ def d0(self,other): def d2(self,other): # print "\n\nself%s %s\nn: %i other n: %i" % (hash(self), self, self.n,other.n) + # i really can't understand what the '%' here means, can you explain that, thanks. return (other.n * self.squared + self.n * other.squared - 2 * (self.ls % other.ls)) / (self.n * other.n) def d4(self,other):