-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic latex display support if unicodeit is installed (#858)
If the external package [unicodeit](https://github.com/svenkreiss/unicodeit) is installed, translate variable names which contain simple LaTeX into unicode that mimics the correct LaTeX rendering. This only works for very basic LaTeX like `$\alpha$`.
- Loading branch information
1 parent
d83dc28
commit 6f057af
Showing
13 changed files
with
151 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import contextlib | ||
import warnings | ||
from iminuit.warnings import OptionalDependencyWarning | ||
|
||
|
||
@contextlib.contextmanager | ||
def optional_module_for(functionality, *, replace=None, stacklevel=3): | ||
try: | ||
yield | ||
except ModuleNotFoundError as e: | ||
package = e.name.split(".")[0] | ||
if replace: | ||
package = replace.get(package, package) | ||
msg = ( | ||
f"{functionality} requires optional package {package!r}. " | ||
f"Install {package!r} manually to enable this functionality." | ||
) | ||
warnings.warn(msg, OptionalDependencyWarning, stacklevel=stacklevel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""Warnings used by iminuit.""" | ||
|
||
|
||
class IMinuitWarning(RuntimeWarning): | ||
"""Generic iminuit warning.""" | ||
|
||
|
||
class OptionalDependencyWarning(IMinuitWarning): | ||
"""Feature requires an optional external package.""" | ||
|
||
|
||
class HesseFailedWarning(IMinuitWarning): | ||
"""HESSE failed warning.""" | ||
|
||
|
||
class PerformanceWarning(UserWarning): | ||
"""Warning about performance issues.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
┌───┬──────┬───────────┬───────────┬────────────┬────────────┬─────────┬─────────┬───────┐ | ||
│ │ Name │ Value │ Hesse Err │ Minos Err- │ Minos Err+ │ Limit- │ Limit+ │ Fixed │ | ||
├───┼──────┼───────────┼───────────┼────────────┼────────────┼─────────┼─────────┼───────┤ | ||
│ 0 │ α │ 1.00 │ 0.01 │ │ │ │ │ │ | ||
└───┴──────┴───────────┴───────────┴────────────┴────────────┴─────────┴─────────┴───────┘ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
┌───┬──────────┬───────────┬───────────┬────────────┬────────────┬─────────┬─────────┬───────┐ | ||
│ │ Name │ Value │ Hesse Err │ Minos Err- │ Minos Err+ │ Limit- │ Limit+ │ Fixed │ | ||
├───┼──────────┼───────────┼───────────┼────────────┼────────────┼─────────┼─────────┼───────┤ | ||
│ 0 │ $\alpha$ │ 1.00 │ 0.01 │ │ │ │ │ │ | ||
└───┴──────────┴───────────┴───────────┴────────────┴────────────┴─────────┴─────────┴───────┘ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm confused by this comment. The linked bug report says that the ipykernel dependency was intentionally removed, and you list ipykernel explicitly, so I find it hard to understand why prevent upgrading.