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

setting using asymptote for graphics by default #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mathics_django/web/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from mathics.core.definitions import Definitions
from mathics.core.evaluation import Evaluation, Output
from mathics.core.expression import(Expression, Symbol, SymbolTrue, String)
from mathics_django.web.format import format_output


Expand All @@ -30,6 +31,7 @@ def get_session_evaluation(session):
definitions, format='unformatted', output=WebOutput())
_evaluations[session.session_key] = evaluation
evaluation.format_output = lambda expr, format: format_output(evaluation, expr, format)
Expression('LoadModule', String("pymathics.asy")).evaluate(evaluation)
return evaluation


Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def read(*rnames):
is_PyPy = platform.python_implementation() == "PyPy"

INSTALL_REQUIRES = []
DEPENDENCY_LINKS = []
DEPENDENCY_LINKS = ["http://github.com/Mathics3/pymathics-asy#egg=pymathics-asy"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't do this. We want to reduce complexity and the number of dependencies and this just adds this back in.

The front ends should allow for reading profiles and customization.

And the mathics-ominbus project was created to pull in all of the different pieces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, then I would discard this PR. However, I think this would be a suitable (temporary) patch to fix the issue with graphics, this is why I put it here.
The other way to solve the graphics issue would be to update and debug all the javascript machinery.

Copy link
Member

@rocky rocky Mar 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably think about and discuss a strategy, short-term and long term.

I confess that in a way I did I think the same kind of thing with pymathics-graphics that you are doing here. So I understand and am sympathetic to short-term workarounds.

Personally, I am happier with short-term workarounds only after we have a clear idea of what the longer-term strategy is.

A long while ago, it was my impression that we were going to eventually ditch Django and go with some sort of Jupyter-based solution. At least in my mind, that hasn't been feasible yet because the foundations of the Mathics core and how it interacts with "front-ends" just doesn't feel fully worked out, although we are in my opinion making good progresss toward that end,.

Copy link
Contributor Author

@mmatera mmatera Mar 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I agree with that, and I thought that the strategy was more or less this one:

  • Fix graphics in Django with a plugin (pymathics-matplotlib or this one) that works in a very short term, in order to have a functional candidate for release soon. I would also prefer to use Matplotlib instead Asymptote for rendering graphics, but it happens that the development of the asy interface is much more advanced than the mpl one. This is why I have used it in this PR.

  • Use this to improve the way in which graphics packages are loaded and works. Regarding this, working on pymathics-asy I think I have discovered the root of the problem with graphics: it is rooted in the javascript/MathJax postprocessing. To really fix it we should look at the javascript routines that perform the XHTML replaces (mathics.js). We will need to do that if we want to have svg graphics. By now, I solve this by sending png graphics.

  • In the long term, to use what we learned working on that plugin to improve the jupyter's interface, which in the long term replace Django frontend as the main frontend of the project. Yesterday I have been doing some progress in that direction. I am updating this binder: https://mybinder.org/v2/gh/mmatera/nbcoursebase/master with the improvements to make online checks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Thanks for the information and plan!

Let me think about abount this, look at the code, try things, and try to understand the what's been done and the existing code.


if sys.platform == "darwin":
INSTALL_REQUIRES += ["scikit-image"]
Expand All @@ -61,6 +61,7 @@ def read(*rnames):
"django >= 3.0, < 3.2",
"networkx",
"requests",
"pymathics-asy",
]


Expand Down