Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions package/MDAnalysis/coordinates/XDR.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ def __init__(
self.n_atoms = self._xdr.n_atoms

if not refresh_offsets:
lock_name = offsets_filename(self.filename, ending="lock")
open(lock_name, "a").close()

self._load_offsets()
else:
self._read_offsets(store=True)
Expand All @@ -194,23 +197,18 @@ def __init__(
self.convert_pos_from_native(self.ts.dimensions[:3])

@classmethod
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are two of the functions removed and _load_offsets() suddenly a class method?

def parse_n_atoms(cls, filename, **kwargs):
with cls._file(filename) as f:
n_atoms = f.n_atoms
return n_atoms

def close(self):
"""close reader"""
self._xdr.close()

def _load_offsets(self):
"""load frame offsets from file, reread them from the trajectory if that
fails. To prevent the competition of generating the same offset file
from multiple processes, an `InterProcessLock` is used."""

fname = offsets_filename(self.filename)
lock_name = offsets_filename(self.filename, ending="lock")

# check if the location of the lock is writable.
# create lock file
open(lock_name, "a").close()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems... unnecessary, considering context manager below...


# check if the location of the lock is writable.
try:
with FileLock(lock_name) as filelock:
pass
Expand All @@ -224,6 +222,7 @@ def _load_offsets(self):
return
else:
raise


with FileLock(lock_name) as filelock:
if not isfile(fname):
Expand All @@ -236,6 +235,7 @@ def _load_offsets(self):
# this warning can be avoided by loading Universe like:
# u = mda.Universe(data.TPR, data.XTC, refresh_offsets=True)
# refer to Issue #1893

data = read_numpy_offsets(fname)
if not data:
warnings.warn(
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/core/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _apply(self, group):

class _Selectionmeta(type):
def __init__(cls, name, bases, classdict):
type.__init__(type, name, bases, classdict)
super().__init__(name, bases, classdict)
try:
_SELECTIONDICT[classdict["token"]] = cls
_SELECTIONDICT[classdict["token"].lower()] = cls
Expand Down
1 change: 1 addition & 0 deletions package/doc/sphinx/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class KeyStyle(UnsrtStyle):
html_theme_options = {
"mda_official": True,
"extra_nav_links": extra_nav_links,
"display_version": True,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? Please explain. Especially since it's a deprecated option:

https://sphinx-rtd-theme.readthedocs.io/en/stable/configuring.html#confval-display_version

}

# Theme options are theme-specific and customize the look and feel of a theme
Expand Down
Loading