Skip to content

Commit 5d32227

Browse files
authored
Add more digits to the delta of openDX (#89)
- fix #88 - write out OpeDX delta with 7 significant figures - add test - update CHANGES and AUTHORS
1 parent 729d04c commit 5d32227

5 files changed

Lines changed: 24 additions & 2 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ Contributors:
2222
* Lily Wang <lilyminium>
2323
* Josh Vermaas <jvermaas>
2424
* Irfan Alibay <IAlibay>
25+
* Zhiyi Wu <xiki-tempula>

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The rules for this file:
2121

2222
* Allow parsing/writing gzipped DX files
2323
* Update doc theme to use sphinx-rtd-theme (#80)
24+
* Delta of OpenDX writes 7 significant figures (#89)
2425

2526
Fixes
2627

doc/source/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
# General information about the project.
6262
project = u'GridDataFormats'
6363
authors = (u'Oliver Beckstein, Jan Domanski, Jesse Johnson, Max Linke, Tyler Luchko, '
64-
u'Dominik Mierzejewski, Giacomo Fiorin, Lily Wang, Josh Vermaas, Irfan Alibay')
64+
u'Dominik Mierzejewski, Giacomo Fiorin, Lily Wang, Josh Vermaas, '
65+
u'Irfan Alibay,Zhiyi Wu')
6566
copyright = u'2007-2021, ' + authors
6667

6768
# The version info for the project you're documenting, acts as replacement for

gridData/OpenDX.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
Known issues for writing OpenDX files
5656
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5757
58+
* APBS require the delta to be written to the seventh significant figure.
59+
The delta is now written to reflect this increase in precision.
60+
61+
.. versionchanged:: 0.6.0
62+
5863
* PyMOL_ requires OpenDX files with the type specification "double" in
5964
the `class array` section (see issue `#35`_). By default (since
6065
release 0.4.0), the type is set to the one that most closely
@@ -241,7 +246,9 @@ def write(self, stream):
241246
self._write_line(stream, 'origin %f %f %f\n' % tuple(self.origin))
242247
for delta in self.delta:
243248
self._write_line(
244-
stream, ('delta '+self.ndformat(' %f')+'\n') % tuple(delta))
249+
stream, ('delta ' +
250+
self.ndformat(' {:.7g}').format(*delta) +
251+
'\n'))
245252

246253
def edges(self):
247254
"""Edges of the grid cells, origin at centre of 0,0,..,0 grid cell.

gridData/tests/test_dx.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,15 @@ def test_write_dx_ValueError(tmpdir, nptype, outfile, counts=100, ndim=3):
8080
with tmpdir.as_cwd():
8181
g.export(outfile)
8282

83+
84+
def test_delta_precision(tmpdir):
85+
'''Test if the delta has been written to the 7th significant figure.'''
86+
g = Grid(datafiles.DX)
87+
g.delta = np.array([90, 90, 150]) / 257
88+
with tmpdir.as_cwd():
89+
g.export("grid.dx")
90+
g2 = Grid("grid.dx")
91+
assert_almost_equal(
92+
g.delta, g2.delta,
93+
decimal=7,
94+
err_msg="deltas of written grid do not match original")

0 commit comments

Comments
 (0)