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

Using Vec<f64> as parameters only works when adding argmin-math as dependency #306

Closed
StefanMathis opened this issue Dec 29, 2022 · 2 comments

Comments

@StefanMathis
Copy link

In a downstream crate, I added argmin 0.7.0 as a dependency (but not argmin-math). I then tried to setup a solver like this:

let solver = NelderMead::new(vec![
    vec![3.0f64, 3.0f64],
    vec![2.0f64, 1.5f64],
    vec![1.0f64, 0.5f64],
]).unwrap();

This fails with the error message that the trait ArgminAdd is not implemented for Vec<f64>. However, once I add argmin-math as a direct dependency of the downstream crate as well, it works (it is not necessary to import the trait).

Is this expected behaviour?

@stefan-k
Copy link
Member

Yes, this is intended and documented in the book. Unfortunately there are currently some difficulties to actually find the book, depending on which path you took ;) I assume that your path was either via the API documentation or the examples, which both so far make no mention of the book. The former is fixed in #270 (but will only go live with the next release) and I will fix the latter by turning the examples into their own crates with dedicated Cargo.toml files hopefully soon.

It may seem a bit tedious having to add both argmin and argmin-math but this split approach has a couple of advantages, in particular in terms of maintainability and in terms of flexibility for the users. For instance, it allows one to cut down on compilation time and code size if needed by enabling one to explicitly specify which functionality is needed.

Apologies for the inconvenience and thanks for this issue, because it really helps improving the "docs experience".

@StefanMathis
Copy link
Author

Thank you for your fast and detailed answer. Your assumptions were correct, I went the path of API documentation + examples.

I think the split approach is the right one, keep up the good work :-) I consider this issue to be resolved.

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

2 participants