Skip to content

Commit

Permalink
change init of tempdir in caribuscene to allow testing existence in _…
Browse files Browse the repository at this point in the history
…_del__
  • Loading branch information
christian34 committed Jan 22, 2025
1 parent 894b768 commit 330766c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/alinea/caribu/CaribuScene.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def __init__(self, scene=None, light=None, pattern=None, opt=None,
z_soil = self.scene.getZmin()
self.soil = domain_mesh(self.pattern, z_soil, soil_mesh)

self.tempdir = None
self.tempdir = '' # allow testing existence in __del__
if filecache:
self.tempdir = tempfile.mkdtemp() if not debug else './caribuscene_'+str(id(self))
self.canfile = None
Expand Down Expand Up @@ -553,7 +553,7 @@ def run(self, direct=True, infinite=False, d_sphere=0.5, layers=10,
materials = materials + [(albedo,)] * len(self.soil)
self.materialvalues = materials

if not self.tempdir is None:
if self.tempdir != '':
self.canfile = os.path.join(self.tempdir,'cscene.can')
self.optfile = os.path.join(self.tempdir,'band0.opt')
write_scene(triangles, materials, canfile = self.canfile, optfile = self.optfile)
Expand Down

0 comments on commit 330766c

Please sign in to comment.