Comments (4)
Just FYI, the MathObject Real stores the same number of digits as perl reals, but it only displays fewer. It uses the %g
format for sprintf()
by default, which gives 6 digits of precision. You could change that to get more (or fewer).
from pg.
Thank you for pointing that out. So the number of digits actually differs. repr(o) gives a higher precision than float(o). But is it nessecary to limit the number of digits for some reason?
from pg.
I don't believe there is any reason to limit the number. The internal format stores about 17 digits of precision (it actually uses 54 binary digits, and that gives 16 to 17 digits of precision in base 10, depending on the number being represented -- the conversion doesn't match up with decimal digits precisely). So if repr(0)
produces 17 or more, then that is the best you can do.
from pg.
As I understand it, this function _webwork_safe_json
is used to as a convenience function to convert Sage objects into JSON objects that can be interpreted properly by WeBWorK. This is necessary, since the standard representations of Sage objects are not JSON compatible. For instance we have:
- For floats:
print float(pi)
print repr(pi)
returns
3.14159265359
pi
- For elements of free modules:
M = FreeModule(base_ring=QQ,rank=2)
v = M([1,0])
print list(v)
print repr(v)
returns
[1, 0]
(1, 0)
- For matrices:
I = matrix.identity(2)
print [list(i) for i in I.rows()]
print repr(I)
returns
[[1, 0], [0, 1]]
[1 0]
[0 1]
So the last case handled in
elif isinstance(o, SageObject):
json_obj = repr(o)
seems not to cover the cases treated before.
from pg.
Related Issues (20)
- Warnings when using upToConstant where C0 is already defined HOT 1
- Scaffold section with PopUp breaks subsequent MathObjects HOT 2
- parserRadioMultiAnswer default answer checker doesn't handle list objects HOT 1
- Change behaviour of helpLink in hardcopy?
- Currency errors with hardcopy HOT 14
- macros from OPL that moved to pg: issue with reliance on other macro libraries HOT 5
- q within [@...@] PGML blocks HOT 4
- Syntax bug with PGlateximage.pl and negative parameter values HOT 3
- radio buttons with only one option HOT 5
- unicode characters in strings HOT 1
- Variable adjacent to code substitution in TEXT causes hardcopy error. HOT 8
- PGstatisticsmacros error HOT 2
- Inconsistent/incomplete behaviour for radio button custom answer checkers HOT 3
- inserting an answer between two multiAnswer inputs HOT 13
- issue with `q` and parsing in PGML HOT 9
- PGML bold within a word HOT 3
- Macros whose first line starts with =head1 fail to load. HOT 6
- answer hints in multiple choice HOT 13
- CheckboxList reveals the correct answers HOT 3
- MathQuill toolbar placement in a relatively positioned parent - bug when in an RTL course. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pg.