Last change
on this file since 2267 was
2263,
checked in by ole, 19 years ago
|
Work towards a test_all.py at the inundation directory level. Most tests pass except a few in least_squares, data_manager and cg_solve...
|
File size:
1.1 KB
|
Rev | Line | |
---|
[1122] | 1 | import unittest |
---|
| 2 | from Numeric import allclose, asarray |
---|
| 3 | import most2nc |
---|
| 4 | from Scientific.IO.NetCDF import NetCDFFile |
---|
[2263] | 5 | import os |
---|
[1122] | 6 | |
---|
[2263] | 7 | FN = 'small___.txt' |
---|
| 8 | |
---|
[1122] | 9 | class Test_most2nc(unittest.TestCase): |
---|
| 10 | def setUp(self): |
---|
[2263] | 11 | fid = open(FN, 'w') |
---|
| 12 | fid.write("""4 4 |
---|
| 13 | 150.66667 |
---|
| 14 | 150.83334 |
---|
| 15 | 151. |
---|
| 16 | 151.16667 |
---|
| 17 | -34. |
---|
| 18 | -34.16667 |
---|
| 19 | -34.33333 |
---|
| 20 | -34.5 |
---|
| 21 | -1. -2. -3. -4. |
---|
| 22 | -5. -6. -7. -8. |
---|
| 23 | -9. -10. -11. -12. |
---|
| 24 | -13. -14. -15. -16. |
---|
| 25 | """) |
---|
| 26 | fid.close() |
---|
| 27 | |
---|
[1122] | 28 | def tearDown(self): |
---|
[2263] | 29 | os.remove(FN) |
---|
[1122] | 30 | |
---|
| 31 | def test_small_nxn(self): |
---|
[2263] | 32 | most2nc.most2nc(input_file=FN,output_file='test.nc'\ |
---|
[1123] | 33 | ,inverted_bathymetry = False,verbose = False) |
---|
[1122] | 34 | |
---|
| 35 | fid = NetCDFFile('test.nc') |
---|
| 36 | elevation = fid.variables['ELEVATION'][:] |
---|
[1123] | 37 | fid.close() |
---|
[1122] | 38 | |
---|
[1123] | 39 | z=[[-13., -14., -15., -16.]\ |
---|
| 40 | ,[-9., -10., -11., -12.]\ |
---|
| 41 | ,[-5., -6., -7., -8.]\ |
---|
| 42 | ,[-1., -2., -3., -4.]] |
---|
[1122] | 43 | z = asarray(z) |
---|
| 44 | |
---|
[1123] | 45 | assert allclose(z,elevation) |
---|
| 46 | import os |
---|
| 47 | os.remove('test.nc') |
---|
[2263] | 48 | |
---|
| 49 | if __name__ == "__main__": |
---|
| 50 | suite = unittest.makeSuite(Test_most2nc,'test') |
---|
| 51 | runner = unittest.TextTestRunner() |
---|
| 52 | runner.run(suite) |
---|
Note: See
TracBrowser
for help on using the repository browser.