astropy/astropy — pull request #984 by Epitrochoid (2013-04-14 22:04:49+00:00)
Title: Initial implementation of tracking and warning about correlated error

Added fields uid and correlated_list to class NDData. The field uid holds a unique id for that instance generated via uuid4() of the standard library. Correlated_list holds a list of uids of previous NDData instances combined through any method implementing _arithmetic.

Added logic to initialize uid and correlated_list in __init__ of NDData.

Added logic to set the correlated_list of result to the sum of the correlated_list of self and operand in _arithmetic. Checks for intersections of the two correlated_lists (if both operand and self carry uncertainty) and issues a warning if a single uid appears in both.

Issues:

Organization. I tried to follow the existing code for figuring out where to put things, I'm not completely sure it all follows style guidelines though. Likely improvements could be made to improve extensibility of added feature, I'll keep thinking about it.

Documentation. I added a parameter 'clist' to __init__ in NDData but did not document it in the docstring. Do I document it manually following the style of the rest of the docstring, or is it generated using a tool? I was also unsure of how verbosely to comment code, comments in the source file seemed sparse, so I avoided trying to use them liberally.

Testing. I did not run the existing tests or write one for the new functionality. I am trying to fix an error with my pytest install ("NameError: global name 'basestring' is not defined" on Arch Linux), but once I fix that I plan to work on getting comfortable with the testing framework.

Optimization. Currently if an NDData object appears twice in a chain of arithmetic operations, its uid appears twice in the result's correlated_list. I'm not sure if checking for redundancy would be too much of a performance hit for the improvement of space usage. Keeping the list ordered might be a good medium (I'm also not sure how well built in ordering functions will handle UUID objects).

Thank you,
Mabry Cervin
mpcervin@uncg.edu