oist-ncbc / spykesim

Extended edit similarity measurement for high dimensional discrete-time series signal (e.g., multi-unit spike-train).
https://pypi.org/project/spykesim
MIT License
20 stars 3 forks source link

Computing the profile twice #24

Closed rcojocaru closed 4 years ago

rcojocaru commented 4 years ago

In editsim.pyx:

def gen_profile(self, th_=5, sigma=5):
    ...................................................
    for uidx, mats in zip(uidxs, mats_list):
        profile = regularize_profile(barton_sternberg(mats, self._sim_bp, 2*len(mats)))
        if profile.sum() >= th_:
            self.profiles[uidx] = regularize_profile(barton_sternberg(mats, self._sim_bp, 2*len(mats)))
    return self 

I think you could just use: if profile.sum() >= th_: self.profiles[uidx] = profile

because you are computing the same thing twice. This would save some time.

KeitaW commented 4 years ago

Thanks for the report! That's exactly right. Let me fix that shortly...

rcojocaru commented 4 years ago

Ok, thanks!

KeitaW commented 4 years ago

Done! https://github.com/KeitaW/spykesim/commit/12d71bf525175af1dadd530aa70bda30c81c8c97