Skip to content

Commit

Permalink
Merge pull request #249 from glotzerlab/remove-deprecated-features
Browse files Browse the repository at this point in the history
Remove deprecated features.
  • Loading branch information
joaander authored May 31, 2023
2 parents fc807fc + 81fc629 commit 0a2335b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 132 deletions.
4 changes: 1 addition & 3 deletions .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ assignees: 'joaander'
Release checklist:

- [ ] Run *bumpversion*.
- [ ] Update change log.
- ``git log --format=oneline --first-parent `git log -n 1 --pretty=format:%H -- CHANGELOG.rst`...``
- [milestone](https://github.com/glotzerlab/gsd/milestones)
- [ ] Review the change log.
- [ ] Check for new or duplicate contributors since the last release:
`comm -13 <(git log LAST_TAG --format="%aN <%aE>" | sort | uniq) <(git log --format="%aN <%aE>" | sort | uniq)`.
Add entries to `.mailmap` to remove duplicates.
Expand Down
8 changes: 1 addition & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ Resolves #???
<!--- Please build the sphinx documentation and check that any changes to
documentation display properly. -->

## Change log

<!-- Propose a change log entry. -->
```
```

## Checklist:

- [ ] I have reviewed the [**Contributor Guidelines**](https://github.com/glotzerlab/gsd/blob/trunk-patch/CONTRIBUTING.rst).
- [ ] I agree with the terms of the [**GSD Contributor Agreement**](https://github.com/glotzerlab/gsd/blob/trunk-patch/ContributorAgreement.md).
- [ ] My name is on the list of contributors (`doc/credits.rst`) in the pull request source branch.
- [ ] I have added a change log entry to ``CHANGELOG.rst``.
9 changes: 8 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ Change Log

*Removed:*

* ``gsd.__version__``.
* ``gsd.__version__`` - use `gsd.version.version`.
* ``gsd.hoomd.Snapshot`` - use `gsd.hoomd.Frame`
(`#249 <https://github.com/glotzerlab/gsd/pull/249>`__).
* ``gsd.hoomd.HOOMDTrajectory.read_frame`` - use `gsd.hoomd.HOOMDTrajectory.__getitem__`
(`#249 <https://github.com/glotzerlab/gsd/pull/249>`__).
* The file modes ``'wb'``, ``'wb+'``, ``'rb'``, ``'rb+'``, ``'ab'``, ``'xb'``, and ``'xb+'``. Use
``'r'``, ``'r+'``, ``'w'``, ``'x'``, or ``'a'``
(`#249 <https://github.com/glotzerlab/gsd/pull/249>`__).

v2.x
----
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Append frames to a gsd file:
... s.particles.N = 4+i;
... s.particles.position = numpy.random.random(size=(4+i,3))
... return s;
>>> with gsd.hoomd.open('test.gsd', 'ab') as t:
>>> with gsd.hoomd.open('test.gsd', 'a') as t:
... t.extend( (create_frame(i) for i in range(10)) )
... print(len(t))
11
Expand Down
3 changes: 0 additions & 3 deletions doc/hoomd-examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ Write frames to a gsd file
`append <gsd.hoomd.HOOMDTrajectory.append>` and `extend <gsd.hoomd.HOOMDTrajectory.extend>` methods
add frames to the trajectory.

.. note:: `gsd.hoomd.HOOMDTrajectory` currently does not support files opened in
the 'ab' mode.

.. tip:: When using `extend <gsd.hoomd.HOOMDTrajectory.extend>`, pass in a
generator or generator expression to avoid storing the entire
trajectory in memory before writing it out.
Expand Down
51 changes: 0 additions & 51 deletions gsd/fl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -195,28 +195,6 @@ def open(name, mode, application=None, schema=None, schema_version=None):
When opening a file for writing (``'w'``, ``'x'``, or ``'a'`` modes): The
given ``application``, ``schema``, and ``schema_version`` must not be None.
.. deprecated:: 2.9.0
The following values to ``mode`` are deprecated:
+------------------+---------------------------------------------+
| mode | description |
+==================+=============================================+
| ``'rb'`` | Equivalent to ``'r'`` |
+------------------+---------------------------------------------+
| ``'rb+'`` | Equivalent to ``'r+'`` |
+------------------+---------------------------------------------+
| ``'wb'`` | Equivalent to ``'w'`` |
+------------------+---------------------------------------------+
| ``'wb+'`` | Equivalent to ``'w'`` |
+------------------+---------------------------------------------+
| ``'xb'`` | Equivalent to ``'x'`` |
+------------------+---------------------------------------------+
| ``'xb+'`` | Equivalent to ``'x'`` |
+------------------+---------------------------------------------+
| ``'ab'`` | Equivalent to ``'r+'`` |
+------------------+---------------------------------------------+
Example:
.. ipython:: python
Expand Down Expand Up @@ -317,35 +295,6 @@ cdef class GSDFile:

self.mode = mode

if mode == 'wb':
mode = 'w'
warnings.warn("The 'wb' mode is deprecated, use 'w'",
FutureWarning)
elif mode == 'wb+':
mode = 'w'
warnings.warn("The 'wb+' mode is deprecated, use 'w'",
FutureWarning)
elif mode == 'rb':
mode = 'r'
warnings.warn("The 'rb' mode is deprecated, use 'r'",
FutureWarning)
elif mode == 'rb+':
mode = 'r+'
warnings.warn("The 'rb+' mode is deprecated, use 'r+'",
FutureWarning)
elif mode == 'xb':
mode = 'x'
warnings.warn("The 'xb' mode is deprecated, use 'x'",
FutureWarning)
elif mode == 'xb+':
mode = 'x'
warnings.warn("The 'xb+' mode is deprecated, use 'x'",
FutureWarning)
elif mode == 'ab':
mode = 'r+'
warnings.warn("The 'ab' mode is deprecated, use 'r+'",
FutureWarning)

if mode == 'w':
c_flags = libgsd.GSD_OPEN_READWRITE
overwrite = 1
Expand Down
87 changes: 22 additions & 65 deletions gsd/hoomd.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,33 @@ def validate(self):
self.group = self.group.reshape([self.N, self.M])


class Snapshot(object):
class Frame:
"""System state at one point in time.
.. deprecated:: 2.8.0
Attributes:
configuration (`ConfigurationData`): Configuration data.
particles (`ParticleData`): Particles.
bonds (`BondData`): Bonds.
angles (`BondData`): Angles.
dihedrals (`BondData`): Dihedrals.
impropers (`BondData`): Impropers.
pairs (`BondData`): Special pair.
Replaced by `Frame`.
constraints (`ConstraintData`): Distance constraints.
state (dict): State data.
log (dict): Logged data (values must be `numpy.ndarray` or
`array_like`)
"""

def __init__(self):
if not isinstance(self, Frame):
warnings.warn("Snapshot is deprecated, use Frame", FutureWarning)

self.configuration = ConfigurationData()
self.particles = ParticleData()
self.bonds = BondData(2)
Expand Down Expand Up @@ -617,36 +632,6 @@ def validate(self):
raise RuntimeError('Not a valid state: ' + k)


class Frame(Snapshot):
"""System state at one point in time.
Attributes:
configuration (`ConfigurationData`): Configuration data.
particles (`ParticleData`): Particles.
bonds (`BondData`): Bonds.
angles (`BondData`): Angles.
dihedrals (`BondData`): Dihedrals.
impropers (`BondData`): Impropers.
pairs (`BondData`): Special pair.
constraints (`ConstraintData`): Distance constraints.
state (dict): State data.
log (dict): Logged data (values must be `numpy.ndarray` or
`array_like`)
"""

def __init__(self):
super().__init__()


class _HOOMDTrajectoryIterable(object):
"""Iterable over a HOOMDTrajectory object."""

Expand Down Expand Up @@ -858,7 +843,7 @@ def extend(self, iterable):
for item in iterable:
self.append(item)

def read_frame(self, idx):
def _read_frame(self, idx):
"""Read the frame at the given index from the file.
Args:
Expand All @@ -871,14 +856,7 @@ def read_frame(self, idx):
from frame 0, or initialize from default values if not in frame 0. Cache
frame 0 data to avoid file read overhead. Return any default data as
non-writable numpy arrays.
.. deprecated:: v2.5
"""
warnings.warn("Deprecated, trajectory[idx]", FutureWarning)
return self._read_frame(idx)

def _read_frame(self, idx):
"""Implements read_frame."""
if idx >= len(self):
raise IndexError

Expand Down Expand Up @@ -1095,27 +1073,6 @@ def open(name, mode='r'):
| | Creates the file if it doesn't exist. |
+------------------+---------------------------------------------+
.. deprecated:: 2.9.0
The following values to ``mode`` are deprecated:
+------------------+---------------------------------------------+
| mode | description |
+==================+=============================================+
| ``'rb'`` | Equivalent to ``'r'`` |
+------------------+---------------------------------------------+
| ``'rb+'`` | Equivalent to ``'r+'`` |
+------------------+---------------------------------------------+
| ``'wb'`` | Equivalent to ``'w'`` |
+------------------+---------------------------------------------+
| ``'wb+'`` | Equivalent to ``'w'`` |
+------------------+---------------------------------------------+
| ``'xb'`` | Equivalent to ``'x'`` |
+------------------+---------------------------------------------+
| ``'xb+'`` | Equivalent to ``'x'`` |
+------------------+---------------------------------------------+
| ``'ab'`` | Equivalent to ``'r+'`` |
+------------------+---------------------------------------------+
"""
if fl is None:
raise RuntimeError("file layer module is not available")
Expand Down
2 changes: 1 addition & 1 deletion gsd/test/test_fl.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ def test_flush(tmp_path, open_mode, n_flush):
# Ensure that the data is buffered by opening the file with a 2nd
# handle read-only and checking it.
with gsd.fl.open(name=tmp_path / 'test_flush.gsd',
mode='rb') as f_readonly:
mode='r') as f_readonly:
assert not f_readonly.chunk_exists(frame=0, name='chunk1')
assert not f_readonly.chunk_exists(frame=1, name='chunk2')
assert f_readonly.nframes == 0
Expand Down

0 comments on commit 0a2335b

Please sign in to comment.