Skip to content
Closed
Show file tree
Hide file tree
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 Jan 9, 2021
9b9072e
adding options to ToString
mmatera Jan 10, 2021
657a738
Merge remote-tracking branch 'upstream/master' into newcellstotexfixes2
mmatera Jan 16, 2021
5441b9f
clean up
mmatera Jan 16, 2021
f10e3e0
restoring tests
mmatera Jan 16, 2021
b1ff26f
merge options
mmatera Jan 16, 2021
4a2f03e
Merge branch 'fixnamedOptionsPattern' into newcellstotexfixes2
mmatera Jan 16, 2021
5ed9220
fix optionpatterns with names
mmatera Jan 16, 2021
2a632b1
Merge branch 'fixnamedOptionsPattern' into newcellstotexfixes2
mmatera Jan 16, 2021
b1d1b88
merge
mmatera Jan 16, 2021
997ed17
fix OptionValue related
mmatera Jan 16, 2021
1d80bdc
Merge branch 'fixnamedOptionsPattern' into newcellstotexfixes2
mmatera Jan 16, 2021
a02a129
adding and fixing tests
mmatera Jan 17, 2021
d464c2f
Merge branch 'fixnamedOptionsPattern' of https://github.com/mathics/M…
mmatera Jan 19, 2021
b701894
fixing OptionQ
mmatera Jan 22, 2021
34c7646
(Stub) adding support for attributes in Function
mmatera Jan 22, 2021
bb8b78a
improve support of symbol Function with a third argument
mmatera Jan 22, 2021
15b993a
fix attribute support in abstract functions
mmatera Jan 22, 2021
39c9208
Improving support for OptionValue. Adding tests
mmatera Jan 16, 2021
1aae381
(Stub) adding support for attributes in Function
mmatera Jan 22, 2021
ed75290
DRY option tests
mmatera Jan 23, 2021
00ee8a3
merge to master
mmatera Jan 23, 2021
233f6c6
fix options
mmatera Jan 23, 2021
b549ebb
merge
mmatera Jan 23, 2021
efe392b
improve Hash support
mmatera Jan 23, 2021
ec97564
improve Hash support
mmatera Jan 23, 2021
9d163ff
fixing OptionValue
mmatera Jan 25, 2021
0b21fd3
Try 3.9
rocky Jan 23, 2021
6899ef4
Disable a test on OSX until we figure out what's wrong
rocky Jan 23, 2021
9bda8c4
basic.yml -> ubuntu.yml
rocky Jan 23, 2021
4530cbf
Will reinstate via GUI
rocky Jan 23, 2021
790a257
Create ubuntu.yml
rocky Jan 23, 2021
0e5436a
Combinatorica: Use RandomPermuation2 ...
rocky Jan 24, 2021
e5bc62a
Test up to but not including 2.1 Partitions
rocky Jan 24, 2021
016cd96
Added a dictionary for qualified named characters
GarkGarcia Jan 13, 2021
e347ab3
Refactored and renamed stuff
GarkGarcia Jan 13, 2021
553ebdf
Fixed a bug that aliased named character whose WL representation is t…
GarkGarcia Jan 15, 2021
e6a1fd7
Moved stuff to mathics.core.character and removed duplicate code
GarkGarcia Jan 15, 2021
0f66790
Fixed WL_TO_PLAIN_DICT
GarkGarcia Jan 16, 2021
ef474d2
Extracted the dictionaries to a separate file and cleaned the code
GarkGarcia Jan 16, 2021
af72edb
Added yaml as a dependency
GarkGarcia Jan 16, 2021
f3ef486
Fixed wrong import
GarkGarcia Jan 16, 2021
a16ed22
Fixed deprecation warning
GarkGarcia Jan 16, 2021
a33782f
Fixed some errors
GarkGarcia Jan 16, 2021
9865420
Fixed the last failing test
GarkGarcia Jan 16, 2021
753a2c1
Fixed another test
GarkGarcia Jan 16, 2021
fadc604
Fixed yet another test
GarkGarcia Jan 16, 2021
9adfdf1
Added missing entries `named-characters`
GarkGarcia Jan 16, 2021
034d816
Fixed syntax error
GarkGarcia Jan 16, 2021
d512025
Removed unnecessary file
GarkGarcia Jan 16, 2021
bd51315
Changed the format of the yml table
GarkGarcia Jan 17, 2021
8324fda
Use external mathics-scanner
rocky Jan 18, 2021
99d68d6
workflows test using github
rocky Jan 18, 2021
fa8c4d5
More import conversions
rocky Jan 18, 2021
b55e86b
Travis needs to get code from github for now..
rocky Jan 18, 2021
03c2246
Fixed https://github.com/mathics/Mathics/pull/1117#issuecomment-76256…
GarkGarcia Jan 19, 2021
a19fdcc
Added a PyYAML install in Makefile and .travis.yml
GarkGarcia Jan 19, 2021
0860093
Fixed typo
GarkGarcia Jan 19, 2021
727078e
Removed references to PyYAML in CI
GarkGarcia Jan 19, 2021
472e0ed
Revise for reworked mathics-scanner
rocky Jan 23, 2021
519e8ea
DRY load modules. fix Hash and FileHash symbols
mmatera Jan 26, 2021
117d6e3
Merge branch 'master' of https://github.com/mathics/Mathics into newc…
mmatera Jan 26, 2021
7719b83
merge
mmatera Feb 14, 2021
d31c40e
merge
mmatera Feb 14, 2021
87e8d36
Use MathicsSingleLineFeeder + lint changes
rocky Feb 21, 2021
6f25908
Merge remote-tracking branch 'upstream/master' into newcellstotexfixes2
mmatera Feb 21, 2021
0a26f3f
clean up
mmatera Feb 21, 2021
9b69dd5
merge remote
mmatera Feb 21, 2021
af54884
Merge remote-tracking branch 'upstream/master' into newcellstotexfixes2
mmatera Mar 3, 2021
1b5178b
Merge remote-tracking branch 'upstream/master' into newcellstotexfixes2
mmatera Mar 3, 2021
a9f6631
using asy for export
mmatera Mar 4, 2021
5a9782f
merge
mmatera Mar 7, 2021
e646493
Merge remote-tracking branch 'upstream/master' into newcellstotexfixes2
mmatera Mar 25, 2021
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
6 changes: 3 additions & 3 deletions mathics/builtin/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1876,9 +1876,9 @@ class Sum(_IterationFunction, SympyFunction):
>> Sum[x ^ 2, {x, 1, y}] - y * (y + 1) * (2 * y + 1) / 6
= 0

## >> (-1 + a^n) Sum[a^(k n), {k, 0, m-1}] // Simplify
## = -1 + (a ^ n) ^ m # this is what I am getting
## = Piecewise[{{m (-1 + a ^ n), a ^ n == 1}, {-1 + (a ^ n) ^ m, True}}]

>> (-1 + a^n) Sum[a^(k n), {k, 0, m-1}] // Simplify
= Piecewise[{{m (-1 + a ^ n), a ^ n == 1}, {-1 + (a ^ n) ^ m, True}}]

Infinite sums:
>> Sum[1 / 2 ^ i, {i, 1, Infinity}]
Expand Down
2 changes: 1 addition & 1 deletion mathics/builtin/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ class Eigenvalues(Builtin):

Symbolic eigenvalues:
>> Eigenvalues[{{Cos[theta],Sin[theta],0},{-Sin[theta],Cos[theta],0},{0,0,1}}] // Sort
= {1, Cos[theta] + Sqrt[(-1 + Cos[theta]) (1 + Cos[theta])], Cos[theta] - Sqrt[(-1 + Cos[theta]) (1 + Cos[theta])]}
= {1, Cos[theta] + Sqrt[-1 + Cos[theta] ^ 2], Cos[theta] - Sqrt[-1 + Cos[theta] ^ 2]}

>> Eigenvalues[{{7, 1}, {-4, 3}}]
= {5, 5}
Expand Down
2 changes: 0 additions & 2 deletions mathics/core/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,6 @@ def get_package_names(self) -> typing.List[str]:
packages = [c.get_string_value() for c in packages.leaves]
return packages

# return sorted({name.split("`")[0] for name in self.get_names()})

def shorten_name(self, name_with_ctx) -> str:
if "`" not in name_with_ctx:
return name_with_ctx
Expand Down
2 changes: 0 additions & 2 deletions mathics/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,3 @@ def format_result(self, str_expression=None, timeout=None, form=None):
if form is None:
form = self.form
return self.last_result.do_format(self.evaluation, form)


108 changes: 108 additions & 0 deletions test/test_cellstotex.py
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"]')
Copy link
Member

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.

Copy link
Contributor Author

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...

Copy link
Member

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?

Copy link
Contributor Author

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.


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