Closed JonasMoss closed 1 week ago
I think adding attributes to the ml***
functions (https://github.com/JonasMoss/univariateML/issues/39) would make this much easier.
Added automatic checks for testing the logLik. I don't think the remaining tests, such as tests for support, would be meaningful to automatize, as they are already handled by the "decorator" functon in conjunction with metadata. This is solved for now.
Currently, most of the automated tests for the
ml***
functions are copy-pasta. This has two downsides: 1.) It is hard to verify if each test is complete. 2.) I we want to implement more tests or change the object structure, we would have to modify 22 tests.One test file that avoids this problem is
test_input_checks.R
. This goes through everyml***
file with just a couple of lines.Most of the tests are straight-forward such as checking whether the input checks work, if the objects have all the needed attributes, etc. I propose the following pattern:
Then
These function attributes can then be used to do both testing and populating attributes of the
univariateML
objects. Takemlcauchy
and considerThis setup allows us to test a lot of things easily (currently untested), such as the existence of the appropriate
d***
andr***
functions and whether the parameter names are correct. (They should be the first parameters afterx
.)Potential problems: The attributes can be removed from the function
mlcauchy
, which will break the function in most scenarios. An alternative is to start each function with a variable such asname = quote(mlcauchy)
which identifies the function instead of usingmatch.call()
.