qubx :: tree :: Node_numpy :: Class Node_numpy
[hide private]
[frames] | no frames]

Class Node_numpy

source code

object --+
         |
        Node_numpy

Represents the (sub-)tree under a particular node in a qub tree, in an open file or in memory.

This is the 'numpy' flavor of qubx.tree.Node

Instance Methods [hide private]
 
__init__(self, name='', storage=None)
Creates a new node, in memory, with name.
source code
 
__del__(self) source code
 
loosen_shared_children(self) source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code
 
__re_str(self, fi, indent='') source code
 
__str_data(self, fi, indent) source code
 
__str_datas(self, cf, fi, indent) source code
 
print_summary(self, indent='') source code
 
__nonzero__(self) source code
 
__len__(self)
Returns the number of child nodes.
source code
 
__getitem__(self, key)
Returns a child node, by number or by name.
source code
 
set_name(self, x) source code
 
set_data(self, x) source code
 
get_lineComment(self) source code
 
set_lineComment(self, x) source code
 
get_parent(self) source code
 
get_path(self) source code
 
get_root(self) source code
 
clone(self, deep=True, file=None)
Returns a copy of the (sub-)tree rooted here, copied into file, or else in-memory.
source code
 
__re_store(self, file=None) source code
 
get_modified(self)
Returns whether anything's different from on disk.
source code
 
saveAs(self, path, as_copy=False)
Creates a new file at path, moves the (sub-)tree rooted here into the file, and save()s.
source code
 
saveAsText(self, path)
Writes a text representation of the (sub-)tree rooted here, to path on disk.
source code
 
save(self)
When this node is the root of an open file (self.storage.file != None), writes any modifications to disk.
source code
 
__pre_save(self)
Recursively refreshes the child and sibling positions, in case they have moved, so nodes are accurately marked unclean and modified.
source code
 
__re_save(self)
Recursively writes any modifications to disk.
source code
 
re_read(self)
Recursively reads storage and instantiates child and sibling nodes, during Open.
source code
 
close(self)
If this node is the root of an open file, moves it into memory and close the file.
source code
 
getBytes(self)
Returns the binary representation of the (sub-)tree rooted here, just as it would be on disk, as a string.
source code
 
__re_measure(self)
Returns the number of bytes needed to store the (sub-)tree rooted here.
source code
 
re_map_data(self) source code
 
list(self)
Returns the names of all child Nodes.
source code
 
find(self, name)
Returns the first child with name, or the NullNode.
source code
 
next(self, name)
Returns the next sibling with name, or the NullNode.
source code
 
nextSameName(self)
Returns the next sibling with name == self.name, or the NullNode.
source code
 
append(self, childOrName)
inserts after the last child node and returns it.
source code
 
insert(self, childOrName, after=None)
insert(str, after): inserts a new child node after the given child or first, with the given name, or '', and returns it append(Node, after): inserts an existing node after the given child or first, first removing it from its former parent if any, and returns it
source code
 
appendClone(self, other, deep=True)
Inserts a copy of other, after the last child, and returns it.
source code
 
insertClone(self, other, deep=True, after=None)
Inserts a copy of other, after the given child or first, and returns it.
source code
 
remove(self, child, re_store=True)
Removes the given child, making it its own root.
source code
 
setChanged(self)
artifact from when data edits didn't go memmap straight to disk; had to be marked changed; does nothing.
source code
 
lock(self, timeoutMS=None)
the native flavor has a mutex, mainly to protect the ref-count.
source code
 
unlock(self)
the native flavor has a mutex, mainly to protect the ref-count.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]
  name
the label
  data
read: the Data object managing this node's data
  lineComment
read/write the string data of the child named QTR_LINE_COMMENT
  isNull
  child
first child Node, or the NullNode
  sibling
sibling Node, or the NullNode
  parent
parent Node, or the NullNode
  path
path of the open file containing this node, or ''
  modified
whether this or any child...
  root
the head of the tree, with no parent; possibly self.
  __child
  __data
  __dirtee
  __parent
  __sibling
  storage

Inherited from object: __class__

Method Details [hide private]

__init__(self, name='', storage=None)
(Constructor)

source code 

Creates a new node, in memory, with name.

Internal use only: Manages existing NodeStorage.

Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__getitem__(self, key)
(Indexing operator)

source code 

Returns a child node, by number or by name. If by name, and None, returns a newly-appended Node.

clone(self, deep=True, file=None)

source code 

Returns a copy of the (sub-)tree rooted here, copied into file, or else in-memory. If not deep, skips the children.

get_modified(self)

source code 

Returns whether anything's different from on disk. Adjusts child and sibling positions first in case anything's moved.

saveAs(self, path, as_copy=False)

source code 

Creates a new file at path, moves the (sub-)tree rooted here into the file, and save()s. This node becomes the root.

Parameters:
  • as_copy - (def False) if True: may save a copy without re-parenting anything (faster) if overall size <= MAX_QUICK_WRITE_BYTES

appendClone(self, other, deep=True)

source code 

Inserts a copy of other, after the last child, and returns it. If not deep, skip other's children.

insertClone(self, other, deep=True, after=None)

source code 

Inserts a copy of other, after the given child or first, and returns it. If not deep, skip other's children.

remove(self, child, re_store=True)

source code 

Removes the given child, making it its own root.

Internal use only: re_store=False: when we remove it from a file-bound tree only to re-insert it somewhere else in the same tree.

lock(self, timeoutMS=None)

source code 

the native flavor has a mutex, mainly to protect the ref-count. This flavor does nothing.

unlock(self)

source code 

the native flavor has a mutex, mainly to protect the ref-count. This flavor does nothing.


Property Details [hide private]

name

the label

Get Method:
unreachable(self)
Set Method:
unreachable(self, x)

data

read: the Data object managing this node's data

write: replaces this node's data with the contents of a string, numpy.array (len(shape) <= 2), [list of] list of numbers, another Node.data, or None.

Get Method:
unreachable(self)
Set Method:
unreachable(self, x)

lineComment

read/write the string data of the child named QTR_LINE_COMMENT

Get Method:
unreachable(self)
Set Method:
unreachable(self, x)

isNull

Get Method:
unreachable(self)

child

first child Node, or the NullNode

Get Method:
unreachable(self)

sibling

sibling Node, or the NullNode

Get Method:
unreachable(self)

parent

parent Node, or the NullNode

Get Method:
unreachable(self)

path

path of the open file containing this node, or ''

Get Method:
unreachable(self)

modified

whether this or any child... has changed since Open or save(as)

Get Method:
unreachable(self)

root

the head of the tree, with no parent; possibly self.

Get Method:
unreachable(self)