Skip to content

Commit

Permalink
remove dependency on TeX
Browse files Browse the repository at this point in the history
  • Loading branch information
md-arif-shaikh committed Apr 24, 2023
1 parent 7288857 commit 0e76e8b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ jobs:
# See https://stackoverflow.com/questions/58121461/runtimeerror-failed-to-process-string-with-tex-because-latex-could-not-be-found
# and https://github.com/garrettj403/SciencePlots/issues/53
sudo apt update
sudo apt-get install texlive-latex-extra texlive-fonts-recommended cm-super
# sudo apt-get install texlive-latex-extra texlive-fonts-recommended cm-super
elif [ "$RUNNER_OS" == "macOS" ]; then
# Install macports for the latex stuff. See https://github.com/GiovanniBussi/macports-ci
curl -LO https://raw.githubusercontent.com/GiovanniBussi/macports-ci/master/macports-ci
source ./macports-ci install
sudo port install texlive-latex-extra texlive-fonts-recommended
# sudo port install texlive-latex-extra texlive-fonts-recommended
fi
pip install pytest nbconvert ipykernel latex
Expand Down
4 changes: 2 additions & 2 deletions examples/gw_eccentricity_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"from gw_eccentricity import measure_eccentricity\n",
"from gw_eccentricity import get_available_methods\n",
"from gw_eccentricity.plot_settings import use_fancy_plotsettings, labelsDict\n",
"use_fancy_plotsettings() # for better looking plots"
"use_fancy_plotsettings(usetex=False)"
]
},
{
Expand Down Expand Up @@ -884,7 +884,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
"version": "3.10.9"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/load_waveform_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
"}\n",
"origin = \"LAL\"\n",
"dataDict = load_waveform(origin, **kwargs)\n",
"use_fancy_plotsettings() # use better defaults for plotting\n",
"use_fancy_plotsettings(usetex=False)\n",
"fig, ax = plt.subplots(figsize=(12, 4))\n",
"# Plot the amplitude of the (2,2) mode\n",
"ax.plot(dataDict[\"t\"], np.abs(dataDict[\"hlm\"][(2, 2)]), label=kwargs[\"approximant\"])\n",
Expand Down Expand Up @@ -371,7 +371,7 @@
"dataDict = load_waveform(origin, **kwargs)\n",
"\n",
"# use better defaults for plotting\n",
"use_fancy_plotsettings()\n",
"use_fancy_plotsettings(usetex=False)\n",
"fig, ax = plt.subplots(figsize=(12, 4))\n",
"# plot amplitude of the (2, 2) mode of eccentric waveform\n",
"ax.plot(dataDict[\"t\"], np.abs(dataDict[\"hlm\"][(2, 2)]), label=origin)\n",
Expand Down Expand Up @@ -499,7 +499,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
"version": "3.10.9"
},
"vscode": {
"interpreter": {
Expand Down
60 changes: 34 additions & 26 deletions gw_eccentricity/eccDefinition.py
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,7 @@ def get_fref_out(self, fref_in, method):
def make_diagnostic_plots(
self,
add_help_text=True,
usetex=True,
usetex=False,
style=None,
use_fancy_settings=True,
twocol=False,
Expand Down Expand Up @@ -1977,7 +1977,7 @@ def make_diagnostic_plots(
Default is True.
usetex:
If True, use TeX to render texts.
Default is True.
Default is False.
style:
Set font size, figure size suitable for particular use case. For
example, to generate plot for "APS" journals, use style="APS". For
Expand Down Expand Up @@ -2062,7 +2062,7 @@ def plot_eccentricity(
fig=None,
ax=None,
add_help_text=True,
usetex=True,
usetex=False,
style="Notebook",
use_fancy_settings=True,
add_vline_at_tref=True,
Expand All @@ -2082,7 +2082,7 @@ def plot_eccentricity(
Default is True.
usetex:
If True, use TeX to render texts.
Default is True.
Default is False.
style:
Set font size, figure size suitable for particular use case. For
example, to generate plot for "APS" journals, use style="APS". For
Expand Down Expand Up @@ -2134,7 +2134,7 @@ def plot_decc_dt(
fig=None,
ax=None,
add_help_text=True,
usetex=True,
usetex=False,
style="Notebook",
use_fancy_settings=True,
**kwargs):
Expand All @@ -2155,7 +2155,7 @@ def plot_decc_dt(
Default is True.
usetex:
If True, use TeX to render texts.
Default is True.
Default is False.
style:
Set font size, figure size suitable for particular use case. For
example, to generate plot for "APS" journals, use style="APS". For
Expand Down Expand Up @@ -2207,7 +2207,7 @@ def plot_mean_anomaly(
fig=None,
ax=None,
add_help_text=True,
usetex=True,
usetex=False,
style="Notebook",
use_fancy_settings=True,
add_vline_at_tref=True,
Expand All @@ -2227,7 +2227,7 @@ def plot_mean_anomaly(
Default is True.
usetex:
If True, use TeX to render texts.
Default is True.
Default is False.
style:
Set font size, figure size suitable for particular use case. For
example, to generate plot for "APS" journals, use style="APS". For
Expand Down Expand Up @@ -2279,7 +2279,7 @@ def plot_omega22(
fig=None,
ax=None,
add_help_text=True,
usetex=True,
usetex=False,
style="Notebook",
use_fancy_settings=True,
**kwargs):
Expand All @@ -2302,7 +2302,7 @@ def plot_omega22(
Default is True.
usetex:
If True, use TeX to render texts.
Default is True.
Default is False.
style:
Set font size, figure size suitable for particular use case. For
example, to generate plot for "APS" journals, use style="APS". For
Expand Down Expand Up @@ -2350,12 +2350,20 @@ def plot_omega22(
ax.set_ylim(ymin - pad, ymax + pad)
# add help text
if add_help_text:
if usetex:
help_text = (
r"\noindent To avoid extrapolation, first and last\\"
r"extrema are excluded when\\"
r"evaluating $\omega_{a}$/$\omega_{p}$ interpolants")
else:
help_text = (
"To avoid extrapolation, first and last\n"
"extrema are excluded when\n"
r"evaluating $\omega_{a}$/$\omega_{p}$ interpolants")
ax.text(
0.22,
0.98,
(r"\noindent To avoid extrapolation, first and last\\"
r"extrema are excluded when\\"
r"evaluating $\omega_{a}$/$\omega_{p}$ interpolants"),
help_text,
ha="left",
va="top",
transform=ax.transAxes)
Expand All @@ -2373,7 +2381,7 @@ def plot_omega22_average(
fig=None,
ax=None,
add_help_text=True,
usetex=True,
usetex=False,
style="Notebook",
use_fancy_settings=True,
plot_omega22=True,
Expand All @@ -2394,7 +2402,7 @@ def plot_omega22_average(
Default is True.
usetex:
If True, use TeX to render texts.
Default is True.
Default is False.
style:
Set font size, figure size suitable for particular use case. For
example, to generate plot for "APS" journals, use style="APS". For
Expand Down Expand Up @@ -2459,7 +2467,7 @@ def plot_omega22_average(
ax.text(
0.35,
0.98,
(r"\noindent omega22_average should be "
(r"omega22_average should be "
"monotonically increasing."),
ha="left",
va="top",
Expand All @@ -2476,7 +2484,7 @@ def plot_amp22(
fig=None,
ax=None,
add_help_text=True,
usetex=True,
usetex=False,
style="Notebook",
use_fancy_settings=True,
**kwargs):
Expand All @@ -2498,7 +2506,7 @@ def plot_amp22(
Default is True.
usetex:
If True, use TeX to render texts.
Default is True.
Default is False.
style:
Set font size, figure size suitable for particular use case. For
example, to generate plot for "APS" journals, use style="APS". For
Expand Down Expand Up @@ -2546,7 +2554,7 @@ def plot_phase_diff_ratio_between_extrema(
fig=None,
ax=None,
add_help_text=True,
usetex=True,
usetex=False,
style="Notebook",
use_fancy_settings=True,
**kwargs):
Expand All @@ -2571,7 +2579,7 @@ def plot_phase_diff_ratio_between_extrema(
Default is True.
usetex:
If True, use TeX to render texts.
Default is True.
Default is False.
style:
Set font size, figure size suitable for particular use case. For
example, to generate plot for "APS" journals, use style="APS". For
Expand Down Expand Up @@ -2637,7 +2645,7 @@ def plot_residual_omega22(
fig=None,
ax=None,
add_help_text=True,
usetex=True,
usetex=False,
style="Notebook",
use_fancy_settings=True,
**kwargs):
Expand All @@ -2660,7 +2668,7 @@ def plot_residual_omega22(
Default is True.
usetex:
If True, use TeX to render texts.
Default is True.
Default is False.
style:
Set font size, figure size suitable for particular use case. For
example, to generate plot for "APS" journals, use style="APS". For
Expand Down Expand Up @@ -2710,7 +2718,7 @@ def plot_residual_amp22(
fig=None,
ax=None,
add_help_text=True,
usetex=True,
usetex=False,
style="Notebook",
use_fancy_settings=True,
**kwargs):
Expand All @@ -2729,7 +2737,7 @@ def plot_residual_amp22(
Default is True.
usetex:
If True, use TeX to render texts.
Default is True.
Default is False.
style:
Set font size, figure size suitable for particular use case. For
example, to generate plot for "APS" journals, use style="APS". For
Expand Down Expand Up @@ -2781,7 +2789,7 @@ def plot_data_used_for_finding_extrema(
fig=None,
ax=None,
add_help_text=True,
usetex=True,
usetex=False,
style="Notebook",
use_fancy_settings=True,
add_vline_at_tref=True,
Expand All @@ -2802,7 +2810,7 @@ def plot_data_used_for_finding_extrema(
Default is True.
usetex:
If True, use TeX to render texts.
Default is True.
Default is False.
style:
Set font size, figure size suitable for particular use case. For
example, to generate plot for "APS" journals, use style="APS". For
Expand Down
5 changes: 3 additions & 2 deletions gw_eccentricity/plot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ def use_fancy_plotsettings(usetex=True, style="Notebook"):
rc("legend", frameon=False)
rc("legend", fontsize=fontSizeDict[style])
# Fonts
rc("font", family="serif")
rc("font", serif="times")
if usetex:
rc("font", family="serif")
rc("font", serif="times")
rc("font", size=fontSizeDict[style])
# Lines
rc("lines", linewidth=1.0)
Expand Down

0 comments on commit 0e76e8b

Please sign in to comment.