normal-computing / thermox

Exact OU processes with JAX
Apache License 2.0
31 stars 6 forks source link

Fix how sample function handles Processed inputs #25

Closed denismelanson closed 4 months ago

denismelanson commented 4 months ago

Fixes #22

denismelanson commented 4 months ago

We should write tests to ensure that these different types of inputs are handled properly going forward. I'm still new to this repo, so I would like some guidance as to how to write the tests for these functions.

KaelanDt commented 4 months ago

We should write tests to ensure that these different types of inputs are handled properly going forward. I'm still new to this repo, so I would like some guidance as to how to write the tests for these functions.

Indeed this wasn't properly tested, so good idea. I realise we don't really have tests for the sampler functions by themselves (only by proxy in the test_log_prob.py file, so it could be good to write one an include an example with ProcessedDriftMatrix and ProcessedDiffusionMatrix if you want! You can look at these tests https://github.com/normal-computing/thermox/blob/main/tests/test_log_prob.py for inspiration

SamDuffield commented 4 months ago

Tests could definitely do with an upgrade, I would be in favour of having refactoring to have test file for each code file, i.e. test_linalg.py, test_prob.py, test_sampler.py, test_utils.py

denismelanson commented 4 months ago

I see a potential problem with how this function handles ProcessedDriftMatrix. Reading the docs, it seems like for the A argument, one can use an array representing the drift matrix or a ProcessedDriftMatrix instance generated by utils.preprocess_drift_matrix. However, the code actually needs the transformed and preprocessed A_y matrix generated by utils.preprocess. This seemed unintuitive to me and caused me some confusion, so I imagine it could for other users as well.

I'm wondering if we could fix this by simply adding more details in the docstring of the function. Alternatively, we could remove the support for Processed inputs and always ensure we preprocess the inputs the correct way.