From 679b6b87253e6fd28b112658829d0650876cda7c Mon Sep 17 00:00:00 2001 From: Sylwester Arabas Date: Sat, 19 Aug 2023 19:54:57 +0200 Subject: [PATCH] add missing fill() abstract method to StorageBase (#1119) --- PySDM/backends/impl_common/storage_utils.py | 4 ++++ PySDM/backends/impl_thrust_rtc/storage.py | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/PySDM/backends/impl_common/storage_utils.py b/PySDM/backends/impl_common/storage_utils.py index 67a235a14..c3f7b9fa5 100644 --- a/PySDM/backends/impl_common/storage_utils.py +++ b/PySDM/backends/impl_common/storage_utils.py @@ -56,6 +56,10 @@ def urand(self, generator): def upload(self, data): raise NotImplementedError() + @abstractmethod + def fill(self, other): + raise NotImplementedError() + def get_data_from_ndarray(array, storage_class: Type[StorageBase], copy_fun): if str(array.dtype).startswith("int"): diff --git a/PySDM/backends/impl_thrust_rtc/storage.py b/PySDM/backends/impl_thrust_rtc/storage.py index 783b8e3ad..0e634e201 100644 --- a/PySDM/backends/impl_thrust_rtc/storage.py +++ b/PySDM/backends/impl_thrust_rtc/storage.py @@ -497,14 +497,14 @@ def divide_if_not_zero(self, divisor): Impl.divide_if_not_zero(self, divisor) return self - def fill(self, value): - if isinstance(value, Storage): - trtc.Copy(value.data, self.data) + def fill(self, other): + if isinstance(other, Storage): + trtc.Copy(other.data, self.data) else: - if isinstance(value, int): - dvalue = trtc.DVInt64(value) - elif isinstance(value, float): - dvalue = BACKEND._get_floating_point(value) + if isinstance(other, int): + dvalue = trtc.DVInt64(other) + elif isinstance(other, float): + dvalue = BACKEND._get_floating_point(other) else: raise TypeError("Only Storage, int and float are supported.") trtc.Fill(self.data, dvalue)