You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ValueErrorTraceback (mostrecentcalllast)
CellIn[20], line3932interpolator=Lasso()
33#interpolator = LinearRegression()--->39interpolPlot(df, gdf_shape, 'longitude','latitude', 'pm25', interpolator, resolution=50, partitions=15, cmap='inferno', Tcolor='k', markersize=0.3, plot_train_points=True, extrapolate=True)
File~\anaconda3\lib\site-packages\vayu\interpolPlot.py:191, ininterpolPlot(df, shape_df, long, lat, pollutant, Interpolator, resolution, partitions, cmap, Tcolor, markersize, plot_train_points, extrapolate)
188ax.legend()
190bounds=np.linspace(vmin, vmax, partitions)
-->191fig.colorbar(sm, cax=cax, ticks=bounds,
192boundaries=bounds, format="%.2f")
193returnaxFile~\anaconda3\lib\site-packages\matplotlib\figure.py:1293, inFigureBase.colorbar(self, mappable, cax, ax, use_gridspec, **kwargs)
1289NON_COLORBAR_KEYS= ['fraction', 'pad', 'shrink', 'aspect', 'anchor',
1290'panchor']
1291cb_kw= {k: vfork, vinkwargs.items() ifknotinNON_COLORBAR_KEYS}
->1293cb=cbar.Colorbar(cax, mappable, **cb_kw)
1295ifnotuserax:
1296self.sca(current_ax)
File~\anaconda3\lib\site-packages\matplotlib\_api\deprecation.py:384, indelete_parameter.<locals>.wrapper(*inner_args, **inner_kwargs)
379 @functools.wraps(func)
380defwrapper(*inner_args, **inner_kwargs):
381iflen(inner_args) <=name_idxandnamenotininner_kwargs:
382# Early return in the simple, non-deprecated case (much faster than383# calling bind()).-->384returnfunc(*inner_args, **inner_kwargs)
385arguments=signature.bind(*inner_args, **inner_kwargs).arguments386ifis_varargsandarguments.get(name):
File~\anaconda3\lib\site-packages\matplotlib\colorbar.py:402, inColorbar.__init__(self, ax, mappable, cmap, norm, alpha, values, boundaries, orientation, ticklocation, extend, spacing, ticks, format, drawedges, filled, extendfrac, extendrect, label, location)
399self.ticklocation=ticklocation401self.set_label(label)
-->402self._reset_locator_formatter_scale()
404ifnp.iterable(ticks):
405self._locator=ticker.FixedLocator(ticks, nbins=len(ticks))
File~\anaconda3\lib\site-packages\matplotlib\colorbar.py:1173, inColorbar._reset_locator_formatter_scale(self)
1167def_reset_locator_formatter_scale(self):
1168""" 1169 Reset the locator et al to defaults. Any user-hardcoded changes 1170 need to be re-entered if this gets called (either at init, or when 1171 the mappable normal gets changed: Colorbar.update_normal) 1172 """->1173self._process_values()
1174self._locator=None1175self._minorlocator=NoneFile~\anaconda3\lib\site-packages\matplotlib\colorbar.py:1107, inColorbar._process_values(self)
1105self.norm.vmin=01106self.norm.vmax=1->1107self.norm.vmin, self.norm.vmax=mtransforms.nonsingular(
1108self.norm.vmin, self.norm.vmax, expander=0.1)
1109if (notisinstance(self.norm, colors.BoundaryNorm) and1110 (self.boundariesisNone)):
1111b=self.norm.inverse(b)
File~\anaconda3\lib\site-packages\matplotlib\colors.py:1250, inNormalize.vmin(self, value)
1248ifvalue!=self._vmin:
1249self._vmin=value->1250self._changed()
File~\anaconda3\lib\site-packages\matplotlib\colors.py:1278, inNormalize._changed(self)
1273def_changed(self):
1274""" 1275 Call this whenever the norm is changed to notify all the 1276 callback listeners to the 'changed' signal. 1277 """->1278self.callbacks.process('changed')
File~\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py:309, inCallbackRegistry.process(self, s, *args, **kwargs)
307exceptExceptionasexc:
308ifself.exception_handlerisnotNone:
-->309self.exception_handler(exc)
310else:
311raiseFile~\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py:96, in_exception_printer(exc)
94def_exception_printer(exc):
95if_get_running_interactive_framework() in ["headless", None]:
--->96raiseexc97else:
98traceback.print_exc()
File~\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py:304, inCallbackRegistry.process(self, s, *args, **kwargs)
302iffuncisnotNone:
303try:
-->304func(*args, **kwargs)
305# this does not capture KeyboardInterrupt, SystemExit,306# and GeneratorExit307exceptExceptionasexc:
File~\anaconda3\lib\site-packages\matplotlib\cm.py:665, inScalarMappable.changed(self)
660defchanged(self):
661""" 662 Call this whenever the mappable is changed to notify all the 663 callbackSM listeners to the 'changed' signal. 664 """-->665self.callbacks.process('changed', self)
666self.stale=TrueFile~\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py:309, inCallbackRegistry.process(self, s, *args, **kwargs)
307exceptExceptionasexc:
308ifself.exception_handlerisnotNone:
-->309self.exception_handler(exc)
310else:
311raiseFile~\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py:96, in_exception_printer(exc)
94def_exception_printer(exc):
95if_get_running_interactive_framework() in ["headless", None]:
--->96raiseexc97else:
98traceback.print_exc()
File~\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py:304, inCallbackRegistry.process(self, s, *args, **kwargs)
302iffuncisnotNone:
303try:
-->304func(*args, **kwargs)
305# this does not capture KeyboardInterrupt, SystemExit,306# and GeneratorExit307exceptExceptionasexc:
File~\anaconda3\lib\site-packages\matplotlib\colorbar.py:514, inColorbar.update_normal(self, mappable)
511self.norm=mappable.norm512self._reset_locator_formatter_scale()
-->514self._draw_all()
515ifisinstance(self.mappable, contour.ContourSet):
516CS=self.mappableFile~\anaconda3\lib\site-packages\matplotlib\colorbar.py:579, inColorbar._draw_all(self)
577ifself._extend_upper():
578ind=ind[:-1]
-->579self._add_solids(X, Y, self._values[ind, np.newaxis])
File~\anaconda3\lib\site-packages\matplotlib\colorbar.py:595, inColorbar._add_solids(self, X, Y, C)
593self._add_solids_patches(X, Y, C, mappable)
594else:
-->595self.solids=self.ax.pcolormesh(
596X, Y, C, cmap=self.cmap, norm=self.norm, alpha=self.alpha,
597edgecolors='none', shading='flat')
598ifnotself.drawedges:
599iflen(self._y) >=self.n_rasterize:
File~\anaconda3\lib\site-packages\matplotlib\__init__.py:1442, in_preprocess_data.<locals>.inner(ax, data, *args, **kwargs)
1439 @functools.wraps(func)
1440definner(ax, *args, data=None, **kwargs):
1441ifdataisNone:
->1442returnfunc(ax, *map(sanitize_sequence, args), **kwargs)
1444bound=new_sig.bind(ax, *args, **kwargs)
1445auto_label= (bound.arguments.get(label_namer)
1446orbound.kwargs.get(label_namer))
File~\anaconda3\lib\site-packages\matplotlib\axes\_axes.py:6220, inAxes.pcolormesh(self, alpha, norm, cmap, vmin, vmax, shading, antialiased, *args, **kwargs)
6217shading=shading.lower()
6218kwargs.setdefault('edgecolors', 'none')
->6220X, Y, C, shading=self._pcolorargs('pcolormesh', *args,
6221shading=shading, kwargs=kwargs)
6222coords=np.stack([X, Y], axis=-1)
6223# convert to one dimensional array, except for 3D RGB(A) arraysFile~\anaconda3\lib\site-packages\matplotlib\axes\_axes.py:5717, inAxes._pcolorargs(self, funcname, shading, *args, **kwargs)
5715iffuncname=='pcolormesh':
5716ifnp.ma.is_masked(X) ornp.ma.is_masked(Y):
->5717raiseValueError(
5718'x and y arguments to pcolormesh cannot have '5719'non-finite values or be of type '5720'numpy.ma.core.MaskedArray with masked values')
5721# safe_masked_invalid() returns an ndarray for dtypes other5722# than floating point.5723ifisinstance(X, np.ma.core.MaskedArray):
ValueError: xandyargumentstopcolormeshcannothavenon-finitevaluesorbeoftypenumpy.ma.core.MaskedArraywithmaskedvalues
Reason:
The error is in producing 15(or n) partition in colormesh when lasso is giving a constant value, as constant value cant be divided into 15(or n) partition.
Solution:
As a solution, code should have a try-catch block so it will ignore that error, for smooth execution.
The text was updated successfully, but these errors were encountered:
InterpolPlot: Lasso is giving ValueError in Colormesh
Code:
Error:
Reason:
The error is in producing
15(or n)
partition incolormesh
whenlasso
is giving a constant value, as constant value cant be divided into15(or n)
partition.Solution:
As a solution, code should have a
try-catch
block so it will ignore that error, for smooth execution.The text was updated successfully, but these errors were encountered: