Converter

class astropy.io.votable.converters.Converter(field, config={}, pos=None) [edit on github][source]

Bases: object

The base class for all converters. Each subclass handles converting a specific VOTABLE data type to/from the TABLEDATA and BINARY on-disk representations.

Parameters :

field : Field

object describing the datatype

config : dict

The parser configuration dictionary

pos : tuple

The position in the XML file where the FIELD object was found. Used for error messages.

Methods Summary

binparse(read) Reads some number of bytes from the BINARY format representation by calling the function read, and returns the native in-memory object representation for the datatype handled by self.
parse(value[, config, pos]) Convert the string value from the TABLEDATA format into an object with the correct native in-memory datatype and mask flag.
output(value, mask) Convert the object value (in the native in-memory datatype) to a unicode string suitable for serializing in the TABLEDATA format.
parse_scalar(value[, config, pos]) Parse a single scalar of the underlying type of the converter.
binoutput(value, mask) Convert the object value in the native in-memory datatype to a string of bytes suitable for serialization in the BINARY format.

Methods Documentation

binparse(read) [edit on github][source]

Reads some number of bytes from the BINARY format representation by calling the function read, and returns the native in-memory object representation for the datatype handled by self.

Parameters :

read : function

A function that given a number of bytes, returns a byte string.

Returns :

native : tuple (value, mask)

The value as a Numpy array or scalar, and mask is True if the value is missing.

parse(value, config={}, pos=None) [edit on github][source]

Convert the string value from the TABLEDATA format into an object with the correct native in-memory datatype and mask flag.

Parameters :

value : str

value in TABLEDATA format

Returns :

native : tuple (value, mask)

The value as a Numpy array or scalar, and mask is True if the value is missing.

output(value, mask) [edit on github][source]

Convert the object value (in the native in-memory datatype) to a unicode string suitable for serializing in the TABLEDATA format.

Parameters :

value : native type corresponding to this converter

The value

mask : bool

If True, will return the string representation of a masked value.

Returns :

tabledata_repr : unicode

parse_scalar(value, config={}, pos=None) [edit on github][source]

Parse a single scalar of the underlying type of the converter. For non-array converters, this is equivalent to parse. For array converters, this is used to parse a single element of the array.

Parameters :

value : str

value in TABLEDATA format

Returns :

native : tuple (value, mask)

The value as a Numpy array or scalar, and mask is True if the value is missing.

binoutput(value, mask) [edit on github][source]

Convert the object value in the native in-memory datatype to a string of bytes suitable for serialization in the BINARY format.

Parameters :

value : native type corresponding to this converter

The value

mask : bool

If True, will return the string representation of a masked value.

Returns :

bytes : byte string

The binary representation of the value, suitable for serialization in the BINARY format.

Page Contents