Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix python library bugs #763

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions InterfacePython/TasmanianAddons.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
# IN WHOLE OR IN PART THE USE, STORAGE OR DISPOSAL OF THE SOFTWARE.
##############################################################################################################################################################################

from ctypes import c_int, c_double, c_char_p, c_void_p, POINTER, CFUNCTYPE, cdll
from ctypes import c_int, c_double, c_char_p, c_void_p, POINTER, CFUNCTYPE, CDLL, RTLD_GLOBAL
import numpy as np
import sys

import TasmanianConfig
import TasmanianSG
TasmanianInputError = TasmanianConfig.TasmanianInputError

pLibCTSG = cdll.LoadLibrary(TasmanianConfig.__path_libcaddons__)
pLibCTSG = CDLL(TasmanianConfig.__path_libcaddons__, mode = RTLD_GLOBAL)

type_1Dfunc = CFUNCTYPE(c_double, c_double)
type_lpnmodel = CFUNCTYPE(None, c_int, POINTER(c_double), c_int, POINTER(c_double), c_int, POINTER(c_int))
Expand Down
4 changes: 2 additions & 2 deletions InterfacePython/TasmanianDreamLikely.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
# IN WHOLE OR IN PART THE USE, STORAGE OR DISPOSAL OF THE SOFTWARE.
##############################################################################################################################################################################

from ctypes import c_char_p, c_int, c_double, c_void_p, POINTER, cdll, create_string_buffer
from ctypes import c_char_p, c_int, c_double, c_void_p, POINTER, CDLL, create_string_buffer, RTLD_GLOBAL
import numpy as np
import sys

from TasmanianConfig import __path_libdream__
from TasmanianConfig import TasmanianInputError as InputError

pLibDTSG = cdll.LoadLibrary(__path_libdream__)
pLibDTSG = CDLL(__path_libdream__, mode = RTLD_GLOBAL)

pLibDTSG.tsgGetNumOutputsLikelihood.restype = c_int

Expand Down
9 changes: 5 additions & 4 deletions InterfacePython/TasmanianDreamSampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# IN WHOLE OR IN PART THE USE, STORAGE OR DISPOSAL OF THE SOFTWARE.
##############################################################################################################################################################################

from ctypes import c_char_p, c_int, c_double, c_void_p, POINTER, cdll, CFUNCTYPE
from ctypes import c_char_p, c_int, c_double, c_void_p, POINTER, CDLL, CFUNCTYPE, RTLD_GLOBAL
import numpy as np
import sys

Expand All @@ -47,10 +47,11 @@
type_dream_dupdate = CFUNCTYPE(c_double)
type_dream_random = CFUNCTYPE(c_double)

pLibDTSG = cdll.LoadLibrary(__path_libdream__)
pLibDTSG = CDLL(__path_libdream__, mode = RTLD_GLOBAL)

pLibDTSG.tsgGenUniformSamples.argtypes = [c_int, c_int, POINTER(c_double), POINTER(c_double), c_char_p, c_int, type_dream_random, POINTER(c_double)]
pLibDTSG.tsgGenGaussianSamples.argtypes = [c_int, c_int, POINTER(c_double), POINTER(c_double), c_char_p, c_int, type_dream_random, POINTER(c_double)]

pLibDTSG.tsgGenUniformSamples.argtypes = [c_int, c_int, POINTER(c_double), POINTER(c_double), c_char_p, c_int, type_dream_random]
pLibDTSG.tsgGenGaussianSamples.argtypes = [c_int, c_int, POINTER(c_double), POINTER(c_double), c_char_p, c_int, type_dream_random]

pLibDTSG.tsgDreamSample.argtypes = [c_int, c_int, c_int,
type_dream_pdf, c_void_p,
Expand Down
4 changes: 2 additions & 2 deletions InterfacePython/TasmanianDreamState.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# IN WHOLE OR IN PART THE USE, STORAGE OR DISPOSAL OF THE SOFTWARE.
##############################################################################################################################################################################

from ctypes import c_char_p, c_int, c_double, c_void_p, POINTER, cdll, create_string_buffer
from ctypes import c_char_p, c_int, c_double, c_void_p, POINTER, CDLL, create_string_buffer, RTLD_GLOBAL
import numpy as np
import sys

Expand All @@ -37,7 +37,7 @@

from TasmanianSG import TasmanianSparseGrid as SparseGrid

pLibDTSG = cdll.LoadLibrary(__path_libdream__)
pLibDTSG = CDLL(__path_libdream__, mode = RTLD_GLOBAL)

pLibDTSG.tsgMakeDreamState.restype = c_void_p
pLibDTSG.tsgMakeDreamState.argtypes = [c_int, c_int]
Expand Down
4 changes: 2 additions & 2 deletions InterfacePython/TasmanianGradientDescent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# RESPONSIBILITY FOR ALL LIABILITIES, PENALTIES, FINES, CLAIMS, CAUSES OF ACTION, AND COSTS AND EXPENSES, CAUSED BY, RESULTING
# FROM OR ARISING OUT OF, IN WHOLE OR IN PART THE USE, STORAGE OR DISPOSAL OF THE SOFTWARE.

from ctypes import c_char_p, c_int, c_double, c_void_p, POINTER, cdll, cast, CFUNCTYPE, Structure
from ctypes import c_char_p, c_int, c_double, c_void_p, POINTER, CDLL, cast, CFUNCTYPE, Structure, RTLD_GLOBAL
from numpy.ctypeslib import as_ctypes
import numpy as np
import sys
Expand All @@ -48,7 +48,7 @@ class optimization_status(Structure):
def clean_status(input_status):
return dict((field, getattr(input_status, field)) for field, _ in input_status._fields_)

pLibDTSG = cdll.LoadLibrary(__path_libdream__)
pLibDTSG = CDLL(__path_libdream__, mode = RTLD_GLOBAL)

pLibDTSG.tsgGradientDescentState_Construct.restype = c_void_p
pLibDTSG.tsgGradientDescentState_Construct.argtypes = [c_int, POINTER(c_double), c_double]
Expand Down
10 changes: 3 additions & 7 deletions InterfacePython/TasmanianSG.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
# IN WHOLE OR IN PART THE USE, STORAGE OR DISPOSAL OF THE SOFTWARE.
##############################################################################################################################################################################

from ctypes import c_char_p, c_int, c_double, c_void_p, POINTER, cdll, create_string_buffer
from ctypes import c_char_p, c_int, c_double, c_void_p, POINTER, CDLL, create_string_buffer, RTLD_GLOBAL
import numpy as np
import sys

from TasmanianConfig import TasmanianInputError, __path_libsparsegrid__
pLibTSG = cdll.LoadLibrary(__path_libsparsegrid__)
pLibTSG = CDLL(__path_libsparsegrid__, mode = RTLD_GLOBAL)

# The ctypes library requires that we manually specify the return types of functions. In C, this is done by header files, so the
# declarations below serve as a header.
Expand Down Expand Up @@ -62,8 +62,6 @@
pLibTSG.tsgGetLoadedPoints.restype = POINTER(c_double)
pLibTSG.tsgGetNeededPoints.restype = POINTER(c_double)
pLibTSG.tsgGetPoints.restype = POINTER(c_double)
pLibTSG.tsgGetQuadratureWeights.restype = POINTER(c_double)
pLibTSG.tsgGetInterpolationWeights.restype = POINTER(c_double)
pLibTSG.tsgBatchGetInterpolationWeights.restype = POINTER(c_double)
pLibTSG.tsgIsSetDomainTransfrom.restype = c_int
pLibTSG.tsgIsSetConformalTransformASIN.restype = c_int
Expand Down Expand Up @@ -110,9 +108,7 @@
pLibTSG.tsgGetLoadedPointsStatic.argtypes = [c_void_p, POINTER(c_double)]
pLibTSG.tsgGetNeededPointsStatic.argtypes = [c_void_p, POINTER(c_double)]
pLibTSG.tsgGetPointsStatic.argtypes = [c_void_p, POINTER(c_double)]
pLibTSG.tsgGetQuadratureWeights.argtypes = [c_void_p, POINTER(c_double)]
pLibTSG.tsgGetQuadratureWeightsStatic.argtypes = [c_void_p]
pLibTSG.tsgGetInterpolationWeights.argtypes = [c_void_p, POINTER(c_double)]
pLibTSG.tsgGetQuadratureWeightsStatic.argtypes = [c_void_p, POINTER(c_double)]
pLibTSG.tsgGetInterpolationWeightsStatic.argtypes = [c_void_p, POINTER(c_double), POINTER(c_double)]
pLibTSG.tsgLoadNeededValues.argtypes = [c_void_p, POINTER(c_double)]
pLibTSG.tsgGetLoadedValuesStatic.argtypes = [c_void_p, POINTER(c_double)]
Expand Down
1 change: 0 additions & 1 deletion InterfacePython/testAcceleration.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def checkEvaluateConsistency(self):
'grid.makeWaveletGrid(2, 1, 3, 1)',
'grid.makeWaveletGrid(2, 1, 3, 3)',
'grid.makeFourierGrid(2, 1, 3, "level")' ]
lTests = ['grid.makeLocalPolynomialGrid(2, 3, 4, 1, "localp")']

iNumGPUs = grid.getNumGPUs()
lsAccelTypes = ["none", "cpu-blas", "gpu-cuda", "gpu-cublas", "gpu-magma"]
Expand Down
Loading