Skip to content

Commit

Permalink
pad array when size changed
Browse files Browse the repository at this point in the history
  • Loading branch information
jensdebruijn committed Oct 31, 2024
1 parent d5a04e0 commit 7e55cdf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions honeybees/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ def export_value(self, name: str, value: np.ndarray, conf: dict) -> None:
)
ds[name].attrs["_ARRAY_DIMENSIONS"] = array_dimensions
index = conf["_time_index"].index(self.model.current_time)
if value.size < ds[name][index].size:
print("Padding array with NaNs or -1 - temporary solution")
value = np.pad(
value,
(0, ds[name][index].size - value.size),
mode="constant",
constant_values=np.nan
if value.dtype in (float, np.float32, np.float64)
else -1,
)
ds[name][index] = value
else:
folder = os.path.join(self.export_folder, name)
Expand Down

0 comments on commit 7e55cdf

Please sign in to comment.