ICSM/pgmuvi

[BUG] need more elegant way of dealing with a 1-element light curve

Offen

#35 geöffnet am 27.08.2023

 (4 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (6 Forks)auto 404
good first issuetest needed

Repository-Metriken

Stars
 (14 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Describe the bug The current implementation of the Lightcurve object allows the creation of a 1-element light curve, but subsequently throws an error when the set_model method is called:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Volumes/SSD2TBShaanpatiKhan/MovedHomeFolder/sundar/work/SAGE/2308/PGMUVI_2comp/test_pgmuvi_2comp_newest.py", line 287, in driver
    main(runall=True)
  File "/Volumes/SSD2TBShaanpatiKhan/MovedHomeFolder/sundar/work/SAGE/2308/PGMUVI_2comp/test_pgmuvi_2comp_newest.py", line 279, in main
    _ = pgmuvi_2comp(lightcurve_1d, period_guess,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/SSD2TBShaanpatiKhan/MovedHomeFolder/sundar/work/SAGE/2308/PGMUVI_2comp/test_pgmuvi_2comp_newest.py", line 37, in pgmuvi_2comp
    lightcurve.set_model(model="1D", likelihood="learn", num_mixtures=2)
  File "/Volumes/SSD2TBShaanpatiKhan/MovedHomeFolder/sundar/work/pgmuvi/pgmuvi/lightcurve.py", line 493, in set_model
    self.model = model_dic_1[model](self._xdata_transformed,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/SSD2TBShaanpatiKhan/MovedHomeFolder/sundar/work/pgmuvi/pgmuvi/gps.py", line 46, in __init__
    self.covar_module.initialize_from_data(train_x, train_y)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gpytorch/kernels/spectral_mixture_kernel.py", line 244, in initialize_from_data
    min_dist = sorted_dists[..., 0, :]
               ~~~~~~~~~~~~^^^^^^^^^^^
IndexError: index 0 is out of bounds for dimension 1 with size 0

To Reproduce Steps to reproduce the behaviour:

lc = Lightcurve(torch.Tensor([[0.]]), torch.Tensor([[6.9557]]), xtransform='minmax')
lc.set_model(model="1D", likelihood="learn", num_mixtures=2)

Expected behaviour An attempt to create the Lightcurve object should throw an exception in the case of a one-element light curve.

Contributor Guide