olavolav / uniplot

Lightweight plotting to the terminal. 4x resolution via Unicode.
MIT License
343 stars 16 forks source link

[Question] Does Uniplot Support .py files? #6

Closed robertdefilippi closed 3 years ago

robertdefilippi commented 3 years ago

Hello,

This is an interesting project! Thank you for taking the time to put it together.

Quick question:

When testing out uniplot I'm able to call .plot() from the python console or through ipython, and get a visualization quite easily. However, it does not work when I include uniplot in a .py file and I execute the file.

# foo.py
import unipolot as plot
import math
x = [math.sin(i / 20) + i / 300 for i in range(600)]
p = plot(x)

$ python foo.py
Traceback (most recent call last):
  File "foo.py", line 4, in <module>
    p = plot(x)
TypeError: 'module' object is not callable

Is this expected behaviour, or am I missing something from the docs?

Thanks,

olavolav commented 3 years ago

Hi @robertdefilippi, it should work once you change the import line to from uniplot import plot.

So your whole file would be:

# foo.py
from uniplot import plot
import math
x = [math.sin(i / 20) + i / 300 for i in range(600)]
plot(x)

Does this help you?

robertdefilippi commented 3 years ago

Yup. Thanks for seeing the error in my code 😄