py5coding / py5generator

Meta-programming project that creates the py5 library code.
https://py5coding.org/
GNU General Public License v3.0
52 stars 13 forks source link

`remap()` should return `NaN`/ `nan` and not throw a `ZeroDivisionError` #109

Closed hx2A closed 2 years ago

hx2A commented 2 years ago

In the old Processing IDE some edge cases of map() return NaN/ nan

image

Now, py5 raises a ZeroDivisionError: float division by zero, which seems fair also.

Should we document this somehow or print a warning? Or chance it to be more like Processing?

I really don't know!

Originally posted by @villares in https://github.com/py5coding/py5generator/discussions/108

hx2A commented 2 years ago

Now it will return NaN and print a warning.

I want to take a closer look at Python's warnings library. There are a few things I think I can do better.

hx2A commented 2 years ago

This is fixed, and I made some minor upgrades to the other Python warnings.

Now back to the ASCII character issue...