AllenDowney/ThinkDSP

getattr in thinkplot.py Config

grfiv opened this issue · 5 comments

grfiv commented

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])
grfiv commented

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)
grfiv commented

OK. Started fresh and it does not recur.

Good news. Thanks for following up.