Skip to content

Commit

Permalink
Merge pull request #30 from sfarrens/astropy_fix
Browse files Browse the repository at this point in the history
Astropy fix
  • Loading branch information
sfarrens authored Nov 22, 2018
2 parents 561d3a5 + 9e036e2 commit 1521766
Show file tree
Hide file tree
Showing 19 changed files with 307 additions and 408 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ branches:
# install package and dependencies
install:
- pip install coverage nose pytest pytest-cov
- pip install scikit-image
- if [[ $TRAVIS_PYTHON_VERSION > '3' ]]; then pip install astropy; fi
- if [[ $TRAVIS_PYTHON_VERSION < '3' ]]; then pip install astropy==2.0.9; fi
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then pip install numpy future scipy astropy progressbar2 sphinx sphinx-rtd-theme numpydoc travis-sphinx coveralls; fi

# run unit tests
Expand Down
48 changes: 29 additions & 19 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ModOpt
======

|travis| |coveralls| |license| |python27| |python35|
|travis| |coveralls| |license| |python27| |python35| |python36|

.. |travis| image:: https://travis-ci.org/CEA-COSMIC/ModOpt.svg?branch=master
:target: https://travis-ci.org/CEA-COSMIC/ModOpt
Expand All @@ -12,17 +12,20 @@ ModOpt
.. |license| image:: https://img.shields.io/github/license/mashape/apistatus.svg
:target: https://github.com/CEA-COSMIC/ModOpt/blob/master/LICENCE.txt

.. |python27| image:: https://img.shields.io/badge/python-2.7-yellow.svg
.. |python27| image:: https://img.shields.io/badge/python-2.7-green.svg
:target: https://www.python.org/

.. |python35| image:: https://img.shields.io/badge/python-3.5-yellow.svg
.. |python35| image:: https://img.shields.io/badge/python-3.5-green.svg
:target: https://www.python.org/

.. |python36| image:: https://img.shields.io/badge/python-3.6-green.svg
:target: https://www.python.org/

:Author: Samuel Farrens `([email protected]) <[email protected]>`_

:Version: 1.1.7
:Version: 1.2.0

:Date: 26/10/2018
:Date: 21/11/2018

:Documentation: |link-to-docs|

Expand Down Expand Up @@ -52,17 +55,15 @@ Required Packages
In order to run the code in this repository the following packages must be
installed:

* |link-to-python| [Tested with 2.7.11 and 3.6.3]

* |link-to-numpy| [Tested with v1.13.3]
* |link-to-python| [Last tested with v2.7.15 and v3.7.0]

* |link-to-scipy| [Tested with v1.0.0]
* |link-to-numpy| [Tested with v1.15.4]

* |link-to-future| [Tested with v0.16.0]
* |link-to-scipy| [Tested with v1.1.0]

* |link-to-astropy| [Tested with v2.0.2]
* |link-to-future| [Tested with v0.17.1]

* |link-to-progressbar| [Tested with v3.34.3]
* |link-to-progressbar| [Tested with v3.38.0]

.. |link-to-python| raw:: html

Expand All @@ -84,11 +85,6 @@ installed:
<a href="http://python-future.org/quickstart.html"
target="_blank">Future</a>

.. |link-to-astropy| raw:: html

<a href="http://www.astropy.org/"
target="_blank">Astropy</a>

.. |link-to-progressbar| raw:: html

<a href="https://progressbar-2.readthedocs.io/en/latest/"
Expand All @@ -99,15 +95,29 @@ Optional Packages

The following packages can optionally be installed to add extra functionality:

* |link-to-matplotlib| [Tested with v2.1.0]
* |link-to-astropy| [Last tested with v3.0.5]

* |link-to-matplotlib| [Last tested with v3.0.2]

* |link-to-termcolor| [Tested with v1.1.0]
* |link-to-skimage| [Last tested with v0.14.1]

* |link-to-termcolor| [Last tested with v1.1.0]

.. |link-to-astropy| raw:: html

<a href="http://www.astropy.org/"
target="_blank">Astropy</a>

.. |link-to-matplotlib| raw:: html

<a href="http://matplotlib.org/"
target="_blank">Matplotlib</a>

.. |link-to-skimage| raw:: html

<a href="https://scikit-image.org/"
target="_blank">Scikit-Image</a>

.. |link-to-termcolor| raw:: html

<a href="https://pypi.python.org/pypi/termcolor"
Expand Down
40 changes: 23 additions & 17 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ ModOpt Documentation

:Author: Samuel Farrens <[email protected]>

:Version: 1.1.7
:Version: 1.2.0

:Date: 26/10/2018
:Date: 21/11/2018

ModOpt is a series of Modular Optimisation tools for solving inverse problems.

Expand All @@ -35,18 +35,15 @@ Required Packages
In order to run the code in this repository the following packages must be
installed:

* |link-to-python| [Tested with 2.7.11 and 3.6.3]
* |link-to-python| [Last tested with v2.7.15 and v3.7.0]

* |link-to-numpy| [Tested with v1.13.3]
* |link-to-numpy| [Tested with v1.15.4]

* |link-to-scipy| [Tested with v1.0.0]
* |link-to-scipy| [Tested with v1.1.0]

* |link-to-future| [Tested with v0.16.0]

* |link-to-astropy| [Tested with v2.0.2]

* |link-to-progressbar| [Tested with v3.34.3]
* |link-to-future| [Tested with v0.17.1]

* |link-to-progressbar| [Tested with v3.38.0]

.. |link-to-python| raw:: html

Expand All @@ -68,11 +65,6 @@ installed:
<a href="http://python-future.org/quickstart.html"
target="_blank">Future</a>

.. |link-to-astropy| raw:: html

<a href="http://www.astropy.org/"
target="_blank">Astropy</a>

.. |link-to-progressbar| raw:: html

<a href="https://progressbar-2.readthedocs.io/en/latest/"
Expand All @@ -83,15 +75,29 @@ Optional Packages

The following packages can optionally be installed to add extra functionality:

* |link-to-matplotlib| [Tested with v2.1.0]
* |link-to-astropy| [Last tested with v2.0.8 and v3.0.5]

* |link-to-matplotlib| [Last tested with v3.0.2]

* |link-to-termcolor| [Tested with v1.1.0]
* |link-to-skimage| [Last tested with v0.14.1]

* |link-to-termcolor| [Last tested with v1.1.0]

.. |link-to-astropy| raw:: html

<a href="http://www.astropy.org/"
target="_blank">Astropy</a>

.. |link-to-matplotlib| raw:: html

<a href="http://matplotlib.org/"
target="_blank">Matplotlib</a>

.. |link-to-skimage| raw:: html

<a href="https://scikit-image.org/"
target="_blank">Scikit-Image</a>

.. |link-to-termcolor| raw:: html

<a href="https://pypi.python.org/pypi/termcolor"
Expand Down
18 changes: 10 additions & 8 deletions modopt/base/observable.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
##########################################################################
# XXX - Copyright (C) XXX, 2017
# Distributed under the terms of the CeCILL-B license, as published by
# the CEA-CNRS-INRIA. Refer to the LICENSE file or to
# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
# for details.
##########################################################################
# -*- coding: utf-8 -*-

"""Observable
This module contains observable classes
:Author: Benoir Sarthou
"""

import time
import numpy as np
Expand Down Expand Up @@ -179,7 +181,7 @@ def _remove_observer(self, signal, observer):
self._observers[signal].remove(observer)


class MetricObserver:
class MetricObserver(object):
"""Wrapper of the metric to the observer object notify by the Observable
class.
Expand Down
8 changes: 6 additions & 2 deletions modopt/base/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
"""

from inspect import getargspec
from sys import version_info
from functools import wraps
if version_info[0] < 3: # pragma: no cover
from inspect import getargspec as argspec
else:
from inspect import getfullargspec as argspec


def add_args_kwargs(func):
Expand All @@ -32,7 +36,7 @@ def add_args_kwargs(func):
@wraps(func)
def wrapper(*args, **kwargs):

props = getargspec(func)
props = argspec(func)

# if 'args' not in props:
if isinstance(props[1], type(None)):
Expand Down
4 changes: 2 additions & 2 deletions modopt/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
:Author: Samuel Farrens <[email protected]>
:Version: 1.1.7
:Version: 1.2.0
"""

# Package Version
version_info = (1, 1, 7)
version_info = (1, 2, 0)
__version__ = '.'.join(str(c) for c in version_info)

__about__ = ('ModOpt \n\n '
Expand Down
19 changes: 14 additions & 5 deletions modopt/math/convolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@
from builtins import zip
import numpy as np
import scipy.signal
from astropy.convolution import convolve_fft
from modopt.base.np_adjust import rotate_stack
from modopt.interface.errors import warn
try:
from astropy.convolution import convolve_fft
except ImportError: # pragma: no cover
import_astropy = False
warn('astropy not found, will default to scipy for convolution')
else:
import_astropy = True
try:
import pyfftw
except ImportError: # pragma: no cover
Expand All @@ -24,7 +30,7 @@
warn('Using pyFFTW "monkey patch" for scipy.fftpack')


def convolve(data, kernel, method='astropy'):
def convolve(data, kernel, method='scipy'):
r"""Convolve data with kernel
This method convolves the input data with a given kernel using FFT and
Expand All @@ -37,7 +43,7 @@ def convolve(data, kernel, method='astropy'):
kernel : np.ndarray
Input kernel array, normally a 2D kernel
method : str {'astropy', 'scipy'}, optional
Convolution method (default is 'astropy')
Convolution method (default is 'scipy')
Returns
-------
Expand Down Expand Up @@ -86,6 +92,9 @@ def convolve(data, kernel, method='astropy'):
if method not in ('astropy', 'scipy'):
raise ValueError('Invalid method. Options are "astropy" or "scipy".')

if not import_astropy: # pragma: no cover
method = 'scipy'

if method == 'astropy':
return convolve_fft(data, kernel, boundary='wrap', crop=False,
nan_treatment='fill', normalize_kernel=False)
Expand All @@ -94,7 +103,7 @@ def convolve(data, kernel, method='astropy'):
return scipy.signal.fftconvolve(data, kernel, mode='same')


def convolve_stack(data, kernel, rot_kernel=False, method='astropy'):
def convolve_stack(data, kernel, rot_kernel=False, method='scipy'):
r"""Convolve stack of data with stack of kernels
This method convolves the input data with a given kernel using FFT and
Expand All @@ -109,7 +118,7 @@ def convolve_stack(data, kernel, rot_kernel=False, method='astropy'):
rot_kernel : bool
Option to rotate kernels by 180 degrees
method : str {'astropy', 'scipy'}, optional
Convolution method (default is 'astropy')
Convolution method (default is 'scipy')
Returns
-------
Expand Down
4 changes: 3 additions & 1 deletion modopt/math/matrix.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

"""MATRIX ROUTINES
This module contains methods for matrix operations.
Expand Down Expand Up @@ -230,7 +232,7 @@ def rotate(matrix, angle):
new_index = np.array(np.dot(index, rot_matrix(angle)), dtype='int') + shift
new_index[new_index >= shape[0]] -= shape[0]

return matrix[list(zip(new_index.T))].reshape(shape.T)
return matrix[tuple(zip(new_index.T))].reshape(shape.T)


class PowerMethod(object):
Expand Down
Loading

0 comments on commit 1521766

Please sign in to comment.