Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Yann21 committed Aug 17, 2024
1 parent dc04455 commit 933ab3b
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 124 deletions.
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

13 changes: 0 additions & 13 deletions AUTHORS.rst

This file was deleted.

8 changes: 0 additions & 8 deletions HISTORY.rst

This file was deleted.

11 changes: 0 additions & 11 deletions MANIFEST.in

This file was deleted.

27 changes: 0 additions & 27 deletions logging.conf

This file was deleted.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ pytest = "^7.4.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.ruff]
indent-width=2
3 changes: 1 addition & 2 deletions tests/test_chunking.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import numpy as np
import pytest

from yann_utils.chunking import (chunk_obj, get_chunks, persist_chunks,
reconstruct_obj)
from yann_utils.chunking import chunk_obj, get_chunks, persist_chunks, reconstruct_obj


@pytest.fixture
Expand Down
19 changes: 0 additions & 19 deletions tox.ini

This file was deleted.

31 changes: 16 additions & 15 deletions yann_utils/phd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
import subprocess
import os


def csv_to_latex_png(df, png_filename, caption):
# 1. Convert the df to LaTeX table format
latex_code = r"""
# 1. Convert the df to LaTeX table format
latex_code = r"""
\documentclass{standalone}
\usepackage{booktabs}
\begin{document}
"""
latex_code += df.to_latex(index=True, escape=False, caption=caption)
latex_code += r"\end{document}"
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:
latex_file.write(latex_code)
with open("temp_table.tex", "w") as latex_file:
latex_file.write(latex_code)

# 2. Compile the LaTeX to produce a PDF
subprocess.call(["pdflatex", "-interaction=nonstopmode", "temp_table.tex"])
# 2. Compile the LaTeX to produce a PDF
subprocess.call(["pdflatex", "-interaction=nonstopmode", "temp_table.tex"])

# 3. Convert the PDF to PNG
subprocess.call(["pdftoppm", "-png", "temp_table.pdf", "temp_table"])
# 3. Convert the PDF to PNG
subprocess.call(["pdftoppm", "-png", "temp_table.pdf", "temp_table"])

# Rename to the desired png filename
os.rename("temp_table-1.png", png_filename)
# Rename to the desired png filename
os.rename("temp_table-1.png", png_filename)

# Clean up intermediate files
for ext in [".tex", ".aux", ".log", ".pdf"]:
os.remove("temp_table" + ext)
# Clean up intermediate files
for ext in [".tex", ".aux", ".log", ".pdf"]:
os.remove("temp_table" + ext)
4 changes: 3 additions & 1 deletion yann_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import Dict, Generator, Tuple
import pickle
from tqdm import tqdm
import os


A = TypeVar("A")
Expand Down Expand Up @@ -107,6 +108,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 @@ -132,6 +134,7 @@ def load(self, name: str) -> Any:
def __repr__(self):
return "\n".join(self.locs)


def set_seed(seed):
import random
import numpy as np
Expand All @@ -141,4 +144,3 @@ def set_seed(seed):
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
# if torch is installed

0 comments on commit 933ab3b

Please sign in to comment.