Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: Init arrays with np.empty, dtype=object instead lists of None #212

Merged
merged 1 commit into from Jun 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 8 additions & 12 deletions fissa/core.py
Expand Up @@ -693,9 +693,8 @@ def separation_prep(self, redo=False):
nCell = len(outputs[0][1])

# predefine data structures
raw = [[None for t in range(self.nTrials)] for c in range(nCell)]
raw = np.asarray(raw)
roi_polys = np.copy(raw)
raw = np.empty((nCell, self.nTrials), dtype=object)
roi_polys = np.empty_like(raw)

# Set outputs
for trial in range(self.nTrials):
Expand Down Expand Up @@ -848,11 +847,10 @@ def separate(self, redo_prep=False, redo_sep=False):
outputs = [_separate_cfg(X, roi_label=i) for i, X in enumerate(self.raw)]

# Define output shape as an array of objects shaped (n_roi, n_trial)
sep = [[None for t in range(n_trial)] for c in range(n_roi)]
sep = np.array(sep, dtype=object)
result = np.copy(sep)
mixmat = np.copy(sep)
info = np.copy(sep)
sep = np.empty((n_roi, n_trial), dtype=object)
result = np.empty_like(sep)
mixmat = np.empty_like(sep)
info = np.empty_like(sep)

# Place our outputs into the initialised arrays
for i_roi, (sep_i, match_i, mixmat_i, conv_i) in enumerate(outputs):
Expand Down Expand Up @@ -924,10 +922,8 @@ def calc_deltaf(self, freq, use_raw_f0=True, across_trials=True):
and Δf/f\ :sub:`0` value will be relative to the trial-specific f0.
Default is ``True``.
"""
deltaf_raw = [[None for t in range(self.nTrials)]
for c in range(self.nCell)]
deltaf_raw = np.asarray(deltaf_raw)
deltaf_result = np.copy(deltaf_raw)
deltaf_raw = np.empty_like(self.raw)
deltaf_result = np.empty_like(self.result)

# loop over cells
for cell in range(self.nCell):
Expand Down