Skip to content

Commit

Permalink
Chore: publish; Update: project plot save args
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanHeng committed Feb 28, 2024
1 parent edd721f commit 72b0b56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = '0.37.0'
VERSION = '0.37.1'
DESCRIPTION = 'Machine Learning project startup utilities'
LONG_DESCRIPTION = 'My commonly used utilities for machine learning projects'

Expand All @@ -13,7 +13,7 @@
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
url='https://github.com/StefanHeng/stef-util',
download_url='https://github.com/StefanHeng/stef-util/archive/refs/tags/v0.37.0.tar.gz',
download_url='https://github.com/StefanHeng/stef-util/archive/refs/tags/v0.37.1.tar.gz',
packages=find_packages(),
include_package_data=True,
install_requires=[
Expand Down
10 changes: 8 additions & 2 deletions stefutil/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def __init__(
logger.info(f'Created directory {pl.i(path)}')

def save_fig(
self, title: str = None, save: bool = True, prefix_time: bool = True, save_path: str = None, time_args: Dict = None
self, title: str = None, save: bool = True, prefix_time: bool = True, save_path: str = None, time_args: Dict = None,
fmt: str = 'png', **kwargs
):
"""
:param title: Rendered figure title
Expand All @@ -106,6 +107,7 @@ def save_fig(
Otherwise, timestamp is appended to the end
:param save_path: disk path to save figure
:param time_args: `now` arguments
:param fmt: file format
"""
if save:
try:
Expand All @@ -130,7 +132,11 @@ def save_fig(
else:
fnm = f'{title}, {t}.png'
path = os_join((save_path or self.plot_path), fnm)
plt.savefig(path, dpi=300)
args = dict(fmt=fmt)
if fmt == 'png':
args['dpi'] = 300
args.update(kwargs)
plt.savefig(path, **args)
if self.verbose:
d_log = dict(title=title, path=path)
logger.info(f'Saved figure w/ {pl.i(d_log)}')

0 comments on commit 72b0b56

Please sign in to comment.