Field Meta¶
This module defines the structure of meta-data that describes the field name, field type, special field attribute, etc. for a field in a dataset.
-
class
nupic.data.field_meta.
FieldMetaInfo
(name, type, special)¶ This class acts as a container of meta-data for a single field (column) of a dataset. Each instance of this class has
name
,type
, andspecial
properties.Examples:
Access a sub-element from an instance of FieldMetaInfo:
metainfo.name
metainfo.type
metainfo.special
Create a single element of
FieldMetaInfo
from a tuple ofname
,type
, andspecial
:e = ('pounds', FieldMetaType.float, FieldMetaSpecial.none) m = FieldMetaInfo.createFromFileFieldElement(e)
Parameters: - name (str) – field name
- type (str) – one of the values from FieldMetaType
- special (str) – one of the values from FieldMetaSpecial
Raises: ValueError – if type or special arg values are invalid
-
static
createFromFileFieldElement
(fieldInfoTuple)¶ Creates a
fieldmeta.FieldMetaInfo
instance from a tuple containingname
,type
, andspecial
.Parameters: fieldInfoTuple – Must contain name
,type
, andspecial
Returns: FieldMetaInfo
instance
-
classmethod
createListFromFileFieldList
(fields)¶ Creates a FieldMetaInfo list from the a list of tuples. Basically runs
createFromFileFieldElement()
on each tuple.Example:
# Create a list of FieldMetaInfo instances from a list of File meta-data # tuples el = [("pounds", FieldMetaType.float, FieldMetaSpecial.none), ("price", FieldMetaType.float, FieldMetaSpecial.none), ("id", FieldMetaType.string, FieldMetaSpecial.sequence), ("date", FieldMetaType.datetime, FieldMetaSpecial.timestamp), ] ml = FieldMetaInfo.createListFromFileFieldList(el)
Parameters: fields – a sequence of field attribute tuples conforming to the format of name
,type
, andspecial
Returns: A list of FieldMetaInfo
elements corresponding to the given ‘fields’ list.
-
class
nupic.data.field_meta.
FieldMetaType
¶ Public values for the field data types. Valid types are:
string
datetime
int
float
bool
list
sdr
-
classmethod
isValid
(fieldDataType)¶ Check a candidate value whether it’s one of the valid field data types
Parameters: fieldDataType – (string) candidate field data type Returns: True if the candidate value is a legitimate field data type value; False if not
-
class
nupic.data.field_meta.
FieldMetaSpecial
¶ Public values for the “special” field attribute. Valid values are:
R
: resetS
: sequenceT
: timestampC
: categoryL
: learning
-
classmethod
isValid
(attr)¶ Check a candidate value whether it’s one of the valid attributes
Parameters: attr – (string) candidate value Returns: True if the candidate value is a legitimate “special” field attribute; False if not