Consolidate all array writeability checking in new PyArray_RequireWriteable

This is mostly a code cleanup, but it does have a user-visible effect
in that attempting to write to a unwriteable array now consistently
raises ValueError. (It used to randomly raise either ValueError or
RuntimeError.)

Passes numpy.test("full").
Funnel all assignments to PyArrayObject->base through a single point

This patch removes all direct assignments of non-NULL values to the
'base' field on PyArrayObjects. A new utility function was created to
set up UPDATEIFCOPY arrays, and all assignments to 'base' were
adjusted to use either PyArray_SetBaseObject or the new
PyArray_SetUpdateIfCopyBase.

One advantage of this is that it produces more consistent error
handling. This error handling revealed a bug in the nditer code,
which this patch does *not* yet fix.

The bug is that npyiter_new_temp_array sometimes (when dealing with
reversed axes) creates an array and then returns a view onto it. But,
npyiter_allocate_arrays assumes that the array returned by
npyiter_new_temp_array can have UPDATEIFCOPY set, which requires
reassigning its 'base' field. Previously, this meant that the
temporary array leaked. Now, it produces a ValueError.

This code path doesn't seem to actually be hit very often; only one of
the nditer tests fails because of the change. See
   numpy/core/tests/test_nditer.py:test_iter_array_cast_buggy
Add a test for ndarray.diagonal()

All 'expected' values were computed using numpy 1.5.1, so we can be
pretty sure that the recent rewrite didn't change any results.
Transition scheme for allowing PyArray_Diagonal to return a view

PyArray_Diagonal is changed to return a copy of the diagonal (as in
numpy 1.6 and earlier), but with a new (hidden) WARN_ON_WRITE flag
set. Writes to this array (or views thereof) will continue to work as
normal, but the first write will trigger a DeprecationWarning.

We also issue this warning if someone extracts a non-numpy writeable
view of the array (e.g., by accessing the Python-level .data
attribute). There are likely still places where the data buffer is
exposed that I've missed -- review welcome!

New known-fail test: eye() for maskna arrays was only implemented by
exploiting ndarray.diagonal's view-ness, so it is now unimplemented
again, and the corresponding test is marked known-fail.
Document the PyArray_Diagonal transition scheme.
Typo fix

Thanks to Travis for catching it.
Merge branch 'master' into clean-up-diagonal
Un-KNOWNFAIL the nditer test after merging Mark's fix from master
Fix a C90 compatibility error
Add a missing guard for Python versions <2.6
Clean up PyArray_Diagonal changes based on Chuck's feedback

- NPY_ARRAY_WARN_ON_WRITE flag definition is protected by #ifdef
  _MULTIARRAYMODULE, to make totally sure that we can recycle the flag
  bit later.
- Improve docs for PyArray_SetUpdateIfCopyBase.
- Make the deprecation warning for writes to the diagonal array
  somewhat more terse.
- Use DEPRECATE macro instead of calling PyErr_Warn/PyErr_WarnEx
  directly.
- Comment formatting fixed.
Don't assume ctypes is available, it's not true on Python 2.4
Fix diagonal-related warnings and tests on Python 3
Add a little command-line tool for running tests, plus tox support

Tox is a handy little tool to make it easier than not to run proper
tests that exercise the build system and are run against multiple
Python versions: http://pypi.python.org/pypi/tox
See comment at the top of tox.ini for hints.
ENH: Explicit import of modules into the space in core/__init__.py

Otherwise there is no strict guarantee that they would be available
later on during population of __all__.

This issue was ran into while opening a python file in emacs with python-mode
and ropemacs:

Loading pymacs...done
Pymacs loading ropemacs...
File mode specification error: (error "Python: Traceback (most recent call last):
  File \"/usr/lib/python2.7/dist-packages/Pymacs/pymacs.py\", line 146, in loop
    value = eval(text)
  File \"<string>\", line 1, in <module>
  File \"/usr/lib/python2.7/dist-packages/Pymacs/pymacs.py\", line 246, in pymacs_load_helper
    object = __import__(module_name)
  File \"/usr/lib/python2.7/dist-packages/ropemacs/__init__.py\", line 4, in <module>
    import ropemode.interface
  File \"/usr/lib/python2.7/dist-packages/ropemode/interface.py\", line 3, in <module>
    import rope.base.change
  File \"/usr/lib/python2.7/dist-packages/rope/base/change.py\", line 2, in <module>
    import difflib
  File \"/usr/lib/python2.7/difflib.py\", line 36, in <module>
    from collections import namedtuple as _namedtuple
  File \"collections.py\", line 16, in <module>
    import numpy as np
  File \"/usr/lib/pymodules/python2.7/numpy/__init__.py\", line 137, in <module>
    import add_newdocs
  File \"/usr/lib/pymodules/python2.7/numpy/add_newdocs.py\", line 9, in <module>
    from numpy.lib import add_newdoc
  File \"/usr/lib/pymodules/python2.7/numpy/lib/__init__.py\", line 4, in <module>
    from type_check import *
  File \"/usr/lib/pymodules/python2.7/numpy/lib/type_check.py\", line 8, in <module>
    import numpy.core.numeric as _nx
  File \"/usr/lib/pymodules/python2.7/numpy/core/__init__.py\", line 30, in <module>
    __all__ += numeric.__all__
NameError: name numeric is not defined
")
Move internal NPY_ARRAY_WARN_ON_WRITE flag into an internal header.
Rename PyArray_RequireWriteable to PyArray_FailUnlessWriteable

Also clean up its API slightly so that the caller passes in a name
describing the array being checked which is used to generate an error
message, rather than writing an error message from scratch.
Merge pull request #286 from yarikoptic/master

Explicit import of modules into the space in core/__init__.py
Merge pull request #285 from njsmith/add-tox

Add a little command-line tool for running tests, plus tox support
ENH: Make internal per-op nditer flags type a typedef

There are 8 flags now, so to add another one requires
bumping up the size. This change makes that easy.
Also, because the internal structure of nditer is
not exposed to the ABI, we can change it at will.