Skip to content

Graph live update exception

Hi, I have an issue when updating graph with yade running 'live':

Unhandled exception in thread started by <function liveUpdate at 0x7f3782de2e18>
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/william/Yade/install/lib/x86_64-linux-gnu/yade-mybuild/py/yade/plot.py in liveUpdate(timestamp)
    512                         for ax in axes:
    513                                 try:
--> 514                                         ax.relim() # recompute axes limits
    515                                         ax.autoscale_view()
    516                                 except RuntimeError: pass # happens if data are being updated and have not the same dimension at the very moment

/usr/lib/python3/dist-packages/matplotlib/axes/_base.py in relim(self, visible_only)
   1936         for line in self.lines:
   1937             if not visible_only or line.get_visible():
-> 1938                 self._update_line_limits(line)
   1939 
   1940         for p in self.patches:

/usr/lib/python3/dist-packages/matplotlib/axes/_base.py in _update_line_limits(self, line)
   1799         Figures out the data limit of the given line, updating self.dataLim.
   1800         """
-> 1801         path = line.get_path()
   1802         if path.vertices.size == 0:
   1803             return

/usr/lib/python3/dist-packages/matplotlib/lines.py in get_path(self)
    955         """
    956         if self._invalidy or self._invalidx:
--> 957             self.recache()
    958         return self._path
    959 

/usr/lib/python3/dist-packages/matplotlib/lines.py in recache(self, always)
    665             y = self._y
    666 
--> 667         self._xy = np.column_stack(np.broadcast_arrays(x, y)).astype(float)
    668         self._x, self._y = self._xy.T  # views
    669 

/usr/lib/python3/dist-packages/numpy/lib/stride_tricks.py in broadcast_arrays(*args, **kwargs)
    247     args = [np.array(_m, copy=False, subok=subok) for _m in args]
    248 
--> 249     shape = _broadcast_shape(*args)
    250 
    251     if all(array.shape == shape for array in args):

/usr/lib/python3/dist-packages/numpy/lib/stride_tricks.py in _broadcast_shape(*args)
    182     # use the old-iterator because np.nditer does not handle size 0 arrays
    183     # consistently
--> 184     b = np.broadcast(*args[:32])
    185     # unfortunately, it cannot handle 32 or more arguments directly
    186     for pos in range(32, len(args), 31):

ValueError: shape mismatch: objects cannot be broadcast to a single shape

My update function is very standard and this happens randomly

plot.plots={'time':('totalStress_yy',
                    'normalContactStress_yy',
                    'shearContactStress_yy',
                    'normalLubrifStress_yy',
                    'shearLubrifStress_yy',
                    'kineticStress_yy'),
            'time2':('phi'),
            'time3':('totalStress_xy',
                     'normalContactStress_xy',
                     'shearContactStress_xy',
                     'normalLubrifStress_xy',
                     'shearLubrifStress_xy',
                     'kineticStress_xy'),
			'time4': ('correction')};

plot.plot(subPlots=True);

def UpPlot():
        global th_lastValue, m_stopOnStrain;
        [normalContactStress, shearContactStress, normalLubrifStress, shearLubrifStress] = Law2_ScGeom_ImplicitLubricationPhys.getTotalStresses();
        kineticStress = getTotalDynamicStress();
        
        totalStress = normalContactStress + shearContactStress + normalLubrifStress + shearLubrifStress + kineticStress;
        
        th_lastValue = th_lastValue[1:] + [abs(totalStress[1,1])];
        phi = 1.-porosity();
        
        if abs(O.cell.hSize[0,1]/O.cell.hSize[0,0]) > 1:
            flipCell();
            
        plot.addData(
                totalStress = totalStress,
                totalStress2 = getStress(),
                kineticStress = kineticStress,
                normalContactStress = normalContactStress,
                shearContactStress = shearContactStress,
                normalLubrifStress = normalLubrifStress,
                shearLubrifStress = shearLubrifStress,
                phi = phi,
                iter = O.iter,
                strain = O.cell.trsf,
                time = O.time,
                time2 = O.time,
                time3 = O.time,
                time4 = O.time,
                correction = O.cell.velGrad[1][1]);