AllenDowney / ThinkDSP

Think DSP: Digital Signal Processing in Python, by Allen B. Downey.
https://allendowney.github.io/ThinkDSP/
3.93k stars 3.2k forks source link

getattr in thinkplot.py Config #26

Closed grfiv closed 7 years ago

grfiv commented 7 years ago

I am using your notebooks with Jupyter 4.2.1 and Python 3.5.2 under Ubuntu Desktop 16.10

The code snippet

def Config(**options):
    for name in names:
        if name in options:
            getattr(pyplot, name)(options[name])

generates TypeError: 'tuple' object is not callable

The following seems to fix it for me

def Config(**options):
    for name in names:
        if name in options:
            try:
                getattr(pyplot, name)(options[name])
            except TypeError:
                setattr(pyplot, name, options[name])
AllenDowney commented 7 years ago

Thanks for reporting this. I'll investigate as soon as I get a change.

Can you tell me what parameters you are passing to Config?

On Fri, Feb 24, 2017 at 12:35 PM, George Fisher notifications@github.com wrote:

I am using your notebooks with Jupyter 4.2.1 and Python 3.5.2

The code snippet

def Config(**options): for name in names: if name in options: getattr(pyplot, name)(options[name])

generates TypeError: 'tuple' object is not callable

The following seems to fix it for me

def Config(**options): for name in names: if name in options: try: getattr(pyplot, name)(options[name]) except TypeError: setattr(pyplot, name, options[name])

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AllenDowney/ThinkDSP/issues/26, or mute the thread https://github.com/notifications/unsubscribe-auth/ABy37UBuTT_HQLP54LKgOXBMYxy3KzzDks5rfxTigaJpZM4MLeY3 .

grfiv commented 7 years ago

http://localhost:8888/notebooks/code/chap02.ipynb

signal = thinkdsp.SquareSignal(100)
duration = signal.period*3
segment = signal.make_wave(duration, framerate=10000)
segment.plot()
thinkplot.config(ylim=[-1.05, 1.05], legend=False)
AllenDowney commented 7 years ago

Huh. I can't replicate that.

Just for debugging purposes, would you clone a fresh copy of the repo and run that notebook again?

On Fri, Feb 24, 2017 at 1:33 PM, George Fisher notifications@github.com wrote:

http://localhost:8888/notebooks/code/chap02.ipynb

signal = thinkdsp.SquareSignal(100) duration = signal.period*3 segment = signal.make_wave(duration, framerate=10000) segment.plot() thinkplot.config(ylim=[-1.05, 1.05], legend=False)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AllenDowney/ThinkDSP/issues/26#issuecomment-282367977, or mute the thread https://github.com/notifications/unsubscribe-auth/ABy37bdK9UADzXMEYV-9qGBM7e1nmwlXks5rfyKOgaJpZM4MLeY3 .

grfiv commented 7 years ago

OK. Started fresh and it does not recur.

AllenDowney commented 7 years ago

Good news. Thanks for following up.