Skip to content

Commit

Permalink
Merge pull request #208 from HERA-Team/allow_force_pspeccontainer
Browse files Browse the repository at this point in the history
Handle bytes/str comparisons in PSpecContainer
  • Loading branch information
philbull committed Jun 26, 2019
2 parents 4a877f1 + 7eb4b8e commit 15e4555
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hera_pspec/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,19 @@ def _load_pspec(self, pspec_group):
pspec_group : HDF5 group
Group containing datasets that contain power spectrum and
supporting information, in a standard format expected by UVPSpec.
Returns
-------
uvp : UVPSpec
Returns a UVPSpec object constructed from the input HDF5 group.
"""
# Check that group is tagged as containing UVPSpec (pspec_type attribute)
if 'pspec_type' in list(pspec_group.attrs.keys()):
if pspec_group.attrs['pspec_type'] != uvpspec.UVPSpec.__name__:

# Convert bytes -> str if needed
pspec_type = pspec_group.attrs['pspec_type']
if isinstance(pspec_type, bytes): pspec_type = pspec_type.decode()
if pspec_type != uvpspec.UVPSpec.__name__:
raise TypeError("HDF5 group is not tagged as a UVPSpec object.")
else:
raise TypeError("HDF5 group is not tagged as a UVPSpec object.")
Expand Down Expand Up @@ -206,7 +210,7 @@ def get_pspec(self, group, psname=None):
psname : str, optional
The name of the power spectrum to return.
Returns
-------
uvp : UVPSpec or list of UVPSpec
Expand Down

0 comments on commit 15e4555

Please sign in to comment.