Skip to content

Commit

Permalink
Merge pull request #2923 from lilyminium/fix-2921
Browse files Browse the repository at this point in the history
Update function signatures in core.Universe
  • Loading branch information
orbeckst authored Aug 28, 2020
2 parents 3e6b38c + 84d2275 commit a8227f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 30 deletions.
1 change: 1 addition & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Changes
* Sets the minimal RDKit version for CI to 2020.03.1 (Issue #2827, PR #2831)
* Removes deprecated waterdynamics.HydrogenBondLifetimes (PR #2842)
* Make NeighborSearch return empty atomgroup, residue, segments instead of list (Issue #2892, PR #2907)
* Updated Universe creation function signatures to named arguments (Issue #2921)

Deprecations

Expand Down
39 changes: 9 additions & 30 deletions package/MDAnalysis/core/universe.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,18 @@ def _topology_from_file_like(topology_file, topology_format=None,
"Error: {2}".format(topology_file, parser, err))
return topology

# py3 TODO
#def _resolve_formats(*coordinates, format=None, topology_format=None):
def _resolve_formats(*coordinates, **kwargs):
format = kwargs.get('format', None)
topology_format = kwargs.get('topology_format', None)

def _resolve_formats(*coordinates, format=None, topology_format=None):
if not coordinates:
if format is None:
format = topology_format
elif topology_format is None:
topology_format = format
return format, topology_format

# py3 TODO
#def _resolve_coordinates(filename, *coordinates, format=None,
# all_coordinates=False):
def _resolve_coordinates(*args, **kwargs):
filename = args[0]
coordinates = args[1:]
format = kwargs.get('format', None)
all_coordinates = kwargs.get('all_coordinates', False)

def _resolve_coordinates(filename, *coordinates, format=None,
all_coordinates=False):
if all_coordinates or not coordinates and filename is not None:
try:
get_reader_for(filename, format=format)
Expand Down Expand Up @@ -287,6 +278,7 @@ class Universe(object):
:mod:`ChainReader<MDAnalysis.coordinates.chain>`, which contains the
functionality to treat independent trajectory files as a single virtual
trajectory.
**kwargs: extra arguments are passed to the topology parser.
Attributes
----------
Expand All @@ -310,23 +302,10 @@ class Universe(object):
``topology`` and ``trajectory`` are reserved
upon unpickle.
"""
# Py3 TODO
# def __init__(self, topology=None, *coordinates, all_coordinates=False,
# format=None, topology_format=None, transformations=None,
# guess_bonds=False, vdwradii=None,
# in_memory=False, in_memory_step=1,
# **kwargs):
def __init__(self, *args, **kwargs):
topology = args[0] if args else None
coordinates = args[1:]
all_coordinates = kwargs.pop('all_coordinates', False)
format = kwargs.pop('format', None)
topology_format = kwargs.pop('topology_format', None)
transformations = kwargs.pop('transformations', None)
guess_bonds = kwargs.pop('guess_bonds', False)
vdwradii = kwargs.pop('vdwradii', None)
in_memory = kwargs.pop('in_memory', False)
in_memory_step = kwargs.pop('in_memory_step', 1)
def __init__(self, topology=None, *coordinates, all_coordinates=False,
format=None, topology_format=None, transformations=None,
guess_bonds=False, vdwradii=None, in_memory=False,
in_memory_step=1, **kwargs):

self._trajectory = None # managed attribute holding Reader
self._cache = {}
Expand Down

0 comments on commit a8227f0

Please sign in to comment.