My code scans through folders and for every folder plots a graph. However at the moment when using my curve fitting code for one of the graphs it produces a runtime error code as:
RuntimeError: Optimal parameters not found: Number of calls to function has reached maxfev = 5000.
This is annoying because it stops the code and stops the scanning of subsequent folders. Is there any way for the code once the runtime error occurs for it to just skip that snippet of code? So that the rest of the folders are scanned and the subsequent graphs produced.
Advertisement
Answer
Yes, put the code in try block.
try: (CODE TO TRY) except Exception: (Code to execute if error)