Skip to content

Commit

Permalink
Merge branch 'develop' into fmt-blame
Browse files Browse the repository at this point in the history
  • Loading branch information
RMeli committed Jan 8, 2025
2 parents 04a87a5 + 5eef341 commit 982a1fb
Show file tree
Hide file tree
Showing 110 changed files with 9,472 additions and 6,318 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/gh-ci-cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,11 @@ jobs:
fail-fast: false
matrix:
# Stick to macos-13 because some of our
# optional depss don't support arm64 (i.e. macos-14)
# optional deps don't support arm64 (i.e. macos-14)
#
# add "3.13" once conda-forge packages are available (see #4805)
os: [ubuntu-latest, macos-13]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -285,11 +287,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-14, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
wheels: ['true', 'false']
exclude:
- os: "macos-14"
python-version: "3.9"
steps:
# Checkout to have access to local actions (i.e. setup-os)
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .pep8speaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ scanner:

pycodestyle: # Valid if scanner.linter is pycodestyle
max-line-length: 79
ignore: ["E203", "E701"]
ignore: ["E203", "E701", "W503"]
exclude: []
count: False
first: False
Expand All @@ -17,7 +17,7 @@ pycodestyle: # Valid if scanner.linter is pycodestyle

flake8: # Valid if scanner.linter is flake8
max-line-length: 79
ignore: ["E203", "E501", "E701"]
ignore: ["E203", "E501", "E701", "W503"]
exclude: []
count: False
show-source: False
Expand Down
1 change: 1 addition & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Fixes
the function to prevent shared state. (Issue #4655)

Enhancements
* Addition of 'water' token for water selection (Issue #4839)
* Enables parallelization for analysis.density.DensityAnalysis (Issue #4677, PR #4729)
* Enables parallelization for analysis.contacts.Contacts (Issue #4660)
* Enable parallelization for analysis.nucleicacids.NucPairDist (Issue #4670)
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
and write your own Python code.
"""

__all__ = ['AtomGroup', 'Selection']
__all__ = ["AtomGroup", "Selection"]

from .groups import AtomGroup
from .selection import Selection
61 changes: 40 additions & 21 deletions package/MDAnalysis/core/_get_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@
import copy
import inspect

from .. import (_READERS, _READER_HINTS,
_PARSERS, _PARSER_HINTS,
_MULTIFRAME_WRITERS, _SINGLEFRAME_WRITERS, _CONVERTERS)
from .. import (
_READERS,
_READER_HINTS,
_PARSERS,
_PARSER_HINTS,
_MULTIFRAME_WRITERS,
_SINGLEFRAME_WRITERS,
_CONVERTERS,
)
from ..lib import util


Expand Down Expand Up @@ -80,8 +86,8 @@ def get_reader_for(filename, format=None):
return format

# ChainReader gets returned even if format is specified
if _READER_HINTS['CHAIN'](filename):
format = 'CHAIN'
if _READER_HINTS["CHAIN"](filename):
format = "CHAIN"
# Only guess if format is not specified
if format is None:
for fmt_name, test in _READER_HINTS.items():
Expand All @@ -103,7 +109,9 @@ def get_reader_for(filename, format=None):
" Use the format keyword to explicitly set the format: 'Universe(...,format=FORMAT)'\n"
" For missing formats, raise an issue at "
"https://github.com/MDAnalysis/mdanalysis/issues".format(
format, filename, _READERS.keys()))
format, filename, _READERS.keys()
)
)
raise ValueError(errmsg) from None


Expand Down Expand Up @@ -158,7 +166,7 @@ def get_writer_for(filename, format=None, multiframe=None):
The `filename` argument has been made mandatory.
"""
if filename is None:
format = 'NULL'
format = "NULL"
elif format is None:
try:
root, ext = util.get_ext(filename)
Expand All @@ -172,18 +180,24 @@ def get_writer_for(filename, format=None, multiframe=None):
else:
format = util.check_compressed_format(root, ext)

if format == '':
raise ValueError((
'File format could not be guessed from {}, '
'resulting in empty string - '
'only None or valid formats are supported.'
).format(filename))
if format == "":
raise ValueError(
(
"File format could not be guessed from {}, "
"resulting in empty string - "
"only None or valid formats are supported."
).format(filename)
)

format = format.upper()
if multiframe is None:
# Multiframe takes priority, else use singleframe
options = copy.copy(_SINGLEFRAME_WRITERS) # do copy to avoid changing in place
options.update(_MULTIFRAME_WRITERS) # update overwrites existing entries
options = copy.copy(
_SINGLEFRAME_WRITERS
) # do copy to avoid changing in place
options.update(
_MULTIFRAME_WRITERS
) # update overwrites existing entries
errmsg = "No trajectory or frame writer for format '{0}'"
elif multiframe is True:
options = _MULTIFRAME_WRITERS
Expand All @@ -192,9 +206,11 @@ def get_writer_for(filename, format=None, multiframe=None):
options = _SINGLEFRAME_WRITERS
errmsg = "No single frame writer for format '{0}'"
else:
raise ValueError("Unknown value '{0}' for multiframe,"
" only True, False, None allowed"
"".format(multiframe))
raise ValueError(
"Unknown value '{0}' for multiframe,"
" only True, False, None allowed"
"".format(multiframe)
)

try:
return options[format]
Expand Down Expand Up @@ -252,10 +268,13 @@ def get_parser_for(filename, format=None):
" See https://docs.mdanalysis.org/documentation_pages/topology/init.html#supported-topology-formats\n"
" For missing formats, raise an issue at \n"
" https://github.com/MDAnalysis/mdanalysis/issues".format(
format, _PARSERS.keys()))
format, _PARSERS.keys()
)
)
raise ValueError(errmsg) from None
else:
return _PARSERS['MINIMAL']
return _PARSERS["MINIMAL"]


def get_converter_for(format):
"""Return the appropriate topology converter for ``format``.
Expand All @@ -276,6 +295,6 @@ def get_converter_for(format):
try:
writer = _CONVERTERS[format]
except KeyError:
errmsg = f'No converter found for {format} format'
errmsg = f"No converter found for {format} format"
raise TypeError(errmsg) from None
return writer
7 changes: 5 additions & 2 deletions package/MDAnalysis/core/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class ConverterWrapper:
be accessed as a method with the name of the package in lowercase, i.e.
`convert_to.parmed()`
"""

_CONVERTERS = {}

def __init__(self, ag):
Expand Down Expand Up @@ -199,6 +200,8 @@ def __call__(self, package, *args, **kwargs):
try:
convert = getattr(self, package.lower())
except AttributeError:
raise ValueError(f"No {package!r} converter found. Available: "
f"{' '.join(self._CONVERTERS.keys())}") from None
raise ValueError(
f"No {package!r} converter found. Available: "
f"{' '.join(self._CONVERTERS.keys())}"
) from None
return convert(*args, **kwargs)
Loading

0 comments on commit 982a1fb

Please sign in to comment.