Skip to content

Fix GensetModule.sample_action() raising TypeError on strict_bound=True - #120

Open
petermllrr wants to merge 1 commit into
ahalev:masterfrom
petermllrr:master
Open

Fix GensetModule.sample_action() raising TypeError on strict_bound=True#120
petermllrr wants to merge 1 commit into
ahalev:masterfrom
petermllrr:master

Conversation

@petermllrr

@petermllrr petermllrr commented Jun 5, 2026

Copy link
Copy Markdown

Fixes #119

Replaces the delegation to super().sample_action() in GensetModule with an implementation that handles the module's 2-dimensional action space.

GensetModule defines a 2D action space [on_off_flag, power_setpoint], but its sample_action delegated the power component to BaseModule.sample_action(). BaseModule assumes a scalar action space and calls self._action_space.normalize(self.max_production), passing a scalar into a shape-(2,) space. The shape check in space.py then raises:

TypeError: Unable to normalize scalar value, expected array-like of shape 2

📚 Documentation preview 📚: https://python-microgrid--120.org.readthedocs.build/en/120/

@ahalev

ahalev commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Could you add a unit test in test_genset_module.py with an example of the failure this PR fixes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GensetModule.sample_action() raises TypeError when called via Microgrid.sample_action(strict_bound=True)

2 participants