From ca410a82fe88c4103e1b6a3715881d3fe5eefae3 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 16 Sep 2019 15:12:42 -0500 Subject: [PATCH] Ensure strings when setting openmc.lib.Tally.scores In using lists of containing integer reactions as the scores, e.g. ``` t = openmc.lib.Tally() t.scores = [901] ``` The setter would fail as the integers do not have an encode method. This converts all incoming scores to strings prior to passing values to the shared library. --- openmc/lib/tally.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/lib/tally.py b/openmc/lib/tally.py index 97b7437ea3..e6dd3ddbff 100644 --- a/openmc/lib/tally.py +++ b/openmc/lib/tally.py @@ -319,7 +319,7 @@ class Tally(_FortranObjectWithID): @scores.setter def scores(self, scores): scores_ = (c_char_p * len(scores))() - scores_[:] = [x.encode() for x in scores] + scores_[:] = [str(x).encode() for x in scores] _dll.openmc_tally_set_scores(self._index, len(scores), scores_) @property