def normalize_in_schema(cls, schema): r"""Normalization for the 'subtype' scalar property in a schema.""" if cls.name in schema: return schema if not units.is_null_unit(schema.get('units', '')): schema.setdefault(cls.name, 'float') return schema
def get_extract_properties(cls, metadata): r"""Get the list of properties that should be kept when extracting a typedef from message metadata. Args: metadata (dict): Metadata that typedef is being extracted from. Returns: list: Keywords that should be kept in the typedef. """ out = super(ScalarMetaschemaType, cls).get_extract_properties(metadata) dtype = metadata.get('subtype', metadata['type']) if (((dtype in ScalarMetaschemaProperties._flexible_types) and (metadata['type'] not in ['1darray', 'ndarray']) and (not metadata.get('fixed_precision', False)))): out.remove('precision') if units.is_null_unit(metadata.get('units', '')): out.remove('units') return out
def test_is_null_unit(self): r"""Test is_null_unit.""" assert (units.is_null_unit('n/a')) assert (units.is_null_unit('')) assert (not units.is_null_unit('cm'))