Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cryptic error when using line_plot #621

Closed
Jiehong opened this issue Oct 14, 2024 · 5 comments
Closed

cryptic error when using line_plot #621

Jiehong opened this issue Oct 14, 2024 · 5 comments

Comments

@Jiehong
Copy link

Jiehong commented Oct 14, 2024

Hello,

I use numbat on the cli, and I saw that some plot functions now exist. So I tried to run:

let A0 = 3 cm
let ω = 20 Hz
let λ = 1.5 s

fn amplitude(t) = A0 exp(-t/λ) cos(ω t)

line_plot(amplitude, 0 s, 8 s) |>
  xlabel("Time") |>
  ylabel("Amplitude") |>
  show

I expected the show to maybe fail, but maybe I could save it to svg or something.

However, it never reached that point at all, because the following line fails with an error:

>>> line_plot(amplitude, 0 s, 8 s)
error: runtime error
 = User error: …

The ... are not something I added.

So I guess I am a user, and thus an error :D

So, perhaps functions not supported in the CLI show not be callable with an error saying this function is only supported in the browser, or (bigger fix I think), the plot function should work in the CLI, but show could be replaced by save_svg or something like that (`àla matplotlib: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.savefig.html).

@Goju-Ryu
Copy link
Contributor

Goju-Ryu commented Oct 14, 2024

That is very likely caused by unit_of being called on a value of zero. See #521 for more context.
It required a hotfix and the error message for that is the "..." you experience.

@Goju-Ryu
Copy link
Contributor

I just checked the implementation and can confirm it is because your second argument is 0. Use a value slightly higher or lower and it should be resolved.

@Jiehong Jiehong closed this as completed Oct 16, 2024
@sharkdp
Copy link
Owner

sharkdp commented Oct 23, 2024

Let's leave this open until this #521 mess is resolved 😄. Users should not have to adapt their plot ranges because of this.

@sharkdp sharkdp reopened this Oct 23, 2024
@Goju-Ryu
Copy link
Contributor

Yeah, I formulated myself in an unfortunate way. I meant that the error would be avoided, but this is absolutely a valid problem and one of the most common values for a starting point shouldn't trigger an error.

@sharkdp
Copy link
Owner

sharkdp commented Jan 1, 2025

Closed via e8bac1f

@sharkdp sharkdp closed this as completed Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants