Skip to content

Commit

Permalink
Merge pull request #165 from LSSTDESC/tqz/fix_oldevaluator
Browse files Browse the repository at this point in the history
remove column that are not computed by the scipy functions
  • Loading branch information
ztq1996 authored Dec 2, 2024
2 parents 83f0930 + 7017240 commit 820e3ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/rail/estimation/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def estimate(self, input_data):
self.set_data("input", input_data)
self.run()
self.finalize()
return self.get_handle("output")
results = self.get_handle("output")
results.read(force = True)
return results

def run(self):
self.open_model(**self.config)
Expand Down
15 changes: 9 additions & 6 deletions src/rail/evaluation/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,19 +481,22 @@ def run(self):
out_table = {}
for pit_metric in pit_metrics:
value = PIT_METRICS[pit_metric]()

# The result objects of some meta-metrics are bespoke scipy objects with inconsistent fields.
# Here we do our best to store the relevant fields in `out_table`.
if isinstance(value, list): # pragma: no cover
out_table[f"PIT_{pit_metric}"] = value
elif pit_metric== 'OutRate':
out_table[f"PIT_{pit_metric}_stat"] = [value]
else:
out_table[f"PIT_{pit_metric}_stat"] = [
getattr(value, "statistic", None)
]
out_table[f"PIT_{pit_metric}_pval"] = [getattr(value, "p_value", None)]
out_table[f"PIT_{pit_metric}_significance_level"] = [
getattr(value, "significance_level", None)
]
if getattr(value, "pvalue", None) is not None:
out_table[f"PIT_{pit_metric}_pval"] = [getattr(value, "p_value", None)]
if getattr(value, "significance_level", None) is not None:
out_table[f"PIT_{pit_metric}_significance_level"] = [
getattr(value, "significance_level", None)
]

POINT_METRICS = dict(
SimgaIQR=PointSigmaIQR,
Expand All @@ -516,7 +519,7 @@ def run(self):
if self.config.do_cde:
value = CDELoss(pz_data, zgrid, z_true).evaluate()
out_table["CDE_stat"] = [value.statistic]
out_table["CDE_pval"] = [value.p_value]
# out_table["CDE_pval"] = [value.p_value]

# Converting any possible None to NaN to write it
out_table_to_write = {
Expand Down

0 comments on commit 820e3ea

Please sign in to comment.