Skip to content

Commit

Permalink
KnotTheory hacks and workarounds...
Browse files Browse the repository at this point in the history
Workaround:
```
   BeginPackage["KnotTheory`", {"TubePlot`"}]
```

More generally, `BeginPackage[string, needs_list]` doesn't work.

Run `test/test_knottheory.py` only if KnotTheory environment variable is set.
  • Loading branch information
rocky committed May 7, 2021
1 parent 804efa5 commit 6523d29
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions mathics/builtin/scoping.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,9 @@ class BeginPackage(Builtin):
Protect[System`Private`$ContextPathStack, System`$Packages];
context
""",
# "BeginPackage[context_String, needs__]": """
# BeginPackage[context]; Needs[Map[Needs, needs]];
# """
}


Expand Down Expand Up @@ -680,6 +683,7 @@ class EndPackage(Builtin):
System`Private`newctx],
Most[System`Private`$ContextPathStack]};
Protect[System`Private`$ContextPathStack];
Print["EndPackage: "<>System`Private`$ContextStack];
Null]]
""",
}
Expand Down
6 changes: 4 additions & 2 deletions mathics/packages/KnotTheory/init.m
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,9 @@ crossing and False if it is positive (right handed).

End[]; EndPackage[]

BeginPackage["KnotTheory`", {"TubePlot`"}]
(* BeginPackage["KnotTheory`", {"TubePlot`"}]*)
Needs["TubePlot`"];
BeginPackage["KnotTheory`"]

TorusKnot;

Expand All @@ -781,7 +783,7 @@ crossing and False if it is positive (right handed).
TubePlotPrelude -> EdgeForm[{}], Boxed -> False, ViewPoint -> {0, 0, 1}
];

End[]; (*EndPackage[]*)
End[]; EndPackage[]
(* End source file src/TubePlot.m*)


Expand Down
5 changes: 5 additions & 0 deletions test/test_knottheory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
import os
import pytest

from .helper import evaluate, check_evaluation

import pytest
Expand All @@ -10,6 +13,8 @@
)


@pytest.mark.skipif(not os.environ.get("KnotTheory", False),
reason="set environment varable KnotTheory to run this test")
def test_knottheory():
evaluate(
"""K = PD[X[1,9,2,8], X[3,10,4,11],
Expand Down

0 comments on commit 6523d29

Please sign in to comment.