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

Modify _create_indexfun to create functions that allow custom types #42

Closed
MartinuzziFrancesco opened this issue Feb 27, 2024 · 0 comments · Fixed by #43
Closed

Modify _create_indexfun to create functions that allow custom types #42

MartinuzziFrancesco opened this issue Feb 27, 2024 · 0 comments · Fixed by #43

Comments

@MartinuzziFrancesco
Copy link
Member

The problem here is relatively straightforward. At the moment the implementation of _create_indexfun simply writes the spectral indices formulas as julia functions as they are. This works fine, but the limitation is that only Float64 computation is possible. This is because some of the formulas contain constant parameters that default to Float64.

in order to navigate around the problem we would need a more specific implementation of _create_indexfun that does two things:

  • creates kwargs out of constant parameters like so INDEX(a::Number, b::Number, c::Number; const1::Number=1.0) = [formula]
  • additionally, we would have a type argument, that defaults to Float64, and wraps the kwargs constants. Building on the previous example it would be something like INDEX(::Type{T}, a::Number, b::Number, c::Number; const1::Number=T(1.0)) where {T <: Number} = [formula]

After this is done there should be some restructure of the existing codebase to adapt all user facing functions to add this as an argument: compute_index(index_name, params, ::Type{T}) where {T <: Number}

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

Successfully merging a pull request may close this issue.

1 participant