Skip to content

Commit

Permalink
Merge pull request #1386 from econ-ark/SaveFigMetadataBug
Browse files Browse the repository at this point in the history
Remove metadata argument for jpg in make_figs
  • Loading branch information
mnwhite authored Feb 20, 2024
2 parents 6c89ee9 + c962d1e commit 6a73c4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions HARK/tests/test_HARKutilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import unittest
from types import SimpleNamespace

import matplotlib.pyplot as plt
import numpy as np

from HARK.rewards import (
Expand All @@ -14,7 +15,7 @@
CRRAutilityPPP,
CRRAutilityPPPP,
)
from HARK.utilities import construct_assets_grid
from HARK.utilities import construct_assets_grid, make_figs


class testsForHARKutilities(unittest.TestCase):
Expand Down Expand Up @@ -66,7 +67,7 @@ def test_CRRAutilityPPPP(self):
self.derivative_func_comparison(CRRAutilityPPPP, CRRAutilityPPP)

def test_asset_grid(self):
# test linear asset grid
# Test linear asset grid

params = {
"aXtraMin": 0.0,
Expand All @@ -83,3 +84,10 @@ def test_asset_grid(self):
test = np.unique(np.diff(aXtraGrid).round(decimals=3))

self.assertEqual(test.size, 1)

def test_make_figs(self):
# Test the make_figs() function with a trivial output
plt.figure()
plt.plot(np.linspace(1, 5, 40), np.linspace(4, 8, 40))
make_figs("test", True, False, target_dir="")
plt.clf()
2 changes: 1 addition & 1 deletion HARK/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ def make_figs(figure_name, saveFigs, drawFigs, target_dir="Figures"):
print(f"Saving figure {figure_name} in {target_dir}")
plt.savefig(
os.path.join(target_dir, f"{figure_name}.jpg"),
metadata={"CreationDate": None},
# metadata is not supported for jpg
) # For web/html
plt.savefig(
os.path.join(target_dir, f"{figure_name}.png"),
Expand Down

0 comments on commit 6a73c4f

Please sign in to comment.