CDAT / cdms

8 stars 10 forks source link

cdms2.setAutoBounds(wrong_param) should generate an error #429

Open jypeter opened 3 years ago

jypeter commented 3 years ago

I had forgotten once again the exact parameters of cdms2.setAutoBounds and the help is still not showing much in cdms 3.2.5 (I remember an issue about help/docstrings, but can't find it)

>>> help(cdms2.setAutoBounds)
Help on function setAutoBounds in module cdms2.axis:
setAutoBounds(mode)
(END)

So I just thought I'd give a crappy argument to setAutoBounds and I would get an error message telling me what the allowed arguments are. Except that crappy arguments are just silently ignored! Printing an error message would be safer and more useful

>>> cdms2.setAutoBounds('crap')
>>> cdms2.getAutoBounds()
2
>>> cdms2.setAutoBounds(20)
>>> cdms2.getAutoBounds()
2
>>> cdms2.setAutoBounds('off')
>>> cdms2.getAutoBounds()
0
>>> cdms2.setAutoBounds(20)
>>> cdms2.getAutoBounds()
0
>>> cdms2.setAutoBounds(-3.14)
>>> cdms2.getAutoBounds()
0

I resorted to finding the setAutoBounds doc in readthedocs but I sometimes wonder if I'm the only person reading the documentation

BTW, the documentation says Note: In versions of CDMS prior to V4.0, the default mode was 'on' but nothing about the current default, which seems to be grid.