Skip to content

Commit 64524f7

Browse files
committed
ruff lint and format tests
1 parent cd51ace commit 64524f7

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
lines changed

bindings/pyroot/pythonizations/test/rdataframe_makenumpy.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import gc
2+
import sys
13
import unittest
2-
import ROOT
4+
35
import numpy as np
4-
import sys
5-
import gc
6+
import ROOT
67

78

89
class DataFrameFromNumpy(unittest.TestCase):
@@ -11,9 +12,7 @@ class DataFrameFromNumpy(unittest.TestCase):
1112
with RDataFrame.
1213
"""
1314

14-
dtypes = [
15-
"int32", "int64", "uint32", "uint64", "float32", "float64"
16-
]
15+
dtypes = ["int32", "int64", "uint32", "uint64", "float32", "float64"]
1716

1817
def test_dtypes(self):
1918
"""
@@ -159,14 +158,14 @@ def test_sliced_array(self):
159158
"""
160159
Test correct reading of a sliced numpy array (#13690)
161160
"""
162-
table = np.array([[1,2], [3,4]], dtype="int64")
163-
columns = {'x': table[:,0], 'y': table[:,1]}
161+
table = np.array([[1, 2], [3, 4]], dtype="int64")
162+
columns = {"x": table[:, 0], "y": table[:, 1]}
164163
df = ROOT.RDF.FromNumpy(columns)
165-
x_col = df.Take['Long64_t']("x")
166-
y_col = df.Take['Long64_t']("y")
167-
self.assertEqual(list(x_col.GetValue()), [1,3])
168-
self.assertEqual(list(y_col.GetValue()), [2,4])
164+
x_col = df.Take["Long64_t"]("x")
165+
y_col = df.Take["Long64_t"]("y")
166+
self.assertEqual(list(x_col.GetValue()), [1, 3])
167+
self.assertEqual(list(y_col.GetValue()), [2, 4])
169168

170169

171-
if __name__ == '__main__':
170+
if __name__ == "__main__":
172171
unittest.main()

bindings/pyroot/pythonizations/test/rvec_asrvec.py

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import gc
2+
import sys
13
import unittest
2-
import ROOT
4+
35
import numpy as np
4-
import sys
5-
import gc
6+
import ROOT
67

78

89
def get_maximum_for_dtype(dtype):
@@ -11,6 +12,7 @@ def get_maximum_for_dtype(dtype):
1112
if np.issubdtype(dtype, np.floating):
1213
return np.finfo(dtype).max
1314

15+
1416
def get_minimum_for_dtype(dtype):
1517
if np.issubdtype(dtype, np.integer):
1618
return np.iinfo(dtype).min
@@ -25,9 +27,7 @@ class AsRVec(unittest.TestCase):
2527
"""
2628

2729
# Helpers
28-
dtypes = [
29-
"int16", "int32", "int64", "uint16", "uint32", "uint64", "float32", "float64", "bool"
30-
]
30+
dtypes = ["int16", "int32", "int64", "uint16", "uint32", "uint64", "float32", "float64", "bool"]
3131

3232
def check_memory_adoption(self, root_obj, np_obj):
3333
np_obj[0] = get_maximum_for_dtype(np_obj.dtype)
@@ -49,12 +49,11 @@ def test_dtypes(self):
4949
self.check_memory_adoption(root_obj, np_obj)
5050
self.check_size(2, root_obj)
5151

52-
5352
def test_object_dtype_strings(self):
5453
"""
5554
Test adoption of numpy arrays with dtype=object and dtype=str containing strings
5655
"""
57-
for dtype in [object, np.str_, '<U13']:
56+
for dtype in [object, np.str_, "<U13"]:
5857
with self.subTest(dtype=dtype):
5958
np_obj = np.array(["test_string_1", "test_string_2"], dtype=dtype)
6059
root_obj = ROOT.VecOps.AsRVec(np_obj)
@@ -63,10 +62,9 @@ def test_object_dtype_strings(self):
6362
self.assertEqual(root_obj[0], np_obj[0])
6463
self.assertEqual(root_obj[1], np_obj[1])
6564

66-
6765
def test_object_dtype_mixed_types(self):
6866
"""
69-
Test that a TypeError is raised for numpy arrays with dtype=object
67+
Test that a TypeError is raised for numpy arrays with dtype=object
7068
containing elements of different types
7169
"""
7270
np_obj = np.array(["string", {}], dtype=object)
@@ -76,7 +74,6 @@ def test_object_dtype_mixed_types(self):
7674

7775
self.assertIn("All elements in the numpy array must be of the same type", str(context.exception))
7876

79-
8077
def test_multidim(self):
8178
"""
8279
Test adoption of multi-dimensional numpy arrays
@@ -142,5 +139,5 @@ def test_refcount(self):
142139
self.assertEqual(sys.getrefcount(np_obj), 2)
143140

144141

145-
if __name__ == '__main__':
142+
if __name__ == "__main__":
146143
unittest.main()

0 commit comments

Comments
 (0)