MilesCranmer commited on
Commit
2665e2b
1 Parent(s): 177ae5a

Clean up how fonts are set

Browse files
Files changed (1) hide show
  1. gui/app.py +14 -8
gui/app.py CHANGED
@@ -1,6 +1,8 @@
1
  import multiprocessing as mp
2
  import os
 
3
  import time
 
4
 
5
  import gradio as gr
6
  import numpy as np
@@ -8,10 +10,15 @@ import pandas as pd
8
  from matplotlib import pyplot as plt
9
 
10
  plt.ioff()
11
- import tempfile
12
- from pathlib import Path
13
-
14
- empty_df = pd.DataFrame(
 
 
 
 
 
15
  {
16
  "equation": [],
17
  "loss": [],
@@ -69,17 +76,17 @@ def _greet_dispatch(
69
  df = pd.read_csv(file_input)
70
  if len(df) == 0:
71
  return (
72
- empty_df,
73
  "The file is empty!",
74
  )
75
  if len(df.columns) == 1:
76
  return (
77
- empty_df,
78
  "The file has only one column!",
79
  )
80
  if len(df) > 10_000 and not force_run:
81
  return (
82
- empty_df,
83
  "You have uploaded a file with more than 10,000 rows. "
84
  "This will take very long to run. "
85
  "Please upload a subsample of the data, "
@@ -417,7 +424,6 @@ def main():
417
 
418
 
419
  def replot_pareto(df, maxsize):
420
- plt.rcParams["font.family"] = "IBM Plex Mono"
421
  fig, ax = plt.subplots(figsize=(6, 6), dpi=100)
422
 
423
  if len(df) == 0 or "Equation" not in df.columns:
 
1
  import multiprocessing as mp
2
  import os
3
+ import tempfile
4
  import time
5
+ from pathlib import Path
6
 
7
  import gradio as gr
8
  import numpy as np
 
10
  from matplotlib import pyplot as plt
11
 
12
  plt.ioff()
13
+ plt.rcParams["font.family"] = [
14
+ "IBM Plex Mono",
15
+ # Fallback fonts:
16
+ "DejaVu Sans Mono",
17
+ "Courier New",
18
+ "monospace",
19
+ ]
20
+
21
+ empty_df = lambda: pd.DataFrame(
22
  {
23
  "equation": [],
24
  "loss": [],
 
76
  df = pd.read_csv(file_input)
77
  if len(df) == 0:
78
  return (
79
+ empty_df(),
80
  "The file is empty!",
81
  )
82
  if len(df.columns) == 1:
83
  return (
84
+ empty_df(),
85
  "The file has only one column!",
86
  )
87
  if len(df) > 10_000 and not force_run:
88
  return (
89
+ empty_df(),
90
  "You have uploaded a file with more than 10,000 rows. "
91
  "This will take very long to run. "
92
  "Please upload a subsample of the data, "
 
424
 
425
 
426
  def replot_pareto(df, maxsize):
 
427
  fig, ax = plt.subplots(figsize=(6, 6), dpi=100)
428
 
429
  if len(df) == 0 or "Equation" not in df.columns: