Closed e-koch closed 9 years ago
It should be mentioned that the parameters are also saved via the FITS output, despite the title of the PR.
@astrofrog @ChrisBeaumont - I think this is ready to be reviewed.
Looks good to me!
I had the wrong values being passed to the wrong keywords in the header.
test_benchmark
doesn't seem to test for differences in the parameters?
Ah good point -- perhaps this PR should also update the implementation of Dendrogram.__eq__
(https://github.com/dendrograms/astrodendro/blob/master/astrodendro/dendrogram.py#L459) to compare parameter equality?
Two issues have cropped up now that I'm not quite sure how to address properly:
-np.inf
. Is there an accepted standard for representing infinities in headers?test_benchmark
computes the dendrograms using a custom function, so min_delta
and min_npix
are never set, and the dendrograms are not equal. Should Dendrogram.__eq__
do something more sophisticated than checking if the parameter dicts are the same? Or should the test be altered?@ChrisBeaumont @astrofrog -- I've asked (and googled) around a bit about handling infs in FITS headers and have not gotten a decisive answer. Do either of you have an idea for handling this? Instead of using -np.inf
, could min_val
default to the minimum in the data?
@e-koch - as far as I know there is no standard way of representing infinity or NaN if FITS headers (but @embray can disagree if this has changed).
Instead of using -np.inf, could min_val default to the minimum in the data?
That sounds like a reasonable workaround to me.
test_benchmark computes the dendrograms using a custom function, so min_delta and min_npix are never set
Would it be easy in this PR to modify test_benchmark to fix this?
Sorry for letting this get stale. The code changes here look good to me so, if you can add the above workarounds to get the test suite to pass, I'm fine with merging
@ChrisBeaumont - I altered min_val
to be the minimum minus 1. Setting to the minimum causes no trunk to be created for data that is all the same value, which is completely unrealistic but it makes sense to me that it be recognized as a single structure. This cropped up in test_statistic_dimensionality
.
As for test_benchmark
, I'm disagreeing with my earlier comment that Dendrogram.__eq__
should test for differences in the parameters. Since used-defined functions can be given, one doesn't have to specify the parameters explicitly to get the same tree structure, so perhaps equality should only test the tree structure? min_val
should be compared though.
@ChrisBeaumont - I altered Dendrogram.__eq__
to only compare min_delta
and npix
if they were set (!=0, as by default). min_value
is always compared.
Do you have any thoughts on this approach? It should enable equality tests in the cases that a custom function is provided (like in test_benchmark
).
@e-koch 2 minor comments, but I'm OK with merging once they are addressed.
@ChrisBeaumont - Thanks! Should be ready to merge now.
Thanks!
The parameters dictionary isn't currently included when saving. This just adds that ability to the import and export functions.