Skip to content

Fix printing bugs around the gsym argument to Ga#340

Merged
eric-wieser merged 3 commits intopygae:masterfrom
eric-wieser:fix-gsym-bugs
May 18, 2020
Merged

Fix printing bugs around the gsym argument to Ga#340
eric-wieser merged 3 commits intopygae:masterfrom
eric-wieser:fix-gsym-bugs

Conversation

@eric-wieser
Copy link
Copy Markdown
Member

@eric-wieser eric-wieser commented May 13, 2020

We should merge #339 first, putting up now to trial CI.

See commit messages for an explanation of this change.

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

Review Jupyter notebook visual diffs & provide feedback on notebooks.


Powered by ReviewNB

@eric-wieser eric-wieser added the component: printer string, latex, and ansi escape printing label May 13, 2020
@lgtm-com

This comment has been minimized.

@eric-wieser eric-wieser force-pushed the fix-gsym-bugs branch 3 times, most recently from 2bc0f6c to 16c70bc Compare May 15, 2020 08:35
@eric-wieser eric-wieser requested a review from utensil May 15, 2020 08:39
@eric-wieser eric-wieser marked this pull request as ready for review May 15, 2020 08:39
@codecov
Copy link
Copy Markdown

codecov bot commented May 15, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@ce67568). Click here to learn what that means.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #340   +/-   ##
=========================================
  Coverage          ?   75.88%           
=========================================
  Files             ?       16           
  Lines             ?     4500           
  Branches          ?        0           
=========================================
  Hits              ?     3415           
  Misses            ?     1085           
  Partials          ?        0           
Impacted Files Coverage Δ
galgebra/atoms.py 97.53% <100.00%> (ø)
galgebra/ga.py 80.63% <100.00%> (ø)
galgebra/printer.py 71.73% <100.00%> (ø)
galgebra/_utils/kwarg_parser.py 78.57% <0.00%> (ø)
galgebra/_utils/parser.py 96.35% <0.00%> (ø)
galgebra/__init__.py 100.00% <0.00%> (ø)
galgebra/mv.py 74.91% <0.00%> (ø)
galgebra/_utils/cached_property.py 95.45% <0.00%> (ø)
galgebra/deprecated.py 100.00% <0.00%> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce67568...8a91ea6. Read the comment docs.

Comment thread galgebra/ga.py Outdated
Comment thread galgebra/printer.py

def _print_Determinant(self, expr):
# sympy `uses |X|` by default, we want `det (X)`
return r"\det\left ( {}\right )".format(self._print(expr.args[0]))
Copy link
Copy Markdown
Member

@utensil utensil May 16, 2020

Choose a reason for hiding this comment

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

These two styles are just two styles, does SymPy has an option for it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, it does not. We could make a patch upstream to support an option, but for now it's easiest just to add it here.

This ran into three issues with sympy:
* Determinant objects are not considered commutative, which breaks Mv.
  This is a bug.
  We work around it by making _our_ determinant subclass explicitly commutative
* There is no MatrixFunction builtin. We define our own for now.
* The default printing of `Determinant` isn't what we want. We can override it in our printer.

This fixes:

* the value of gsym affecting whether the printing is italic
* the state of the printer at construction affecting the lifetime printing behavior
Previously this was computed once in the constructor, and once again, possibly with a completely different value, when constructing the reciprocal basis blades.

Making this a cached_property ensures we compute it exactly once.
This fixes the weird statefulness in the notebook included in this commit.
For some reason, the Metric was creating the symbol `|g|` while the Ga was creating the symbol `det(g)`.
Merging these together makes the picture a lot clearer.
@eric-wieser eric-wieser requested a review from utensil May 18, 2020 10:24
@eric-wieser eric-wieser marked this pull request as ready for review May 18, 2020 10:27
Copy link
Copy Markdown
Member

@utensil utensil left a comment

Choose a reason for hiding this comment

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

Reviewed commit by commit.

@eric-wieser eric-wieser merged commit e15bf4d into pygae:master May 18, 2020
@eric-wieser eric-wieser deleted the fix-gsym-bugs branch May 19, 2020 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug component: printer string, latex, and ansi escape printing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants