111 lines
5.8 KiB
Diff
111 lines
5.8 KiB
Diff
From 42b9c691fdd2d0001c61f78cc8adfbb9c994f6b4 Mon Sep 17 00:00:00 2001
|
|
From: Mattias Ellert <mattias.ellert@physics.uu.se>
|
|
Date: Fri, 17 Nov 2023 11:46:14 +0100
|
|
Subject: [PATCH 3/3] Fix pythonizations test errors on ix86 Linux
|
|
|
|
======================================================================
|
|
ERROR: test_sliced_array (rdataframe_makenumpy.DataFrameFromNumpy.test_sliced_array)
|
|
Test correct reading of a sliced numpy array (#13690)
|
|
----------------------------------------------------------------------
|
|
Traceback (most recent call last):
|
|
File "/builddir/build/BUILD/root-6.30.00/bindings/pyroot/pythonizations/test/rdataframe_makenumpy.py", line 153, in test_sliced_array
|
|
x_col = df.Take['Long64_t']("x")
|
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
cppyy.gbl.std.runtime_error: Could not instantiate Take<Long64_t>:
|
|
ROOT::RDF::RResultPtr<vector<Long64_t> > ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void>::Take(basic_string_view<char,char_traits<char> > column = "") =>
|
|
runtime_error: Column x has type int while the id specified is associated to type Long64_t
|
|
----------------------------------------------------------------------
|
|
|
|
======================================================================
|
|
ERROR: test_dtypes (rtensor.AsRTensor.test_dtypes)
|
|
Test adoption of numpy arrays with different data types
|
|
----------------------------------------------------------------------
|
|
Traceback (most recent call last):
|
|
File "/builddir/build/BUILD/root-6.30.00/bindings/pyroot/pythonizations/test/rtensor.py", line 45, in test_dtypes
|
|
root_obj = ROOT.TMVA.Experimental.RTensor(self.cpptypes[i])(np_obj)
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
File "/builddir/build/BUILD/root-6.30.00/redhat-linux-build/lib/ROOT/_pythonization/_tmva/_rtensor.py", line 131, in RTensorInit
|
|
return self._original_init_(data,shape,layout)
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
TypeError: none of the 6 overloaded methods succeeded. Full details:
|
|
RTensor<long,vector<long> >::RTensor<long,vector<long> >(TMVA::Experimental::RTensor<long,vector<long> >&&) =>
|
|
TypeError: takes at most 1 arguments (3 given)
|
|
RTensor<long,vector<long> >::RTensor<long,vector<long> >(const TMVA::Experimental::RTensor<long,vector<long> >&) =>
|
|
TypeError: takes at most 1 arguments (3 given)
|
|
RTensor<long,vector<long> >::RTensor<long,vector<long> >(shared_ptr<vector<long> > container, vector<unsigned int> shape, TMVA::Experimental::MemoryLayout layout = MemoryLayout::RowMajor) =>
|
|
TypeError: could not convert argument 1
|
|
RTensor<long,vector<long> >::RTensor<long,vector<long> >(vector<unsigned int> shape, TMVA::Experimental::MemoryLayout layout = MemoryLayout::RowMajor) =>
|
|
TypeError: takes at most 2 arguments (3 given)
|
|
RTensor<long,vector<long> >::RTensor<long,vector<long> >(long* data, vector<unsigned int> shape, vector<unsigned int> strides, TMVA::Experimental::MemoryLayout layout = MemoryLayout::RowMajor) =>
|
|
TypeError: could not convert argument 1 (could not convert argument to buffer or nullptr)
|
|
RTensor<long,vector<long> >::RTensor<long,vector<long> >(long* data, vector<unsigned int> shape, TMVA::Experimental::MemoryLayout layout = MemoryLayout::RowMajor) =>
|
|
TypeError: could not convert argument 1 (could not convert argument to buffer or nullptr)
|
|
----------------------------------------------------------------------
|
|
---
|
|
.../pyroot/pythonizations/test/rdataframe_makenumpy.py | 8 ++++----
|
|
bindings/pyroot/pythonizations/test/rtensor.py | 8 +-------
|
|
2 files changed, 5 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/bindings/pyroot/pythonizations/test/rdataframe_makenumpy.py b/bindings/pyroot/pythonizations/test/rdataframe_makenumpy.py
|
|
index cd2ebc9b5b..cc46f5bea1 100644
|
|
--- a/bindings/pyroot/pythonizations/test/rdataframe_makenumpy.py
|
|
+++ b/bindings/pyroot/pythonizations/test/rdataframe_makenumpy.py
|
|
@@ -142,19 +142,19 @@ class DataFrameFromNumpy(unittest.TestCase):
|
|
gc.collect()
|
|
ref4 = sys.getrefcount(x)
|
|
self.assertEqual(ref1, ref4)
|
|
-
|
|
+
|
|
def test_sliced_array(self):
|
|
"""
|
|
Test correct reading of a sliced numpy array (#13690)
|
|
"""
|
|
- table = np.array([[1,2], [3,4]])
|
|
+ table = np.array([[1,2], [3,4]], dtype="int64")
|
|
columns = {'x': table[:,0], 'y': table[:,1]}
|
|
df = ROOT.RDF.FromNumpy(columns)
|
|
x_col = df.Take['Long64_t']("x")
|
|
y_col = df.Take['Long64_t']("y")
|
|
- self.assertEqual(list(x_col.GetValue()), [1,3])
|
|
+ self.assertEqual(list(x_col.GetValue()), [1,3])
|
|
self.assertEqual(list(y_col.GetValue()), [2,4])
|
|
-
|
|
+
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|
|
diff --git a/bindings/pyroot/pythonizations/test/rtensor.py b/bindings/pyroot/pythonizations/test/rtensor.py
|
|
index 99b458cfa9..ca119f0b41 100644
|
|
--- a/bindings/pyroot/pythonizations/test/rtensor.py
|
|
+++ b/bindings/pyroot/pythonizations/test/rtensor.py
|
|
@@ -2,7 +2,6 @@ import unittest
|
|
import ROOT
|
|
RTensor = ROOT.TMVA.Experimental.RTensor
|
|
import numpy as np
|
|
-import platform
|
|
|
|
|
|
def check_shape(root_obj, np_obj):
|
|
@@ -21,18 +20,13 @@ class AsRTensor(unittest.TestCase):
|
|
dtypes = [
|
|
"int32", "int64", "uint32", "uint64", "float32", "float64"
|
|
]
|
|
- cpptypes = ["int", "long", "unsigned int", "unsigned long", "float", "double"]
|
|
+ cpptypes = ["int32_t", "int64_t", "uint32_t", "uint64_t", "float", "double"]
|
|
|
|
# Tests
|
|
def test_dtypes(self):
|
|
"""
|
|
Test adoption of numpy arrays with different data types
|
|
"""
|
|
- #using long long on Linux does not work although it is same size as long
|
|
- if (platform.system() == "Windows") :
|
|
- self.cpptypes[1] = "long long"
|
|
- self.cpptypes[3] = "unsigned long long"
|
|
-
|
|
i = 0
|
|
for dtype in self.dtypes:
|
|
np_obj = np.array([[1, 2], [3, 4], [5, 6]], dtype=dtype)
|
|
--
|
|
2.43.0
|
|
|