Skip to content

Commit

Permalink
np.NaN -> np.nan for numpy 2.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
k1o0 committed Oct 21, 2024
1 parent 62d76fa commit 09905da
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ibllib/io/extractors/fibrephotometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def _extract(self, light_source_map=None, collection=None, regions=None, **kwarg
regions = regions or [k for k in fp_data['raw'].keys() if 'Region' in k]
out_df = fp_data['raw'].filter(items=regions, axis=1).sort_index(axis=1)
out_df['times'] = ts
out_df['wavelength'] = np.NaN
out_df['wavelength'] = np.nan
out_df['name'] = ''
out_df['color'] = ''
# Extract channel index
Expand Down
8 changes: 4 additions & 4 deletions ibllib/io/extractors/opto_trials.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class LaserBool(BaseBpodTrialsExtractor):
def _extract(self, **kwargs):
_logger.info('Extracting laser datasets')
# reference pybpod implementation
lstim = np.array([float(t.get('laser_stimulation', np.NaN)) for t in self.bpod_trials])
lprob = np.array([float(t.get('laser_probability', np.NaN)) for t in self.bpod_trials])
lstim = np.array([float(t.get('laser_stimulation', np.nan)) for t in self.bpod_trials])
lprob = np.array([float(t.get('laser_probability', np.nan)) for t in self.bpod_trials])

# Karolina's choice world legacy implementation - from Slack message:
# it is possible that some versions I have used:
Expand All @@ -30,9 +30,9 @@ def _extract(self, **kwargs):
# laserOFF_trials=(optoOUT ==0);
if 'PROBABILITY_OPTO' in self.settings.keys() and np.all(np.isnan(lstim)):
lprob = np.zeros_like(lprob) + self.settings['PROBABILITY_OPTO']
lstim = np.array([float(t.get('opto_ON_time', np.NaN)) for t in self.bpod_trials])
lstim = np.array([float(t.get('opto_ON_time', np.nan)) for t in self.bpod_trials])
if np.all(np.isnan(lstim)):
lstim = np.array([float(t.get('optoOUT', np.NaN)) for t in self.bpod_trials])
lstim = np.array([float(t.get('optoOUT', np.nan)) for t in self.bpod_trials])
lstim[lstim == 255] = 1
else:
lstim[~np.isnan(lstim)] = 1
Expand Down
2 changes: 1 addition & 1 deletion ibllib/io/extractors/training_trials.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _extract(self):
feedbackType = np.zeros(len(self.bpod_trials), np.int64)
for i, t in enumerate(self.bpod_trials):
state_names = ['correct', 'error', 'no_go', 'omit_correct', 'omit_error', 'omit_no_go']
outcome = {sn: ~np.isnan(t['behavior_data']['States timestamps'].get(sn, [[np.NaN]])[0][0]) for sn in state_names}
outcome = {sn: ~np.isnan(t['behavior_data']['States timestamps'].get(sn, [[np.nan]])[0][0]) for sn in state_names}
assert np.sum(list(outcome.values())) == 1
outcome = next(k for k in outcome if outcome[k])
if outcome == 'correct':
Expand Down
2 changes: 1 addition & 1 deletion ibllib/qc/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def overall_outcome(outcomes: iter, agg=max) -> spec.QC:
one.alf.spec.QC
The overall outcome.
"""
outcomes = filter(lambda x: x not in (None, np.NaN), outcomes)
outcomes = filter(lambda x: x not in (None, np.nan), outcomes)
return agg(map(spec.QC.validate, outcomes))

def _set_eid_or_path(self, session_path_or_eid):
Expand Down
2 changes: 1 addition & 1 deletion ibllib/qc/task_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def compute(self, **kwargs):
iti = (np.roll(data['stimOn_times'], -1) - data['stimOff_times'])[:-1]
metric = np.r_[np.nan_to_num(iti, nan=np.inf), np.nan] - 1.
passed[check] = np.abs(metric) <= 0.1
passed[check][-1] = np.NaN
passed[check][-1] = np.nan
metrics[check] = metric

# Checks common to training QC
Expand Down

0 comments on commit 09905da

Please sign in to comment.