Skip to content
Snippets Groups Projects
Commit c24a7946 authored by Martin Bauer's avatar Martin Bauer
Browse files

Python Module improvements

- cellIntervalToSlice more flexible
parent 5a1facc9
Branches
Tags
No related merge requests found
...@@ -58,13 +58,16 @@ def sliceToCellInterval( s ): ...@@ -58,13 +58,16 @@ def sliceToCellInterval( s ):
def cellIntervalToSlice(cellInterval, collapseExtentOne=True): def cellIntervalToSlice(cellInterval, collapseExtentOne=True):
if not hasattr(collapseExtentOne, '__len__'):
collapseExtentOne = (collapseExtentOne, collapseExtentOne, collapseExtentOne)
slices = [] slices = []
for i in range(3): for i, collapseInfo in enumerate(collapseExtentOne):
if collapseExtentOne and cellInterval.min[i] == cellInterval.max[i]: if collapseInfo and cellInterval.min[i] == cellInterval.max[i]:
slices.append( cellInterval.min[i] ) slices.append( cellInterval.min[i] )
else: else:
slices.append( slice(cellInterval.min[i], cellInterval.max[i]+1,None ) ) slices.append( slice(cellInterval.min[i], cellInterval.max[i]+1,None ) )
return slices return tuple(slices)
......
...@@ -10,6 +10,9 @@ def toGpuArray(f, withGhostLayers=True): ...@@ -10,6 +10,9 @@ def toGpuArray(f, withGhostLayers=True):
dtype = np.dtype(f.dtypeStr) dtype = np.dtype(f.dtypeStr)
strides = [dtype.itemsize*a for a in f.strides] strides = [dtype.itemsize*a for a in f.strides]
res = GPUArray(f.sizeWithGhostLayers, dtype, gpudata=f.ptr, strides=strides) res = GPUArray(f.sizeWithGhostLayers, dtype, gpudata=f.ptr, strides=strides)
if withGhostLayers is True:
return res
ghostLayers = normalizeGhostlayerInfo(f, withGhostLayers) ghostLayers = normalizeGhostlayerInfo(f, withGhostLayers)
glCutoff = [ f.nrOfGhostLayers - gl for gl in ghostLayers ] glCutoff = [ f.nrOfGhostLayers - gl for gl in ghostLayers ]
res = res[ glCutoff[0]:-glCutoff[0] if glCutoff[0] > 0 else None, res = res[ glCutoff[0]:-glCutoff[0] if glCutoff[0] > 0 else None,
......
...@@ -87,7 +87,7 @@ object python_createUniformBlockGrid(tuple args, dict kw) ...@@ -87,7 +87,7 @@ object python_createUniformBlockGrid(tuple args, dict kw)
*it != "dx" && *it != "dx" &&
*it != "oneBlockPerProcess" ) *it != "oneBlockPerProcess" )
{ {
PyErr_SetString( PyExc_ValueError, (std::string("Unknown Parameter") + (*it) ).c_str() ); PyErr_SetString( PyExc_ValueError, (std::string("Unknown Parameter: ") + (*it) ).c_str() );
throw boost::python::error_already_set(); throw boost::python::error_already_set();
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment