My first Jython task

What is a HIPE task?

A HIPE task is everything you see in the Task view of HIPE. Choose any entry in this view and double click on it.

HIPE tasks can be written in Jython and Java. Jython is the language you use to write scripts in the Editor view of HIPE

A simple HIPE task

The following is a simple task that takes a Table Dataset as input and outputs an array with the averages of each column of the Table Dataset.

class TableAverageTask(JTask):  # 1
   'Averages the columns of a Table Dataset.'
   def __init__(self, name="tableAverage"):
       JTask.__init__(self, name)
       self.setDescription("Computes the average of each column of a Table Dataset.")  # 2
       p = TaskParameter("table", valueType = TableDataset, mandatory = 1)  # 3
       p.description = "The table of whose columns to compute the average"
       p = TaskParameter("result", valueType = Double1d, type = OUT)  # 4
       p.description = "The array of averages of the table's columns"
   def execute(self):  # 5
       columns = self.table.columnCount
       divider = 1.0 / columns
       self.result = Double1d(table.rowCount)
       for column in range(columns):
       self.result = self.result.multiply(divider)

Turning the task into a plugin

Installing and sharing the plugin

Edit | Attach | Watch | Print version | History: r11 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2011-09-12 - DavideRizzo
This site is powered by the TWiki collaboration platform Powered by Perl