MBravoS / splotch

Simple PLOTs, Contours and Histograms is a small package with wrapper functions designed to simplify plotting calls from matplotlib.
BSD 3-Clause "New" or "Revised" License
5 stars 0 forks source link

splotch.subplots() should raise exception if ha or va not recognised #63

Closed AstroRobin closed 3 years ago

AstroRobin commented 3 years ago

When passing strings into ha and va in splotch.subplots(), if a string is not recognised, instead of raising an error, the function will continue and take the default value instead. This is an issue for example if the user spells 'centre' as 'center'.

MBravoS commented 3 years ago

Should both "centre" and "center" spellings be accepted and lead to the same result? Or should we go for only one? I would need to check, but if we decide the latter then we should follow what matplotlib does (which I guess is "center").

AstroRobin commented 3 years ago

Yes, in fact, I have now implemented the following validation:

# Validate ha and va:
ha = 'centre' if ha == 'center' else ha
va = 'centre' if va == 'center' else va
if ha not in ['left','right','centre']:
    raise ValueError(f"'{ha}' was not recognised for `ha`, must be one of 'left', 'right' or 'centre'")
if va not in ['top','bottom','centre']:
    raise ValueError(f"'{va}' was not recognised for `va`, must be one of 'top', 'bottom' or 'centre'")
AstroRobin commented 3 years ago

Fixed as of 0.5.4.5.