gpilab / core-nodes

The core nodes are a collection of basic data manipulation and visualization algorithms.
http://docs.gpilab.com/en/develop/NodeDev/devguide.html
BSD 3-Clause "New" or "Revised" License
11 stars 6 forks source link

Bug in Dimensions node #47

Open JuanCab opened 2 years ago

JuanCab commented 2 years ago

When running through the YouTube Tutorial 1.3 video I discovered that the Dimension node in that video would trigger a crash when set to 'Tile' as a 4 column by 3 row set of images and then hitting compute. The error message was

Traceback (most recent call last):
  File "/Users/XXXX/miniforge3/envs/gpi_env/lib/python3.7/site-packages/gpi/functor.py", line 378, in run
    self._proxy.append(['retcode', self._func()])
  File "/Users/XXXXX/miniforge3/envs/gpi_env/lib/python3.7/site-packages/gpi_core/shapers/GPI/Dimensions_GPI.py", line 616, in compute
    out.shape = self.shape
ValueError: cannot reshape array of size 691200 into shape ()

A quick investigation showed that if the initUI(self) function in the class is run, then we get a crash. In certain situations when this initUI(self) is not run (for example, removing the connection to the Dimensions node and reconnecting it only triggers validate(self) and compute(self)), the function works as advertised. In InitUI(self) we set self.shape = [], which may be a problem in that an empty tuple is then used for the shape, which causes a problem when trying to reshape the array later.

Interestingly running InitUI(self) followed by validate(self) and compute(self) still triggers the problem even through validate(self) is supposed to set the self.shape value. A little bit of poking around confirmed that the initial validate(self) after initUI(self) if we have op==8 ('Tile') set doesn't appear to actually initialize self.shape. not sure where the initialization should take place in the validate(self) function, but it is likely the bug fix needs to be there.

JuanCab commented 2 years ago

The Workaround is to not use the Dimensions node to tile and instead use the capacity to tile that is built in to ImageDisplay (likely added after the 8 year old tutorials were developed).

JuanCab commented 2 years ago

This should be reopened, pull request #49 did NOT in fact fix this problem! I manually applied the pull request edits and get the following error:

Fri Jan 21 11:54:12 2022 - gpi.functor:380 - ERROR - PROCESS: 'Dimensions':'' compute() failed.
Traceback (most recent call last):
  File "/Users/XXXXX/miniforge3/envs/gpi_env/lib/python3.7/site-packages/gpi/functor.py", line 378, in run
    self._proxy.append(['retcode', self._func()])
  File "/Users/XXXXX/miniforge3/envs/gpi_env/lib/python3.7/site-packages/gpi_core/shapers/GPI/Dimensions_GPI.py", line 616, in compute
    out.shape = self.shape
TypeError: 'numpy.float64' object cannot be interpreted as an integer