loading all filters with a wild card crashes impolitely
Closed this issue · 3 comments
moustakas commented
This works fine
decam = filters.load_filters('decam2014-*')
but this causes doom and destruction:
decam = filters.load_filters('decam2014*')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-76-017fef935f54> in <module>()
----> 1 decam = filters.load_filters('decam2014*')
/usr/local/lib/python2.7/site-packages/speclite-0.4.dev338-py2.7.egg/speclite/filters.pyc in load_filters(*names)
1504 responses = []
1505 for name in names_to_load:
-> 1506 responses.append(load_filter(name))
1507 return FilterSequence(responses)
1508
/usr/local/lib/python2.7/site-packages/speclite-0.4.dev338-py2.7.egg/speclite/filters.pyc in load_filter(name, load_from_cache, verbose)
1571 'data/filters/{0}.ecsv'.format(name))
1572 if not os.path.isfile(file_name):
-> 1573 raise ValueError('No such filter file "{0}".'.format(file_name))
1574 if verbose:
1575 print('Loading filter response from "{0}".'.format(file_name))
ValueError: No such filter file "/usr/local/lib/python2.7/site-packages/speclite-0.4.dev338-py2.7.egg/speclite/data/filters/decam2014*.ecsv".
dkirkby commented
The error message could certainly be improved here, or do you think passing a bad string should not raise a ValueError at all?
dkirkby commented
This case is now unit-tested and raises a ValueError with the more helpful message:
ValueError: Invalid wildcard pattern 'decam2014*'. Use '<group>-*'.
I also added a few other new error messages to handle common problems:
ValueError: No such group 'sdss'. Choose one of ['sdss2010', 'decam2014', 'wise2010', 'bessell'].
ValueError: Invalid filter name 'nosuch'. Use '<group>-<band>'.
ValueError: No such filter 'sdss2010-y' in this group.
I just committed the changes to the master branch.
moustakas commented
This look good to me; feel free to close.