Skip to content
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
7 changes: 4 additions & 3 deletions InterfacePython/TasmanianSG.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
pLibTSG.tsgGetPointsStatic.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.tsgGetDifferentiationWeightsStatic.argtypes = [c_void_p, POINTER(c_double), POINTER(c_double)]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ssclift This was missing and it is another manifestation of the Apple M chip problems.

Depending on the Python implementation, this line is either optional or if omitted it will result in a segfault. There is never a warning or a proper error message.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I'll keep that in mind for further updates.

pLibTSG.tsgLoadNeededValues.argtypes = [c_void_p, POINTER(c_double)]
pLibTSG.tsgGetLoadedValuesStatic.argtypes = [c_void_p, POINTER(c_double)]
pLibTSG.tsgEvaluate.argtypes = [c_void_p, POINTER(c_double), POINTER(c_double)]
Expand Down Expand Up @@ -1091,11 +1092,11 @@ def getDifferentiationWeights(self, lfX):
lfX: a 1-D numpy.ndarray with length iDimensions
the entries indicate the points for evaluating the weights

output: a 1-D numpy.ndarray of length getNumPoints()
output: a 2-D numpy.ndarray of size (getNumPoints(), iDimensions)
the order of the weights matches the order in getPoints()

TODO: This, and the C++ call, would probably benefit from using a
sparse matrix data structure.
Similar to the other Weights methods, those are generally slower than
the internal alternatives, e.g., differentiate() or evaluate().
'''
iNumX = len(lfX)
if (iNumX != self.getNumDimensions()):
Expand Down
2 changes: 2 additions & 0 deletions InterfacePython/testExceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ def getSparseGridTests(self):
["grid1 = Tasmanian.SparseGrid(); grid1.setGPUID(grid1.getNumGPUs());", "iGPUID"],
["grid.makeLocalPolynomialGrid(1, 1, 1, 1, 'localp'); Tasmanian.loadNeededPoints(lambda x, tid : x, grid, 1);", "notError"],
["grid.makeLocalPolynomialGrid(1, 1, 1, 1, 'localp'); Tasmanian.loadNeededPoints(lambda x, tid : np.ones((2,)) * x, grid, 1);", "loadNeededValues"],
["grid.makeLocalPolynomialGrid(1, 1, 1, 1, 'localp'); grid.getDifferentiationWeights((1, 2));", "lfX"],
["grid.makeLocalPolynomialGrid(2, 0, 2, 1, 'localp'); grid.getDifferentiationWeights(np.array((1.0, 2.0)));", "notError"],
]

def getCustomTabulatedTests(self):
Expand Down
7 changes: 6 additions & 1 deletion InterfacePython/testMakeUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def checkMakeAgainstKnown(self):
aW1 = grid.getInterpolationWeights(aX1)
aW2 = grid.getInterpolationWeights(aX2)
aW3 = grid.getInterpolationWeights(aX3)
aWW = np.row_stack([aW1, aW2, aW3])
aWW = np.vstack([aW1, aW2, aW3])
np.testing.assert_equal(aW, aWW, "Batch weights", True)

grid.makeGlobalGrid(3, 0, 1, 'level', 'chebyshev')
Expand All @@ -116,6 +116,11 @@ def checkMakeAgainstKnown(self):
aA = np.array([[0.0, 0.0, 0.0], [0.0, 0.0, -0.707106781186548], [0.0, 0.0, 0.707106781186548], [0.0, -0.707106781186548, 0.0], [0.0, 0.707106781186548, 0.0], [-0.707106781186548, 0.0, 0.0], [0.707106781186548, 0.0, 0.0]])
np.testing.assert_almost_equal(aA, grid.getPoints(), 14, "Original equal", True)

grid = Tasmanian.makeLocalPolynomialGrid(2, 1, 1, 2, "localp")
aW = grid.getDifferentiationWeights(np.array((0.5, 0.5)))
aA = np.array(((-1.0, -1.0), (0.0, 0.0), (0.0, 1.0), (0.0, 0.0), (1.0, 0.0)))
np.testing.assert_almost_equal(aA, aW, 14, "Differentiation weights", True)

# number of points
grid = Tasmanian.makeLocalPolynomialGrid(2, 1, 2, 2, "localp")
iNN = grid.getNumNeeded()
Expand Down