Skip to content

Commit

Permalink
Just use 'super()'
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizu committed Aug 14, 2020
1 parent 70e7e35 commit 663d21c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions scopyon/analysis/hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, n_components=1,
self.min_var = min_var

def _check(self):
super(ParticleTrackingHMM, self)._check()
super()._check()

self.diffusivities_ = numpy.asarray(self.diffusivities_)
assert self.diffusivities_.shape == (self.n_components, 1)
Expand Down Expand Up @@ -104,7 +104,7 @@ def _get_n_fit_scalars_per_param(self):

def _init(self, X, lengths=None):
_check_and_set_gaussian_n_features(self, X)
super(ParticleTrackingHMM, self)._init(X, lengths=lengths)
super()._init(X, lengths=lengths)

_, n_features = X.shape
if hasattr(self, 'n_features') and self.n_features != n_features:
Expand All @@ -131,7 +131,7 @@ def _init(self, X, lengths=None):
self.intensity_vars_ = numpy.tile([var], (self.n_components, 1))

def _initialize_sufficient_statistics(self):
stats = super(ParticleTrackingHMM, self)._initialize_sufficient_statistics()
stats = super()._initialize_sufficient_statistics()

stats['post'] = numpy.zeros(self.n_components)
stats['obs1**2'] = numpy.zeros((self.n_components, 1))
Expand All @@ -155,7 +155,7 @@ def _compute_log_likelihood(self, X):

def _accumulate_sufficient_statistics(self, stats, obs, framelogprob,
posteriors, fwdlattice, bwdlattice):
super(ParticleTrackingHMM, self)._accumulate_sufficient_statistics(
super()._accumulate_sufficient_statistics(
stats, obs, framelogprob, posteriors, fwdlattice, bwdlattice)

if any(param in self.params for param in 'dmv'):
Expand All @@ -168,7 +168,7 @@ def _accumulate_sufficient_statistics(self, stats, obs, framelogprob,
stats['obs2**2'] += numpy.dot(posteriors.T, obs[:, [1]] ** 2)

def _do_mstep(self, stats):
super(ParticleTrackingHMM, self)._do_mstep(stats)
super()._do_mstep(stats)

denom = stats['post'][:, numpy.newaxis]
if 'd' in self.params:
Expand Down Expand Up @@ -251,7 +251,7 @@ def __init__(self, n_components=1, n_oligomers=1,
assert self.n_components % self.n_oligomers == 0

def _check(self):
super(ParticleTrackingHMM, self)._check()
super()._check()

self.diffusivities_ = np.asarray(self.diffusivities_)
assert self.diffusivities_.shape == (self.n_components, 1)
Expand Down Expand Up @@ -284,7 +284,7 @@ def _get_n_fit_scalars_per_param(self):

def _init(self, X, lengths=None):
_check_and_set_gaussian_n_features(self, X)
super(ParticleTrackingHMM, self)._init(X, lengths=lengths)
super()._init(X, lengths=lengths)

_, n_features = X.shape
if hasattr(self, 'n_features') and self.n_features != n_features:
Expand Down Expand Up @@ -312,7 +312,7 @@ def _init(self, X, lengths=None):
self.intensity_vars_ = np.array([[var]])

def _initialize_sufficient_statistics(self):
stats = super(ParticleTrackingHMM, self)._initialize_sufficient_statistics()
stats = super()._initialize_sufficient_statistics()
stats['post'] = np.zeros(self.n_components)
stats['obs1**2'] = np.zeros((self.n_components, 1))
stats['obs2'] = np.zeros((self.n_components, 1))
Expand Down Expand Up @@ -340,7 +340,7 @@ def _compute_log_likelihood(self, X):

def _accumulate_sufficient_statistics(self, stats, obs, framelogprob,
posteriors, fwdlattice, bwdlattice):
super(ParticleTrackingHMM, self)._accumulate_sufficient_statistics(
super()._accumulate_sufficient_statistics(
stats, obs, framelogprob, posteriors, fwdlattice, bwdlattice)

if any(param in self.params for param in 'dmv'):
Expand All @@ -361,7 +361,7 @@ def _accumulate_sufficient_statistics(self, stats, obs, framelogprob,
# assert False

def _do_mstep(self, stats):
super(ParticleTrackingHMM, self)._do_mstep(stats)
super()._do_mstep(stats)

denom = stats['post'][:, np.newaxis]
# print("denom=", denom.shape)
Expand Down

0 comments on commit 663d21c

Please sign in to comment.