Re: Mean-Variance-Standard Deviation Calculator

Regarding this project: mean-variance-standard-deviation-calculator

I just want to report something that I think should be reworded:

The readme says this:

The input of the function should be a list containing 9 digits. The function should convert the list into a 3 x 3 Numpy array…

And

If a list containing less than 9 elements is passed into the function, it should raise a ValueError exception

The third test test_calculate_with_few_digits is fine as it is, however, I don’t understand why we are not told to also provide a condition if there are too many digits.

I understand that the main purpose of the project is to utilize numpy and it’s various methods. The point I am making is that without the right conditional checks on the input, numpy will have a value error. This is something that a programmer should be aware of and should work out in their code.

This is just along the lines of trying to form good habits in thinking about solving problems. I don’t think we want sewage in our water because someone didn’t account for all the factors in their code. Crazy things have happened.

import numpy as np
np.array([0,1,2,3,4,5,6,7,8]).reshape(3,3)
np.array([0,1,2,3,4,5,6,7]).reshape(3,3) # ValueError
np.array([0,1,2,3,4,5,6,7,8,9]).reshape(3,3) # ValueError

My suggestion:

Add another test (test_calculate_with_many_digits to the project to test for too many digits.

Reword the one paragraph in the project readme to be something like this:

If a list containing more or less than 9 elements is passed into the function, it should raise a ValueError exception …

Cheers! :sunglasses:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.