Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matplotlib deprecation warning and numpy TypeError #36

Open
asebian opened this issue Dec 19, 2021 · 1 comment
Open

Matplotlib deprecation warning and numpy TypeError #36

asebian opened this issue Dec 19, 2021 · 1 comment

Comments

@asebian
Copy link

asebian commented Dec 19, 2021

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 asebian changed the title Matplotlib deprecation warning and TypeError Matplotlib deprecation warning and numpy TypeError Dec 19, 2021
@AlecHang
Copy link

AlecHang commented Nov 28, 2023

Modify the sentence in line 186 from /usr/local/lib/python3.9/dist-packages/rayopt/utils.py (path depends on your python version):
for i in np.arange(1, n + 1):

In this case i is an integer and no error occurs anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants