Skip to content

Commit

Permalink
test_smax_redis_client tests all now passing
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKGrimes committed Mar 12, 2024
1 parent 4bb8b1b commit 4e42c1f
Show file tree
Hide file tree
Showing 5 changed files with 1,096 additions and 97 deletions.
9 changes: 8 additions & 1 deletion src/smax/smax_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from .smax_data_types import SmaxData, \
SmaxInt, SmaxFloat, SmaxBool, SmaxStr, SmaxStrArray, SmaxArray, SmaxStruct, \
SmaxInt8, SmaxInt16, SmaxInt32, SmaxInt64, SmaxFloat32, SmaxFloat64, \
_TYPE_MAP, _REVERSE_TYPE_MAP, _SMAX_TYPE_MAP, _REVERSE_SMAX_TYPE_MAP
_TYPE_MAP, _REVERSE_TYPE_MAP, _SMAX_TYPE_MAP, _REVERSE_SMAX_TYPE_MAP, \
optional_metadata

class SmaxClient(ABC):

Expand Down Expand Up @@ -150,4 +151,10 @@ def print_smax(smax_value, verbose, indent=0):
print(indent_str, f" date : {datetime.datetime.utcfromtimestamp(smax_value.date)}", sep="")
print(indent_str, f" origin : {smax_value.origin}", sep="")
print(indent_str, f" seq : {smax_value.seq}", sep="")
for meta in optional_metadata:
if hasattr(smax_value, meta):
if getattr(smax_value, meta) is not None:
print(indent_str, f" {meta} : {getattr(smax_value, meta)}", sep="")



11 changes: 10 additions & 1 deletion src/smax/smax_data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
# A .data property is included for backwards compatibility with the SmaxData
# named tuple above.

optional_metadata = [
"description",
"unit",
"coords"
]

@dataclass
class SmaxVarBase(object):
"""Class defining the metadata for SMA-X data types.
Expand Down Expand Up @@ -266,7 +272,10 @@ def __post_init__(self, *args, **kwargs):
except AttributeError:
pass

self.dim = self.shape
if len(self.shape) == 1:
self.dim = self.shape[0]
else:
self.dim = self.shape
self.type = _REVERSE_TYPE_MAP[self.dtype.type]

def __repr__(self):
Expand Down
Loading

0 comments on commit 4e42c1f

Please sign in to comment.