Skip to content

ListPlot[] error handling (and NestList[]) needs going over #1057

@rocky

Description

@rocky

Description

NestList doesn't check data given it so it can give a Python traceback.

How to Reproduce

Steps to reproduce the behavior.

For Django:

ListPlot[NestList[# + RandomChoice[{+1, -1}] &, 0, 10]]
...
  File "/src/external-vcs/github/Mathics3/mathics-core/mathics/builtin/drawing/plot.py", line 361, in eval
    return eval_ListPlot(
           ^^^^^^^^^^^^^^
  File "/src/external-vcs/github/Mathics3/mathics-core/mathics/eval/plot.py", line 222, in eval_ListPlot
    for j, point in enumerate(seg):
                    ^^^^^^^^^^^^^^
TypeError: 'float' object is not iterable

Expected behavior

An error message like:

ListPlot::lpn: {{}, {{1., 1.}}, {{1., 2.}}, {}}
     is not a list of numbers or pairs of numbers.

Additional context

Many of thte example https://www.wolfram.com/language/elementary-introduction/3rd-ed/27-applying-functions-repeatedly.html fail because our NestList is not handling arguments properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions