Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Commit

Permalink
override transformers methods for dimension and memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
marscher committed Feb 9, 2015
1 parent b7c7dab commit 72f43e1
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ def map_to_memory(self):
# done in parametrize
pass

def dimension(self):
return 1

def get_memory_per_frame(self):
"""
Returns the memory requirements per frame, in bytes
:return:
"""
# 4 bytes per frame for an integer index
return 4

def get_constant_memory(self):
"""
Returns the constant memory requirements, in bytes
:return:
"""
# memory for cluster centers and discrete trajectories
return 4 * self.data_producer.dimension() + 4 * self.data_producer.n_frames_total()

def param_add_data(self, X, itraj, t, first_chunk, last_chunk_in_traj, last_chunk, ipass, Y=None):
"""
first pass: calculate centroids
Expand All @@ -64,7 +85,8 @@ def param_add_data(self, X, itraj, t, first_chunk, last_chunk_in_traj, last_chun
self.centroids.append(X[0])
log.info("Run regspace clustering with dmin=%f;"
" First centroid=%s" % (self.dmin, X[0]))

# TODO: optimize with cython, support different metrics
# see mixtape.libdistance
for x in X:
dist = np.fromiter((np.linalg.norm(x - c, 2)
for c in self.centroids), dtype=np.float32)
Expand Down

0 comments on commit 72f43e1

Please sign in to comment.