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

Invalid number format #1

Open
Decimation opened this issue Dec 20, 2020 · 12 comments
Open

Invalid number format #1

Decimation opened this issue Dec 20, 2020 · 12 comments
Assignees
Labels
bug Something isn't working external issue something beyond our direct control

Comments

@Decimation
Copy link

Decimation commented Dec 20, 2020

I keep getting an "Invalid number format" exception on line 38 when calling either function. I have everything set up correctly, and it works on the Student Software, but not on my Nspire. I'm not sure what's going wrong.

@adriweb
Copy link
Member

adriweb commented Dec 20, 2020 via email

@Decimation
Copy link
Author

It works correctly when using the functions within the original document, just not in any other document. The same is true for using it on the computer software. So it does work on the calculator, but it looks like you need to use the original document.

@adriweb
Copy link
Member

adriweb commented Dec 20, 2020

Ah, ok, thanks for the details, that’s helpful. For now I guess users will have to copy/paste the python snippet in their own documents.

@adriweb adriweb self-assigned this Dec 20, 2020
@typelogic
Copy link

Having similar issue here

@adriweb
Copy link
Member

adriweb commented Apr 14, 2021

Ok thanks, I'll check what's going on with my own calc now updated to OS 5.3

@Decimation
Copy link
Author

I tried it on the latest OS version and the error is still present.

@Decimation
Copy link
Author

It works correctly when using the functions within the original document, just not in any other document. The same is true for using it on the computer software. So it does work on the calculator, but it looks like you need to use the original document.

Like I also noted earlier, this is still the case. It works if you copy the source code into your Python document, just not if you import the module.

@adriweb
Copy link
Member

adriweb commented Apr 18, 2021

Alright, so I've been digging into this a bit, let me explain what's going on:

In order to evaluate an expression, I store then recall the expression (which gets evaluated) on the math engine's side via call ti_system's writeST/readST.
The problem is that when reading back the value, anything with a / will error with "TypeError: Invalid number format".
To prevent that, the script made the evaluated expression replace / by a magic token, on the Basic/math-engine side, then replaced back to a / on the Python side. However evaluating a Basic function (even if defined as LibPub) seems broken from the ti_system helpers if it's not in the same doc :(

So right now, I'm not sure what to do to make it easy for users.

@adriweb adriweb added bug Something isn't working external issue something beyond our direct control labels Apr 18, 2021
@Decimation
Copy link
Author

I just developed a fix to both issues:

I created a forked version named xpy which you can see here.

It works when you import the Python module in separate documents, and it solves the "Invalid number format" error.

This was the fix:

def eval_expr2(name):
  return _cleanstr(readST("string("+name+")"))

@adriweb
Copy link
Member

adriweb commented Apr 19, 2021

It looks like you just removed the replacements, which was in fact the very first version I had.

Are you sure you version handles the division character in the output? For instance (x+x)/y should give 2*x/y.

@Decimation
Copy link
Author

I see what you mean. Neither version works with the division character in the string output. It still works with other output and in separate documents, though.

However, I'm not sure what to do regarding the division character, as you pointed out.

@adriweb
Copy link
Member

adriweb commented Apr 19, 2021 via email

This was referenced Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external issue something beyond our direct control
Projects
None yet
Development

No branches or pull requests

3 participants