Table Attributes#
Attributes are descriptors attached to Table classes. They
describe scalar values associated with an entire table of
data. Instead of repeating the value for every row, attributes
efficiently store it just once.
Attributes are preserved through serialization, because they are stored in table metadata.
Example usage:
from quivr import Table, StringAttribute, Float64Column
class Observations(Table):
x = Float64Column()
y = Float64Column()
z = Float64Column()
reference_frame = StringAttribute(default="earth")
obs = Observations.from_data(
x=[1, 2, 3],
y=[4, 5, 6]
z=[7, 8, 9],
reference_frame="mars"
)
print(obs.reference_frame) # prints 'mars'
- class quivr.StringAttribute(default=None)#
StringAttribute represents a string which is stored as UTF-8 bytes in Table metadata.
- class quivr.FloatAttribute(default=None, nbytes=8)#
FloatAttribute represents a floating-point number which is stored as little-endian bytes in Table metadata.
The number of bytes used to store the float must be specified up-front.
- class quivr.IntAttribute(default=None, nbytes=8, signed=True)#
IntAttribute represents an integer which is stored as little-endian bytes in Table metadata.
The number of bytes used to store the integer must be specified up-front, as well as whether it is signed.
- Parameters:
default (
Optional[int]) – The default value for this attribute. If no default is provided, then the attribute must be set whenever constructing a table that uses it.nbytes (
int) – The number of bytes to use to store the integer. Must be 1, 2, 4 or 8.signed (
bool) – Whether the integer is signed or unsigned.