pymc-devs / nuts-rs

A implementation of NUTS in rust
MIT License
57 stars 3 forks source link

README example doesn't compile #15

Closed hombit closed 11 months ago

hombit commented 1 year ago
error[E0609]: no field `step_size_adapt` on type `SamplerArgs`
   --> src/nl_fit/nuts.rs:293:22
    |
293 |         sampler_args.step_size_adapt.target = 0.8;
    |                      ^^^^^^^^^^^^^^^ unknown field
    |
    = note: available fields are: `num_tune`, `num_draws`, `maxdepth`, `store_gradient`, `store_unconstrained` ... and 3 others

error[E0609]: no field `store_mass_matrix` on type `nuts_rs::adapt_strategy::GradDiagOptions`
   --> src/nl_fit/nuts.rs:296:40
    |
296 |         sampler_args.mass_matrix_adapt.store_mass_matrix = true;
    |                                        ^^^^^^^^^^^^^^^^^ unknown field
    |
    = note: available fields are: `dual_average_options`, `mass_matrix_options`, `early_window`, `step_size_window`, `mass_matrix_switch_freq`, `early_mass_matrix_switch_freq`
help: one of the expressions' fields has a field of the same name
    |
296 |         sampler_args.mass_matrix_adapt.mass_matrix_options.store_mass_matrix = true;
    |                                        ++++++++++++++++++++

error[E0308]: mismatched types
   --> src/nl_fit/nuts.rs:303:71
    |
303 |         let mut sampler = new_sampler(logp_func, sampler_args, chain, seed);
    |                           -----------                                 ^^^^ expected `&mut _`, found integer
    |                           |
    |                           arguments to this function are incorrect
    |
    = note: expected mutable reference `&mut _`
                            found type `{integer}`
note: function defined here
   --> /Users/hombit/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nuts-rs-0.8.0/src/cpu_sampler.rs:184:8
    |
184 | pub fn new_sampler<F: CpuLogpFunc, R: Rng + ?Sized>(
    |        ^^^^^^^^^^^
help: consider mutably borrowing here
    |
303 |         let mut sampler = new_sampler(logp_func, sampler_args, chain, &mut seed);
    |                                                                       ++++

error[E0599]: no method named `to_vec` found for associated type `<impl nuts_rs::Chain as nuts_rs::Chain>::Stats` in the current scope
   --> src/nl_fit/nuts.rs:314:34
    |
314 |             let _info_vec = info.to_vec(); // We can collect the stats in a Vec
    |                                  ^^^^^^ method not found in `<impl Chain as Chain>::Stats`

error[E0599]: no method named `start_location` found for reference `&DivergenceInfo` in the current scope
   --> src/nl_fit/nuts.rs:317:66
    |
317 |                 println!("Divergence at position {:?}", div_info.start_location());
    |                                                                  ^^^^^^^^^^^^^^-- help: remove the arguments
    |                                                                  |
    |                                                                  field, not a method
aseyboldt commented 1 year ago

Thanks for letting us know. Seems I forgot to update the readme with the contents of lib.rs. Should be fixed by #16

aseyboldt commented 11 months ago

Should be fixed on main