Skip to content

Commit

Permalink
Merge pull request #30 from mschweikardt/main
Browse files Browse the repository at this point in the history
add print representation of Lookup object
  • Loading branch information
dreoilin committed Sep 3, 2024
2 parents ea5915b + faba08c commit 2288ae4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ setup_requires =
matplotlib
psf_utils
tqdm
prettytable
install_requires =
numpy
scipy
matplotlib
psf_utils
tqdm
prettytable

[options.packages.find]
where = src
where = src
21 changes: 21 additions & 0 deletions src/pygmid/Lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import scipy.io
from scipy.interpolate import interpn
import pickle
import prettytable

from .constants import *
from .numerical import interp1
Expand Down Expand Up @@ -413,3 +414,23 @@ def fco(self, **kwargs):
dimensions
"""
return self.look_up('SFL_STH', **kwargs)

def __str__(self):

tab = prettytable.PrettyTable()
tab.field_names = ['Variable', 'Size', 'Min', 'Max']

for k, v in self.__DATA.items():

is_numeric = np.issubdtype(v.dtype, np.number)

if is_numeric:
size = str(v.shape).replace('(', '').replace(')', '').\
replace(', ', 'x').replace(',', '')

tab.add_row([ k
, size if size else '1'
, f'{v.min():.2e}' if is_numeric else 'N/A'
, f'{v.max():.2e}' if is_numeric else 'N/A'])

return tab.get_string()

0 comments on commit 2288ae4

Please sign in to comment.