Faults¶
Faults¶
- class Faults(node=None, **kwargs)[source]¶
Faults component.
Contains faults in a single tree structure, faults attributes and preprocessing actions.
- Parameters:
node (FaultSegment, optional) – Root node for fault’s tree.
- apply(func, attr, *args, inplace=False, **kwargs)¶
Apply function to attributes.
- Parameters:
func (callable) – A function to apply. Must accept data as its first argument.
attr (str, array-like) – Attributes to get data from.
args (misc) – Any additional positional arguments to
func
.kwargs (misc) – Any additional named arguments to
func
.
- Returns:
output – Transformed component.
- Return type:
- property attributes¶
Array of attributes.
- property class_name¶
Name of the component.
- del_state(*args)¶
State remover.
- dump(path, **kwargs)¶
Dump attributes into file.
- Parameters:
- Returns:
comp – BaseComponent unchanged.
- Return type:
- static dump_array_ascii(buffer, array, header=None, fmt='%f', compressed=True)¶
Writes array-like data into an ASCII buffer.
- Parameters:
- property empty¶
True if component is empty else False.
- empty_like()¶
Get an empty component with the same state and the structure of embedded BaseComponents (if any).
- property field¶
Field associated with the component.
- get_blocks(segment, **kwargs)[source]¶
Calculate grid blocks for the tree of faults.
- Parameters:
segment (class instance) – FaultSegment class.
kwargs (misc) – Any additional named arguments to append.
- Returns:
comp – faults component with calculated grid blocks and fault in block projections.
- Return type:
faults
- init_state(**kwargs)¶
Init state attributes.
- items()¶
Returns pairs of attribute’s names and data.
- keys()¶
Array of attributes.
- load(path_or_buffer, **kwargs)¶
Load data from a file or buffer.
- Parameters:
- Returns:
comp – BaseComponent with loaded attributes.
- Return type:
- property names¶
List of fault names.
- ravel(attr=None, order='F', inplace=True)¶
Ravel attributes where applicable assuming by default Fortran order.
- reshape(attr, newshape, order='C', inplace=True)¶
Reshape numpy.ndarray attributes.
- Parameters:
- Returns:
output
- Return type:
BaseComponent if inplace else reshaped attribute itself.
- property resolver¶
Tree resolver.
- property root¶
Tree root.
- set_state(**kwargs)¶
State setter.
- property state¶
Get state.
- update(faultsdata, mode='w', **kwargs)[source]¶
Update tree nodes with new faultsdata. If fault does not exists, it will be attached to root.
- Parameters:
- Returns:
out – Faults with updated attributes.
- Return type:
- values()¶
Returns a generator of attribute’s data.
FaultSegment¶
- class FaultSegment(*args, parent=None, children=None, name=None, ntype=None, **kwargs)[source]¶
Fault’s node.
- Parameters:
name (str, optional) – Node’s name.
- property ancestors¶
All parent nodes and their parent nodes.
>>> from anytree import Node >>> udo = Node("Udo") >>> marc = Node("Marc", parent=udo) >>> lian = Node("Lian", parent=marc) >>> udo.ancestors () >>> marc.ancestors (Node('/Udo'),) >>> lian.ancestors (Node('/Udo'), Node('/Udo/Marc'))
- property anchestors¶
All parent nodes and their parent nodes - see
ancestors
.The attribute anchestors is just a typo of ancestors. Please use ancestors. This attribute will be removed in the 3.0.0 release.
- apply(func, attr, *args, inplace=False, **kwargs)¶
Apply function to attributes.
- Parameters:
func (callable) – A function to apply. Must accept data as its first argument.
attr (str, array-like) – Attributes to get data from.
args (misc) – Any additional positional arguments to
func
.kwargs (misc) – Any additional named arguments to
func
.
- Returns:
output – Transformed component.
- Return type:
- property attributes¶
Array of attributes.
- property children¶
All child nodes.
>>> from anytree import Node >>> n = Node("n") >>> a = Node("a", parent=n) >>> b = Node("b", parent=n) >>> c = Node("c", parent=n) >>> n.children (Node('/n/a'), Node('/n/b'), Node('/n/c'))
Modifying the children attribute modifies the tree.
Detach
The children attribute can be updated by setting to an iterable.
>>> n.children = [a, b] >>> n.children (Node('/n/a'), Node('/n/b'))
Node c is removed from the tree. In case of an existing reference, the node c does not vanish and is the root of its own tree.
>>> c Node('/c')
Attach
>>> d = Node("d") >>> d Node('/d') >>> n.children = [a, b, d] >>> n.children (Node('/n/a'), Node('/n/b'), Node('/n/d')) >>> d Node('/n/d')
Duplicate
A node can just be the children once. Duplicates cause a
TreeError
:>>> n.children = [a, b, d, a] Traceback (most recent call last): ... anytree.node.exceptions.TreeError: Cannot add node Node('/n/a') multiple times as child.
- property class_name¶
Name of the component.
- del_state(*args)¶
State remover.
- property depth¶
Number of edges to the root Node.
>>> from anytree import Node >>> udo = Node("Udo") >>> marc = Node("Marc", parent=udo) >>> lian = Node("Lian", parent=marc) >>> udo.depth 0 >>> marc.depth 1 >>> lian.depth 2
- property descendants¶
All child nodes and all their child nodes.
>>> from anytree import Node >>> udo = Node("Udo") >>> marc = Node("Marc", parent=udo) >>> lian = Node("Lian", parent=marc) >>> loui = Node("Loui", parent=marc) >>> soe = Node("Soe", parent=lian) >>> udo.descendants (Node('/Udo/Marc'), Node('/Udo/Marc/Lian'), Node('/Udo/Marc/Lian/Soe'), Node('/Udo/Marc/Loui')) >>> marc.descendants (Node('/Udo/Marc/Lian'), Node('/Udo/Marc/Lian/Soe'), Node('/Udo/Marc/Loui')) >>> lian.descendants (Node('/Udo/Marc/Lian/Soe'),)
- drop(attr)¶
Drop an attribute.
- dump(path, **kwargs)¶
Dump attributes into file.
- Parameters:
- Returns:
comp – BaseComponent unchanged.
- Return type:
- static dump_array_ascii(buffer, array, header=None, fmt='%f', compressed=True)¶
Writes array-like data into an ASCII buffer.
- Parameters:
- property empty¶
True if component is empty else False.
- empty_like()¶
Get an empty component with the same state and the structure of embedded BaseComponents (if any).
- property field¶
Field associated with the component.
- property fullname¶
Full name from root.
- property height¶
Number of edges on the longest path to a leaf Node.
>>> from anytree import Node >>> udo = Node("Udo") >>> marc = Node("Marc", parent=udo) >>> lian = Node("Lian", parent=marc) >>> udo.height 2 >>> marc.height 1 >>> lian.height 0
- init_state(**kwargs)¶
Init state attributes.
- property is_leaf¶
Node has no children (External Node).
>>> from anytree import Node >>> udo = Node("Udo") >>> marc = Node("Marc", parent=udo) >>> lian = Node("Lian", parent=marc) >>> udo.is_leaf False >>> marc.is_leaf False >>> lian.is_leaf True
- property is_root¶
Node is tree root.
>>> from anytree import Node >>> udo = Node("Udo") >>> marc = Node("Marc", parent=udo) >>> lian = Node("Lian", parent=marc) >>> udo.is_root True >>> marc.is_root False >>> lian.is_root False
- items()¶
Returns pairs of attribute’s names and data.
- iter_path_reverse()¶
Iterate up the tree from the current node to the root node.
>>> from anytree import Node >>> udo = Node("Udo") >>> marc = Node("Marc", parent=udo) >>> lian = Node("Lian", parent=marc) >>> for node in udo.iter_path_reverse(): ... print(node) Node('/Udo') >>> for node in marc.iter_path_reverse(): ... print(node) Node('/Udo/Marc') Node('/Udo') >>> for node in lian.iter_path_reverse(): ... print(node) Node('/Udo/Marc/Lian') Node('/Udo/Marc') Node('/Udo')
- keys()¶
Array of attributes.
- property leaves¶
Tuple of all leaf nodes.
>>> from anytree import Node >>> udo = Node("Udo") >>> marc = Node("Marc", parent=udo) >>> lian = Node("Lian", parent=marc) >>> loui = Node("Loui", parent=marc) >>> lazy = Node("Lazy", parent=marc) >>> udo.leaves (Node('/Udo/Marc/Lian'), Node('/Udo/Marc/Loui'), Node('/Udo/Marc/Lazy')) >>> marc.leaves (Node('/Udo/Marc/Lian'), Node('/Udo/Marc/Loui'), Node('/Udo/Marc/Lazy'))
- load(path_or_buffer, **kwargs)¶
Load data from a file or buffer.
- Parameters:
- Returns:
comp – BaseComponent with loaded attributes.
- Return type:
- property name¶
Node’s name.
- property ntype¶
Node’s type.
- property parent¶
Parent Node.
On set, the node is detached from any previous parent node and attached to the new node.
>>> from anytree import Node, RenderTree >>> udo = Node("Udo") >>> marc = Node("Marc") >>> lian = Node("Lian", parent=marc) >>> print(RenderTree(udo)) Node('/Udo') >>> print(RenderTree(marc)) Node('/Marc') └── Node('/Marc/Lian')
Attach
>>> marc.parent = udo >>> print(RenderTree(udo)) Node('/Udo') └── Node('/Udo/Marc') └── Node('/Udo/Marc/Lian')
Detach
To make a node to a root node, just set this attribute to None.
>>> marc.is_root False >>> marc.parent = None >>> marc.is_root True
- property path¶
Path from root node down to this Node.
>>> from anytree import Node >>> udo = Node("Udo") >>> marc = Node("Marc", parent=udo) >>> lian = Node("Lian", parent=marc) >>> udo.path (Node('/Udo'),) >>> marc.path (Node('/Udo'), Node('/Udo/Marc')) >>> lian.path (Node('/Udo'), Node('/Udo/Marc'), Node('/Udo/Marc/Lian'))
- ravel(attr=None, order='F', inplace=True)¶
Ravel attributes where applicable assuming by default Fortran order.
- reshape(attr, newshape, order='C', inplace=True)¶
Reshape numpy.ndarray attributes.
- Parameters:
- Returns:
output
- Return type:
BaseComponent if inplace else reshaped attribute itself.
- property root¶
Tree Root Node.
>>> from anytree import Node >>> udo = Node("Udo") >>> marc = Node("Marc", parent=udo) >>> lian = Node("Lian", parent=marc) >>> udo.root Node('/Udo') >>> marc.root Node('/Udo') >>> lian.root Node('/Udo')
- separator = '/'¶
- set_state(**kwargs)¶
State setter.
- property siblings¶
Tuple of nodes with the same parent.
>>> from anytree import Node >>> udo = Node("Udo") >>> marc = Node("Marc", parent=udo) >>> lian = Node("Lian", parent=marc) >>> loui = Node("Loui", parent=marc) >>> lazy = Node("Lazy", parent=marc) >>> udo.siblings () >>> marc.siblings () >>> lian.siblings (Node('/Udo/Marc/Loui'), Node('/Udo/Marc/Lazy')) >>> loui.siblings (Node('/Udo/Marc/Lian'), Node('/Udo/Marc/Lazy'))
- property size¶
Tree size — the number of nodes in tree starting at this node.
>>> from anytree import Node >>> udo = Node("Udo") >>> marc = Node("Marc", parent=udo) >>> lian = Node("Lian", parent=marc) >>> loui = Node("Loui", parent=marc) >>> soe = Node("Soe", parent=lian) >>> udo.size 5 >>> marc.size 4 >>> lian.size 2 >>> loui.size 1
- property state¶
Get state.
- values()¶
Returns a generator of attribute’s data.