Fix exception error in cosm.py