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
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ env:
- SETUP_CMD=""
- COVERALLS=false
- BUILD_CMD="pip install -v package/ && pip install testsuite/"
- CONDA_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer"
- CONDA_ALL_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer matplotlib netcdf4 scikit-learn scipy seaborn coveralls clustalw=2.1"
# Install griddataformats from PIP so that scipy is only installed in the full build (#1147)
- PIP_DEPENDENCIES='griddataformats'
- CONDA_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer matplotlib scipy griddataformats"
- CONDA_ALL_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer matplotlib netcdf4 scikit-learn scipy griddataformats seaborn coveralls clustalw=2.1"
- CONDA_CHANNELS='biobuilds conda-forge'
- CONDA_CHANNEL_PRIORITY=True
- NUMPY_VERSION=stable
Expand Down
5 changes: 4 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ The rules for this file:
------------------------------------------------------------------------------


mm/dd/17 richardjgowers, rathann, jbarnoud
mm/dd/17 richardjgowers, rathann, jbarnoud, manuel.nuno.melo

* 0.16.2

Enhancements
* Added support for lazy loading of modules, with delayed, on-access errors
for missing optional dependencies (addresses Issues #577, #1361 and #1159)

Fixes
* fixed GROWriter truncating long resids from the wrong end (Issue #1395)
* Fixed dtype of numpy arrays to accomodate 32 bit architectures (Issue #1362)
* Groups are hashable on python 3 (Issue #1397)

Changes
* scipy and matplotlib are now required dependencies (Issue #1159)


06/03/17 utkbansal, kain88-de, xiki-tempula, kaplajon, wouterboomsma,
Expand Down
26 changes: 1 addition & 25 deletions package/MDAnalysis/analysis/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,31 +118,7 @@
import os.path
import errno
import warnings

try:
from gridData import Grid
except ImportError:
raise ImportError(
"""ImportError: The GridDataFormats package can not be found!

The 'gridData' module from GridDataFormats could not be
imported. Please install it first. You can try installing
directly from the internet:

pip install GridDataFormats

or

conda config --add channels conda-forge
conda install griddataformats

Alternatively, download the package from

http://pypi.python.org/pypi/GridDataFormats/

and install in the usual manner.
"""
)
from gridData import Grid

import MDAnalysis
from MDAnalysis.core import groups
Expand Down
25 changes: 4 additions & 21 deletions package/MDAnalysis/analysis/distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,9 @@
import logging
logger = logging.getLogger("MDAnalysis.analysis.distances")

try:
from scipy import sparse
except ImportError:
sparse = None
msg = "scipy.sparse could not be imported: some functionality will " \
"not be available in contact_matrix()"
warnings.warn(msg, category=ImportWarning)
logger.warn(msg)
del msg
# Optional and/or lazily imported modules
from MDAnalysis.lib import lazy
scipy = lazy.import_module('scipy.sparse', level='base')
Copy link
Member

Choose a reason for hiding this comment

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

This will only load scipy.sparse and nothing else from scipy?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will be equivalent to
import scipy.sparse
in that it results on the 'scipy' name being added to the namespace.
On module access both scipy and scipy.sparse are fully imported.

The level='base' keyword tells the function to return a reference to the base module (scipy). From then on you use scipy.sparse.whatever, just like it had been imported with import.

The difference to the default import_module call (without level='base') is that in the default case the returned reference is to the submodule. In that case you use sparse = import_module('scipy.sparse'), as equivalent to from scipy import sparse.


def contact_matrix(coord, cutoff=15.0, returntype="numpy", box=None):
'''Calculates a matrix of contacts.
Expand Down Expand Up @@ -93,12 +87,6 @@ def contact_matrix(coord, cutoff=15.0, returntype="numpy", box=None):
The contact matrix is returned in a format determined by the `returntype`
keyword.


Note
----
:mod:`scipy.sparse` is require for using *sparse* matrices; if it cannot
be imported then an `ImportError` is raised.

See Also
--------
:mod:`MDAnalysis.analysis.contacts` for native contact analysis
Expand All @@ -112,14 +100,9 @@ def contact_matrix(coord, cutoff=15.0, returntype="numpy", box=None):
adj = (distance_array(coord, coord, box=box) < cutoff)
return adj
elif returntype == "sparse":
if sparse is None:
# hack: if we are running with minimal dependencies then scipy was
# not imported and we have to bail here (see scipy import at top)
raise ImportError("For sparse matrix functionality you need to "
"import scipy.")
# Initialize square List of Lists matrix of dimensions equal to number
# of coordinates passed
sparse_contacts = sparse.lil_matrix((len(coord), len(coord)), dtype='bool')
sparse_contacts = scipy.sparse.lil_matrix((len(coord), len(coord)), dtype='bool')
if box is not None:
# with PBC
contact_matrix_pbc(coord, sparse_contacts, box, cutoff)
Expand Down
Loading