From 1ce3b58dabba59741343cbd9e7e4c9f58f10f91b Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 29 Oct 2019 19:53:05 +0100 Subject: Return cell id as string expression when required --- boltzgen/kernel/memory/index.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/boltzgen/kernel/memory/index.py b/boltzgen/kernel/memory/index.py index e89e9ee..75b0ebc 100644 --- a/boltzgen/kernel/memory/index.py +++ b/boltzgen/kernel/memory/index.py @@ -9,10 +9,16 @@ class XYZ(CellIndex): pass def gid(self, x, y, z=0): - return x*self.geometry.size_y*self.geometry.size_z + y*self.geometry.size_z + z + if any(map(lambda v: isinstance(v, str), [x,y,z])): + return "(%s)*%d + (%s)*%d + %s" % (x, self.geometry.size_y*self.geometry.size_z, y, self.geometry.size_z, z) + else: + return x*self.geometry.size_y*self.geometry.size_z + y*self.geometry.size_z + z class ZYX(CellIndex): pass def gid(self, x, y, z=0): - return z*self.geometry.size_x*self.geometry.size_y + y*self.geometry.size_x + x + if any(map(lambda v: isinstance(v, str), [x,y,z])): + return "(%s)*%d + (%s)*%d + %s" % (z, self.geometry.size_x*self.geometry.size_y, y, self.geometry.size_x, x) + else: + return z*self.geometry.size_x*self.geometry.size_y + y*self.geometry.size_x + x -- cgit v1.2.3