avoid nested functions for readability
avoid nested functions for readability

zasdfgbnm/qutip,zasdfgbnm/qutip,qutip/qutip,anubhavvardhan/qutip,qutip/qutip,cgranade/qutip,anubhavvardhan/qutip,cgranade/qutip