Permalink
Browse files

Move (un)packbits docstrings to add_newdocs.py. Fix typos.

  • Loading branch information...
1 parent 9902bd1 commit 11943ab29867441fc0b8662f77eb788afc5f4f46 @pv pv committed Feb 14, 2009
Showing with 44 additions and 35 deletions.
  1. +42 −4 numpy/add_newdocs.py
  2. +2 −31 numpy/lib/src/_compiled_base.c
View
@@ -2502,11 +2502,11 @@
##############################################################################
#
-# lib._compile_base functions
+# lib._compiled_base functions
#
##############################################################################
-add_newdoc('numpy.lib._compile_base', 'digitize',
+add_newdoc('numpy.lib._compiled_base', 'digitize',
"""
digitize(x,bins)
@@ -2519,7 +2519,7 @@
Beyond the bounds of the bins 0 or len(bins) is returned as appropriate.
""")
-add_newdoc('numpy.lib._compile_base', 'bincount',
+add_newdoc('numpy.lib._compiled_base', 'bincount',
"""
bincount(x,weights=None)
@@ -2533,7 +2533,7 @@
See also: histogram, digitize, unique.
""")
-add_newdoc('numpy.lib._compile_base', 'add_docstring',
+add_newdoc('numpy.lib._compiled_base', 'add_docstring',
"""
docstring(obj, docstring)
@@ -2543,6 +2543,44 @@
raise a TypeError
""")
+add_newdoc('numpy.lib._compiled_base', 'packbits',
+ """
+ out = numpy.packbits(myarray, axis=None)
+
+ myarray : an integer type array whose elements should be packed to bits
+
+ This routine packs the elements of a binary-valued dataset into a
+ NumPy array of type uint8 ('B') whose bits correspond to
+ the logical (0 or nonzero) value of the input elements.
+ The dimension over-which bit-packing is done is given by axis.
+ The shape of the output has the same number of dimensions as the input
+ (unless axis is None, in which case the output is 1-d).
+
+ Example:
+ >>> a = array([[[1,0,1],
+ ... [0,1,0]],
+ ... [[1,1,0],
+ ... [0,0,1]]])
+ >>> b = numpy.packbits(a,axis=-1)
+ >>> b
+ array([[[160],[64]],[[192],[32]]], dtype=uint8)
+
+ Note that 160 = 128 + 32
+ 192 = 128 + 64
+ """)
+
+add_newdoc('numpy.lib._compiled_base', 'unpackbits',
+ """
+ out = numpy.unpackbits(myarray, axis=None)
+
+ myarray - array of uint8 type where each element represents a bit-field
+ that should be unpacked into a boolean output array
+
+ The shape of the output array is either 1-d (if axis is None) or
+ the same shape as the input array with unpacking done along the
+ axis specified.
+ """)
+
##############################################################################
#
@@ -544,35 +544,6 @@ arr_add_docstring(PyObject *NPY_UNUSED(dummy), PyObject *args)
}
-static char packbits_doc[] =
- "out = numpy.packbits(myarray, axis=None)\n\n"
- " myarray : an integer type array whose elements should be packed to bits\n\n"
- " This routine packs the elements of a binary-valued dataset into a\n"
- " NumPy array of type uint8 ('B') whose bits correspond to\n"
- " the logical (0 or nonzero) value of the input elements.\n"
- " The dimension over-which bit-packing is done is given by axis.\n"
- " The shape of the output has the same number of dimensions as the input\n"
- " (unless axis is None, in which case the output is 1-d).\n"
- "\n"
- " Example:\n"
- " >>> a = array([[[1,0,1],\n"
- " ... [0,1,0]],\n"
- " ... [[1,1,0],\n"
- " ... [0,0,1]]])\n"
- " >>> b = numpy.packbits(a,axis=-1)\n"
- " >>> b\n"
- " array([[[160],[64]],[[192],[32]]], dtype=uint8)\n\n"
- " Note that 160 = 128 + 32\n"
- " 192 = 128 + 64\n";
-
-static char unpackbits_doc[] =
- "out = numpy.unpackbits(myarray, axis=None)\n\n"
- " myarray - array of uint8 type where each element represents a bit-field\n"
- " that should be unpacked into a boolean output array\n\n"
- " The shape of the output array is either 1-d (if axis is None) or\n"
- " the same shape as the input array with unpacking done along the\n"
- " axis specified.";
-
/* PACKBITS
This function packs binary (0 or 1) 1-bit per pixel arrays
@@ -820,9 +791,9 @@ static struct PyMethodDef methods[] = {
{"add_docstring", (PyCFunction)arr_add_docstring, METH_VARARGS,
NULL},
{"packbits", (PyCFunction)io_pack, METH_VARARGS | METH_KEYWORDS,
- packbits_doc},
+ NULL},
{"unpackbits", (PyCFunction)io_unpack, METH_VARARGS | METH_KEYWORDS,
- unpackbits_doc},
+ NULL},
{NULL, NULL} /* sentinel */
};

0 comments on commit 11943ab

Please sign in to comment.