Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditions never met adapt_grid() #5

Open
avigan opened this issue Oct 3, 2024 · 0 comments
Open

Conditions never met adapt_grid() #5

avigan opened this issue Oct 3, 2024 · 0 comments

Comments

@avigan
Copy link
Contributor

avigan commented Oct 3, 2024

Looking at the adapt_grid.py module I think there are some problems with conditions that can never be met:

https://github.com/exoAtmospheres/ForMoSA/blob/aa43396a094aff925af8456eff2d7d4d46083156/ForMoSA/adapt/adapt_grid.py#L97C1-L98C1

nan_mod_ind = ~np.isnan(model_to_adapt)
if len(np.where(nan_mod_ind is False)[0]) == 0:
    mod_spectro, mod_photo = adapt_model(global_params, wav_mod_nativ, model_to_adapt, res_mod_obs_merge, obs_name=obs_name, indobs=indobs)

Even if there are many NaN in model_to_adapt, the condition len(np.where(nan_mod_ind is False)[0]) == 0 will always be True. This is because nan_mod_ind is an ndarray so it will never be False. The test is False is extremely specific: it means that nan_mod_ind must be the object False.

Proposed solution:

nan_mod_ind = np.isnan(model_to_adapt)
if np.any(nan_mod_ind):
    ... # print error message
else:
    mod_spectro, mod_photo = adapt_model(global_params, wav_mod_nativ, model_to_adapt, res_mod_obs_merge, obs_name=obs_name, indobs=indobs)

np.any(nan_mod_ind) check if any of the elements in nan_mod_ind is True.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant