Repository: wright-group/WrightTools

Issue:
remove_nans_1D fails for list
```
>>> wt.kit.remove_nans_1D([np.nan, 1, 2, 2])
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    wt.kit.remove_nans_1D([np.nan, 1, 2, 2])
  File "/home/kyle/wright/WrightTools/WrightTools/kit/_array.py", line 223, in rem
ove_nans_1D
    return tuple(a[goods] for a in args)
  File "/home/kyle/wright/WrightTools/WrightTools/kit/_array.py", line 223, in <ge
nexpr>
    return tuple(a[goods] for a in args)
TypeError: list indices must be integers or slices, not list
>>> wt.kit.remove_nans_1D(np.array([np.nan, 1, 2, 2]))
(array([1., 2., 2.]),)
```

Discussion:
pep8speaks: Hello @ksunden! Thanks for submitting the PR.

 - In the file [`WrightTools/kit/_array.py`](https://github.com/wright-group/WrightTools/blob/405cd2cd8b838ac1bbf3b676aaaeb5f7a6de2a3d/WrightTools/kit/_array.py), following are the PEP8 issues :

> [Line 216:35](https://github.com/wright-group/WrightTools/blob/405cd2cd8b838ac1bbf3b676aaaeb5f7a6de2a3d/WrightTools/kit/_array.py#L216): [E712](https://duckduckgo.com/?q=pep8%20E712) comparison to False should be 'if cond is False:' or 'if not cond:'

 - In the file [`tests/kit/remove_nans_1D.py`](https://github.com/wright-group/WrightTools/blob/405cd2cd8b838ac1bbf3b676aaaeb5f7a6de2a3d/tests/kit/remove_nans_1D.py), following are the PEP8 issues :

> [Line 30:1](https://github.com/wright-group/WrightTools/blob/405cd2cd8b838ac1bbf3b676aaaeb5f7a6de2a3d/tests/kit/remove_nans_1D.py#L30): [E302](https://duckduckgo.com/?q=pep8%20E302) expected 2 blank lines, found 1


ksunden: ```
>>> a = np.array([np.nan, 1, 2, 2])
>>> np.isnan(a)
array([ True, False, False, False])
>>> not np.isnan(a)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    not np.isnan(a)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any()
 or a.all()
>>> np.isnan(a) == False
array([False,  True,  True,  True])
>>> np.isnan(a) is False
False
```
Hush, pep8speaks, that doesn't work here....

Patch:
diff --git a/WrightTools/kit/_array.py b/WrightTools/kit/_array.py
index 66cfb11..16136f1 100644
--- a/WrightTools/kit/_array.py
+++ b/WrightTools/kit/_array.py
@@ -210,17 +210,10 @@ def remove_nans_1D(*args):
     tuple
         Tuple of 1D arrays in same order as given, with nan indicies removed.
     """
-    # find all indicies to keep
-    bads = np.array([])
-    for arr in args:
-        bad = np.array(np.where(np.isnan(arr))).flatten()
-        bads = np.hstack((bad, bads))
-    if hasattr(args, 'shape') and len(args.shape) == 1:
-        goods = [i for i in np.arange(args.shape[0]) if i not in bads]
-    else:
-        goods = [i for i in np.arange(len(args[0])) if i not in bads]
-    # apply
-    return tuple(a[goods] for a in args)
+    vals = np.isnan(args[0])
+    for a in args:
+        vals |= np.isnan(a)
+    return tuple(np.array(a)[vals == False] for a in args)
 
 
 def share_nans(*arrs):


Test patch:
diff --git a/tests/kit/remove_nans_1D.py b/tests/kit/remove_nans_1D.py
old mode 100644
new mode 100755
index 31d15ab..8c09a16
--- a/tests/kit/remove_nans_1D.py
+++ b/tests/kit/remove_nans_1D.py
@@ -1,3 +1,4 @@
+#! /usr/bin/env python3
 """Test remove_nans_1D."""
 
 
@@ -18,10 +19,20 @@ def test_simple():
     assert wt.kit.remove_nans_1D(arr)[0].all() == np.arange(0, 6, dtype=float).all()
 
 
-def test_list():
+def test_multiple():
     arrs = [np.random.random(21) for _ in range(5)]
     arrs[0][0] = np.nan
     arrs[1][-1] = np.nan
     arrs = wt.kit.remove_nans_1D(*arrs)
     for arr in arrs:
         assert arr.size == 19
+
+
+def test_list():
+    assert np.all(wt.kit.remove_nans_1D([np.nan, 1, 2, 3])[0] == np.array([1, 2, 3]))
+
+
+if __name__ == "__main__":
+    test_simple()
+    test_multiple()
+    test_list()