import numpy as np

import _unwrap_2d
import _unwrap_3d


def unwrap(wrapped_array,
           wrap_around_axis_0=False,
           wrap_around_axis_1=False,
           wrap_around_axis_2=False):
    '''From ``image``, wrapped to lie in the interval [-pi, pi), recover the
    original, unwrapped image.

    Parameters
    ----------
    image : 2D or 3D ndarray, optionally a masked array
    wrap_around : bool or sequence of bool

    Returns
    -------
    image_unwrapped : array_like
    '''
    wrapped_array = np.require(wrapped_array, np.float32, ['C'])
    if wrapped_array.ndim not in [2,3]:
        raise ValueError('input array needs to have 2 or 3 dimensions')

    wrapped_array_masked = np.ma.asarray(wrapped_array)
    unwrapped_array = np.empty_like(wrapped_array_masked.data)
    if wrapped_array.ndim == 2:
        _unwrap_2d._unwrap2D(wrapped_array_masked.data,
                           np.ma.getmaskarray(wrapped_array_masked).astype(np.uint8),
                           unwrapped_array,
                           bool(wrap_around_axis_0), bool(wrap_around_axis_1))
    elif wrapped_array.ndim == 3:
        _unwrap_3d._unwrap3D(wrapped_array_masked.data,
                           np.ma.getmaskarray(wrapped_array_masked).astype(np.uint8),
                           unwrapped_array,
                           bool(wrap_around_axis_0), bool(wrap_around_axis_1), bool(wrap_around_axis_2))

    if np.ma.isMaskedArray(wrapped_array):
        return np.ma.array(unwrapped_array, mask = wrapped_array_masked.mask)
    else:
        return unwrapped_array

    #TODO: set_fill to minimum value
    #TODO: check for empty mask, not a single contiguous pixel


@@ -76,27 +76,16 @@
 d_array,
-%0A          
  wrap_ar
@@ -92,89 +92,8 @@
 ound
-_axis_0=False,%0A           wrap_around_axis_1=False,%0A           wrap_around_axis_2
 =Fal
@@ -503,13 +503,14 @@
  in 
-%5B2,3%5D
+(2, 3)
 :%0A  
@@ -538,50 +538,627 @@
 r('i
-nput array needs to have 2 or 3 dimensions
+mage must be 2 or 3 dimensional')%0A    if isinstance(wrap_around, bool):%0A        wrap_around = %5Bwrap_around%5D * wrapped_array.ndim%0A    elif (hasattr(wrap_around, '__getitem__')%0A          and not isinstance(wrap_around, basestring)):%0A        if not len(wrap_around) == wrapped_array.ndim:%0A            raise ValueError('Length of wrap_around must equal the '%0A                             'dimensionality of image')%0A        wrap_around = %5Bbool(wa) for wa in wrap_around%5D%0A    else:%0A        raise ValueError('wrap_around must be a bool or a sequence with '%0A                         'length equal to the dimensionality of image
 ')%0A%0A
@@ -1513,37 +1513,32 @@
                 
-bool(
 wrap_around_axis
@@ -1528,39 +1528,29 @@
  wrap_around
-_axis_0), bool(
+%5B0%5D, 
 wrap_around_
@@ -1548,24 +1548,19 @@
 p_around
-_axis_1)
+%5B1%5D
 )%0A    el
@@ -1800,21 +1800,16 @@
         
-bool(
 wrap_aro
@@ -1815,49 +1815,29 @@
 ound
-_axis_0), bool(wrap_around_axis_1), bool(
+%5B0%5D, wrap_around%5B1%5D, 
 wrap
@@ -1847,16 +1847,11 @@
 ound
-_axis_2)
+%5B2%5D
 )%0A%0A 

Refactor wrap_around argument.