rwl / PYPOWER

Port of MATPOWER to Python
http://rwl.github.io/PYPOWER/api/
Other
329 stars 110 forks source link

Variable bi in runpf must be converted from float to int #57

Closed rwl closed 3 years ago

rwl commented 4 years ago

In line 245 (image below), the variable bi is indicating the index number which should be an integer. But values stored in the numpy array ‘gen’ are all floats. Thus, the variable should be converted to a float.

https://github.com/rwl/PYPOWER/blob/5e71627fd03ce199e8815765942ddd2da53d30c7/pypower/runpf.py#L245

As reported via email by Aeishwarya Umesh Baviskar

Bengt commented 3 years ago

This causes an error with scipy 1.6.1. So either pin the package version of scipy needs to be pinned to <= 1.6.0, or the casting done as suggested. Workaround:

pip install scipy==1.6.0
Bengt commented 3 years ago

I see errors like these:

Traceback (most recent call last):
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/mosaik/scheduler.py", line 62, in sim_process
    yield from step(world, sim, input_data)
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/mosaik/scheduler.py", line 236, in step
    next_step = yield sim.proxy.step(sim.next_step, inputs)
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/mosaik_api.py", line 387, in wrapper
    ret = func(*args, **kwargs)
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/mosaik_pypower/mosaik.py", line 178, in step
    res.append(model.perform_powerflow(ppc))
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/mosaik_pypower/model.py", line 94, in perform_powerflow
    res = runpf(case, ppo)
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/pypower/runpf.py", line 94, in runpf
    ppc = ext2int(ppc)
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/pypower/ext2int.py", line 120, in ext2int
    bs[ n2i[ppc["gen"][:, GEN_BUS].astype(int)] ] )
IndexError: arrays used as indices must be of integer (or boolean) type
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/test/test_demo.py", line 11, in test_demo_run_for_one_minute
    run_for_one_minute()
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/mosaik_demo/demo/demo.py", line 56, in run_for_one_minute
    main(end=ONE_MINUTE_IN_SECONDS)
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/mosaik_demo/demo/demo.py", line 63, in main
    world.run(until=end)  # As fast as possible
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/mosaik/scenario.py", line 295, in run
    sync_process(scheduler.run(self, until, rt_factor, rt_strict),
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/mosaik/util.py", line 126, in sync_process
    return world.env.run(until=world.env.process(generator))
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/simpy/core.py", line 254, in run
    self.step()
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/simpy/io/base.py", line 81, in step
    callback(event)
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/simpy/core.py", line 85, in callback
    raise event._value
  File "/builds/offis.energy/mosaik/mosaik.demo_semver/.tox/py38/lib/python3.8/site-packages/mosaik/scheduler.py", line 40, in run
    yield env.all_of(processes)
IndexError: arrays used as indices must be of integer (or boolean) type

Source: https://gitlab.com/offis.energy/mosaik/mosaik.demo_semver/-/jobs/1047571971