Skip to content

PlotExampleSpectrum() fails in Python3 due to changed '/'-operator meaning #70

Description

@ldpgh

PlotExampleSpectrum(ntf, M=1, osr=osr, f0=f0)

Traceback (most recent call last):

File "", line 1, in
PlotExampleSpectrum(ntf, M=1, osr=osr, f0=f0)

File ".....\lib\site-packages\deltasigma_PlotExampleSpectrum.py", line 103, in PlotExampleSpectrum
plt.plot(freq, dbv(spec0[:N/2 + 1]), 'c', linewidth=1)

TypeError: slice indices must be integers or None or have an index method


... running Python 3.7.0

Change line File ".....\lib\site-packages\deltasigma_PlotExampleSpectrum.py", line 103, in PlotExampleSpectrum
plt.plot(freq, dbv(spec0[:N/2 + 1]), 'c', linewidth=1)
to
plt.plot(freq, dbv(spec0[:int(N/2.0) + 1]), 'c', linewidth=1)

or whatever is convinient to let N/2 return an integer number.

Activity

  1. ldpgh commented on Aug 20, 2019

    @ldpgh
    Author

    same issue on line 106

    File "", line 1, in
    PlotExampleSpectrum(ntf, M=1, osr=osr, f0=f0)

    File ".......\lib\site-packages\deltasigma_PlotExampleSpectrum.py", line 106, in PlotExampleSpectrum
    plt.plot(freq, dbp(spec_smoothed[:N/2 + 1]), 'b', linewidth=3)

    TypeError: slice indices must be integers or None or have an index method

  2. ldpgh commented on Aug 20, 2019

    @ldpgh
    Author

    ... and on line 87, 88
    f1_bin = np.round(f1N)
    f2_bin = np.round(f2
    N)
    have been modified to
    f1_bin = int(np.round(f1N))
    f2_bin = int(np.round(f2
    N))

  3. ldpgh commented on Aug 20, 2019

    @ldpgh
    Author

    ... and voila got a pretty nice spectrum.

    And not to forget ... Thank you for all the effort you spent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions