Skip to content

Commit

Permalink
replace shutil.rmtree with meep.delete_directory
Browse files Browse the repository at this point in the history
  • Loading branch information
oskooi committed Feb 25, 2020
1 parent 325e915 commit 4de4ba4
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 54 deletions.
7 changes: 2 additions & 5 deletions python/tests/chunks.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import unittest
import meep as mp
import shutil

class TestChunks(unittest.TestCase):

def setUp(self):
self.temp_dir = mp.make_output_directory()
self.temp_dir = mp.make_output_directory()

def tearDown(self):
mp.all_wait()
if mp.am_master():
shutil.rmtree(self.temp_dir,ignore_errors=True)
mp.delete_directory(self.temp_dir)

def test_chunks(self):
sxy = 10
Expand Down
7 changes: 2 additions & 5 deletions python/tests/cyl_ellipsoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import unittest
import meep as mp
import shutil

def dummy_eps(vec):
return 1.0
Expand All @@ -13,12 +12,10 @@ class TestCylEllipsoid(unittest.TestCase):
ref_Hz = -4.5623185899766e-5

def setUp(self):
self.temp_dir = mp.make_output_directory()
self.temp_dir = mp.make_output_directory()

def tearDown(self):
mp.all_wait()
if mp.am_master():
shutil.rmtree(self.temp_dir,ignore_errors=True)
mp.delete_directory(self.temp_dir)

def init(self):

Expand Down
7 changes: 2 additions & 5 deletions python/tests/dft_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
import numpy as np
import meep as mp
import os
import shutil

class TestDFTFields(unittest.TestCase):

def setUp(self):
self.temp_dir = mp.make_output_directory()
self.temp_dir = mp.make_output_directory()

def tearDown(self):
mp.all_wait()
if mp.am_master():
shutil.rmtree(self.temp_dir,ignore_errors=True)
mp.delete_directory(self.temp_dir)

def init(self):
resolution = 10
Expand Down
7 changes: 2 additions & 5 deletions python/tests/dispersive_eigenmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from meep import mpb
import h5py
import os
import shutil

class TestDispersiveEigenmode(unittest.TestCase):
# ----------------------------------------- #
Expand All @@ -40,12 +39,10 @@ def call_chi1(self,material,omega):
np.testing.assert_allclose(n,n_actual)

def setUp(self):
self.temp_dir = mp.make_output_directory()
self.temp_dir = mp.make_output_directory()

def tearDown(self):
mp.all_wait()
if mp.am_master():
shutil.rmtree(self.temp_dir,ignore_errors=True)
mp.delete_directory(self.temp_dir)

def verify_output_and_slice(self,material,omega):
# Since the slice routines average the diagonals, we need to do that too:
Expand Down
7 changes: 2 additions & 5 deletions python/tests/field_functions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import unittest
import meep as mp
import shutil

def f(r, ex, hz, eps):
return (r.x * r.norm() + ex) - (eps * hz)
Expand All @@ -16,12 +15,10 @@ class TestFieldFunctions(unittest.TestCase):
vol = mp.Volume(size=mp.Vector3(1), center=mp.Vector3())

def setUp(self):
self.temp_dir = mp.make_output_directory()
self.temp_dir = mp.make_output_directory()

def tearDown(self):
mp.all_wait()
if mp.am_master():
shutil.rmtree(self.temp_dir,ignore_errors=True)
mp.delete_directory(self.temp_dir)

def init(self):
resolution = 20
Expand Down
5 changes: 1 addition & 4 deletions python/tests/holey_wvg_cavity.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import unittest
import meep as mp
import numpy as np
import shutil

class TestHoleyWvgCavity(unittest.TestCase):

Expand Down Expand Up @@ -41,9 +40,7 @@ def setUp(self):
self.temp_dir = mp.make_output_directory()

def tearDown(self):
mp.all_wait()
if mp.am_master():
shutil.rmtree(self.temp_dir,ignore_errors=True)
mp.delete_directory(self.temp_dir)

def test_resonant_modes(self):
self.sim.sources = [mp.Source(mp.GaussianSource(self.fcen, fwidth=self.df),
Expand Down
6 changes: 1 addition & 5 deletions python/tests/mpb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import sys
import time
import unittest
import shutil

import h5py
import numpy as np
Expand Down Expand Up @@ -35,10 +34,7 @@ def setUp(self):
def tearDown(self):
end = time.time() - self.start
print("{}: {:.2f}s".format(self.filename_prefix, end))

mp.all_wait()
if mp.am_master():
shutil.rmtree(self.temp_dir,ignore_errors=True)
mp.delete_directory(self.temp_dir)

def init_solver(self, geom=True):
num_bands = 8
Expand Down
5 changes: 1 addition & 4 deletions python/tests/pw_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import unittest

import meep as mp
import shutil

class TestPwSource(unittest.TestCase):

Expand Down Expand Up @@ -57,9 +56,7 @@ def _pw_amp(x):
self.s = s

def tearDown(self):
mp.all_wait()
if mp.am_master():
shutil.rmtree(self.temp_dir,ignore_errors=True)
mp.delete_directory(self.temp_dir)

def test_pw_source(self):
self.sim.run(mp.at_end(mp.output_efield_z), until=400)
Expand Down
7 changes: 2 additions & 5 deletions python/tests/ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@

import unittest
import meep as mp
import shutil

class TestRing(unittest.TestCase):

def setUp(self):
self.temp_dir = mp.make_output_directory()
self.temp_dir = mp.make_output_directory()

def tearDown(self):
mp.all_wait()
if mp.am_master():
shutil.rmtree(self.temp_dir,ignore_errors=True)
mp.delete_directory(self.temp_dir)

def init(self):
n = 3.4
Expand Down
5 changes: 1 addition & 4 deletions python/tests/simulation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import shutil
import sys
import unittest
import warnings
Expand All @@ -22,9 +21,7 @@ def setUp(self):
self.temp_dir = mp.make_output_directory()

def tearDown(self):
mp.all_wait()
if mp.am_master():
shutil.rmtree(self.temp_dir,ignore_errors=True)
mp.delete_directory(self.temp_dir)

def test_interpolate_numbers(self):

Expand Down
7 changes: 2 additions & 5 deletions python/tests/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import meep as mp
import numpy as np
import os
import shutil

# Make sure we have matplotlib installed
import matplotlib
Expand Down Expand Up @@ -117,12 +116,10 @@ def view_sim():
plt.show()
class TestVisualization(unittest.TestCase):
def setUp(self):
self.temp_dir = mp.make_output_directory()
self.temp_dir = mp.make_output_directory()

def tearDown(self):
mp.all_wait()
if mp.am_master():
shutil.rmtree(self.temp_dir,ignore_errors=True)
mp.delete_directory(self.temp_dir)

def test_plot2D(self):
# Check plotting of geometry with several sources, monitors, and PMLs
Expand Down
2 changes: 0 additions & 2 deletions tests/h5test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,6 @@ int main(int argc, char **argv) {
}
#endif /* HAVE_HDF5 */

all_wait();
sync();
delete_directory(temp_dir);

return 0;
Expand Down

0 comments on commit 4de4ba4

Please sign in to comment.