From 39c0ecba20bd54f2eafd8350151e60efbcc5c162 Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Tue, 16 Feb 2021 12:23:45 +1300 Subject: [PATCH] fix(DeprecationWarning): related to numpy (#1058) * Passing None into shape arguments as an alias for () is deprecated. * tostring() is deprecated. Use tobytes() instead. --- flopy/discretization/structuredgrid.py | 2 +- flopy/utils/utils_def.py | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/flopy/discretization/structuredgrid.py b/flopy/discretization/structuredgrid.py index b82828d703..ac1052781b 100644 --- a/flopy/discretization/structuredgrid.py +++ b/flopy/discretization/structuredgrid.py @@ -195,7 +195,7 @@ def __init__( if laycbd is not None: self.__laycbd = laycbd else: - self.__laycbd = np.zeros(self.__nlay, dtype=int) + self.__laycbd = np.zeros(self.__nlay or (), dtype=int) #################### # Properties diff --git a/flopy/utils/utils_def.py b/flopy/utils/utils_def.py index b806317c25..7bf468356c 100644 --- a/flopy/utils/utils_def.py +++ b/flopy/utils/utils_def.py @@ -38,12 +38,8 @@ def set_float(self, precision): return def read_text(self, nchar=20): - textvalue = self._read_values(self.character, nchar).tostring() - if not isinstance(textvalue, str): - textvalue = textvalue.decode().strip() - else: - textvalue = textvalue.strip() - return textvalue + bytesvalue = self._read_values(self.character, nchar).tobytes() + return bytesvalue.decode().strip() def read_integer(self): return self._read_values(self.integer, 1)[0]