From b8322ddc52241d3c2a49c4ebdf2e8865c6f36bb9 Mon Sep 17 00:00:00 2001 From: spaulins-usgs Date: Fri, 29 Jan 2021 07:02:42 -0800 Subject: [PATCH] Fix(print MFArray): Fixed printing of layered arrays - issue #1043 (#1045) * Fix(print MFArray): Fixed printing of layered arrays - issue #1043 * refactor(Array string): Cleaned up formatting --- flopy/mf6/data/mfdatastorage.py | 43 +++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/flopy/mf6/data/mfdatastorage.py b/flopy/mf6/data/mfdatastorage.py index 88fcd2a752..f5fac1dd78 100644 --- a/flopy/mf6/data/mfdatastorage.py +++ b/flopy/mf6/data/mfdatastorage.py @@ -450,29 +450,52 @@ def get_data_str(self, formal): data_str = "" # Assemble strings for internal array data for index, storage in enumerate(self.layer_storage.elements()): + if self.layered: + layer_str = "Layer_{}".format(str(index + 1)) + else: + layer_str = "" if storage.data_storage_type == DataStorageType.internal_array: if storage.internal_data is not None: header = self._get_layer_header_str(index) if formal: if self.layered: - data_str = "{}Layer_{}{{{}}}" "\n({})\n".format( - data_str, index + 1, header, repr(storage) + data_str = "{}{}{{{}}}" "\n({})\n".format( + data_str, + layer_str, + header, + repr(self.get_data((index,))), ) else: - data_str = "{}{{{}}}\n({})\n".format( - data_str, header, repr(storage) + data_str = "{}{}{{{}}}\n({})\n".format( + data_str, + layer_str, + header, + repr(self.get_data((index,))), ) else: - data_str = "{}{{{}}}\n({})\n".format( - data_str, header, str(storage) + data_str = "{}{}{{{}}}\n({})\n".format( + data_str, + layer_str, + header, + str(self.get_data((index,))), ) elif ( storage.data_storage_type == DataStorageType.internal_constant ): - if storage.data_const_value is not None: - data_str = "{}{{{}}}" "\n".format( - data_str, self._get_layer_header_str(index) - ) + if formal: + if storage.data_const_value is not None: + data_str = "{}{}{{{}}}" "\n".format( + data_str, + layer_str, + self._get_layer_header_str(index), + ) + else: + if storage.data_const_value is not None: + data_str = "{}{}{{{}}}" "\n".format( + data_str, + layer_str, + self._get_layer_header_str(index), + ) return data_str def _get_layer_header_str(self, layer):