Skip to content

Commit

Permalink
Added the raw rst docs files to MANIFEST.in to satisfy issue 32
Browse files Browse the repository at this point in the history
  • Loading branch information
hgomersall committed Jan 10, 2014
1 parent c7bddae commit 6073bd4
Show file tree
Hide file tree
Showing 9 changed files with 238 additions and 43 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Expand Up @@ -11,4 +11,4 @@ include pyfftw/utils.pxi
include test/test_*.py
include test/__init__.py
recursive-include include *.h
recursive-include docs *.html *.css *.png *.js
recursive-include docs *.html *.css *.png *.js *.rst
6 changes: 3 additions & 3 deletions pyfftw/builders/_utils.py
Expand Up @@ -136,7 +136,7 @@ def _Xfftn(a, s, axes, overwrite_input,
FFTW_array_slicer=FFTW_array_slicer)

# We copy the data back into the internal FFTW object array
internal_array = FFTW_object.get_input_array()
internal_array = FFTW_object.input_array
internal_array[:] = 0
internal_array[FFTW_array_slicer] = (
a_copy[update_input_array_slicer])
Expand Down Expand Up @@ -176,7 +176,7 @@ def _Xfftn(a, s, axes, overwrite_input,

if not avoid_copy:
# Copy the data back into the (likely) destroyed array
FFTW_object.get_input_array()[:] = a_copy
FFTW_object.input_array[:] = a_copy

return FFTW_object

Expand Down Expand Up @@ -231,7 +231,7 @@ def __call__(self, input_array=None, output_array=None,
# Do the update here (which is a copy, so it's alignment
# safe etc).

internal_input_array = self.get_input_array()
internal_input_array = self.input_array
input_array = numpy.asanyarray(input_array)

if self._input_destroyed:
Expand Down
8 changes: 4 additions & 4 deletions pyfftw/builders/builders.py
Expand Up @@ -52,7 +52,7 @@
array that is passed in (due to ``s`` dictating a larger size), then the
extra entries are padded with zeros. This is a one time action. If the
internal input array is then extracted using
:meth:`pyfftw.FFTW.get_input_array`, it is possible to
:attr:`pyfftw.FFTW.input_array`, it is possible to
persistently fill the padding space with whatever the user desires, so
subsequent calls with a new input only overwrite the values that aren't
padding (even if the array that is used for the call is bigger than the
Expand All @@ -73,7 +73,7 @@
will be correctly loaded with the values within the input array, it is
not necessarily the case that the internal array *is* the input array.
The actual internal input array can always be retrieved with
:meth:`pyfftw.FFTW.get_input_array`.
:attr:`pyfftw.FFTW.input_array`.
**Example:**
Expand Down Expand Up @@ -178,7 +178,7 @@
:func:`pyfftw.n_byte_align`). If and only if a realignment is
necessary is a new array created. If a new array *is* created, it is
up to the calling code to acquire that new input array using
:func:`pyfftw.FFTW.get_input_array`.
:attr:`pyfftw.FFTW.input_array`.
The resultant :class:`pyfftw.FFTW` object that is created will be
designed to operate on arrays that are aligned. If the object is
Expand Down Expand Up @@ -207,7 +207,7 @@
Like ``auto_align_input``, If a new array is created, it is
up to the calling code to acquire that new input array using
:func:`pyfftw.FFTW.get_input_array`.
:attr:`pyfftw.FFTW.input_array`.
* ``avoid_copy``: By default, these functions will always create a copy
(and sometimes more than one) of the passed in input array. This is
Expand Down
4 changes: 2 additions & 2 deletions pyfftw/interfaces/_utils.py
Expand Up @@ -87,7 +87,7 @@ def _Xfftn(a, s, axes, overwrite_input, planner_effort,

# Only copy if the input array is what was actually used
# (otherwise it shouldn't be overwritten)
if FFTW_object.get_input_array() is a:
if FFTW_object.input_array is a:
a[:] = a_copy

if cache.is_enabled():
Expand All @@ -99,7 +99,7 @@ def _Xfftn(a, s, axes, overwrite_input, planner_effort,
if reload_after_transform:
a_copy = a.copy()

orig_output_array = FFTW_object.get_output_array()
orig_output_array = FFTW_object.output_array
output_shape = orig_output_array.shape
output_dtype = orig_output_array.dtype
output_alignment = FFTW_object.output_alignment
Expand Down
116 changes: 99 additions & 17 deletions pyfftw/pyfftw.pyx
Expand Up @@ -22,6 +22,8 @@ from libc.stdlib cimport calloc, malloc, free
from libc.stdint cimport intptr_t, int64_t
from libc cimport limits

import warnings

include 'utils.pxi'

cdef extern from *:
Expand Down Expand Up @@ -615,10 +617,10 @@ cdef class FFTW:
cdef int _output_array_alignment
cdef bint _use_threads

cdef object _input_item_strides
cdef object _input_strides
cdef object _input_byte_strides
cdef object _output_item_strides
cdef object _output_strides
cdef object _output_byte_strides
cdef object _input_shape
cdef object _output_shape
cdef object _input_dtype
Expand Down Expand Up @@ -691,6 +693,72 @@ cdef class FFTW:

flags = property(_get_flags_used)

def _get_input_array(self):
'''
Return the input array that is associated with the FFTW
instance.
'''
return self._input_array

input_array = property(_get_input_array)

def _get_output_array(self):
'''
Return the output array that is associated with the FFTW
instance.
'''
return self._output_array

output_array = property(_get_output_array)

def _get_input_strides(self):
'''
Return the strides of the input array for which the FFT is planned.
'''
return self._input_strides

input_strides = property(_get_input_strides)

def _get_output_strides(self):
'''
Return the strides of the output array for which the FFT is planned.
'''
return self._output_strides

output_strides = property(_get_output_strides)

def _get_input_shape(self):
'''
Return the shape of the input array for which the FFT is planned.
'''
return self._input_shape

input_shape = property(_get_input_shape)

def _get_output_shape(self):
'''
Return the shape of the output array for which the FFT is planned.
'''
return self._output_shape

output_shape = property(_get_output_shape)

def _get_input_dtype(self):
'''
Return the dtype of the input array for which the FFT is planned.
'''
return self._input_dtype

input_dtype = property(_get_input_dtype)

def _get_output_dtype(self):
'''
Return the shape of the output array for which the FFT is planned.
'''
return self._output_dtype

output_dtype = property(_get_output_dtype)

def __cinit__(self, input_array, output_array, axes=(-1,),
direction='FFTW_FORWARD', flags=('FFTW_MEASURE',),
unsigned int threads=1, planning_timelimit=None,
Expand Down Expand Up @@ -909,12 +977,12 @@ cdef class FFTW:
raise MemoryError

# Find the strides for all the axes of both arrays in terms of the
# number of elements (as opposed to the number of bytes).
self._input_byte_strides = input_array.strides
self._input_strides = tuple([stride/input_array.itemsize
# number of items (as opposed to the number of bytes).
self._input_strides = input_array.strides
self._input_item_strides = tuple([stride/input_array.itemsize
for stride in input_array.strides])
self._output_byte_strides = output_array.strides
self._output_strides = tuple([stride/output_array.itemsize
self._output_strides = output_array.strides
self._output_item_strides = tuple([stride/output_array.itemsize
for stride in output_array.strides])

# Make sure that the arrays are not too big for fftw
Expand All @@ -926,7 +994,7 @@ cdef class FFTW:
raise ValueError('Dimensions of the input array must be ' +
'less than ', str(limits.INT_MAX))

if self._input_strides[i] >= <Py_ssize_t> limits.INT_MAX:
if self._input_item_strides[i] >= <Py_ssize_t> limits.INT_MAX:
raise ValueError('Strides of the input array must be ' +
'less than ', str(limits.INT_MAX))

Expand All @@ -935,7 +1003,7 @@ cdef class FFTW:
raise ValueError('Dimensions of the output array must be ' +
'less than ', str(limits.INT_MAX))

if self._output_strides[i] >= <Py_ssize_t> limits.INT_MAX:
if self._output_item_strides[i] >= <Py_ssize_t> limits.INT_MAX:
raise ValueError('Strides of the output array must be ' +
'less than ', str(limits.INT_MAX))

Expand All @@ -946,8 +1014,8 @@ cdef class FFTW:
fft_shape = fft_shape_lookup(input_array, output_array)

# Fill in the stride and shape information
input_strides_array = self._input_strides
output_strides_array = self._output_strides
input_strides_array = self._input_item_strides
output_strides_array = self._output_item_strides
for i in range(0, self._rank):
self._dims[i]._n = fft_shape[self._axes[i]]
self._dims[i]._is = input_strides_array[self._axes[i]]
Expand Down Expand Up @@ -1264,7 +1332,7 @@ cdef class FFTW:
copy_needed = True
elif (not input_array.dtype == self._input_dtype):
copy_needed = True
elif (not input_array.strides == self._input_byte_strides):
elif (not input_array.strides == self._input_strides):
copy_needed = True
elif not (<intptr_t>np.PyArray_DATA(input_array)
% self.input_alignment == 0):
Expand Down Expand Up @@ -1374,12 +1442,12 @@ cdef class FFTW:
'The new output array should be the same shape as '
'the output array used to instantiate the object.')

if not new_input_strides == self._input_byte_strides:
if not new_input_strides == self._input_strides:
raise ValueError('Invalid input striding: '
'The strides should be identical for the new '
'input array as for the old.')

if not new_output_strides == self._output_byte_strides:
if not new_output_strides == self._output_strides:
raise ValueError('Invalid output striding: '
'The strides should be identical for the new '
'output array as for the old.')
Expand All @@ -1399,24 +1467,38 @@ cdef class FFTW:
Return the input array that is associated with the FFTW
instance.
*Deprecated since 0.10. Consider using the* :attr:`FFTW.input_array`
*property instead.*
'''
warnings.warn('get_input_array is deprecated. '
'Consider using the input_array property instead.',
DeprecationWarning)

return self._input_array

def get_output_array(self):
'''get_output_array()
Return the output array that is associated with the FFTW
instance.
*Deprecated since 0.10. Consider using the* :attr:`FFTW.output_array`
*property instead.*
'''
warnings.warn('get_output_array is deprecated. '
'Consider using the output_array property instead.',
DeprecationWarning)

return self._output_array

cpdef execute(self):
'''execute()
Execute the planned operation, taking the correct kind of FFT of
the input array (what is returned by :meth:`get_input_array`),
and putting the result in the output array (what is returned by
:meth:`get_output_array`).
the input array (i.e. :attr:`FFTW.input_array`),
and putting the result in the output array (i.e.
:attr:`FFTW.output_array`).
'''
cdef void *input_pointer = (
<void *>np.PyArray_DATA(self._input_array))
Expand Down
16 changes: 16 additions & 0 deletions pyfftw/pyfftw.rst
Expand Up @@ -17,6 +17,22 @@ FFTW Class
.. autoattribute:: pyfftw.FFTW.output_alignment

.. autoattribute:: pyfftw.FFTW.flags

.. autoattribute:: pyfftw.FFTW.input_array

.. autoattribute:: pyfftw.FFTW.output_array

.. autoattribute:: pyfftw.FFTW.input_shape

.. autoattribute:: pyfftw.FFTW.output_shape

.. autoattribute:: pyfftw.FFTW.input_strides

.. autoattribute:: pyfftw.FFTW.output_strides

.. autoattribute:: pyfftw.FFTW.input_dtype

.. autoattribute:: pyfftw.FFTW.output_dtype

.. automethod:: pyfftw.FFTW.__call__

Expand Down
8 changes: 4 additions & 4 deletions sphinx/tutorial.rst
Expand Up @@ -276,14 +276,14 @@ requirements for updating the array.
>>> e = pyfftw.n_byte_align_empty(4, 16, 'complex128')
>>> f = pyfftw.n_byte_align_empty(4, 16, 'complex128')
>>> fft_object = pyfftw.FFTW(d, e)
>>> fft_object.get_input_array() is d # get the input array from the object
>>> fft_object.input_array is d # get the input array from the object
True
>>> f[:] = [1, 2, 3, 4] # Add some data to f
>>> fft_object(f)
array([ 10.+0.j, -2.+2.j, -2.+0.j, -2.-2.j])
>>> fft_object.get_input_array() is d # No longer true!
>>> fft_object.input_array is d # No longer true!
False
>>> fft_object.get_input_array() is f # It has been updated with f :)
>>> fft_object.input_array is f # It has been updated with f :)
True

If the new input array is of the wrong dtype or wrongly strided,
Expand Down Expand Up @@ -435,7 +435,7 @@ Inspecting these objects gives us their shapes:

>>> b.shape
(32, 256)
>>> fft_wrapper_object.get_input_array().shape
>>> fft_wrapper_object.input_array.shape
(32, 256)
>>> a.shape
(128, 64)
Expand Down

0 comments on commit 6073bd4

Please sign in to comment.