-
-
Notifications
You must be signed in to change notification settings - Fork 205
WIP: fixes to make cellstotex to work #1104
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
Closed
Closed
Changes from all commits
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
b0e63ed
fixes to make cellstotex to work
mmatera 9b9072e
adding options to ToString
mmatera 657a738
Merge remote-tracking branch 'upstream/master' into newcellstotexfixes2
mmatera 5441b9f
clean up
mmatera f10e3e0
restoring tests
mmatera b1ff26f
merge options
mmatera 4a2f03e
Merge branch 'fixnamedOptionsPattern' into newcellstotexfixes2
mmatera 5ed9220
fix optionpatterns with names
mmatera 2a632b1
Merge branch 'fixnamedOptionsPattern' into newcellstotexfixes2
mmatera b1d1b88
merge
mmatera 997ed17
fix OptionValue related
mmatera 1d80bdc
Merge branch 'fixnamedOptionsPattern' into newcellstotexfixes2
mmatera a02a129
adding and fixing tests
mmatera d464c2f
Merge branch 'fixnamedOptionsPattern' of https://github.com/mathics/M…
mmatera b701894
fixing OptionQ
mmatera 34c7646
(Stub) adding support for attributes in Function
mmatera bb8b78a
improve support of symbol Function with a third argument
mmatera 15b993a
fix attribute support in abstract functions
mmatera 39c9208
Improving support for OptionValue. Adding tests
mmatera 1aae381
(Stub) adding support for attributes in Function
mmatera ed75290
DRY option tests
mmatera 00ee8a3
merge to master
mmatera 233f6c6
fix options
mmatera b549ebb
merge
mmatera efe392b
improve Hash support
mmatera ec97564
improve Hash support
mmatera 9d163ff
fixing OptionValue
mmatera 0b21fd3
Try 3.9
rocky 6899ef4
Disable a test on OSX until we figure out what's wrong
rocky 9bda8c4
basic.yml -> ubuntu.yml
rocky 4530cbf
Will reinstate via GUI
rocky 790a257
Create ubuntu.yml
rocky 0e5436a
Combinatorica: Use RandomPermuation2 ...
rocky e5bc62a
Test up to but not including 2.1 Partitions
rocky 016cd96
Added a dictionary for qualified named characters
GarkGarcia e347ab3
Refactored and renamed stuff
GarkGarcia 553ebdf
Fixed a bug that aliased named character whose WL representation is t…
GarkGarcia e6a1fd7
Moved stuff to mathics.core.character and removed duplicate code
GarkGarcia 0f66790
Fixed WL_TO_PLAIN_DICT
GarkGarcia ef474d2
Extracted the dictionaries to a separate file and cleaned the code
GarkGarcia af72edb
Added yaml as a dependency
GarkGarcia f3ef486
Fixed wrong import
GarkGarcia a16ed22
Fixed deprecation warning
GarkGarcia a33782f
Fixed some errors
GarkGarcia 9865420
Fixed the last failing test
GarkGarcia 753a2c1
Fixed another test
GarkGarcia fadc604
Fixed yet another test
GarkGarcia 9adfdf1
Added missing entries `named-characters`
GarkGarcia 034d816
Fixed syntax error
GarkGarcia d512025
Removed unnecessary file
GarkGarcia bd51315
Changed the format of the yml table
GarkGarcia 8324fda
Use external mathics-scanner
rocky 99d68d6
workflows test using github
rocky fa8c4d5
More import conversions
rocky b55e86b
Travis needs to get code from github for now..
rocky 03c2246
Fixed https://github.com/mathics/Mathics/pull/1117#issuecomment-76256…
GarkGarcia a19fdcc
Added a PyYAML install in Makefile and .travis.yml
GarkGarcia 0860093
Fixed typo
GarkGarcia 727078e
Removed references to PyYAML in CI
GarkGarcia 472e0ed
Revise for reworked mathics-scanner
rocky 519e8ea
DRY load modules. fix Hash and FileHash symbols
mmatera 117d6e3
Merge branch 'master' of https://github.com/mathics/Mathics into newc…
mmatera 7719b83
merge
mmatera d31c40e
merge
mmatera 87e8d36
Use MathicsSingleLineFeeder + lint changes
rocky 6f25908
Merge remote-tracking branch 'upstream/master' into newcellstotexfixes2
mmatera 0a26f3f
clean up
mmatera 9b69dd5
merge remote
mmatera af54884
Merge remote-tracking branch 'upstream/master' into newcellstotexfixes2
mmatera 1b5178b
Merge remote-tracking branch 'upstream/master' into newcellstotexfixes2
mmatera a9f6631
using asy for export
mmatera 5a9782f
merge
mmatera e646493
Merge remote-tracking branch 'upstream/master' into newcellstotexfixes2
mmatera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| import os | ||
| from mathics.core.parser import parse, MathicsSingleLineFeeder | ||
| from mathics.core.definitions import Definitions | ||
| from mathics.core.evaluation import Evaluation | ||
| from mathics.core.expression import Symbol | ||
| import pytest | ||
| import urllib.request | ||
|
|
||
| external_url = ( | ||
| "https://raw.githubusercontent.com/jkuczm/MathematicaCellsToTeX/master/NoInstall.m" | ||
| ) | ||
|
|
||
| pytestmark = pytest.mark.skipif(os.getenv("SKIP_CELLSTOTEX", None) is not None, | ||
| reason="SKIP_CELLSTOTEX environment variable set") | ||
|
|
||
| try: | ||
| http_code = urllib.request.urlopen(external_url).getcode() | ||
| except: | ||
| url_reachable = False | ||
| else: | ||
| url_reachable = http_code in (200,) # add other 2xx or 3xx's? | ||
|
|
||
| definitions = Definitions(add_builtin=True) | ||
| evaluation = Evaluation(definitions=definitions, catch_interrupt=False) | ||
| set_versionnumber = 'Unprotect[$VersionNumber];$VersionNumber=11;Protect[$VersionNumber];' | ||
| import_url = 'Import@"%s"' % external_url | ||
|
|
||
|
|
||
| def _evaluate(str_expression): | ||
| expr = parse(definitions, MathicsSingleLineFeeder(str_expression)) | ||
| return expr.evaluate(evaluation) | ||
|
|
||
| _evaluate('LoadModule["pymathics.asy"]') | ||
|
|
||
| def test_load(): | ||
| str_expected1 = "{}" | ||
| message1 = "" | ||
| _evaluate(set_versionnumber) | ||
| result1 = _evaluate(import_url) | ||
| expected1 = _evaluate(str_expected1) | ||
|
|
||
|
|
||
| if message1: | ||
| assert result1 == expected1, message1 | ||
| else: | ||
| assert result1 == expected1 | ||
|
|
||
| result2 = _evaluate('Names["CellsToTeX`*"]') | ||
| expected2 = _evaluate('{"CellToTeX", "CellsToTeXException", "CellsToTeXPreamble"}') | ||
| print(result2) | ||
| assert result2 == expected2 | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not url_reachable, reason="skipping since we can't reach %s" % external_url) | ||
| #@pytest.mark.skip( | ||
| # reason="FIXME: full CellToTeX import test is not working yet: implement levelspec > 1" | ||
| #) | ||
| def test_load_and_run(): | ||
| print("load and run") | ||
| str_expected0 = "None" | ||
| _evaluate(set_versionnumber) | ||
| result0 = _evaluate(import_url) | ||
| expected0 = _evaluate(str_expected0) | ||
|
|
||
| if result0 == Symbol("System`$Failed"): | ||
| return 0 | ||
|
|
||
| str_expr1 = 'CellsToTeXPreamble[]' | ||
| str_expected1 = '"\\mmaSet{morefv={gobble=2,},}\\n"' | ||
| result1 = _evaluate(str_expr1) | ||
| expected1 = _evaluate(str_expected1) | ||
| assert result1 == expected1 | ||
|
|
||
| str_expr1 = 'boxes=MakeBoxes[Pi];\ | ||
| cell = Cell[BoxData[boxes], "Input"];res=Catch[CellToTeX[cell, Style->"Input"]]' | ||
| str_expected1 = '"\\begin{mmaCell}{Input}\n \\pi\n\\end{mmaCell}"' | ||
| message1 = "" | ||
| result1 = _evaluate(str_expr1) | ||
| expected1 = _evaluate(str_expected1) | ||
| if message1: | ||
| assert result1 == expected1, message1 | ||
| else: | ||
| assert result1 == expected1 | ||
|
|
||
| str_expr2 = 'boxes=MakeBoxes[(-b \\[PlusMinus] Sqrt[b^2-4*a*c])/(2 a)];\ | ||
| cell = Cell[BoxData[boxes],"Input"];res=Catch[CellToTeX[cell], Style->"Input"]' | ||
| str_expected2 = '"\\begin{mmaCell}{Input}\n \\mmaFrac{-b\\(\\pmb{\\pm}\\)\\mmaSqrt{\\mmaSup{b}{2}-4 a c}}{2 a}\n\\end{mmaCell}"' | ||
| print(str_expr2) | ||
| message2 = "" | ||
| result2 = _evaluate(str_expr2) | ||
| expected2 = _evaluate(str_expected2) | ||
| if message2: | ||
| assert result2 == expected2, message2 | ||
| else: | ||
| assert result2 == expected2 | ||
|
|
||
| str_expr3 = 'boxes=MakeBoxes[Sqrt[Integrate[f[x],{x,a,b}]]];\ | ||
| cell = Cell[BoxData[boxes],"Input"];res=Catch[CellToTeX[cell]]' | ||
| print(str_expr3) | ||
|
|
||
| str_expected3 = '"\\begin{mmaCell}[morefunctionlocal={x}]{Input}\n \\mmaSqrt{\\mmaSubSupM{\\int}{a}{b}f[x]dx}\n\\end{mmaCell}"' | ||
| message3 = "" | ||
| result3 = _evaluate(str_expr3) | ||
| expected3 = _evaluate(str_expected3) | ||
| if message3: | ||
| assert result3 == expected3, message3 | ||
| else: | ||
| assert result3 == expected3 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... maybe it would be better to put this test in the pymathics repository instead of here.
If done here, we would have to have to check to see if pymathics.asy is installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea would be to download and load the module in the test. But first I need to complete the package and make it works...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do it in pymathics-asy then you don't have to download and everything is simpler.
Is there a reason not to do it there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it could be there but is a little bit unrelated to that package. The idea of having this branch in mathics is not to actually merge it, but just to discover and collect several fixed required by the Mathics suit to load this package (and potentially, many others). Once this package (
CellToTeX) pass the tests, we could put this test in a different repository, with the corresponding comments about how to actually make it run.