rayopt icon indicating copy to clipboard operation
rayopt copied to clipboard

Matplotlib deprecation warning and numpy TypeError

Open asebian opened this issue 2 years ago • 1 comments

Hi, working through the jupyter tutorial I came across this warning.

ro.Analysis(s)
/usr/local/lib/python3.9/dist-packages/rayopt/analysis.py:163: MatplotlibDeprecationWarning: 
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
  ax.xaxis.set_smart_bounds(True)
/usr/local/lib/python3.9/dist-packages/rayopt/analysis.py:164: MatplotlibDeprecationWarning: 
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
  ax.yaxis.set_smart_bounds(True)
/usr/local/lib/python3.9/dist-packages/rayopt/analysis.py:163: MatplotlibDeprecationWarning: 
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
  ax.xaxis.set_smart_bounds(True)
/usr/local/lib/python3.9/dist-packages/rayopt/analysis.py:164: MatplotlibDeprecationWarning: 
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
  ax.yaxis.set_smart_bounds(True)
/usr/local/lib/python3.9/dist-packages/rayopt/analysis.py:163: MatplotlibDeprecationWarning: 
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
  ax.xaxis.set_smart_bounds(True)
/usr/local/lib/python3.9/dist-packages/rayopt/analysis.py:164: MatplotlibDeprecationWarning: 
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
  ax.yaxis.set_smart_bounds(True)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-25-00344cd64651> in <module>
----> 1 ro.Analysis(s)

/usr/local/lib/python3.9/dist-packages/rayopt/analysis.py in __init__(self, system, **kwargs)
     72             setattr(self, k, v)
     73         if self.run:
---> 74             self.run()
     75         if self.print:
     76             for t in self.text:

/usr/local/lib/python3.9/dist-packages/rayopt/analysis.py in run(self)
    133                                    sharex=True, sharey=True, squeeze=False)
    134             self.figures.append(fig)
--> 135             self.spots(ax[::-1], self.system.fields)
    136 
    137         if self.plot_opds:

/usr/local/lib/python3.9/dist-packages/rayopt/analysis.py in spots(self, ax, heights, wavelengths, nrays, colors)
    271                 r = paraxial.airy_radius[1]/paraxial.wavelength*wi
    272                 t = GeometricTrace(self.system)
--> 273                 t.rays_point((0, hi), wi, nrays=nrays,
    274                              distribution="hexapolar", clip=True)
    275                 # plot transverse image plane hit pattern (ray spot)

/usr/local/lib/python3.9/dist-packages/rayopt/geometric_trace.py in rays_point(self, yo, wavelength, nrays, distribution, filter, stop, clip)
    208                    distribution="meridional", filter=None, stop=None,
    209                    clip=False):
--> 210         ref, yp, weight = pupil_distribution(distribution, nrays)
    211         self.rays(yo, yp, wavelength, filter=filter, stop=stop,
    212                   clip=clip, weight=weight, ref=ref)

/usr/local/lib/python3.9/dist-packages/rayopt/utils.py in pupil_distribution(distribution, nrays)
    185         l = [np.zeros((2, 1))]
    186         for i in np.arange(1, n + 1.):
--> 187             a = np.linspace(0, 2*np.pi, 6*i, endpoint=False)
    188             l.append([np.sin(a)*i/n, np.cos(a)*i/n])
    189         xy = np.concatenate(l, axis=1).T

<__array_function__ internals> in linspace(*args, **kwargs)

/usr/lib/python3/dist-packages/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
    111 
    112     """
--> 113     num = operator.index(num)
    114     if num < 0:
    115         raise ValueError("Number of samples, %s, must be non-negative." % num)

TypeError: 'numpy.float64' object cannot be interpreted as an integer

Thanks for sharing!

asebian avatar Dec 19 '21 10:12 asebian