()
| 88 | |
| 89 | |
| 90 | def _ensure_slicap() -> bool: |
| 91 | global _slicap_ready, _slicap_check, _slicap_latex |
| 92 | if _slicap_ready is not None: |
| 93 | return _slicap_ready |
| 94 | orig = os.getcwd() |
| 95 | try: |
| 96 | os.chdir(get_cache_dir()) |
| 97 | with contextlib.redirect_stdout(io.StringIO()): |
| 98 | from SLiCAP.SLiCAPmath import _checkExpression |
| 99 | from SLiCAP.SLiCAPhtml import _latex_ENG |
| 100 | from SLiCAP.SLiCAPlatex import sub2rm |
| 101 | _slicap_check = _checkExpression |
| 102 | # IEEE typesetting: subscripts that are plain alphanumeric labels are set |
| 103 | # upright (\mathrm) rather than italic. Applied here, at the single |
| 104 | # SLiCAP→LaTeX boundary, so every generated equation/symbol — component |
| 105 | # value labels and the parameter & model tables alike — is formatted |
| 106 | # consistently. (Free-form user LaTeX fragments do not pass through here |
| 107 | # and keep whatever formatting the user wrote.) |
| 108 | def _latex_ieee(sympy_obj): |
| 109 | s = _latex_ENG(sympy_obj) |
| 110 | return sub2rm(s) if s else s |
| 111 | _slicap_latex = _latex_ieee |
| 112 | _slicap_ready = True |
| 113 | except Exception: |
| 114 | _slicap_ready = False |
| 115 | finally: |
| 116 | os.chdir(orig) |
| 117 | return _slicap_ready |
| 118 | |
| 119 | |
| 120 | # ── calibration ─────────────────────────────────────────────────────────────── |
no test coverage detected