From af54f3512ea4440783369d30ce0c86a4fb2ef50f Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 14 Mar 2019 12:13:38 -0500 Subject: [PATCH] Adding getitem method to _Position. --- openmc/capi/plot.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/openmc/capi/plot.py b/openmc/capi/plot.py index 53639a396a..92245dd743 100644 --- a/openmc/capi/plot.py +++ b/openmc/capi/plot.py @@ -23,6 +23,16 @@ class _Position(Structure): ('y', c_double), ('z', c_double)] + def __getitem__(self, key): + if key == 0: + return self.x + elif key == 1: + return self.y + elif key == 2: + return self.z + + raise ValueError("{} index is invalid for _Position".format(key)) + def __repr__(self): return "({}, {}, {})".format(self.x, self.y, self.z)