LLNL / MuyGPyS

A fast, pure python implementation of the MuyGPs Gaussian process realization and training algorithm.
Other
25 stars 11 forks source link

Need to refactor `tests/backend` tests to depend upon model choices #126

Closed bwpriest closed 1 year ago

bwpriest commented 1 year ago

Right now, we need to combinatorially make tests for each combination of model choices (e.g. DistortionModel and NoiseModel). It would be preferable to instead make a single test interface that takes these choices as arguments. This might be complicated. The pseudo code would look something like

class ModelChassis(OtherSuperclass):
    @classmethod
    def setUpClass(cls):
        super(OtherSuperClass, cls).setUpClass()

    def __init__(self, noise_model, distortion_model, noise_args, distortion_args):
        # Set up members

    def foo_test(self, *args, **kwargs):
        # do absl testing of specific members

class AllModelTests(SuperClass):
    @classmethod
    def setUpClass(cls):
        super(SuperClass, cls).setUpClass()
        cls.homoscedastic_isotropic_model_tests = ModelChassis(
            HomoscedasticNoise, IsotropicDistortion, [additional_arguments]
        )
        cls.heteroscedastic_isotropic_model_tests = ModelChassis(
            HeteroscedasticNoise, IsotropicDistortion, [additional_arguments]
        )
        cls.homoscedastic_anisotropic_model_tests = ModelChassis(
            HomoscedasticNoise, AnisotropicDistortion, [additional_arguments]
        )
        cls.heteroscedastic_anisotropic_model_tests = ModelChassis(
            HeteroscedasticNoise, AnisotropicDistortion, [additional_arguments]
        )

    def foo_test(self, *args, **kwargs):
        self.homoscedastic_isotropic_model_tests.foo_test(*args, **kwargs)
        self.heteroscedastic_isotropic_model_tests.foo_test(*args, **kwargs)
        self.homoscedastic_anisotropic_model_tests.foo_test(*args, **kwargs)
        self.heteroscedastic_anisotropic_model_tests.foo_test(*args, **kwargs)

    ...

We might be able to figure out a single, implementation-independent chassis for doing this for all backend tests, but that also might not be possible due to the differences between the implementations.

bwpriest commented 1 year ago

This seems to not be possible with the way that the backends are currently configured, and the current solution works well enough.