Skip to content

Commit

Permalink
Add LoadReference1D.
Browse files Browse the repository at this point in the history
  • Loading branch information
syamajala committed Jun 24, 2021
1 parent 44d13b7 commit 1fd22c5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ami/flowchart/library/Numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from ami.flowchart.Node import Node
import ami.graph_nodes as gn
import numpy as np
import os


class Sum(Node):
Expand Down Expand Up @@ -653,3 +654,24 @@ def func(arrs):
**kwargs)]

return nodes


class LoadReference1D(CtrlNode):

"""
Load 1d reference array from csv.
"""

nodeName = "LoadReference1D"
uiTemplate = [('path', 'text')]

def __init__(self, name):
super().__init__(name, terminals={"X": {'io': 'out', 'ttype': Array1d},
"Y": {'io': 'out', 'ttype': Array1d}})

def to_operation(self, **kwargs):
path = self.values['path']
assert(os.path.exists(self.values['path']))
assert(path.endswith('.csv'))
arr = np.genfromtxt(path, delimiter=',', usecols=(0, 1), skip_header=1)
return gn.Map(name=self.name()+"_operation", **kwargs, func=lambda: (arr[:, 0], arr[:, 1]))

0 comments on commit 1fd22c5

Please sign in to comment.