[yt-svn] commit/yt: ngoldbaum: Fixing PhasePlot.save() not treating empty names or directory names correctly.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat May 17 14:18:53 PDT 2014


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/50f7a94cc1c8/
Changeset:   50f7a94cc1c8
Branch:      yt-3.0
User:        ngoldbaum
Date:        2014-05-17 22:44:00
Summary:     Fixing PhasePlot.save() not treating empty names or directory names correctly.
Affected #:  1 file

diff -r 5f2c6b6da9cf36ca09548a2c5c6286a77032d2d9 -r 50f7a94cc1c85cf757e1580c7a612652a2330b7c yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -750,6 +750,8 @@
             self._setup_plots()
         if mpl_kwargs is None:
             mpl_kwargs = {}
+        if name is None:
+            name = str(self.profile.pf)
         xfn = self.profile.x_field
         yfn = self.profile.y_field
         if isinstance(xfn, types.TupleType):
@@ -761,11 +763,10 @@
             if isinstance(f, types.TupleType):
                 _f = _f[1]
             middle = "2d-Profile_%s_%s_%s" % (xfn, yfn, _f)
-            if name[-1] == os.sep and not os.path.isdir(name):
-                os.mkdir(name)
-            if name is None:
-                prefix = self.profile.pf
-            elif os.path.isdir(name) and name != str(self.profile.pf):
+            splitname = os.path.split(name)
+            if splitname[0] != '' and not os.path.isdir(splitname[0]):
+                os.makedirs(splitname[0])
+            if os.path.isdir(name) and name != str(self.profile.pf):
                 prefix = name + (os.sep if name[-1] != os.sep else '')
                 prefix += str(self.profile.pf)
             else:
@@ -775,7 +776,6 @@
                 for k, v in self.plots.iteritems():
                     names.append(v.save(name, mpl_kwargs))
                 return names
-
             fn = "%s_%s%s" % (prefix, middle, suffix)
             names.append(fn)
             self.plots[f].save(fn, mpl_kwargs)

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list