Skip to content

Commit

Permalink
ENH: clean up ndimage namespace, add __all__ dicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgommers committed Mar 10, 2011
1 parent e6f0a1e commit f509a5f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
7 changes: 1 addition & 6 deletions scipy/ndimage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,16 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import numpy
from filters import *
from fourier import *
from interpolation import *
from measurements import *
from morphology import *
from io import *

# doccer is moved to scipy.misc in scipy 0.8
from scipy.misc import doccer
doccer = numpy.deprecate(doccer, old_name='doccer',
new_name='scipy.misc.doccer')

from info import __doc__
__version__ = '2.0'

__all__ = filter(lambda s: not s.startswith('_'), dir())
from numpy.testing import Tester
test = Tester().test
10 changes: 10 additions & 0 deletions scipy/ndimage/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
import _nd_image
from scipy.misc import doccer

__all__ = ['correlate1d', 'convolve1d', 'gaussian_filter1d', 'gaussian_filter',
'prewitt', 'sobel', 'generic_laplace', 'laplace',
'gaussian_laplace', 'generic_gradient_magnitude',
'gaussian_gradient_magnitude', 'correlate', 'convolve',
'uniform_filter1d', 'uniform_filter', 'minimum_filter1d',
'maximum_filter1d', 'minimum_filter', 'maximum_filter',
'rank_filter', 'median_filter', 'percentile_filter',
'generic_filter1d', 'generic_filter']


_input_doc = \
"""input : array-like
input array to filter"""
Expand Down
4 changes: 4 additions & 0 deletions scipy/ndimage/fourier.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
import _ni_support
import _nd_image

__all__ = ['fourier_gaussian', 'fourier_uniform', 'fourier_ellipsoid',
'fourier_shift']


def _get_output_fourier(output, input):
if output is None:
if input.dtype.type in [numpy.complex64, numpy.complex128,
Expand Down
4 changes: 4 additions & 0 deletions scipy/ndimage/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
import _ni_support
import _nd_image

__all__ = ['spline_filter1d', 'spline_filter', 'geometric_transform',
'map_coordinates', 'affine_transform', 'shift', 'zoom', 'rotate']


def _extend_mode_to_code(mode):
mode = _ni_support._extend_mode_to_code(mode)
return mode
Expand Down
8 changes: 7 additions & 1 deletion scipy/ndimage/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
import _nd_image
import morphology

__all__ = ['label', 'find_objects', 'labeled_comprehension', 'sum', 'mean',
'variance', 'standard_deviation', 'minimum', 'maximum',
'minimum_position', 'maximum_position', 'extrema', 'center_of_mass',
'histogram', 'watershed_ift']


def label(input, structure = None, output = None):
"""
Label features in an array.
Expand Down Expand Up @@ -417,7 +423,7 @@ def _sum_centered(labels):
if (not _safely_castable_to_int(labels.dtype) or
labels.min() < 0 or labels.max() > labels.size):
unique_labels, new_labels = numpy.unique(labels, return_inverse=True)
counts = numpy.bincount(new_labels)
counts = numpy.bincount(new_labels)
sums = numpy.bincount(new_labels, weights=input.ravel())
if centered:
sums_c = _sum_centered(new_labels)
Expand Down
8 changes: 8 additions & 0 deletions scipy/ndimage/morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
import _nd_image
import filters

__all__ = ['iterate_structure', 'generate_binary_structure', 'binary_erosion',
'binary_dilation', 'binary_opening', 'binary_closing',
'binary_hit_or_miss', 'binary_propagation', 'binary_fill_holes',
'grey_erosion', 'grey_dilation', 'grey_opening', 'grey_closing',
'morphological_gradient', 'morphological_laplace', 'white_tophat',
'black_tophat', 'distance_transform_bf', 'distance_transform_cdt',
'distance_transform_edt']


def _center_is_true(structure, origin):
structure = numpy.array(structure)
Expand Down

0 comments on commit f509a5f

Please sign in to comment.