Skip to content

Commit

Permalink
Removes degrees support (#2482)
Browse files Browse the repository at this point in the history
  • Loading branch information
IAlibay authored Jan 30, 2020
1 parent b567168 commit 59ea579
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 36 deletions.
2 changes: 2 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ mm/dd/yy richardjgowers, kain88-de, lilyminium, p-j-smith, bdice, joaomcteixeira
* 0.21.0

Fixes
* Removes support for reading AMBER NetCDF files with `cell_angle` units set
to `degrees` instead of the convention agreed `degree` (Issue #2327).
* Removes the MassWeight option from gnm (PR #2479).
* AtomGroup.guess_bonds now uses periodic boundary information when available
(Issue #2350)
Expand Down
23 changes: 5 additions & 18 deletions package/MDAnalysis/coordinates/TRJ.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,9 @@ class NCDFReader(base.ReaderBase):
kJ/(mol*Angstrom). It is noted that with 0.19.2 and earlier versions,
velocities would have often been reported in values of angstrom/AKMA
time units instead (Issue #2323).
.. TODO:
* Remove support for `degrees` units in MDAnalysis version > 1.0
(Issue #2327, PR #2326).
.. versionchanged:: 1.0.0
Support for reading `degrees` units for `cell_angles` has now been
removed (Issue #2327)
"""

Expand Down Expand Up @@ -621,21 +620,9 @@ def __init__(self, filename, n_atoms=None, mmap=None, **kwargs):
if self.periodic:
self._verify_units(self.trjfile.variables['cell_lengths'].units,
'angstrom')
# Currently the MDA writer outputs 'degrees' rather than the
# singular form 'degree' agreed in the conventions. As discussed
# in PR #2326 from MDA 1.0 only and 'degree' will be accepted.
# As of v1.0.0 only `degree` is accepted as a unit
cell_angle_units = self.trjfile.variables['cell_angles'].units
if (cell_angle_units.decode('utf-8') == 'degrees'):
wmsg = ("DEPRECATED (1.0): NCDF trajectory {0} uses units of "
"`degrees` for the `cell_angles` variable instead of "
"`degree`. Support for non-AMBER convention units is "
"now deprecated and will end in MDAnalysis version "
"1.0. Afterwards, reading this file will raise an "
"error.")
warnings.warn(wmsg, category=DeprecationWarning)
logger.warning(wmsg)
else:
self._verify_units(cell_angle_units, 'degree')
self._verify_units(cell_angle_units, 'degree')

self._current_frame = 0

Expand Down
18 changes: 0 additions & 18 deletions testsuite/MDAnalysisTests/coordinates/test_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,24 +596,6 @@ def test_program_warn(self, tmpdir, mutation):
"attributes are missing")
assert str(record[0].message.args[0]) == wmsg

def test_degrees_warn(self, tmpdir):
"""Checks that plural degrees throws an user deprecation warning
TODO: remove in MDAnalysis version 1.0 (Issue #2327)"""
mutation = {'cell_angles': 'degrees'}
params = self.gen_params(keypair=mutation, restart=False)
with tmpdir.as_cwd():
self.create_ncdf(params)
with pytest.warns(DeprecationWarning) as record:
NCDFReader(params['filename'])

assert len(record) == 1
wmsg = ("DEPRECATED (1.0): NCDF trajectory {0} uses units of "
"`degrees` for the `cell_angles` variable instead of "
"`degree`. Support for non-AMBER convention units is "
"now deprecated and will end in MDAnalysis version 1.0. "
"Afterwards, reading this file will raise an error.")
assert str(record[0].message.args[0]) == wmsg


class _NCDFWriterTest(object):
prec = 5
Expand Down

0 comments on commit 59ea579

Please sign in to comment.