Skip to content

Commit

Permalink
Docstring done
Browse files Browse the repository at this point in the history
  • Loading branch information
icedoom888 committed Dec 18, 2024
1 parent 11387b7 commit 8602b15
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
46 changes: 45 additions & 1 deletion docs/graphs/edge_attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Edges - Attributes
####################

There are 2 main edge attributes implemented in the `anemoi-graphs`
There are few edge attributes implemented in the `anemoi-graphs`
package:

*************
Expand Down Expand Up @@ -44,3 +44,47 @@ latitude and longitude coordinates of the source and target nodes.
attributes:
edge_length:
_target_: anemoi.graphs.edges.attributes.EdgeDirection
*********************
Attribute from Node
*********************

Attributes can also be copied from nodes to edges. This is done using
the `AttributeFromNode` base class, with specialized versions for source
and target nodes.

*************
From Source
*************

This attribute copies a specific property of the source node to the
edge.

.. code:: yaml
edges:
- source_name: ...
target_name: ...
edge_builders: ...
attributes:
attribute_name:
_target_: anemoi.graphs.edges.attributes.AttributeFromSourceNode
node_attr_name: "attribute_name"
*************
From Target
*************

This attribute copies a specific property of the target node to the
edge.

.. code:: yaml
edges:
- source_name: ...
target_name: ...
edge_builders: ...
attributes:
attribute_name:
_target_: anemoi.graphs.edges.attributes.AttributeFromTargetNode
node_attr_name: "attribute_name"
1 change: 1 addition & 0 deletions src/anemoi/graphs/edges/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def get_raw_values(self, graph: HeteroData, source_name: str, target_name: str)
assert hasattr(graph[node_name], self.node_attr_name)
return graph[node_name][self.node_attr_name].numpy()[edge_index[self.idx]]


class AttributeFromSourceNode(AttributeFromNode):
"""
Copy an attribute of the source node to the edge.
Expand Down

0 comments on commit 8602b15

Please sign in to comment.