s-goldman / Dusty-Evolved-Star-Kit

SED-fitting python package for fitting evolved stars
https://dusty-evolved-star-kit.readthedocs.io
Other
15 stars 2 forks source link

Incorrect error message on negative number of grids #167

Closed TomGoffrey closed 3 years ago

TomGoffrey commented 3 years ago

Describe the bug [Minor] If I pass n=-1 to desk fit I (reasonably) receive an error (See steps to reproduce). However, I believe ValueError: Number of samples, -1, must be non-negative. should be something like ValueError: Number of samples, -1, must be positive.

To Reproduce

$ desk fit --source='desk/put_target_data_here/MSX_LMC_807.csv' --grid='oxygen' --n=-1

You already have the grid!

Scaling to full grid (-2,000 models)
Traceback (most recent call last):
  File "/home/tom/.local/bin/desk", line 11, in <module>
    sys.exit(main())
  File "/home/tom/dev/Dusty-Evolved-Star-Kit/desk/main.py", line 33, in main
    func(**funcargs)
  File "/home/tom/dev/Dusty-Evolved-Star-Kit/desk/console_commands.py", line 155, in fit
    full_outputs, full_model_grid = full_grid.retrieve(full_grid_params)
  File "/home/tom/dev/Dusty-Evolved-Star-Kit/desk/set_up/full_grid.py", line 80, in retrieve
    unique_luminosities = generate_model_luminosities(full_grid_params.n)
  File "/home/tom/dev/Dusty-Evolved-Star-Kit/desk/set_up/full_grid.py", line 45, in generate_model_luminosities
    np.log10(config.fitting["lum_min"]), np.log10(config.fitting["lum_max"]), n
  File "<__array_function__ internals>", line 6, in logspace
  File "/home/tom/.local/lib/python3.6/site-packages/numpy/core/function_base.py", line 263, in logspace
    y = linspace(start, stop, num=num, endpoint=endpoint, axis=axis)
  File "<__array_function__ internals>", line 6, in linspace
  File "/home/tom/.local/lib/python3.6/site-packages/numpy/core/function_base.py", line 115, in linspace
    raise ValueError("Number of samples, %s, must be non-negative." % num)
ValueError: Number of samples, -1, must be non-negative.

If you suspect this is an IPython 7.16.1 bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True

$ desk fit --source='desk/put_target_data_here/MSX_LMC_807.csv' --grid='oxygen' --n=0

You already have the grid!

Scaling to full grid (0 models)
Traceback (most recent call last):
  File "/home/tom/.local/bin/desk", line 11, in <module>
    sys.exit(main())
  File "/home/tom/dev/Dusty-Evolved-Star-Kit/desk/main.py", line 33, in main
    func(**funcargs)
  File "/home/tom/dev/Dusty-Evolved-Star-Kit/desk/console_commands.py", line 155, in fit
    full_outputs, full_model_grid = full_grid.retrieve(full_grid_params)
  File "/home/tom/dev/Dusty-Evolved-Star-Kit/desk/set_up/full_grid.py", line 85, in retrieve
    full_grid_params.scaling_factor_flux_to_Lsun,
  File "/home/tom/dev/Dusty-Evolved-Star-Kit/desk/set_up/scale_dusty.py", line 81, in scale
    full_outputs = vstack(([_outputs] * len(luminosities)))
  File "/home/tom/.local/lib/python3.6/site-packages/astropy/table/operations.py", line 376, in vstack
    tables = _get_list_of_tables(tables)  # validates input
  File "/home/tom/.local/lib/python3.6/site-packages/astropy/table/operations.py", line 50, in _get_list_of_tables
    raise ValueError('no values provided to stack.')
ValueError: no values provided to stack.

If you suspect this is an IPython 7.16.1 bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True

Expected behavior See above

Additional context