Skip to content

Commit

Permalink
Fixed problem running plotting script
Browse files Browse the repository at this point in the history
If a plotting script included function (or class) definitions, it failed
due to the default behaviour of the exec() command. Now it sets globals
and locals in such a way that function defns are allowed.
  • Loading branch information
markgw committed Oct 26, 2020
1 parent 04189cb commit be223be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/python/pimlico/datatypes/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import os
import warnings

from pimlico.datatypes import NamedFileCollection
from past.builtins import execfile

from pimlico.datatypes import NamedFileCollection


class PlotOutput(NamedFileCollection):
"""
Expand All @@ -31,7 +32,7 @@ def plot(self):
cwd = os.getcwd()
os.chdir(self.data_dir)
# Execute the python script
execfile(self.get_absolute_path("plot.py"))
execfile(self.get_absolute_path("plot.py"), locals(), locals())
# Change working dir back
os.chdir(cwd)
# Check that plot.pdf got created
Expand Down

0 comments on commit be223be

Please sign in to comment.