Skip to content

Commit

Permalink
Merge pull request #106 from lsst/u/jeremym/fix-tap-size
Browse files Browse the repository at this point in the history
Fix bugs in how size and arraysize were being handled
  • Loading branch information
JeremyMcCormick authored Sep 27, 2024
2 parents c84042c + b639261 commit b34c43b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions python/felis/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,9 @@ def visit_column(self, column_obj: datamodel.Column, table_obj: Table) -> Tap11B
felis_type = FelisType.felis_type(felis_datatype.value)
column.datatype = column_obj.votable_datatype or felis_type.votable_name

column.arraysize = column_obj.votable_arraysize or column_obj.length
column.arraysize = column_obj.votable_arraysize or (
column_obj.length if (column_obj.length is not None and column_obj.length > 1) else None
)
if (felis_type.is_timestamp or column_obj.datatype == "text") and column.arraysize is None:
column.arraysize = "*"

Expand All @@ -419,16 +421,17 @@ def _is_int(s: str) -> bool:
return False

# Handle the deprecated size attribute
arraysize = column_obj.votable_arraysize
arraysize = column.arraysize
if arraysize is not None and arraysize != "":
if isinstance(arraysize, int):
column.size = arraysize
elif _is_int(arraysize):
column.size = int(arraysize)
elif bool(re.match(r"^[0-9]+\*$", arraysize)):
column.size = int(arraysize.replace("*", ""))
if column.size is not None:
logger.debug(f"Set size to {column.size} for {column.column_name} from arraysize {arraysize}")

if column.size is not None:
logger.debug(f"Set size to {column.size} for {column.column_name} with arraysize {arraysize}")

column.xtype = column_obj.votable_xtype
column.description = column_obj.description
Expand Down

0 comments on commit b34c43b

Please sign in to comment.