From dfa8ca8ae44ecc9ef826ee3463cd1f25feaac1a1 Mon Sep 17 00:00:00 2001 From: ferrari <maxence.ferrari@gmail.com> Date: Wed, 24 Mar 2021 11:19:03 +0100 Subject: [PATCH] Fix nan checking with string --- ipi_extract.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipi_extract.py b/ipi_extract.py index 02babc2..d262239 100644 --- a/ipi_extract.py +++ b/ipi_extract.py @@ -287,7 +287,7 @@ class Callback(object): pos = int(FSSR*event.xdata) mpos = np.argmax(self.song_resample[max(pos-int(FSSR*FSPK),0):pos+int(FSSR*FSPK)]) + max(pos-int(FSSR*FSPK),0) if self.curr_ind[self.curr] is not None: - if np.all(np.isnan(list(self.df[self.offset[self.curr_ind[self.curr], 0]].values()))): + if np.all(pd.isnull(list(self.df[self.offset[self.curr_ind[self.curr], 0]].values()))): self.scat._facecolors[self.curr_ind[self.curr]] = [0.7, 0.2, 0.5, 1] else: self.scat._facecolors[self.curr_ind[self.curr]] = [0, 0, 0, 1] @@ -712,7 +712,7 @@ def main(args): outpath = args.out if os.path.isfile(outpath): if not (args.erase or args.resume): - print(f'Out file {outpath} already exist and erase option isn\'t set.') + print(f'Out file {outpath} already exist and erase or resume option isn\'t set.') return 1 elif args.resume: print(f'Out file {outpath} does not already exist and resume option is set.') @@ -727,7 +727,7 @@ def main(args): ref_dict['callback'].scat.set_offsets(ref_dict['callback'].offset) colors = np.array(len(ref_dict['callback'].offset)*[[0.7, 0.2, 0.5, 1]]) for i, p in enumerate(ref_dict['callback'].offset[:, 0]): - if not np.all(np.isnan(list(ref_dict['callback'].df[p].values()))): + if not np.all(pd.isnull(list(ref_dict['callback'].df[p].values()))): colors[i] = [0, 0, 0, 1] ref_dict['callback'].scat.set_color(colors) plt.draw() -- GitLab