Skip to content

10_05_solution.py code doesn't work for PlotScribe #7

@KayGHD

Description

@KayGHD

Issue Overview

toFile() method from 10_05_solution.py doesn't work with extended classes like PlotScribe

Describe your environment

toDict() for PlotScribe looks like this:

{
'classname': 'PlotScribe',
'color': 'cyan',
'mark': '*',
'trail': '.',
'pos': (0, 0),
'moves': [
['_setDegrees', [135]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]],
['_plotX', [ < function sine at 0x7fc78a4aa4d0 > ]]
],
'x': 0,
'domain': [0, 30]
}

Steps to Reproduce

  1. Added these lines to end of chapter solution:
    scribe3 = PlotScribe(domain=[0, 30], color='cyan')
    scribe3.plotX(sine)
    canvas = CanvasAxis(30, 30, scribes=[scribe, robotScribe, scribe3])

canvas.toFile('solution_file')
2. $ python ./exercise_files/10_05_solution.py

Expected Behavior

Example code should work with example extended scribe class

Current Behavior

TypeError: Object of type function is not JSON serializable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions