From 9588b43c504f84156b80c1e9507fceddb8141e31 Mon Sep 17 00:00:00 2001 From: Ryan Herbst Date: Thu, 26 Sep 2024 11:01:00 -0700 Subject: [PATCH 01/18] Reduce calls in chain --- python/pyrogue/_Root.py | 56 ++++++++++++++++++++++++++++++------- python/pyrogue/_Variable.py | 3 -- tests/test_rate.py | 15 ++++++++++ 3 files changed, 61 insertions(+), 13 deletions(-) diff --git a/python/pyrogue/_Root.py b/python/pyrogue/_Root.py index f13b82218..1ef1dacf2 100644 --- a/python/pyrogue/_Root.py +++ b/python/pyrogue/_Root.py @@ -85,7 +85,8 @@ def update(self,var): """ self._list[var.path] = var - self._check() + if self._period != 0: + self._check() class RootLogHandler(logging.Handler): """Class to listen to log entries and add them to syslog variable""" @@ -482,19 +483,24 @@ def updateGroup(self, period=0): tid = threading.get_ident() # At with call - with self._updateLock: - if tid not in self._updateTrack: + try: + self._updateTrack[tid].increment(period) + except: + with self._updateLock: self._updateTrack[tid] = UpdateTracker(self._updateQueue) + self._updateTrack[tid].increment(period) + + #if tid not in self._updateTrack: + # self._updateTrack[tid] = UpdateTracker(self._updateQueue) - self._updateTrack[tid].increment(period) + #self._updateTrack[tid].increment(period) try: yield finally: # After with is done - with self._updateLock: - self._updateTrack[tid].decrement() + self._updateTrack[tid].decrement() @contextmanager def pollBlock(self): @@ -1000,10 +1006,40 @@ def _queueUpdates(self,var): """ tid = threading.get_ident() - with self._updateLock: - if tid not in self._updateTrack: - self._updateTrack[tid] = UpdateTracker(self._updateQueue) - self._updateTrack[tid].update(var) + try: + self._updateTrack[tid].update(var) + except: + with self._updateLock: + self._updateTrack[tid] = UpdateTracker(self._updateQueue) + self._updateTrack[tid].update(var) + + #if tid not in self._updateTrack: + # self._updateTrack[tid] = UpdateTracker(self._updateQueue) + #self._updateTrack[tid].update(var) + + # Perform update on each variable and recurse the listeners list + def _updateVarWithRecurse(self, v): + + val = v._doUpdate() + + # Call listener functions, + with self._varListenLock: + for func,doneFunc,incGroups,excGroups in self._varListeners: + if v.filterByGroup(incGroups, excGroups): + try: + func(p,val) + + except Exception as e: + if v == self.SystemLog or v == self.SystemLogLast: + print("------- Error Executing Syslog Listeners -------") + print("Error: {}".format(e)) + print("------------------------------------------------") + else: + pr.logException(self._log,e) + + # Process listeners + for l in v._listeners: + self._updateVarWithRecurse(l) # Worker thread def _updateWorker(self): diff --git a/python/pyrogue/_Variable.py b/python/pyrogue/_Variable.py index 28c4b3f11..c07dfb129 100644 --- a/python/pyrogue/_Variable.py +++ b/python/pyrogue/_Variable.py @@ -860,9 +860,6 @@ def _queueUpdate(self): """ """ self._root._queueUpdates(self) - for var in self._listeners: - var._queueUpdate() - def _doUpdate(self): """ """ val = VariableValue(self) diff --git a/tests/test_rate.py b/tests/test_rate.py index ffbb00a97..304e8f7ab 100644 --- a/tests/test_rate.py +++ b/tests/test_rate.py @@ -16,6 +16,9 @@ import time import hwcounter +import cProfile, pstats, io +from pstats import SortKey + #rogue.Logging.setLevel(rogue.Logging.Debug) #import logging #logger = logging.getLogger('pyrogue') @@ -105,6 +108,9 @@ def __init__(self): def test_rate(): + pr = cProfile.Profile() + pr.enable() + with DummyTree() as root: count = 100000 resultRate = {} @@ -178,5 +184,14 @@ def test_rate(): if passed is False: raise AssertionError('Rate check failed') + + pr.disable() + + s = io.StringIO() + sortby = SortKey.CUMULATIVE + ps = pstats.Stats(pr, stream=s).sort_stats(sortby) + ps.print_stats() + print(s.getvalue()) + if __name__ == "__main__": test_rate() From e53a6cd3b569be84bd8df73fd66cfe0b677a6297 Mon Sep 17 00:00:00 2001 From: Ryan Herbst Date: Thu, 26 Sep 2024 11:06:37 -0700 Subject: [PATCH 02/18] Update --- python/pyrogue/_Root.py | 17 +---------------- tests/test_rate.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/python/pyrogue/_Root.py b/python/pyrogue/_Root.py index 1ef1dacf2..abc644b4b 100644 --- a/python/pyrogue/_Root.py +++ b/python/pyrogue/_Root.py @@ -1059,22 +1059,7 @@ def _updateWorker(self): elif len(uvars) > 0: self._log.debug(F'Process update group. Length={len(uvars)}. Entry={list(uvars.keys())[0]}') for p,v in uvars.items(): - val = v._doUpdate() - - # Call listener functions, - with self._varListenLock: - for func,doneFunc,incGroups,excGroups in self._varListeners: - if v.filterByGroup(incGroups, excGroups): - try: - func(p,val) - - except Exception as e: - if v == self.SystemLog or v == self.SystemLogLast: - print("------- Error Executing Syslog Listeners -------") - print("Error: {}".format(e)) - print("------------------------------------------------") - else: - pr.logException(self._log,e) + self._updateVarWithRecurse(v) # Finalize listeners with self._varListenLock: diff --git a/tests/test_rate.py b/tests/test_rate.py index 304e8f7ab..1b2c9bdcd 100644 --- a/tests/test_rate.py +++ b/tests/test_rate.py @@ -16,8 +16,8 @@ import time import hwcounter -import cProfile, pstats, io -from pstats import SortKey +#import cProfile, pstats, io +#from pstats import SortKey #rogue.Logging.setLevel(rogue.Logging.Debug) #import logging @@ -108,8 +108,8 @@ def __init__(self): def test_rate(): - pr = cProfile.Profile() - pr.enable() + #pr = cProfile.Profile() + #pr.enable() with DummyTree() as root: count = 100000 @@ -185,13 +185,13 @@ def test_rate(): raise AssertionError('Rate check failed') - pr.disable() + #pr.disable() - s = io.StringIO() - sortby = SortKey.CUMULATIVE - ps = pstats.Stats(pr, stream=s).sort_stats(sortby) - ps.print_stats() - print(s.getvalue()) + #s = io.StringIO() + #sortby = SortKey.CUMULATIVE + #ps = pstats.Stats(pr, stream=s).sort_stats(sortby) + #ps.print_stats() + #print(s.getvalue()) if __name__ == "__main__": test_rate() From 815ea4b0832fc35707dd80b20e7c9a6ebe131956 Mon Sep 17 00:00:00 2001 From: Ryan Herbst Date: Thu, 26 Sep 2024 11:28:17 -0700 Subject: [PATCH 03/18] Update linting --- python/pyrogue/_Root.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/python/pyrogue/_Root.py b/python/pyrogue/_Root.py index abc644b4b..721742920 100644 --- a/python/pyrogue/_Root.py +++ b/python/pyrogue/_Root.py @@ -484,17 +484,12 @@ def updateGroup(self, period=0): # At with call try: - self._updateTrack[tid].increment(period) - except: + self._updateTrack[tid].increment(period) + except Exception: with self._updateLock: self._updateTrack[tid] = UpdateTracker(self._updateQueue) self._updateTrack[tid].increment(period) - #if tid not in self._updateTrack: - # self._updateTrack[tid] = UpdateTracker(self._updateQueue) - - #self._updateTrack[tid].increment(period) - try: yield finally: @@ -1008,15 +1003,11 @@ def _queueUpdates(self,var): try: self._updateTrack[tid].update(var) - except: + except Exception: with self._updateLock: self._updateTrack[tid] = UpdateTracker(self._updateQueue) self._updateTrack[tid].update(var) - #if tid not in self._updateTrack: - # self._updateTrack[tid] = UpdateTracker(self._updateQueue) - #self._updateTrack[tid].update(var) - # Perform update on each variable and recurse the listeners list def _updateVarWithRecurse(self, v): From 45edd74355259d94a5d9e4332a74c8e4ecc075c0 Mon Sep 17 00:00:00 2001 From: Ryan Herbst Date: Thu, 26 Sep 2024 11:32:38 -0700 Subject: [PATCH 04/18] more fixes --- python/pyrogue/_Root.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python/pyrogue/_Root.py b/python/pyrogue/_Root.py index 721742920..4353b837a 100644 --- a/python/pyrogue/_Root.py +++ b/python/pyrogue/_Root.py @@ -1002,14 +1002,14 @@ def _queueUpdates(self,var): tid = threading.get_ident() try: - self._updateTrack[tid].update(var) + self._updateTrack[tid].update(var) except Exception: with self._updateLock: - self._updateTrack[tid] = UpdateTracker(self._updateQueue) - self._updateTrack[tid].update(var) + self._updateTrack[tid] = UpdateTracker(self._updateQueue) + self._updateTrack[tid].update(var) # Perform update on each variable and recurse the listeners list - def _updateVarWithRecurse(self, v): + def _updateVarWithRecurse(self, p, v): val = v._doUpdate() @@ -1029,8 +1029,8 @@ def _updateVarWithRecurse(self, v): pr.logException(self._log,e) # Process listeners - for l in v._listeners: - self._updateVarWithRecurse(l) + for vl in v._listeners: + self._updateVarWithRecurse(vl.path, vl) # Worker thread def _updateWorker(self): @@ -1050,7 +1050,7 @@ def _updateWorker(self): elif len(uvars) > 0: self._log.debug(F'Process update group. Length={len(uvars)}. Entry={list(uvars.keys())[0]}') for p,v in uvars.items(): - self._updateVarWithRecurse(v) + self._updateVarWithRecurse(p,v) # Finalize listeners with self._varListenLock: From 0a92e959d2bdf48608a5abe37c28065487b75e29 Mon Sep 17 00:00:00 2001 From: Ryan Herbst Date: Thu, 26 Sep 2024 15:32:03 -0700 Subject: [PATCH 05/18] One more cleanup --- python/pyrogue/_Root.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python/pyrogue/_Root.py b/python/pyrogue/_Root.py index 4353b837a..22f8c0b50 100644 --- a/python/pyrogue/_Root.py +++ b/python/pyrogue/_Root.py @@ -65,11 +65,12 @@ def decrement(self): self._check() def _check(self): - if len(self._list) != 0 and (self._count == 0 or (self._period != 0 and (time.time() - self._last) > self._period)): - #print(f"Update fired {time.time()}") - self._last = time.time() - self._q.put(self._list) - self._list = {} + if self._count == 0 or (self._period != 0 and (time.time() - self._last) > self._period): + if len(self._list) != 0: + #print(f"Update fired {time.time()}") + self._last = time.time() + self._q.put(self._list) + self._list = {} def update(self,var): """ @@ -85,8 +86,7 @@ def update(self,var): """ self._list[var.path] = var - if self._period != 0: - self._check() + self._check() class RootLogHandler(logging.Handler): """Class to listen to log entries and add them to syslog variable""" From 65e14107cb55e588129b3c6d7774413020b23f07 Mon Sep 17 00:00:00 2001 From: Ryan Herbst Date: Thu, 26 Sep 2024 16:58:18 -0700 Subject: [PATCH 06/18] Change the way listens are handled --- python/pyrogue/_Root.py | 55 +++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/python/pyrogue/_Root.py b/python/pyrogue/_Root.py index 22f8c0b50..06d1b3374 100644 --- a/python/pyrogue/_Root.py +++ b/python/pyrogue/_Root.py @@ -1008,30 +1008,6 @@ def _queueUpdates(self,var): self._updateTrack[tid] = UpdateTracker(self._updateQueue) self._updateTrack[tid].update(var) - # Perform update on each variable and recurse the listeners list - def _updateVarWithRecurse(self, p, v): - - val = v._doUpdate() - - # Call listener functions, - with self._varListenLock: - for func,doneFunc,incGroups,excGroups in self._varListeners: - if v.filterByGroup(incGroups, excGroups): - try: - func(p,val) - - except Exception as e: - if v == self.SystemLog or v == self.SystemLogLast: - print("------- Error Executing Syslog Listeners -------") - print("Error: {}".format(e)) - print("------------------------------------------------") - else: - pr.logException(self._log,e) - - # Process listeners - for vl in v._listeners: - self._updateVarWithRecurse(vl.path, vl) - # Worker thread def _updateWorker(self): """ """ @@ -1049,10 +1025,35 @@ def _updateWorker(self): # Process list elif len(uvars) > 0: self._log.debug(F'Process update group. Length={len(uvars)}. Entry={list(uvars.keys())[0]}') - for p,v in uvars.items(): - self._updateVarWithRecurse(p,v) - # Finalize listeners + # Copy list and add listeners + nvars = uvars.copy() + for p,v in uvars.items(): + for vl in v._listeners: + nvars[vl.path] = vl + + # Process the new list + for p,v in nvars.items(): + + # Process updates + val = v._doUpdate() + + # Call root listener functions, + with self._varListenLock: + for func,doneFunc,incGroups,excGroups in self._varListeners: + if v.filterByGroup(incGroups, excGroups): + try: + func(p,val) + + except Exception as e: + if v == self.SystemLog or v == self.SystemLogLast: + print("------- Error Executing Syslog Listeners -------") + print("Error: {}".format(e)) + print("------------------------------------------------") + else: + pr.logException(self._log,e) + + # Finalize root listeners with self._varListenLock: for func,doneFunc,incGroups,excGroups in self._varListeners: if doneFunc is not None: From 6598340c7df1d3c03832c32cc55f31be35dd56ad Mon Sep 17 00:00:00 2001 From: Ryan Herbst Date: Thu, 26 Sep 2024 17:03:37 -0700 Subject: [PATCH 07/18] Change the way listens are handled --- python/pyrogue/_Root.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python/pyrogue/_Root.py b/python/pyrogue/_Root.py index 06d1b3374..45a1aa8b7 100644 --- a/python/pyrogue/_Root.py +++ b/python/pyrogue/_Root.py @@ -1008,6 +1008,13 @@ def _queueUpdates(self,var): self._updateTrack[tid] = UpdateTracker(self._updateQueue) self._updateTrack[tid].update(var) + # Recursively add listeners to update list + def _recurseAddListeners(self, nvars, var): + for vl in var._listeners: + nvars[vl.path] = vl + + self._recurseAddListeners(nvars, vl) + # Worker thread def _updateWorker(self): """ """ @@ -1029,8 +1036,7 @@ def _updateWorker(self): # Copy list and add listeners nvars = uvars.copy() for p,v in uvars.items(): - for vl in v._listeners: - nvars[vl.path] = vl + self._recurseAddListeners(nvars, v) # Process the new list for p,v in nvars.items(): From 340c295f18e7b0c990bfc36b38e4987f59b83a51 Mon Sep 17 00:00:00 2001 From: Benjamin Reese Date: Mon, 30 Sep 2024 13:02:15 -0700 Subject: [PATCH 08/18] Update numpy set functions to be stride aware --- src/rogue/interfaces/memory/Block.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/rogue/interfaces/memory/Block.cpp b/src/rogue/interfaces/memory/Block.cpp index 2c81292ea..7474b9f52 100644 --- a/src/rogue/interfaces/memory/Block.cpp +++ b/src/rogue/interfaces/memory/Block.cpp @@ -903,6 +903,7 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index) PyArrayObject* arr = reinterpret_cast(value.ptr()); npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); + npy_intp* strides = PyArray_STRIDES(arr); if (ndims != 1) throw(rogue::GeneralError::create("Block::setUIntPy", @@ -921,10 +922,18 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index) if (PyArray_TYPE(arr) == NPY_UINT64) { uint64_t* src = reinterpret_cast(PyArray_DATA(arr)); - for (x = 0; x < dims[0]; x++) setUInt(src[x], var, index + x); + uint64_t value = 0; + for (x = 0; x < dims[0]; x++) { + value = &(src + x * strides[0]); + setUInt(value, var, index + x); + } } else if (PyArray_TYPE(arr) == NPY_UINT32) { uint32_t* src = reinterpret_cast(PyArray_DATA(arr)); - for (x = 0; x < dims[0]; x++) setUInt(src[x], var, index + x); + uint32_t vlaue = 0; + for (x = 0; x < dims[0]; x++) { + value = &(src + x * strides[0]); + setUInt(value, var, index + x); + } } else { throw(rogue::GeneralError::create("Block::setUIntPy", "Passed nparray is not of type (uint64 or uint32) for %s", From ca8b0a1159f2baa5375d5a68001c1594ccb0ccb0 Mon Sep 17 00:00:00 2001 From: Benjamin Reese Date: Mon, 30 Sep 2024 13:35:12 -0700 Subject: [PATCH 09/18] Fix all of the set calls --- src/rogue/interfaces/memory/Block.cpp | 53 +++++++++++++++++++++------ 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/src/rogue/interfaces/memory/Block.cpp b/src/rogue/interfaces/memory/Block.cpp index 7474b9f52..c9c697be3 100644 --- a/src/rogue/interfaces/memory/Block.cpp +++ b/src/rogue/interfaces/memory/Block.cpp @@ -922,17 +922,17 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index) if (PyArray_TYPE(arr) == NPY_UINT64) { uint64_t* src = reinterpret_cast(PyArray_DATA(arr)); - uint64_t value = 0; + uint64_t* value = src; for (x = 0; x < dims[0]; x++) { - value = &(src + x * strides[0]); - setUInt(value, var, index + x); + value = src + x * strides[0]; + setUInt(*value, var, index + x); } } else if (PyArray_TYPE(arr) == NPY_UINT32) { uint32_t* src = reinterpret_cast(PyArray_DATA(arr)); - uint32_t vlaue = 0; + uint32_t* value = src; for (x = 0; x < dims[0]; x++) { - value = &(src + x * strides[0]); - setUInt(value, var, index + x); + value = src + x * strides[0]; + setUInt(*value, var, index + x); } } else { throw(rogue::GeneralError::create("Block::setUIntPy", @@ -1070,6 +1070,7 @@ void rim::Block::setIntPy(bp::object& value, rim::Variable* var, int32_t index) PyArrayObject* arr = reinterpret_cast(value.ptr()); npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); + npy_intp* strides = PyArray_STRIDES(arr); if (ndims != 1) throw(rogue::GeneralError::create("Block::setIntPy", @@ -1088,10 +1089,18 @@ void rim::Block::setIntPy(bp::object& value, rim::Variable* var, int32_t index) if (PyArray_TYPE(arr) == NPY_INT64) { int64_t* src = reinterpret_cast(PyArray_DATA(arr)); - for (x = 0; x < dims[0]; x++) setInt(src[x], var, index + x); + int64_t* value = src; + for (x = 0; x < dims[0]; x++) { + value = src + x * strides[0]; + setInt(*value, var, index + x); + } } else if (PyArray_TYPE(arr) == NPY_INT32) { int32_t* src = reinterpret_cast(PyArray_DATA(arr)); - for (x = 0; x < dims[0]; x++) setInt(src[x], var, index + x); + int32_t* value = src; + for (x = 0; x < dims[0]; x++) { + value = src + x * strides[0]; + setInt(*value, var, index + x); + } } else { throw(rogue::GeneralError::create("Block::setIntPy", "Passed nparray is not of type (int64 or int32) for %s", @@ -1232,6 +1241,7 @@ void rim::Block::setBoolPy(bp::object& value, rim::Variable* var, int32_t index) PyArrayObject* arr = reinterpret_cast(value.ptr()); npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); + npy_intp* strides = PyArray_STRIDES(arr); if (ndims != 1) throw(rogue::GeneralError::create("Block::setBoolPy", @@ -1250,7 +1260,11 @@ void rim::Block::setBoolPy(bp::object& value, rim::Variable* var, int32_t index) if (PyArray_TYPE(arr) == NPY_BOOL) { bool* src = reinterpret_cast(PyArray_DATA(arr)); - for (x = 0; x < dims[0]; x++) setBool(src[x], var, index + x); + bool* value = src; + for (x = 0; x < dims[0]; x++) { + value = src + x * strides[0]; + setBool(*value, var, index + x); + } } else { throw(rogue::GeneralError::create("Block::setBoolPy", "Passed nparray is not of type (bool) for %s", @@ -1440,6 +1454,7 @@ void rim::Block::setFloatPy(bp::object& value, rim::Variable* var, int32_t index PyArrayObject* arr = reinterpret_cast(value.ptr()); npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); + npy_intp* strides = PyArray_STRIDES(arr); if (ndims != 1) throw(rogue::GeneralError::create("Block::setFloatPy", @@ -1458,7 +1473,11 @@ void rim::Block::setFloatPy(bp::object& value, rim::Variable* var, int32_t index if (PyArray_TYPE(arr) == NPY_FLOAT32) { float* src = reinterpret_cast(PyArray_DATA(arr)); - for (x = 0; x < dims[0]; x++) setFloat(src[x], var, index + x); + float* value = src; + for (x = 0; x < dims[0]; x++) { + value = src + x * strides[0]; + setFloat(*value, var, index + x); + } } else { throw(rogue::GeneralError::create("Block::setFLoatPy", "Passed nparray is not of type (float32) for %s", @@ -1585,6 +1604,7 @@ void rim::Block::setDoublePy(bp::object& value, rim::Variable* var, int32_t inde PyArrayObject* arr = reinterpret_cast(value.ptr()); npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); + npy_intp* strides = PyArray_STRIDES(arr); if (ndims != 1) throw(rogue::GeneralError::create("Block::setDoublePy", @@ -1603,7 +1623,11 @@ void rim::Block::setDoublePy(bp::object& value, rim::Variable* var, int32_t inde if (PyArray_TYPE(arr) == NPY_FLOAT64) { double* src = reinterpret_cast(PyArray_DATA(arr)); - for (x = 0; x < dims[0]; x++) setDouble(src[x], var, index + x); + double* value = src; + for (x = 0; x < dims[0]; x++) { + value = src + x * strides[0]; + setDouble(*value, var, index + x); + } } else { throw(rogue::GeneralError::create("Block::setFLoatPy", "Passed nparray is not of type (double) for %s", @@ -1730,6 +1754,7 @@ void rim::Block::setFixedPy(bp::object& value, rim::Variable* var, int32_t index PyArrayObject* arr = reinterpret_cast(value.ptr()); npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); + npy_intp* strides = PyArray_STRIDES(arr); if (ndims != 1) throw(rogue::GeneralError::create("Block::setFixedPy", @@ -1748,7 +1773,11 @@ void rim::Block::setFixedPy(bp::object& value, rim::Variable* var, int32_t index if (PyArray_TYPE(arr) == NPY_FLOAT64) { double* src = reinterpret_cast(PyArray_DATA(arr)); - for (x = 0; x < dims[0]; x++) setFixed(src[x], var, index + x); + double* value = src; + for (x = 0; x < dims[0]; x++) { + value = src + x * strides[0]; + setFixed(*value, var, index + x); + } } else { throw(rogue::GeneralError::create("Block::setFixedPy", "Passed nparray is not of type (double) for %s", From a9bee4931d761ba7c1fec360032f7ce74e9a4c47 Mon Sep 17 00:00:00 2001 From: Benjamin Reese Date: Mon, 30 Sep 2024 13:37:27 -0700 Subject: [PATCH 10/18] Whitespace --- src/rogue/interfaces/memory/Block.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/rogue/interfaces/memory/Block.cpp b/src/rogue/interfaces/memory/Block.cpp index c9c697be3..55bf142bc 100644 --- a/src/rogue/interfaces/memory/Block.cpp +++ b/src/rogue/interfaces/memory/Block.cpp @@ -1070,7 +1070,7 @@ void rim::Block::setIntPy(bp::object& value, rim::Variable* var, int32_t index) PyArrayObject* arr = reinterpret_cast(value.ptr()); npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); - npy_intp* strides = PyArray_STRIDES(arr); + npy_intp* strides = PyArray_STRIDES(arr); if (ndims != 1) throw(rogue::GeneralError::create("Block::setIntPy", @@ -1241,7 +1241,7 @@ void rim::Block::setBoolPy(bp::object& value, rim::Variable* var, int32_t index) PyArrayObject* arr = reinterpret_cast(value.ptr()); npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); - npy_intp* strides = PyArray_STRIDES(arr); + npy_intp* strides = PyArray_STRIDES(arr); if (ndims != 1) throw(rogue::GeneralError::create("Block::setBoolPy", @@ -1264,7 +1264,7 @@ void rim::Block::setBoolPy(bp::object& value, rim::Variable* var, int32_t index) for (x = 0; x < dims[0]; x++) { value = src + x * strides[0]; setBool(*value, var, index + x); - } + } } else { throw(rogue::GeneralError::create("Block::setBoolPy", "Passed nparray is not of type (bool) for %s", @@ -1454,7 +1454,7 @@ void rim::Block::setFloatPy(bp::object& value, rim::Variable* var, int32_t index PyArrayObject* arr = reinterpret_cast(value.ptr()); npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); - npy_intp* strides = PyArray_STRIDES(arr); + npy_intp* strides = PyArray_STRIDES(arr); if (ndims != 1) throw(rogue::GeneralError::create("Block::setFloatPy", @@ -1477,7 +1477,7 @@ void rim::Block::setFloatPy(bp::object& value, rim::Variable* var, int32_t index for (x = 0; x < dims[0]; x++) { value = src + x * strides[0]; setFloat(*value, var, index + x); - } + } } else { throw(rogue::GeneralError::create("Block::setFLoatPy", "Passed nparray is not of type (float32) for %s", @@ -1627,7 +1627,7 @@ void rim::Block::setDoublePy(bp::object& value, rim::Variable* var, int32_t inde for (x = 0; x < dims[0]; x++) { value = src + x * strides[0]; setDouble(*value, var, index + x); - } + } } else { throw(rogue::GeneralError::create("Block::setFLoatPy", "Passed nparray is not of type (double) for %s", @@ -1754,7 +1754,7 @@ void rim::Block::setFixedPy(bp::object& value, rim::Variable* var, int32_t index PyArrayObject* arr = reinterpret_cast(value.ptr()); npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); - npy_intp* strides = PyArray_STRIDES(arr); + npy_intp* strides = PyArray_STRIDES(arr); if (ndims != 1) throw(rogue::GeneralError::create("Block::setFixedPy", @@ -1777,7 +1777,7 @@ void rim::Block::setFixedPy(bp::object& value, rim::Variable* var, int32_t index for (x = 0; x < dims[0]; x++) { value = src + x * strides[0]; setFixed(*value, var, index + x); - } + } } else { throw(rogue::GeneralError::create("Block::setFixedPy", "Passed nparray is not of type (double) for %s", From e9a1c3b2e8f84b608644fe716d37c87b124edda1 Mon Sep 17 00:00:00 2001 From: Benjamin Reese Date: Mon, 30 Sep 2024 13:50:36 -0700 Subject: [PATCH 11/18] Fix pointer math --- src/rogue/interfaces/memory/Block.cpp | 41 +++++++++++---------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/rogue/interfaces/memory/Block.cpp b/src/rogue/interfaces/memory/Block.cpp index 55bf142bc..4a8e939d8 100644 --- a/src/rogue/interfaces/memory/Block.cpp +++ b/src/rogue/interfaces/memory/Block.cpp @@ -904,6 +904,7 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index) npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); + void* src = PyArray_DATA(arr); if (ndims != 1) throw(rogue::GeneralError::create("Block::setUIntPy", @@ -921,17 +922,15 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index) var->name_.c_str())); if (PyArray_TYPE(arr) == NPY_UINT64) { - uint64_t* src = reinterpret_cast(PyArray_DATA(arr)); - uint64_t* value = src; + uint64_t* value = reinterpret_cast(src); for (x = 0; x < dims[0]; x++) { - value = src + x * strides[0]; + value = reinterpret_cast(src + x * strides[0]); setUInt(*value, var, index + x); } } else if (PyArray_TYPE(arr) == NPY_UINT32) { - uint32_t* src = reinterpret_cast(PyArray_DATA(arr)); - uint32_t* value = src; + uint32_t* value = reinterpret_cast(src); for (x = 0; x < dims[0]; x++) { - value = src + x * strides[0]; + value = reinterpret_cast(src + x * strides[0]); setUInt(*value, var, index + x); } } else { @@ -1088,17 +1087,15 @@ void rim::Block::setIntPy(bp::object& value, rim::Variable* var, int32_t index) var->name_.c_str())); if (PyArray_TYPE(arr) == NPY_INT64) { - int64_t* src = reinterpret_cast(PyArray_DATA(arr)); - int64_t* value = src; + int64_t* value = reinterpret_cast(src); for (x = 0; x < dims[0]; x++) { - value = src + x * strides[0]; + value = reinterpret_cast(src + x * strides[0]); setInt(*value, var, index + x); } } else if (PyArray_TYPE(arr) == NPY_INT32) { - int32_t* src = reinterpret_cast(PyArray_DATA(arr)); - int32_t* value = src; + int32_t* value = reinterpret_cast(src); for (x = 0; x < dims[0]; x++) { - value = src + x * strides[0]; + value = reinterpret_cast(src + x * strides[0]); setInt(*value, var, index + x); } } else { @@ -1259,10 +1256,9 @@ void rim::Block::setBoolPy(bp::object& value, rim::Variable* var, int32_t index) var->name_.c_str())); if (PyArray_TYPE(arr) == NPY_BOOL) { - bool* src = reinterpret_cast(PyArray_DATA(arr)); - bool* value = src; + bool* value = reinterpret_cast(src); for (x = 0; x < dims[0]; x++) { - value = src + x * strides[0]; + value = reinterpret_cast(src + x * strides[0]); setBool(*value, var, index + x); } } else { @@ -1472,10 +1468,9 @@ void rim::Block::setFloatPy(bp::object& value, rim::Variable* var, int32_t index var->name_.c_str())); if (PyArray_TYPE(arr) == NPY_FLOAT32) { - float* src = reinterpret_cast(PyArray_DATA(arr)); - float* value = src; + float* value = reinterpret_cast(src); for (x = 0; x < dims[0]; x++) { - value = src + x * strides[0]; + value = reinterpret_cast(src + x * strides[0]); setFloat(*value, var, index + x); } } else { @@ -1622,10 +1617,9 @@ void rim::Block::setDoublePy(bp::object& value, rim::Variable* var, int32_t inde var->name_.c_str())); if (PyArray_TYPE(arr) == NPY_FLOAT64) { - double* src = reinterpret_cast(PyArray_DATA(arr)); - double* value = src; + double* value = reinterpret_cast(src); for (x = 0; x < dims[0]; x++) { - value = src + x * strides[0]; + value = reinterpret_cast(src + x * strides[0]); setDouble(*value, var, index + x); } } else { @@ -1772,10 +1766,9 @@ void rim::Block::setFixedPy(bp::object& value, rim::Variable* var, int32_t index var->name_.c_str())); if (PyArray_TYPE(arr) == NPY_FLOAT64) { - double* src = reinterpret_cast(PyArray_DATA(arr)); - double* value = src; + double* value = reinterpret_cast(src); for (x = 0; x < dims[0]; x++) { - value = src + x * strides[0]; + value = reinterpret_cast(src + x * strides[0]); setFixed(*value, var, index + x); } } else { From 342bb2550ee4329870c86f4ccd21e514207fb546 Mon Sep 17 00:00:00 2001 From: Benjamin Reese Date: Mon, 30 Sep 2024 13:50:51 -0700 Subject: [PATCH 12/18] Whitespace --- src/rogue/interfaces/memory/Block.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rogue/interfaces/memory/Block.cpp b/src/rogue/interfaces/memory/Block.cpp index 4a8e939d8..72f933a4c 100644 --- a/src/rogue/interfaces/memory/Block.cpp +++ b/src/rogue/interfaces/memory/Block.cpp @@ -904,7 +904,7 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index) npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); - void* src = PyArray_DATA(arr); + void* src = PyArray_DATA(arr); if (ndims != 1) throw(rogue::GeneralError::create("Block::setUIntPy", From 1f5f06061bba05dddf00b360ed2515c3f6e3f8de Mon Sep 17 00:00:00 2001 From: Benjamin Reese Date: Mon, 30 Sep 2024 13:54:28 -0700 Subject: [PATCH 13/18] Add test for non-contiguous numpy set --- tests/test_list_memory.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_list_memory.py b/tests/test_list_memory.py index 8e4c80e2e..16fcc25bc 100644 --- a/tests/test_list_memory.py +++ b/tests/test_list_memory.py @@ -423,6 +423,9 @@ def test_memory(): root.ListDevice.UInt32List.set(UInt32ListA) root.ListDevice.Int32List.set(Int32ListA) + root.ListDevice.UInt32List.set(UInt32ListA[::2]) + root.ListDevice.Int32List.set(Int32ListA[::2] + root.ListDevice.UInt32List.set(np.array([1,2,3],np.uint32),index=7) root.ListDevice.Int32List.set([1,-22,-33],index=5) From 4af31c3fc3f3c8efd3d4d367a73c6fbd6ba94f12 Mon Sep 17 00:00:00 2001 From: Benjamin Reese Date: Mon, 30 Sep 2024 14:01:29 -0700 Subject: [PATCH 14/18] Fix pointer math --- src/rogue/interfaces/memory/Block.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rogue/interfaces/memory/Block.cpp b/src/rogue/interfaces/memory/Block.cpp index 72f933a4c..03db142e6 100644 --- a/src/rogue/interfaces/memory/Block.cpp +++ b/src/rogue/interfaces/memory/Block.cpp @@ -904,7 +904,7 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index) npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); - void* src = PyArray_DATA(arr); + uint8_t* src = reinterpret_cast(PyArray_DATA(arr)); if (ndims != 1) throw(rogue::GeneralError::create("Block::setUIntPy", @@ -1070,6 +1070,7 @@ void rim::Block::setIntPy(bp::object& value, rim::Variable* var, int32_t index) npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); + uint8_t* src = reinterpret_cast(PyArray_DATA(arr)); if (ndims != 1) throw(rogue::GeneralError::create("Block::setIntPy", @@ -1239,6 +1240,7 @@ void rim::Block::setBoolPy(bp::object& value, rim::Variable* var, int32_t index) npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); + uint8_t* src = reinterpret_cast(PyArray_DATA(arr)); if (ndims != 1) throw(rogue::GeneralError::create("Block::setBoolPy", @@ -1451,6 +1453,7 @@ void rim::Block::setFloatPy(bp::object& value, rim::Variable* var, int32_t index npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); + uint8_t* src = reinterpret_cast(PyArray_DATA(arr)); if (ndims != 1) throw(rogue::GeneralError::create("Block::setFloatPy", @@ -1600,6 +1603,7 @@ void rim::Block::setDoublePy(bp::object& value, rim::Variable* var, int32_t inde npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); + uint8_t* src = reinterpret_cast(PyArray_DATA(arr)); if (ndims != 1) throw(rogue::GeneralError::create("Block::setDoublePy", @@ -1749,6 +1753,7 @@ void rim::Block::setFixedPy(bp::object& value, rim::Variable* var, int32_t index npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); + uint8_t* src = reinterpret_cast(PyArray_DATA(arr)); if (ndims != 1) throw(rogue::GeneralError::create("Block::setFixedPy", From 29ade9d0208b86b4e4128ab136320926a7c39734 Mon Sep 17 00:00:00 2001 From: Benjamin Reese Date: Mon, 30 Sep 2024 14:15:39 -0700 Subject: [PATCH 15/18] Cleanup --- src/rogue/interfaces/memory/Block.cpp | 54 ++++++++++++--------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/src/rogue/interfaces/memory/Block.cpp b/src/rogue/interfaces/memory/Block.cpp index 03db142e6..563d5c923 100644 --- a/src/rogue/interfaces/memory/Block.cpp +++ b/src/rogue/interfaces/memory/Block.cpp @@ -904,7 +904,6 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index) npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); - uint8_t* src = reinterpret_cast(PyArray_DATA(arr)); if (ndims != 1) throw(rogue::GeneralError::create("Block::setUIntPy", @@ -922,16 +921,16 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index) var->name_.c_str())); if (PyArray_TYPE(arr) == NPY_UINT64) { - uint64_t* value = reinterpret_cast(src); + uint64_t* src = reinterpret_cast(PyArray_DATA(arr)); + npy_intp stride = strides[0] / sizeof(uint64_t); for (x = 0; x < dims[0]; x++) { - value = reinterpret_cast(src + x * strides[0]); - setUInt(*value, var, index + x); + setUInt(src[x * stride], var, index + x); } } else if (PyArray_TYPE(arr) == NPY_UINT32) { - uint32_t* value = reinterpret_cast(src); + uint32_t* src = reinterpret_cast(PyArray_DATA(arr)); + npy_intp stride = strides[0] / sizeof(uint32_t); for (x = 0; x < dims[0]; x++) { - value = reinterpret_cast(src + x * strides[0]); - setUInt(*value, var, index + x); + setUInt(src[x * stride], var, index + x); } } else { throw(rogue::GeneralError::create("Block::setUIntPy", @@ -1070,7 +1069,6 @@ void rim::Block::setIntPy(bp::object& value, rim::Variable* var, int32_t index) npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); - uint8_t* src = reinterpret_cast(PyArray_DATA(arr)); if (ndims != 1) throw(rogue::GeneralError::create("Block::setIntPy", @@ -1088,16 +1086,16 @@ void rim::Block::setIntPy(bp::object& value, rim::Variable* var, int32_t index) var->name_.c_str())); if (PyArray_TYPE(arr) == NPY_INT64) { - int64_t* value = reinterpret_cast(src); + int64_t* src = reinterpret_cast(PyArray_DATA(arr)); + npy_intp stride = strides[0] / sizeof(int64_t); for (x = 0; x < dims[0]; x++) { - value = reinterpret_cast(src + x * strides[0]); - setInt(*value, var, index + x); + setInt(src[x * stride], var, index + x); } } else if (PyArray_TYPE(arr) == NPY_INT32) { - int32_t* value = reinterpret_cast(src); + int32_t* src = reinterpret_cast(PyArray_DATA(arr)); + npy_intp stride = strides[0] / sizeof(int32_t); for (x = 0; x < dims[0]; x++) { - value = reinterpret_cast(src + x * strides[0]); - setInt(*value, var, index + x); + setInt(src[x * stride], var, index + x); } } else { throw(rogue::GeneralError::create("Block::setIntPy", @@ -1240,7 +1238,6 @@ void rim::Block::setBoolPy(bp::object& value, rim::Variable* var, int32_t index) npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); - uint8_t* src = reinterpret_cast(PyArray_DATA(arr)); if (ndims != 1) throw(rogue::GeneralError::create("Block::setBoolPy", @@ -1258,10 +1255,10 @@ void rim::Block::setBoolPy(bp::object& value, rim::Variable* var, int32_t index) var->name_.c_str())); if (PyArray_TYPE(arr) == NPY_BOOL) { - bool* value = reinterpret_cast(src); + bool* src = reinterpret_cast(PyArray_DATA(arr)); + npy_intp stride = strides[0] / sizeof(bool); for (x = 0; x < dims[0]; x++) { - value = reinterpret_cast(src + x * strides[0]); - setBool(*value, var, index + x); + setBool(src[x * stride], var, index + x); } } else { throw(rogue::GeneralError::create("Block::setBoolPy", @@ -1453,7 +1450,6 @@ void rim::Block::setFloatPy(bp::object& value, rim::Variable* var, int32_t index npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); - uint8_t* src = reinterpret_cast(PyArray_DATA(arr)); if (ndims != 1) throw(rogue::GeneralError::create("Block::setFloatPy", @@ -1471,10 +1467,10 @@ void rim::Block::setFloatPy(bp::object& value, rim::Variable* var, int32_t index var->name_.c_str())); if (PyArray_TYPE(arr) == NPY_FLOAT32) { - float* value = reinterpret_cast(src); + float* src = reinterpret_cast(PyArray_DATA(arr)); + npy_intp stride = strides[0] / sizeof(float); for (x = 0; x < dims[0]; x++) { - value = reinterpret_cast(src + x * strides[0]); - setFloat(*value, var, index + x); + setFloat(src[x * stride], var, index + x); } } else { throw(rogue::GeneralError::create("Block::setFLoatPy", @@ -1603,7 +1599,6 @@ void rim::Block::setDoublePy(bp::object& value, rim::Variable* var, int32_t inde npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); - uint8_t* src = reinterpret_cast(PyArray_DATA(arr)); if (ndims != 1) throw(rogue::GeneralError::create("Block::setDoublePy", @@ -1621,10 +1616,10 @@ void rim::Block::setDoublePy(bp::object& value, rim::Variable* var, int32_t inde var->name_.c_str())); if (PyArray_TYPE(arr) == NPY_FLOAT64) { - double* value = reinterpret_cast(src); + double* src = reinterpret_cast(PyArray_DATA(arr)); + npy_intp stride = strides[0] / sizeof(double); for (x = 0; x < dims[0]; x++) { - value = reinterpret_cast(src + x * strides[0]); - setDouble(*value, var, index + x); + setDouble(src[x * stride], var, index + x); } } else { throw(rogue::GeneralError::create("Block::setFLoatPy", @@ -1753,7 +1748,6 @@ void rim::Block::setFixedPy(bp::object& value, rim::Variable* var, int32_t index npy_intp ndims = PyArray_NDIM(arr); npy_intp* dims = PyArray_SHAPE(arr); npy_intp* strides = PyArray_STRIDES(arr); - uint8_t* src = reinterpret_cast(PyArray_DATA(arr)); if (ndims != 1) throw(rogue::GeneralError::create("Block::setFixedPy", @@ -1771,10 +1765,10 @@ void rim::Block::setFixedPy(bp::object& value, rim::Variable* var, int32_t index var->name_.c_str())); if (PyArray_TYPE(arr) == NPY_FLOAT64) { - double* value = reinterpret_cast(src); + double* src = reinterpret_cast(PyArray_DATA(arr)); + npy_intp stride = strides[0] / sizeof(double); for (x = 0; x < dims[0]; x++) { - value = reinterpret_cast(src + x * strides[0]); - setFixed(*value, var, index + x); + setFixed(src[x * stride], var, index + x); } } else { throw(rogue::GeneralError::create("Block::setFixedPy", From 59ed5655bb11fd31476fe00b738a3af237f0189e Mon Sep 17 00:00:00 2001 From: Benjamin Reese Date: Mon, 30 Sep 2024 14:19:33 -0700 Subject: [PATCH 16/18] Fix syntax error --- tests/test_list_memory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_list_memory.py b/tests/test_list_memory.py index 16fcc25bc..a042d9926 100644 --- a/tests/test_list_memory.py +++ b/tests/test_list_memory.py @@ -424,7 +424,7 @@ def test_memory(): root.ListDevice.Int32List.set(Int32ListA) root.ListDevice.UInt32List.set(UInt32ListA[::2]) - root.ListDevice.Int32List.set(Int32ListA[::2] + root.ListDevice.Int32List.set(Int32ListA[::2]) root.ListDevice.UInt32List.set(np.array([1,2,3],np.uint32),index=7) root.ListDevice.Int32List.set([1,-22,-33],index=5) From b13c62ca5c7956d975a321c9a70bd3e5a0ec3085 Mon Sep 17 00:00:00 2001 From: Benjamin Reese Date: Mon, 30 Sep 2024 14:38:41 -0700 Subject: [PATCH 17/18] Update test --- tests/test_list_memory.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tests/test_list_memory.py b/tests/test_list_memory.py index a042d9926..576a6a0de 100644 --- a/tests/test_list_memory.py +++ b/tests/test_list_memory.py @@ -423,9 +423,6 @@ def test_memory(): root.ListDevice.UInt32List.set(UInt32ListA) root.ListDevice.Int32List.set(Int32ListA) - root.ListDevice.UInt32List.set(UInt32ListA[::2]) - root.ListDevice.Int32List.set(Int32ListA[::2]) - root.ListDevice.UInt32List.set(np.array([1,2,3],np.uint32),index=7) root.ListDevice.Int32List.set([1,-22,-33],index=5) @@ -447,6 +444,30 @@ def test_memory(): # Test value shift _ = resA[0] >> 5 + root.ListDevice.UInt32List.set(UInt32ListA[::2]) + root.ListDevice.Int32List.set(Int32ListA[::2]) + + resA = root.ListDevice.UInt32List.get() + resB = root.ListDevice.Int32List.get() + + for i in range(16): + + if resA[i] != UInt32ListA[::2][i]: + raise AssertionError(f'Stripe Verification Failure for UInt32ListA at position {i}') + + if resB[i] != Int32ListA[::2][i]: + raise AssertionError(f'Stripe Verification Failure for Int32ListA at position {i}') + + for i in range(16, 32): + + if resA[i] != UInt32ListA[i]: + raise AssertionError(f'Stripe Verification Failure for UInt32ListA at position {i}') + + if resB[i] != Int32ListA[i]: + raise AssertionError(f'Stripe Verification Failure for Int32ListA at position {i}') + + + def run_gui(): import pyrogue.pydm From 8f094c6a4b92587cea483553eadc290eaf558bfe Mon Sep 17 00:00:00 2001 From: Benjamin Reese Date: Mon, 30 Sep 2024 14:46:58 -0700 Subject: [PATCH 18/18] Whitespace --- tests/test_list_memory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_list_memory.py b/tests/test_list_memory.py index 576a6a0de..fb1016a9f 100644 --- a/tests/test_list_memory.py +++ b/tests/test_list_memory.py @@ -457,7 +457,7 @@ def test_memory(): if resB[i] != Int32ListA[::2][i]: raise AssertionError(f'Stripe Verification Failure for Int32ListA at position {i}') - + for i in range(16, 32): if resA[i] != UInt32ListA[i]: @@ -466,7 +466,7 @@ def test_memory(): if resB[i] != Int32ListA[i]: raise AssertionError(f'Stripe Verification Failure for Int32ListA at position {i}') - + def run_gui(): import pyrogue.pydm