Skip to content

Bug: Incorrect handling of NULL in results returning astropy Table #3

@rickyegeland

Description

@rickyegeland

For example:

result = db.fetch_data_table('Baliunas1995', ['S_mean', 'activity_class', 'Pcyc', 'Pcyc2'], meta={'Pcyc':'FAPGrade'}, nulls=True

has a dtype:

[('star', 'S12'), ('S_mean', '<f8'), ('activity_class', 'S12'), ('Pcyc', 'O'), ('Pcyc2', 'O'), ('FAPGrade', 'O')]

Which causes all sorts of problems when trying to plot, for example. The ugly workaround is to cast the column post-fetch:

   print result.dtype
   for i, col in enumerate(result.colnames):
        if col in ('Pcyc', 'Pcyc2'):
            dtype[i] = 'float64'
            result[col].fill_value = np.nan
            result[col] = result[col].astype('float64')
        if col in ('FAPGrade'):
            dtype[i] = 'S'
            result[col].mask = [x is None for x in result[col]]
    result = astropy.table.Table(result, dtype=dtype)
    for col in ('Pcyc', 'Pcyc2'):
        result[col].mask = np.isnan(result[col])
    print "Final:", result.dtype

This needs to be handled in fetchall_astropy()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions