to_table_type#
- gwpy.io.ligolw.to_table_type(val: object, cls: type[Table], colname: str) object[source]#
Cast a value to the correct type for inclusion in a LIGO_LW table.
This method returns the input unmodified if a type mapping for
colnameisn’t found.- Parameters:
- Returns:
- obj
object The input
valcast to the correct type
- obj
Examples
>>> from gwpy.io.ligolw import to_table_type as to_ligolw_type >>> from igwn_ligolw.lsctables import SnglBurstTable >>> x = to_ligolw_type(1.0, SnglBurstTable, 'central_freq')) >>> print(type(x), x) <class 'numpy.float32'> 1.0