SURGroup / UQpy

UQpy (Uncertainty Quantification with python) is a general purpose Python toolbox for modeling uncertainty in physical and mathematical systems.
MIT License
271 stars 79 forks source link

AKMCS incorrect handling of samples=None #57

Closed mcfarljm closed 3 years ago

mcfarljm commented 3 years ago

Calling AKMCS.__init__ with the default value of samples=None produces the following error:

    self.dimension = np.shape(self.samples)[1]
IndexError: tuple index out of range

The reason is that AKMCS.__init__ starts by storing self.samples as: https://github.com/SURGroup/UQpy/blob/80884c6578dab6d70a9e83a3e61bf47bdb2e9a99/src/UQpy/SampleMethods.py#L2682

And then it uses the following logic to find the input dimension:

https://github.com/SURGroup/UQpy/blob/80884c6578dab6d70a9e83a3e61bf47bdb2e9a99/src/UQpy/SampleMethods.py#L2703-L2707

This does not work in the case of samples=None (which is actually the default), because array(None) is not None is True.

Perhaps consider using:

self.samples = np.array(samples) if samples is not None else None

Or otherwise the dimension logic could start by checking if samples is not None as opposed to self.samples.

mds2120 commented 3 years ago

Yes, you are correct. We have not correctly addressed the samples=None case. We will fix it.