Documentation ¶
Index ¶
- func NewTable(dir *Data, names ...string) (*table.Table, error)
- func NewTensor[T string | bool | float32 | float64 | int | int32 | byte](dir *Data, name string, sizes []int, names ...string) (tensor.Tensor, error)
- func PlotColumnZeroOne() *plotcore.ColumnOptions
- type Data
- func (d *Data) Add(it *Data) error
- func (d *Data) AsFloat32() (float32, bool)
- func (d *Data) AsFloat64() (float64, bool)
- func (d *Data) AsInt() (int, bool)
- func (d *Data) AsString() (string, bool)
- func (d *Data) AsTable() *table.Table
- func (d *Data) AsTensor() tensor.Tensor
- func (d *Data) Bytes() []byte
- func (d *Data) Calc() error
- func (d *Data) CalcAll() error
- func (d *Data) DataType() reflect.Kind
- func (d *Data) DirAtPath(dir string) (*Data, error)
- func (d *Data) DirNamesAlpha() []string
- func (d *Data) DirNamesByTime() []string
- func (d *Data) DirTable(fun func(item *Data) bool) *table.Table
- func (d *Data) FlatItemsByTimeFunc(fun func(item *Data) bool) []*Data
- func (d *Data) FlatItemsFunc(fun func(item *Data) bool) []*Data
- func (d *Data) Info() (fs.FileInfo, error)
- func (d *Data) IsDir() bool
- func (d *Data) IsNumeric() bool
- func (d *Data) Item(name string) *Data
- func (d *Data) Items(names ...string) ([]*Data, error)
- func (d *Data) ItemsByTimeFunc(fun func(item *Data) bool) []*Data
- func (d *Data) ItemsFunc(fun func(item *Data) bool) []*Data
- func (d *Data) KnownFileInfo() fileinfo.Known
- func (d *Data) Mkdir(name string) (*Data, error)
- func (d *Data) ModTime() time.Time
- func (d *Data) Mode() fs.FileMode
- func (d *Data) Name() string
- func (d *Data) Open(name string) (fs.File, error)
- func (d *Data) Path() string
- func (d *Data) PlotColumnOptions() *plotcore.ColumnOptions
- func (d *Data) ReadDir(dir string) ([]fs.DirEntry, error)
- func (d *Data) ReadFile(name string) ([]byte, error)
- func (d *Data) SetCalcFunc(fun func() error)
- func (d *Data) SetFloat32(v float32) bool
- func (d *Data) SetFloat64(v float64) bool
- func (d *Data) SetInt(v int) bool
- func (d *Data) SetMetaItems(key string, value any, names ...string) error
- func (d *Data) SetPlotColumnOptions(opts *plotcore.ColumnOptions, names ...string) error
- func (d *Data) SetString(v string) bool
- func (d *Data) Size() int64
- func (d *Data) Stat(name string) (fs.FileInfo, error)
- func (d *Data) Sub(dir string) (fs.FS, error)
- func (d *Data) Sys() any
- func (d *Data) Type() fs.FileMode
- type DirFile
- type File
- type Sizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTable ¶
NewTable makes new table.Table(s) in given directory, for given name(s) (at least one is required). All names must be unique in the directory. Returns the first table created, for immediate use of one item.
func NewTensor ¶
func NewTensor[T string | bool | float32 | float64 | int | int32 | byte](dir *Data, name string, sizes []int, names ...string) (tensor.Tensor, error)
NewTensor returns a new Tensor of given data type, shape sizes, and optional dimension names, in given directory Data item. The name must be unique in the directory.
func PlotColumnZeroOne ¶
func PlotColumnZeroOne() *plotcore.ColumnOptions
PlotColumnZeroOne returns plot options with a fixed 0-1 range
Types ¶
type Data ¶
type Data struct { // Parent is the parent data directory Parent *Data // Meta has metadata, including standardized support for // plotting options, compute functions. Meta metadata.Data // Value is the underlying value of data; // is a map[string]*Data for directories. Value any // contains filtered or unexported fields }
Data is a single item of data, the "file" or "directory" in the data filesystem.
func New ¶
New adds new data item(s) of given basic type to given directory, with given name(s) (at least one is required). Values are initialized to zero value for type. All names must be unique in the directory. Returns the first item created, for immediate use of one value.
func NewData ¶
NewData returns a new Data item in given directory Data item, which can be nil. If not a directory, an error will be generated. The modTime is automatically set to now, and can be used for sorting by order created. The name must be unique within parent.
func NewDir ¶
NewDir returns a new datafs directory with given name. if parent != nil and a directory, this dir is added to it. if name is empty, then it is set to "root", the root directory. Note that "/" is not allowed for the root directory in Go fs. Names must be unique within a directory.
func (*Data) Add ¶
Add adds an item to this directory data item. The only errors are if this item is not a directory, or the name already exists. Names must be unique within a directory.
func (*Data) AsFloat32 ¶
AsFloat32 returns data as a float32 if it is a scalar value that can be so converted. Returns false if not.
func (*Data) AsFloat64 ¶
AsFloat64 returns data as a float64 if it is a scalar value that can be so converted. Returns false if not.
func (*Data) AsInt ¶
AsInt returns data as a int if it is a scalar value that can be so converted. Returns false if not.
func (*Data) AsString ¶
AsString returns data as a string if it is a scalar value that can be so converted. Returns false if not.
func (*Data) Bytes ¶
Bytes returns the byte-wise representation of the data Value. This is the actual underlying data, so make a copy if it can be unintentionally modified or retained more than for immediate use.
func (*Data) Calc ¶
Calc calls function set by Data.SetCalcFunc to compute an updated Value for this data item. Returns an error if func not set, or any error from func itself. Function is stored as CalcFunc in Metadata.
func (*Data) CalcAll ¶
CalcAll calls function set by Data.SetCalcFunc for all items in this directory and all of its subdirectories. Calls Calc on items from FlatItemsByTimeFunc(nil)
func (*Data) DataType ¶
DataType returns the type of the data elements in the tensor. Bool is returned for the Bits tensor type.
func (*Data) DirNamesAlpha ¶
DirNamesAlpha returns the names of items in the directory sorted alphabetically. Data must be dir by this point.
func (*Data) DirNamesByTime ¶
DirNamesByTime returns the names of items in the directory sorted by modTime (order added). Data must be dir by this point.
func (*Data) DirTable ¶
DirTable returns a table.Table for this directory item, with columns as the Tensor elements in the directory and any subdirectories, from FlatItemsByTimeFunc using given filter function. This is a convenient mechanism for creating a plot of all the data in a given directory. If such was previously constructed, it is returned from "DirTable" Metadata key where the table is stored. Row count is updated to current max row. Delete that key to reconstruct if items have changed.
func (*Data) FlatItemsByTimeFunc ¶
FlatItemsByTimeFunc returns all "leaf" (non directory) data items in given directory, recursively descending into directories to return a flat list of the entire subtree, filtered by given function, in time order (i.e., order added). The function can filter out directories to prune the tree. If func is nil, all items are returned.
func (*Data) FlatItemsFunc ¶
FlatItemsFunc returns all "leaf" (non directory) data items in given directory, recursively descending into directories to return a flat list of the entire subtree, filtered by given function, in alpha order. The function can filter out directories to prune the tree. If func is nil, all items are returned.
func (*Data) IsNumeric ¶
IsNumeric returns true if the [DataType] is a basic scalar numerical value, e.g., float32, int, etc.
func (*Data) Item ¶
Item returns data item in given directory by name. This is for fast access and direct usage of known items, and it will crash if item is not found or this data is not a directory.
func (*Data) Items ¶
Items returns data items in given directory by name. error reports any items not found, or if not a directory.
func (*Data) ItemsByTimeFunc ¶
ItemsByTimeFunc returns data items in given directory filtered by given function, in time order (i.e., order added). If func is nil, all items are returned. Any directories within this directory are returned, unless specifically filtered.
func (*Data) ItemsFunc ¶
ItemsFunc returns data items in given directory filtered by given function, in alpha order. If func is nil, all items are returned. Any directories within this directory are returned, unless specifically filtered.
func (*Data) KnownFileInfo ¶
func (*Data) Mkdir ¶
Mkdir creates a new directory with the specified name. The only error is if this item is not a directory.
func (*Data) PlotColumnOptions ¶
func (d *Data) PlotColumnOptions() *plotcore.ColumnOptions
PlotColumnOptions returns plotting options if they have been set, else nil.
func (*Data) ReadDir ¶
ReadDir returns the contents of the given directory within this filesystem. Use "." (or "") to refer to the current directory.
func (*Data) ReadFile ¶
ReadFile reads the named file and returns its contents. A successful call returns a nil error, not io.EOF. (Because ReadFile reads the whole file, the expected EOF from the final Read is not treated as an error to be reported.)
The caller is permitted to modify the returned byte slice. This method should return a copy of the underlying data.
func (*Data) SetCalcFunc ¶
SetCalcFunc sets a function to compute an updated Value for this data item. Function is stored as CalcFunc in Metadata. Can be called by Data.Calc method.
func (*Data) SetFloat32 ¶
SetFloat32 sets data from given float32 if it is a scalar value that can be so set. Returns false if not.
func (*Data) SetFloat64 ¶
SetFloat64 sets data from given float64 if it is a scalar value that can be so set. Returns false if not.
func (*Data) SetInt ¶
SetInt sets data from given int if it is a scalar value that can be so set. Returns false if not.
func (*Data) SetMetaItems ¶
SetMetaItems sets given metadata for items in given directory with given names. Returns error for any items not found.
func (*Data) SetPlotColumnOptions ¶
func (d *Data) SetPlotColumnOptions(opts *plotcore.ColumnOptions, names ...string) error
SetPlotColumnOptions sets given plotting options for named items within this directory (stored in Metadata).
func (*Data) SetString ¶
SetString sets data from given string if it is a scalar value that can be so set. Returns false if not.
func (*Data) Size ¶
Size returns the size of known data Values, or it uses the Sizer interface, otherwise returns 0.
func (*Data) Stat ¶
Stat returns a FileInfo describing the file. If there is an error, it should be of type *PathError.
type DirFile ¶
type DirFile struct { File // contains filtered or unexported fields }
DirFile represents a directory data item for reading, as fs.ReadDirFile.
type File ¶
File represents a data item for reading, as an fs.File. All io functionality is handled by bytes.Reader.