Skip to content

Commit

Permalink
Improved sms2dm fmt compat
Browse files Browse the repository at this point in the history
  • Loading branch information
jreniel committed Jan 25, 2020
1 parent c85e2f6 commit 19e4ac0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
6 changes: 5 additions & 1 deletion pyschism/mesh/sms2dm.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ def geom_string(geom_type, sms2dm):


def nodestring(geom):
raise NotImplementedError
f = "NS "
for i in range(len(geom) -1):
f += f"{geom[i]} "
f += f"-{geom[-1]}\n"
return f


def triangular_elements(geom):
Expand Down
4 changes: 2 additions & 2 deletions tests/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion tests/mesh/test_sms2dm.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,32 @@ def test_write_read(self):
'E4Q': {
id: indexes
for id, indexes in self.elements.items() if len(indexes) == 4
}
},
'boundaries': self.boundaries,
}
tmpdir = tempfile.TemporaryDirectory()
tmpfile = pathlib.Path(tmpdir.name) / 'hgrid.2dm'
writer(grd, pathlib.Path(tmpfile))
grd.pop('boundaries')
self.assertDictEqual(reader(pathlib.Path(tmpfile)), grd)

def test_write_raise_exists(self):
grd = {
'ND': self.nodes,
'E3T': {
id: indexes
for id, indexes in self.elements.items() if len(indexes) == 3
},
'E4Q': {
id: indexes
for id, indexes in self.elements.items() if len(indexes) == 4
}
}
tmpdir = tempfile.TemporaryDirectory()
tmpfile = pathlib.Path(tmpdir.name) / 'hgrid.2dm'
writer(grd, pathlib.Path(tmpfile))
self.assertRaises(Exception, writer, grd, pathlib.Path(tmpfile))


if __name__ == '__main__':
unittest.main()

0 comments on commit 19e4ac0

Please sign in to comment.