From 5a631592f2da57bf1564c263e9602c46e5a5a50c Mon Sep 17 00:00:00 2001 From: Joshua Larsen Date: Tue, 8 Aug 2023 08:57:41 -0700 Subject: [PATCH] update(_ptr_to_recarray): slice pointers prior to setting data to recarray --- modflowapi/extensions/data.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/modflowapi/extensions/data.py b/modflowapi/extensions/data.py index 5449558..5079262 100644 --- a/modflowapi/extensions/data.py +++ b/modflowapi/extensions/data.py @@ -108,21 +108,19 @@ def _ptr_to_recarray(self): return recarray = np.recarray((self._nbound[0],), self._dtype) for name, ptr in self._ptrs.items(): + if name == "auxvar" and self._naux == 0: + continue values = np.copy(ptr) if name in self._boundvars: for ix, nm in enumerate(self.parent._bound_vars): - recarray[nm][0 : self._nbound[0]] = values[ - 0 : self._nbound[0], ix - ] + values = values[0 : self._nbound[0], ix] + recarray[nm][0 : self._nbound[0]] = values elif name == "auxvar": - if self._naux[0] == 0: - continue - else: - for ix in range(self._naux[0]): - nm = self._auxnames[ix] - recarray[nm][0 : self._nbound[0]] = values[ - 0 : self._nbound[0], ix - ] + for ix in range(self._naux[0]): + nm = self._auxnames[ix] + values = values[0 : self._nbound[0], ix] + recarray[nm][0 : self._nbound[0]] = values + elif name == "auxname_cst": pass @@ -135,9 +133,8 @@ def _ptr_to_recarray(self): zip(*np.unravel_index(values, self.parent.model.shape)) ) - recarray[name][0 : self._nbound[0]] = values[ - 0 : self._nbound[0] - ] + values = values[0 : self._nbound[0]] + recarray[name][0 : self._nbound[0]] = values return recarray