Skip to content

Commit

Permalink
Update utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Yann21 committed Feb 6, 2024
1 parent fa5b1e0 commit dc04455
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions yann_utils/phd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import subprocess
import os

def csv_to_latex_png(df, png_filename):
def csv_to_latex_png(df, png_filename, caption):
# 1. Convert the df to LaTeX table format
latex_code = r"""
\documentclass{standalone}
\usepackage{booktabs}
\begin{document}
"""
latex_code += df.to_latex(index=False, escape=False)
latex_code += df.to_latex(index=True, escape=False, caption=caption)
latex_code += r"\end{document}"

with open("temp_table.tex", "w") as latex_file:
Expand Down
12 changes: 12 additions & 0 deletions yann_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def enumerate_flipped(xs: List["E"]) -> Generator[Tuple["E", int], None, None]:

class Cache:
"""Persistent and automated caching of objects."""
import os

locs: List[str] = []

Expand All @@ -130,3 +131,14 @@ def load(self, name: str) -> Any:

def __repr__(self):
return "\n".join(self.locs)

def set_seed(seed):
import random
import numpy as np
import torch

random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
# if torch is installed

0 comments on commit dc04455

Please sign in to comment.