nebius/SWE-bench-extra huggingface dataset:
Repository: wireservice/agate

Issue:
agate.All cannot test whether all data is False
If the column data type is boolean, test gets overwritten to search for True values.


Comments:

Patch:
diff --git a/agate/aggregations/any.py b/agate/aggregations/any.py
index 70fa702..67a9651 100644
--- a/agate/aggregations/any.py
+++ b/agate/aggregations/any.py
@@ -32,7 +32,7 @@ class Any(Aggregation):
         column = table.columns[self._column_name]
         data = column.values()
 
-        if isinstance(column.data_type, Boolean):
+        if isinstance(column.data_type, Boolean) and self._test is None:
             return any(data)
 
         return any(self._test(d) for d in data)


Test patch:
diff --git a/tests/test_aggregations.py b/tests/test_aggregations.py
index c3c8fbb..11eefe1 100644
--- a/tests/test_aggregations.py
+++ b/tests/test_aggregations.py
@@ -138,6 +138,7 @@ class TestBooleanAggregation(unittest.TestCase):
         table = Table(rows, ['test'], [Boolean()])
         Any('test').validate(table)
         self.assertEqual(Any('test').run(table), False)
+        self.assertEqual(Any('test', lambda r: not r).run(table), True)
 
     def test_all(self):
         rows = [
Repository: witchard/grole

Issue:
Change default content type for string to text/html
This feels like it makes more sense. Don't forget to update the doc!

Comments:

Patch:
diff --git a/docs/tutorial.rst b/docs/tutorial.rst
index e7d4091..dd7d9af 100644
--- a/docs/tutorial.rst
+++ b/docs/tutorial.rst
@@ -51,7 +51,7 @@ Responding
 In-built python types returned by registered request handlers are automatically converted into 200 OK HTTP responses. The following mappings apply:
 
 * bytes: Sent directly with content type text/plain
-* string: Encoded as bytes and sent with content type text/plain
+* string: Encoded as bytes and sent with content type text/html
 * others: Encoded as json and sent with content type application/json
 
 Finer grained control of the response data can be achieved using :class:`ResponseBody` or one of it's children. These allow for overriding of the content type. The following are available:
diff --git a/grole.py b/grole.py
index d34ea4d..e8f6506 100755
--- a/grole.py
+++ b/grole.py
@@ -132,7 +132,7 @@ class ResponseString(ResponseBody):
     """
     Response body from a string
     """
-    def __init__(self, data='', content_type='text/plain'):
+    def __init__(self, data='', content_type='text/html'):
         """
         Initialise object, data is the data to send
     


Test patch:
diff --git a/test/test_response.py b/test/test_response.py
index fb58ad8..967e050 100644
--- a/test/test_response.py
+++ b/test/test_response.py
@@ -106,5 +106,29 @@ class TestFile(unittest.TestCase):
         self.assertEqual(writer.data, b'4\r\nfoo\n\r\n0\r\n\r\n')
 
 
+class TestAuto(unittest.TestCase):
+
+    def test_empty(self):
+        res = grole.Response()
+        self.assertTrue(isinstance(res.data, grole.ResponseBody))
+
+    def test_bytes(self):
+        res = grole.Response(b'foo')
+        self.assertTrue(isinstance(res.data, grole.ResponseBody))
+        self.assertEqual(res.data._data, b'foo')
+        self.assertEqual(res.data._headers['Content-Type'], 'text/plain')
+
+    def test_str(self):
+        res = grole.Response('foo')
+        self.assertTrue(isinstance(res.data, grole.ResponseString))
+        self.assertEqual(res.data._data, b'foo')
+        self.assertEqual(res.data._headers['Content-Type'], 'text/html')
+
+    def test_json(self):
+        res = grole.Response({'foo': 'bar'})
+        self.assertTrue(isinstance(res.data, grole.ResponseJSON))
+        self.assertEqual(res.data._data, b'{"foo": "bar"}')
+        self.assertEqual(res.data._headers['Content-Type'], 'application/json')
+
 if __name__ == '__main__':
     unittest.main()
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.]),)
```

Comments:

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()
Repository: wright-group/WrightTools

Issue:
Symmetric square root does not correctly multiple by the sign factor when the output array is supplied
https://github.com/wright-group/WrightTools/blob/e875360573e8375f94ed4ed70a7d8dc02ab92bb5/WrightTools/kit/_calculate.py#L145-L165

Comments:

Patch:
diff --git a/WrightTools/kit/_calculate.py b/WrightTools/kit/_calculate.py
index 50adda6..2aaa11e 100644
--- a/WrightTools/kit/_calculate.py
+++ b/WrightTools/kit/_calculate.py
@@ -137,8 +137,8 @@ def nm_width(center, width, units="wn") -> float:
     number
         Width in nm.
     """
-    red = wt_units.converter(center - width / 2., units, "nm")
-    blue = wt_units.converter(center + width / 2., units, "nm")
+    red = wt_units.converter(center - width / 2.0, units, "nm")
+    blue = wt_units.converter(center + width / 2.0, units, "nm")
     return red - blue
 
 
@@ -162,4 +162,5 @@ def symmetric_sqrt(x, out=None):
     """
     factor = np.sign(x)
     out = np.sqrt(np.abs(x), out=out)
-    return out * factor
+    out *= factor
+    return out
diff --git a/WrightTools/kit/_interpolate.py b/WrightTools/kit/_interpolate.py
index aaf5438..86667ea 100644
--- a/WrightTools/kit/_interpolate.py
+++ b/WrightTools/kit/_interpolate.py
@@ -21,7 +21,7 @@ __all__ = ["zoom2D", "Spline"]
 # --- functions -----------------------------------------------------------------------------------
 
 
-def zoom2D(xi, yi, zi, xi_zoom=3., yi_zoom=3., order=3, mode="nearest", cval=0.):
+def zoom2D(xi, yi, zi, xi_zoom=3.0, yi_zoom=3.0, order=3, mode="nearest", cval=0.0):
     """Zoom a 2D array, with axes.
 
     Parameters
diff --git a/WrightTools/kit/_timestamp.py b/WrightTools/kit/_timestamp.py
index 6ef2355..8a9c01e 100644
--- a/WrightTools/kit/_timestamp.py
+++ b/WrightTools/kit/_timestamp.py
@@ -159,7 +159,7 @@ class TimeStamp:
         format_string = "%Y-%m-%dT%H:%M:%S.%f"
         out = self.datetime.strftime(format_string)
         # timezone
-        if delta_sec == 0.:
+        if delta_sec == 0.0:
             out += "Z"
         else:
             if delta_sec > 0:


Test patch:
diff --git a/tests/kit/symmetric_sqrt.py b/tests/kit/symmetric_sqrt.py
index 2cf5c93..55112d0 100644
--- a/tests/kit/symmetric_sqrt.py
+++ b/tests/kit/symmetric_sqrt.py
@@ -17,3 +17,11 @@ def test_numbers():
     for number in numbers:
         answer = wt.kit.symmetric_sqrt(number)
         assert answer == np.sign(number) * np.sqrt(np.abs(number))
+
+
+def test_no_reallocation():
+    a = np.linspace(-9, 9, 3)
+    out = np.empty_like(a)
+    ret = wt.kit.symmetric_sqrt(a, out=out)
+    assert out is ret
+    assert np.allclose(ret, [-3, 0, 3])