astropy/astropy — pull request #1888 by taldcroft (2014-04-06 02:40:50+00:00)
Title: Easier subclassing for Table

Currently if you subclass table it breaks the I/O methods, because the registry dictionaries do not contain entries for the subclass, only the parent. This makes it quite fiddly to subclass.

e.g.

import astropy.table
class MyTable(astropy.table.Table):
pass

MyTable.read("table.txt", format="ascii")

will raise an exception "No reader defined for format 'ascii' and class 'MyTable'.".

Sometimes this might be necessary, if the subclass alters the structure of the class enough that the original functions are invalid, but most subclasses would not have this problem.

I can think of two ways to make this easier:
1. Alter the registry to search by subclass
2. A class method on Table to register a subclass based on the parent I/O functions (including a wrapper for the readers to return the right subclass).

I have a working version of the latter that I use for my own code, and if it would be useful I can do a PR.

Thanks! Joe Zuntz