<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Advanced
Step1:  As always, let's do imports and initialize a logger and a new bundle.  See Building a System for more details.
Step2:  Enabling/Disabling Logging History
Undo and redo support is built directly into the bundle.  Every time you make a change to a parameter or call a method, a new Parameter is created with the 'history' context.  These parameters then know how to undo or redo that action.  Of course, this can result in a large list of Parameters that you may not want - see the tutorial on Settings for more details on how to change the log size or enable/disable history entirely.
By default history logging is off, so let's first enable it.
Step3:  Undoing
First let's set a value so we know what we're expecting to undo
Step4:  The history context contains a list of parameters, all numbered and ugly.  But there is a convenience method which allows you to get history items by index - including reverse indexing.  This is probably the most common way to get a history item... and you'll most likely want the LATEST item.
Step5:  Here you can see that redo_func and redo_kwargs shows exactly the last call we made to the bundle that actually changed something (we did b['ra@system'] = 10).  
We can also look at what will be called when we undo this item
Step6:  If we want, we can then automatically call that undo method (note that you can also pass the index to undo, but it does assume -1 by default)
Step7:  And we can see that it did exactly what we expected.
<ASSISTANT_TASK:>
Python Code:
!pip install -I "phoebe>=2.1,<2.2"
Explanation: Advanced: Undo/Redo
Setup
Let's first make sure we have the latest version of PHOEBE 2.1 installed. (You can comment out this line if you don't use pip for your installation or don't want to update to the latest release).
End of explanation
%matplotlib inline
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt
logger = phoebe.logger(clevel='INFO')
b = phoebe.default_binary()
Explanation: As always, let's do imports and initialize a logger and a new bundle.  See Building a System for more details.
End of explanation
b.enable_history()
Explanation: Enabling/Disabling Logging History
Undo and redo support is built directly into the bundle.  Every time you make a change to a parameter or call a method, a new Parameter is created with the 'history' context.  These parameters then know how to undo or redo that action.  Of course, this can result in a large list of Parameters that you may not want - see the tutorial on Settings for more details on how to change the log size or enable/disable history entirely.
By default history logging is off, so let's first enable it.
End of explanation
b['ra@system']
b['ra@system'] = 10
b['ra@system']
Explanation: Undoing
First let's set a value so we know what we're expecting to undo
End of explanation
b.get_history(-1)
print b.get_history(-1)['redo_func'], b.get_history(-1)['redo_kwargs']
Explanation: The history context contains a list of parameters, all numbered and ugly.  But there is a convenience method which allows you to get history items by index - including reverse indexing.  This is probably the most common way to get a history item... and you'll most likely want the LATEST item.
End of explanation
print b.get_history(-1)['undo_func'], b.get_history(-1)['undo_kwargs']
Explanation: Here you can see that redo_func and redo_kwargs shows exactly the last call we made to the bundle that actually changed something (we did b['ra@system'] = 10).  
We can also look at what will be called when we undo this item
End of explanation
b.undo()
Explanation: If we want, we can then automatically call that undo method (note that you can also pass the index to undo, but it does assume -1 by default)
End of explanation
b['ra@system']
Explanation: And we can see that it did exactly what we expected.
End of explanation
<END_TASK>