OpenWaterAnalytics / epanet-python

python wrapper for epanet library
76 stars 40 forks source link

Problem with `setvertices` in owa-epanet? #59

Closed csweetapple closed 3 years ago

csweetapple commented 4 years ago

In the EPANET source code, EN_setvertices has five arguments:

EN_setvertices(EN_Project ph, int index, double *x, double *y, int count)

In the owa-epanet toolkit, setvertices is missing the x and y arguments and there is no other function that allows these to be set.

def setvertices(ph, index, count):
    r"""
    setvertices(ph, index, count) -> int

    Parameters
    ----------
    ph: EN_Project
    index: int
    count: int

    """
    return _toolkit.setvertices(ph, index, count)
samhatchett commented 4 years ago

you are right! the interface file messes this up by applying an OUTPUT designation to anything named double *x and double *y. This is obviously a wrong thing to do.

%apply double *OUTPUT {
    double *value,
    double *x,
    double *y,
    double *baseDemand,

SWIG makes this sort of thing very easy for APIs that have clear naming conventions for in, out, and in/out variables. However, there is no consistent way to do this with EPANET. One suggestion might be to simply rename the variables in the epanet function declarations and re-SWIG everything.

All things considered, it would be my preference to bulk re-name the declared variables in the EPANET header file - and use some well-known convention. Probably deserves an issue/conversation on that other repo!

samhatchett commented 3 years ago

finally fixed in dev and available at https://pypi.org/project/owa-epanet/2.2.2/