Remove unused imports; some of this is redundant with the work done in https://github.com/astropy/astropy/pull/1445 on the astropy end, but some of it was a little different too somehow

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2314 ed100bfc-0583-0410-97f2-c26b58777a21
Finally fixed up the _FormatX a class a bit to be more responsible for its own affairs a la _FormatP

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2315 ed100bfc-0583-0410-97f2-c26b58777a21
Cleaned up a bit of code rot found by pylint. This included a handful of small bugs in code not covered by tests (some of which would have been difficult to cover due to external dependencies)

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2316 ed100bfc-0583-0410-97f2-c26b58777a21
Updated this todo note.  This shouldn't be changed before 3.3.

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2317 ed100bfc-0583-0410-97f2-c26b58777a21
Simplify the logic in this branch; don't need all the checks for P/Q

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2318 ed100bfc-0583-0410-97f2-c26b58777a21
As a prerequisite to improving the consistency of how scaled table
columns are handled I finally got around to refactoring the
FITS_rec.field method a bit.  This is work I had been avoiding in
preference to just working on the existing plan of redoing table support
on top of Astropy tables.

That said, this was still relatively easy to do, and I think that the
new, cleaner code will be significantly easier to transfer over to a new
table implementation. It will also lend itself better to supporting
backwards compatibility with the recarray-based approach which will be
necessary for the first few releases that include any new table
implementation.

One major difference to the internal data structures introduced by this
fix is that *all* of the table columns are added to the
FITS_rec._convert list of converted columns, even if they don't require
any scaling or data type conversion.  In the non-conversion case the
array stored in ._convert is just the direct slice of the recarray
returned by recarray.field.  I'm still a little concerned whether this
change leads to memory leaks and that's something I need to test for
before merging this new code.  If it does cause memory leaks it would be
due to a reference cycle, and I think I can find a workaround.

There are a few other TODO items in this commit that need to be
addressed before merging as well.

This commit contains a fix for a bug that hadn't revealed itself until
making these other changes (but was necessary to fix for all the tests
to pass).  This is specifically the fact that the `FITS_rec.copy()`
method (inherited from `ndarray.copy()`) did not perform a deep copy of
all of a FITS_rec's attributes, including the arrays in the `._convert`
list.  This meant that when copying a `FITS_rec` with the copy method
the new array would have its own copy of the *raw* data, but the
converted arrays would remain shared.  This is especially bad in the new
case where slices of *all* of the columns are stored in `._convert`.
This meant that any update to the new table updated the old table as
well (likewise they shared the same column definitions).  So now
`FITS_rec.copy()` is overridden to ensure that all of the table's
attributes get a deep copy.  This in turn revealed that since
`Column.__new__` expects a minimum number of arguments,
`copy.(deep)copy()` did not work on it without first defining custom
`__(deep)copy__` methods.

*whew!*

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2319 ed100bfc-0583-0410-97f2-c26b58777a21
At some point last week I noticed that the array argument to Column was undocumented, so apparently I added documentation for it.

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2320 ed100bfc-0583-0410-97f2-c26b58777a21
Made management of the _ASCIIColDefs spans, starts, and _width attributes a little easier to understand and not dependent on as much unncessary magic/state.

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2321 ed100bfc-0583-0410-97f2-c26b58777a21
Remove a little bit of code rot.  The 'widths' that were being calculated here are no different from the existing self._coldefs.spans list.

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2322 ed100bfc-0583-0410-97f2-c26b58777a21
More code rot removal following the previous two commits. Greatly simplifies and, I hope, clarifies the logic used when formatting ASCII table data. The tests for overlap are, I think, correct now (though more tests wouldn't be a bad idea) but they raise warnings instead of errors in the case of overlapping columns, as they are technically not disallowed by the standard (just discouraged).

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2323 ed100bfc-0583-0410-97f2-c26b58777a21
Allow assignment from np.void objects, which are returned for the rows of multi-field ndarrays (i.e. not recarrays)

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2324 ed100bfc-0583-0410-97f2-c26b58777a21
Add a test for this specific corner case that I wasn't sure would work--looks like it does.  Renamed a misnamed test too..

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2325 ed100bfc-0583-0410-97f2-c26b58777a21
I've done so much work on this I think I should just check it in a WIP before something tragic happens...

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2326 ed100bfc-0583-0410-97f2-c26b58777a21
Renamed the internal class _ASCIIColDefs to _AsciiColDefs for better consistency with _AsciiColumnFormat

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2327 ed100bfc-0583-0410-97f2-c26b58777a21
Another WIP commit.  The new FITS_rec.from_columns is almost working.

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2328 ed100bfc-0583-0410-97f2-c26b58777a21
Moved all the real functionality of new_table into a new
FITS_rec.from_columns class method.  This makes vastly more sense, in
that most of what new_table did was to create a new FITS_rec object and
fill its columns based on the format specification in a list of Column
objects.  It makes sense that such a task belong to the FITS_rec class
itself--some of the code for doing this overlaps with other code already
in FITS_rec, especially for converting from the Numpy-native data
formats to the FITS-native data format.  Not all of the overlapping code
has been refactored, as some of it will take some thinking, but there
are notes for where it seems applicable.

The rest of new_table's responsibilities are to instantiate a
BinTableHDU or TableHDU depending on what was passed into its `tbtype`
argument.  Now, new_table just creates the data array with
FITS_rec.from_columns and uses the normal constuctors for those classes
to instantiate the HDU.  The code is now vastly cleaner and simpler to
follow.  I also modified new_table to allow passing in the `BinTableHDU`
and `TableHDU` classes themselves to specify what type of table to
create, rather than the string.  I think this approach is better
overall, but that's subjective.  I also got rid of the `eval()` call
which I always felt was pretty ugly.

In the process of moving the code around I noticed one slight defect of
the old table creation code: In binary tables, the default values in
string columns were always set to the string '0.0' which seemed odd and
unintuitive.  This has been fixed so that string values are '' (empty
strings) by default.

Finally, there's still some work to be done here--this change is not
quite complete.  For one: The old new_table code had some logic related
to scaled columns.  For now I've removed that logic since it did not
seem to affect the results of any existing tests.  That doesn't mean it
didn't have a purpose though--I need to review exactly what it was meant
for, determine if it is *still* needed, and include some tests that
exercise it.  There is also the matter of handling TDISPn and TNULLn
when converting between ASCII columns and binary columns.  These fields
have different semantics depending on the table type, so the column
conversions need a way to account for those differences.

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2329 ed100bfc-0583-0410-97f2-c26b58777a21
Added a little escape valve in ColDefs.__repr__ so that it doesn't crash debugging sessions

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2330 ed100bfc-0583-0410-97f2-c26b58777a21
Make the regexp for P/Q formats a little stricter--only accept the format codes that the FITS standard states are valid for use in variable length arrays.  Also add a .format attribute to _FormatP/Q classes that contains the FITS format code for the data in the VLAs.

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2331 ed100bfc-0583-0410-97f2-c26b58777a21
For just about the first time, added a modicum of validation to the options in the Column constructor to ensure that columns that validate the FITS standard can't be created.  This also addresses a couple special cases when converting between bin table columns and ASCII table columns: The TNULLn keyword has different meanings between the two table types, and ASCII tables do not support codes like 'Lw' in the TDISPn keywords.

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2332 ed100bfc-0583-0410-97f2-c26b58777a21
Make it easier to keep track whether a column's internal, raw values (the values stored in the base recarray, *not* the values displayed by FITS_rec) are physical, or in their unscaled storage values.  As I noted, it's a little disjointed that the Column is responsible for knowing what units its values are in, while the FITS_rec is responsible for actually scaling/unscaling them as necessary.  But that's what we're stuck with until there's time for more radical changes.

git-svn-id: http://svn6.assembla.com/svn/pyfits/trunk@2333 ed100bfc-0583-0410-97f2-c26b58777a21