|
Wow, their example to "clean up the code" does a bit more than just refactoring to make code more readable, it appears to change the output. One would have to check the resulting code carefully to see if the meaning is still as originally intended, or replaced with code that is more probable to be correct (but no longer working). For instance, it replaces this: if dataset == 'animals':
if dataset == 'turtle':
x_train, y_train, x_test, y_test = datasets.load_turtles(with_bowtie=False)
elif dataset = 'formal_turtle':
x_train, y_train, x_test, y_test = datasets.load_turtles(with_bowtie=True)
else:
with this: if dataset == 'turtle':
x_train, y_train, x_test, y_test = datasets.load_turtles(with_bowtie=False)
elif dataset == 'formal_turtle':
x_train, y_train, x_test, y_test = datasets.load_turtles(with_bowtie=True)
The before-code responds to dataset='animals' with `load_turtles(...)` and to dataset='turtle' or 'formal_turtle' with an error; In the after-code this is reversed, although the apparent logic error and the assignment/equals sign error are resolved. |
I think 'clean up' here means something closer to 'convert this to what I'm trying to write'.