vMeijin / pySmithPlot

Matplotlib extension for creating Smith charts with Python
127 stars 73 forks source link

type error when calling projection=smith #31

Closed bugusan closed 4 years ago

bugusan commented 4 years ago

Using matplotlib 3.2 as well as with trying 1.2, which is recommended in the guideline, I have an "object of type <class 'numpy.float64'> cannot be safely interpreted as an integer" error I don't know why no one has reported it so far.

lt.figure(1, figsize=(4,4), facecolor='w') ax = plt.subplot('111', projection='smith', plot_marker_default=None, axes_normalize_label=False) in this line I get type error below.

TypeError                                 Traceback (most recent call last)
~\Anaconda3\lib\site-packages\numpy\core\function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
    116     try:
--> 117         num = operator.index(num)
    118     except TypeError:

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

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-10-2f840a3fb238> in <module>
     34 
     35 plt.figure(1, figsize=(4,4), facecolor='w')
---> 36 ax = plt.subplot('111', projection='smith', plot_marker_default=None, axes_normalize_label=False)
     37 #axes_normalize=True, axes_impedance=50, axes_normalize_label=True
     38 

~\AppData\Roaming\Python\Python37\site-packages\matplotlib\pyplot.py in subplot(*args, **kwargs)
   1028 
   1029     fig = gcf()
-> 1030     a = fig.add_subplot(*args, **kwargs)
   1031     bbox = a.bbox
   1032     byebye = []

~\AppData\Roaming\Python\Python37\site-packages\matplotlib\figure.py in add_subplot(self, *args, **kwargs)
   1417                     self._axstack.remove(ax)
   1418 
-> 1419             a = subplot_class_factory(projection_class)(self, *args, **kwargs)
   1420 
   1421         return self._add_axes_internal(key, a)

~\AppData\Roaming\Python\Python37\site-packages\matplotlib\axes\_subplots.py in __init__(self, fig, *args, **kwargs)
     74 
     75         # _axes_class is set in the subplot_class_factory
---> 76         self._axes_class.__init__(self, fig, self.figbox, **kwargs)
     77         # add a layout box to this, for both the full axis, and the poss
     78         # of the axis.  We need both because the axes may become smaller

~\Anaconda3\lib\site-packages\smithplot\smithaxes.py in __init__(self, *args, **kwargs)
    372 
    373         # seperate Axes parameter
--> 374         Axes.__init__(self, *args, **SmithAxes.update_scParams(instance=self, filter_dict=True, reset=False, **kwargs))
    375         self.set_aspect(1, adjustable='box', anchor='C')
    376 

~\AppData\Roaming\Python\Python37\site-packages\matplotlib\axes\_base.py in __init__(self, fig, rect, facecolor, frameon, sharex, sharey, label, xscale, yscale, **kwargs)
    452 
    453         self._rasterization_zorder = None
--> 454         self.cla()
    455 
    456         # funcs used to format x and y - fall back on major formatters

~\Anaconda3\lib\site-packages\smithplot\smithaxes.py in cla(self)
    475 
    476         for grid in ['major', "minor"]:
--> 477             self.grid(b=self._get_key("grid.%s.enable" % grid), which=grid)
    478 
    479     def _set_lim_and_transforms(self):

~\Anaconda3\lib\site-packages\smithplot\smithaxes.py in grid(self, b, which, fancy, dividers, threshold, **kwargs)
   1062                             x_div, y_div = d_mat[i, k]
   1063 
-> 1064                             for xs in np.linspace(x0, x1, x_div + 1)[1:]:
   1065                                 x_lines.append([xs, y0, y1])
   1066                                 x_lines.append([xs, -y1, -y0])

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

~\Anaconda3\lib\site-packages\numpy\core\function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
    119         raise TypeError(
    120             "object of type {} cannot be safely interpreted as an integer."
--> 121                 .format(type(num)))
    122 
    123     if num < 0:

TypeError: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.
alexpacini commented 4 years ago

I think this is duplicate of #30 and also fixed in PR #27 and #28.

Those were not merged yet by the author, but if you want I merged them on my branch on my profile. If you want to use it you can install it from my github branch (where I applied #28 ).

python3 -m pip install --user --upgrade git+https://github.com/alexpacini/pySmithPlot#egg=pysmithplot