Skip to content

Commit

Permalink
Avoid RuntimeError for scalar columns.
Browse files Browse the repository at this point in the history
  • Loading branch information
r-xue committed Feb 4, 2025
1 parent 66ee38c commit 997a556
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/xradio/measurement_set/_utils/_msv2/_tables/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,13 +1249,14 @@ def read_col_conversion(
# Use casacore to get the shape of a row for this column
#################################################################################

# Get the total number of rows in the base measurement set
nrows_total = tb_tool.nrows()

# getcolshapestring() only works on columns where a row element is an
# array ie. fails for TIME
# Assumes the RuntimeError is because the column is a scalar
try:
# tb.getcolshapestring() only works on columns where a row element is an
# array i.e. fails for EXPOSURE, TIME_CENTROID
# A RuntimeError will be triggered when calling getcolshapestring() on a column
# contain scalars.
if tb_tool.isscalarcol(col):
# Get the shape of a row for this column
extra_dimensions = ()
else:
shape_string = tb_tool.getcolshapestring(col)[0]
# Convert `shape_string` into a tuple that numpy understands
extra_dimensions = tuple(
Expand All @@ -1264,8 +1265,6 @@ def read_col_conversion(
for idx in shape_string.replace("[", "").replace("]", "").split(", ")
]
)
except RuntimeError:
extra_dimensions = ()

#################################################################################

Expand Down

0 comments on commit 997a556

Please sign in to comment.