Skip to content

Commit b552db1

Browse files
author
Sam Hatchett
committed
adds doubleArray and intArray list wrapper classes and tests
1 parent 8467d38 commit b552db1

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

owa-epanet/test/test_owa_epanet.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,19 @@ def test_setnodevalue():
324324
assert tank_level_list ==[121.0]
325325
clean_dir()
326326

327+
def test_setcurve():
328+
def make_array(values):
329+
dbl_arr = en.doubleArray(len(values))
330+
for i in range(len(values)):
331+
dbl_arr[i] = values[i]
332+
return dbl_arr
327333

334+
epanet_proj = en.createproject()
335+
en.open(ph=epanet_proj, inpFile=example_1_path, rptFile='report.rpt', outFile='output.out')
336+
ok = en.addcurve(ph=epanet_proj, id="my_curve")
337+
curve_index = en.getcurveindex(ph=epanet_proj, id="my_curve")
338+
xvalues = make_array([1,2,3,4,5])
339+
yvalues = make_array([1,2,3,4,5])
340+
en.setcurve(ph=epanet_proj, index=curve_index, xValues=xvalues, yValues=yvalues, nPoints=5)
341+
count = en.getcurvelen(ph=epanet_proj, index=curve_index)
342+
assert count == 5

owa-epanet/wrapper/toolkit.i

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
%include "typemaps.i"
22
%include "cstring.i"
3+
%include "carrays.i"
4+
5+
/* arrays for toolkit functions wanting lists */
6+
%array_class(int, intArray);
7+
%array_class(double, doubleArray);
38

49
/* epanet simple python wrapper */
510
%module (package="epanet") toolkit

0 commit comments

Comments
 (0)