toric.py: rmed: code duplicated in codes.py