Skip to content

Commit

Permalink
Merge pull request #355 from pfafflabatuiuc/small_fixes
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
wpfff committed Dec 6, 2022
2 parents 72a8f4c + 50a025b commit b2cd882
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions plottr/data/datadict.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ def __eq__(self, other: object) -> bool:
else:
return datasets_are_equal(self, other)

def __repr__(self) -> str:
ret = ""
for i, dn in enumerate(self.dependents()):
if i > 0:
ret += "\n"
ret += f"{self.label(dn)}: {self[dn]['values'].shape}"
for ax in self.axes(dn):
ret += f"\n \u2319 {self.label(ax)}: {self[ax]['values'].shape}"
return ret

# Assignment and retrieval of data and meta data

@staticmethod
Expand Down Expand Up @@ -1039,6 +1049,9 @@ def validate(self) -> bool:
msg += (f"Malformed data: {na} is expected to be {axis_num}th "
"axis but has no variation along that axis.\n")

if '__shape__' in v:
v['__shape__'] = shp

if msg != '\n':
raise ValueError(msg)

Expand Down
4 changes: 3 additions & 1 deletion plottr/data/datadict_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
crashes. If the process is suddenly stopped however, we cannot guarantee that the file lock will be deleted.
"""
import os
import logging
import time
import datetime
import uuid
Expand All @@ -34,6 +35,7 @@
DATAFILEXT = 'ddh5'
TIMESTRFORMAT = "%Y-%m-%d %H:%M:%S"

logger = logging.getLogger(__name__)

# FIXME: need correct handling of dtypes and list/array conversion

Expand Down Expand Up @@ -604,7 +606,7 @@ def __init__(self,
def __enter__(self) -> "DDH5Writer":
if self.filepath is None:
self.filepath = _data_file_path(self.data_file_path(), True)
print('Data location: ', self.filepath)
logger.info(f'Data location: {self.filepath}')

nrecords: Optional[int] = self.datadict.nrecords()
if nrecords is not None and nrecords > 0:
Expand Down

0 comments on commit b2cd882

Please sign in to comment.