From 09905dae8b93961d3bf202bcbfe26ee5acfb7ff9 Mon Sep 17 00:00:00 2001 From: Miles Wells Date: Fri, 18 Oct 2024 18:01:36 +0300 Subject: [PATCH] np.NaN -> np.nan for numpy 2.0 support --- ibllib/io/extractors/fibrephotometry.py | 2 +- ibllib/io/extractors/opto_trials.py | 8 ++++---- ibllib/io/extractors/training_trials.py | 2 +- ibllib/qc/base.py | 2 +- ibllib/qc/task_metrics.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ibllib/io/extractors/fibrephotometry.py b/ibllib/io/extractors/fibrephotometry.py index d11a5856e..0c7e97c07 100644 --- a/ibllib/io/extractors/fibrephotometry.py +++ b/ibllib/io/extractors/fibrephotometry.py @@ -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 diff --git a/ibllib/io/extractors/opto_trials.py b/ibllib/io/extractors/opto_trials.py index 9b720259e..b3a931c0d 100644 --- a/ibllib/io/extractors/opto_trials.py +++ b/ibllib/io/extractors/opto_trials.py @@ -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: @@ -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 diff --git a/ibllib/io/extractors/training_trials.py b/ibllib/io/extractors/training_trials.py index 645151383..6b787340d 100644 --- a/ibllib/io/extractors/training_trials.py +++ b/ibllib/io/extractors/training_trials.py @@ -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': diff --git a/ibllib/qc/base.py b/ibllib/qc/base.py index 90899ef72..4385aa463 100644 --- a/ibllib/qc/base.py +++ b/ibllib/qc/base.py @@ -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): diff --git a/ibllib/qc/task_metrics.py b/ibllib/qc/task_metrics.py index 08c824617..86f0e4a9b 100644 --- a/ibllib/qc/task_metrics.py +++ b/ibllib/qc/task_metrics.py @@ -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