LSSTDESC / rail_attic

Redshift Assessment Infrastructure Layers
MIT License
14 stars 9 forks source link

Fix broken references to PIT metric in evaluation/demo.ipynb #352

Closed drewoldag closed 1 year ago

drewoldag commented 1 year ago

This example notebook makes use of several PIT metric functions, that have been moved to qp. Need to update this notebook to use the qp implementation instead of deprecated RAIL implementation.

drewoldag commented 1 year ago

It also looks like there's a problem with duplicated values in the PIT class is qp.

These lines: https://github.com/LSSTDESC/qp/blob/main/src/qp/metrics/pit.py#L54-L55

can end up with duplicated values at the beginning and end (either multiple 0's or 1's).

This is producing an error that looks like this when running goldenspike.ipynb and the evaluation/demo.ipynb

File [~/opt/miniconda3/envs/rail/lib/python3.10/site-packages/scipy/interpolate/_bsplines.py:1293](https://file+.vscode-resource.vscode-cdn.net/Users/drew/code/RAIL/examples/goldenspike_examples/~/opt/miniconda3/envs/rail/lib/python3.10/site-packages/scipy/interpolate/_bsplines.py:1293), in make_interp_spline(x, y, k, t, bc_type, axis, check_finite)
   1290     raise ValueError('Shapes of x {} and y {} are incompatible'
   1291                      .format(x.shape, y.shape))
   1292 if np.any(x[1:] == x[:-1]):
-> 1293     raise ValueError("Expect x to not have duplicates")
   1294 if x.ndim != 1 or np.any(x[1:] < x[:-1]):
   1295     raise ValueError("Expect x to be a 1D strictly increasing sequence.")

ValueError: Expect x to not have duplicates
eacharles commented 1 year ago

This works:

    data_quants = np.quantile(self._pit_samps, eval_grid)
    quant_mask = np.bitwise_and(data_quants > 0., data_quants < 1)
    self._pit = qp.Ensemble(qp.quant, data=dict(quants=eval_grid[quant_mask], locs=np.atleast_2d(data_quants[quant_mask])))

On Apr 28, 2023, at 4:00 PM, Drew Oldag @.***> wrote:

It also looks like there's a problem with duplicated values in the PIT class is qp.

These lines: https://github.com/LSSTDESC/qp/blob/main/src/qp/metrics/pit.py#L54-L55 https://github.com/LSSTDESC/qp/blob/main/src/qp/metrics/pit.py#L54-L55 can end up with duplicated values at the beginning and end (either multiple 0's or 1's).

This is producing an error that looks like this when running goldenspike.ipynb

File ~/opt/miniconda3/envs/rail/lib/python3.10/site-packages/scipy/interpolate/_bsplines.py:1293, in make_interp_spline(x, y, k, t, bc_type, axis, check_finite) 1290 raise ValueError('Shapes of x {} and y {} are incompatible' 1291 .format(x.shape, y.shape)) 1292 if np.any(x[1:] == x[:-1]): -> 1293 raise ValueError("Expect x to not have duplicates") 1294 if x.ndim != 1 or np.any(x[1:] < x[:-1]): 1295 raise ValueError("Expect x to be a 1D strictly increasing sequence.")

ValueError: Expect x to not have duplicates — Reply to this email directly, view it on GitHub https://github.com/LSSTDESC/RAIL/issues/352#issuecomment-1528176628, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRIGIXQCWZKOD5P4KKLUBDXDRDZJANCNFSM6AAAAAAXOM3BNA. You are receiving this because you are subscribed to this thread.