COMPUTE_NOT_PURE

RuntimeSeen in: Runs

What happened

compute() changed one of the strategy's own attributes. Forge compares the strategy's attributes before and after compute() runs, and stops when one was added, removed or replaced. The message names the attribute.

Common causes

  • Setting an attribute on self inside compute(), such as self.count = 0.
  • Replacing or deleting an attribute the strategy already had.

What to do

Keep what compute() works out in local variables. compute() gets the data and the settings only, and keeps no state between runs.

Example

text
strategy.py: compute() changed self.count. compute() gets the data and the settings only, and keeps no state between runs. [COMPUTE_NOT_PURE]

The wording of the message depends on your file, and the code does not.

Ask about this in the forum