Fixed python wrappers usage of enums

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-08-21 09:11:55 +02:00
parent e22f2be08e
commit 94cbeb5758
5 changed files with 18 additions and 11 deletions

View File

@@ -4,9 +4,11 @@ from libcpp.string cimport string
# A header defining the AbstractState class
cimport cAbstractState
cimport constants_header
cdef class AbstractState:
cdef cAbstractState.AbstractState *thisptr # hold a C++ instance which we're wrapping
cpdef update(self, long iInput1, double Value1, double Value2)
cpdef update(self, constants_header.input_pairs iInput1, double Value1, double Value2)
## ----------------------------------------
## Fluid property accessors
@@ -27,7 +29,7 @@ cdef class AbstractState:
cpdef double speed_sound(self) except *
cpdef double molar_mass(self) except *
cpdef double keyed_output(self, long) except *
cpdef double keyed_output(self, constants_header.parameters) except *
cpdef double melting_line(self, int, int, double) except *
cpdef bool has_melting_line(self) except *

View File

@@ -1,5 +1,7 @@
#cython: embedsignature = True, c_string_type=str, c_string_encoding=ascii
# This file is embedded directly in CoolProp.pyx
cimport constants_header
cdef class AbstractState:
"""
This class is a one-to-one python wrapper of the :cpapi:`AbstractState` class
@@ -11,7 +13,7 @@ cdef class AbstractState:
def __dealloc__(self):
del self.thisptr
cpdef update(self, long ipair, double Value1, double Value2):
cpdef update(self, constants_header.input_pairs ipair, double Value1, double Value2):
""" Update function - mirrors c++ function :cpapi:`AbstractState::update` """
self.thisptr.update(ipair, Value1, Value2)
@@ -19,7 +21,7 @@ cdef class AbstractState:
## Fluid property accessors
## ----------------------------------------
cpdef double keyed_output(self, long iOutput) except *:
cpdef double keyed_output(self, parameters iOutput) except *:
""" Update :cpapi:`AbstractState::update` """
return self.thisptr.keyed_output(iOutput)

View File

@@ -23,6 +23,7 @@ from libcpp.vector cimport vector
from constants import *
from constants_header cimport *
import constants_header
cdef bint iterable(object a):
"""

View File

@@ -1,6 +1,8 @@
from libcpp cimport bool
from libcpp.string cimport string
cimport constants_header
cdef extern from "AbstractState.h" namespace "CoolProp":
cdef cppclass AbstractState:
@@ -12,7 +14,7 @@ cdef extern from "AbstractState.h" namespace "CoolProp":
## Property updater
## Uses the indices in CoolProp for the input parameters
void update(long iInput1, double Value1, double Value2) except +ValueError
void update(constants_header.input_pairs iInput1, double Value1, double Value2) except +ValueError
## Bulk properties accessors - temperature and density are directly calculated every time
## All other parameters are calculated on an as-needed basis
@@ -31,7 +33,7 @@ cdef extern from "AbstractState.h" namespace "CoolProp":
double cpmass() except +ValueError
double cvmass() except +ValueError
double keyed_output(long) except+ValueError
double keyed_output(constants_header.parameters) except+ValueError
double molar_mass() except+ValueError
double gas_constant() except+ValueError
double build_phase_envelope() except+ValueError

View File

@@ -2,7 +2,7 @@
# DO NOT MODIFY THE CONTENTS OF THIS FILE!
cdef extern from "DataStructures.h" namespace "CoolProp":
enum parameters:
ctypedef enum parameters:
imolar_mass
irhomolar_reducing
irhomolar_critical
@@ -65,7 +65,7 @@ cdef extern from "DataStructures.h" namespace "CoolProp":
iPH
iODP
iundefined_parameter
enum input_pairs:
ctypedef enum input_pairs:
QT_INPUTS
PQ_INPUTS
PT_INPUTS
@@ -95,7 +95,7 @@ cdef extern from "DataStructures.h" namespace "CoolProp":
DmolarSmolar_INPUTS
DmassUmass_INPUTS
DmolarUmolar_INPUTS
enum fluid_types:
ctypedef enum fluid_types:
FLUID_TYPE_PURE
FLUID_TYPE_PSEUDOPURE
FLUID_TYPE_REFPROP