Skip to content

Commit 42f4c18

Browse files
authored
Remove the no-longer needed print reconfiguration in Ga.__init__ (#257)
`Ga()` and `Sm()` end up calling `str(some_sympy_object)` in multiple places. Previously, this went through our custom printer, which meant we had to temporarily disable latex printing. Making `str(some_sympy_object)` go through our printer was a mistake that interfered with sympy internals, so a previous commit made it no longer do that. As a result, we no longer need to touch the printer in `__init__`. Even though we're already not relying on it, this code is dangerous: * If `Ga(...)` fails, then the latex printer is left disabled * It isn't threadsafe, constructing a `Ga` in one thread interferes with printing in another
1 parent b9cc8fa commit 42f4c18

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

galgebra/ga.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,6 @@ class Ga(metric.Metric):
359359
dual_mode_value = 'I+'
360360
dual_mode_lst = ['+I', 'I+', '-I', 'I-', '+Iinv', 'Iinv+', '-Iinv', 'Iinv-']
361361

362-
restore = False
363-
364362
a = []
365363

366364
presets = {'o3d': 'x,y,z:[1,1,1]:[1,1,0]',
@@ -447,17 +445,8 @@ def __init__(self, bases, *, wedge=True, **kwargs):
447445
See :class:`galgebra.metric.Metric`.
448446
"""
449447

450-
# Each time a geometric algebra is intialized in setup of append
451-
# the printer must be restored to the simple text mode (not
452-
# enhanced text of latex printing) so that when 'str' is used to
453-
# create symbol names the names are not mangled.
454-
455448
self.wedge_print = wedge
456449

457-
if printer.GaLatexPrinter.latex_flg:
458-
printer.GaLatexPrinter.restore()
459-
Ga.restore = True
460-
461450
metric.Metric.__init__(self, bases, **kwargs)
462451

463452
self.par_coords = None
@@ -506,9 +495,6 @@ def __init__(self, bases, *, wedge=True, **kwargs):
506495
self.i = self.e/sqrt(-self.e_sq)
507496
self.i_inv = -self.i
508497

509-
if Ga.restore: # restore printer to appropriate enhanced mode after ga is instantiated
510-
printer.GaLatexPrinter.redirect()
511-
512498
if self.debug:
513499
print('Exit Ga.__init__()')
514500

@@ -2090,10 +2076,6 @@ def __init__(self, __u, __coords, *, ga, norm=False, name=None, root='e', debug=
20902076

20912077
# print '!!!Enter Sm!!!'
20922078

2093-
if printer.GaLatexPrinter.latex_flg:
2094-
printer.GaLatexPrinter.restore()
2095-
Ga.restore = True
2096-
20972079
u = __u
20982080
coords = __coords
20992081
if ga is None:
@@ -2156,9 +2138,6 @@ def __init__(self, __u, __coords, *, ga, norm=False, name=None, root='e', debug=
21562138
s += dxdu[k][i] * dxdu[l][j] * g_base[k, l].subs(sub_pairs)
21572139
g[i, j] = trigsimp(s)
21582140

2159-
if Ga.restore: # restore printer to appropriate enhanced mode after sm is instantiated
2160-
printer.GaLatexPrinter.redirect()
2161-
21622141
Ga.__init__(self, root, g=g, coords=coords, norm=norm, debug=debug)
21632142

21642143
if isinstance(u, mv.Mv): # Construct additional functions for vector manifold

0 commit comments

Comments
 (0)