Plotting only m=0 for axial_waveguide spectrum produces an error
The error is related to the color scaling.
/Users/lkoerber/Documents/programming/tetrax/tetrax/_plotting/plotly.py:312: RuntimeWarning:
invalid value encountered in scalar divide
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[8], line 1
----> 1 spectrum.plot(m=0,n=0)
File ~/Documents/programming/tetrax/tetrax/experiments/eigen/result.py:456, in EigenResult.plot(self, *args, **kwargs)
454 def plot(self: Self, *args, **kwargs) -> None:
455 """Wrapper for :func:`plot_frequencies`.""" # noqa: D401
--> 456 self.plot_frequencies(*args, **kwargs)
File ~/Documents/programming/tetrax/tetrax/experiments/eigen/result.py:512, in EigenResult.plot_frequencies(self, n, k, m, style, fscale, kscale)
507 k = rescale_plotting_k(k, kscale.factor)
509 reduced_data = _reduced_dataframe(
510 self, FREQUENCY_COLUMN_PATTERN, n, k, m, include_km=True
511 )
--> 512 plotly_plot_spectral_data(
513 reduced_data,
514 self.result_info.sample_snapshot.geometry_type,
515 style,
516 fscale,
517 kscale,
518 )
File ~/Documents/programming/tetrax/tetrax/_plotting/plotly.py:312, in plotly_plot_spectral_data(dataframe_with_km, geometry_type, style, fscale, kscale)
306 df_m = dataframe_with_km[
307 dataframe_with_km[AZIMUTHAl_INDEX_COLUMN_NAME] == m
308 ]
310 k = df_m[WAVEVECTOR_COLUMN_NAME]
--> 312 linecolor = px.colors.sample_colorscale(cmap, abs(m) / m_max_abs * 0.9)[0]
313 linestyle = (
314 {"dash": "dash", "color": linecolor} if m < 0 else {"color": linecolor}
315 )
317 for header in frequency_headers:
File ~/miniconda3/lib/python3.12/site-packages/_plotly_utils/colors/__init__.py:885, in sample_colorscale(colorscale, samplepoints, low, high, colortype)
883 sampled_color = find_intermediate_color(colors[low], colors[high], interpolant)
884 sampled_colors.append(sampled_color)
--> 885 return validate_colors(sampled_colors, colortype=colortype)
File ~/miniconda3/lib/python3.12/site-packages/_plotly_utils/colors/__init__.py:369, in validate_colors(colors, colortype)
367 if colortype == "rgb" and not isinstance(colors, str):
368 for j, each_color in enumerate(colors):
--> 369 rgb_color = color_parser(each_color, convert_to_RGB_255)
370 colors[j] = color_parser(rgb_color, label_rgb)
372 return colors
File ~/miniconda3/lib/python3.12/site-packages/_plotly_utils/colors/__init__.py:296, in color_parser(colors, function)
293 return function(colors)
295 if isinstance(colors, tuple) and isinstance(colors[0], Number):
--> 296 return function(colors)
298 if hasattr(colors, "__iter__"):
299 if isinstance(colors, tuple):
File ~/miniconda3/lib/python3.12/site-packages/_plotly_utils/colors/__init__.py:667, in convert_to_RGB_255(colors)
663 rounded_num = decimal.Decimal(str(component * 255.0)).quantize(
664 decimal.Decimal("1"), rounding=decimal.ROUND_HALF_EVEN
665 )
666 # convert rounded number to an integer from 'Decimal' form
--> 667 rounded_num = int(rounded_num)
668 rgb_components.append(rounded_num)
670 return (rgb_components[0], rgb_components[1], rgb_components[2])
ValueError: cannot convert NaN to integer