Text
I’m pleased to announce the release of GarlicSim 0.6.1! (Installation.)
This is a small release, but it has a bunch of interesting features:
garlicsim.general_misc.context_manager has been added. I will blog about it soon.garlicsim_lib.simpacks.GarlicSim.py now launches the GUI. It gets installed automatically in your Python scripts folder.A big feature of this release is that simpacks are now allowed to define their step function in the form of an inplace step function or an inplace step generator. What does that mean?
A simple step function takes the old state and returns the new one, like so:
def step(self):
return State(self.height + 1)
But an inplace step function changes the place in place, like this:
def inplace_step(self):
self.height += 1
But wait, you say. How can we modify a state in place? GarlicSim needs to keep all the states in a time tree as constants, if states will be modified in place, it will ruin the whole thing!
Well, GarlicSim is smart, and when it uses an inplace step function, it duplicates the state before feeding it to the step function on every iteration, so that the original state and all produced states that go to the tree are left unaltered.
One more advantage that the inplace step has is that if you use garlicsim.simulate with it, the step will actually be done in place for better performance, without duplicating on every iteration. For example, if you give garlicsim.simulate an initial state and tell it to do 100 iterations, it will first deepcopy your initial state, then perform 100 iterations of the inplace step function in place, and then return the resulting state. This is done only in garlicsim.simulate, and not in garlicsim.Project, because garlicsim.simulate is the only function that doesn’t reveal the interim states to the user, so we can afford not to keep them as constants.
More info about inplace step functions/generators here.
Go on and install GarlicSim 0.6.1!