Skip to content
Open
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
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ include( cmake/Config.cmake )

set( lvarray_dependencies dl )

if( ENABLE_PYLVARRAY )
execute_process( COMMAND ${Python3_EXECUTABLE} -c "import scipy.sparse"
RESULT_VARIABLE scipy_sparse_result
ERROR_VARIABLE scipy_sparse_error
OUTPUT_QUIET )
if( NOT scipy_sparse_result EQUAL 0 )
message( FATAL_ERROR "ENABLE_PYLVARRAY requires scipy.sparse in ${Python3_EXECUTABLE}: ${scipy_sparse_error}" )
endif()
endif()

blt_list_append( TO lvarray_dependencies ELEMENTS chai IF ENABLE_CHAI )

blt_list_append( TO lvarray_dependencies ELEMENTS RAJA )
Expand Down Expand Up @@ -117,4 +127,3 @@ if( ENABLE_DOCS )
add_subdirectory( docs )
endif()


2 changes: 2 additions & 0 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ blt_add_library( NAME pylvarray
CLEAR_PREFIX TRUE
)

set_target_properties( pylvarray PROPERTIES SUFFIX "${CMAKE_SHARED_MODULE_SUFFIX}" )

target_include_directories( pylvarray
PUBLIC
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
Expand Down
9 changes: 9 additions & 0 deletions src/python/PyCRSMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,16 @@ static PyObject * PyCRSMatrix_toSciPy( PyCRSMatrix * const self, PyObject * cons
"Error constructing the offsets NumPy array", nullptr );

PyObjectRef<> sciPySparse = PyImport_ImportModule( "scipy.sparse" );
if( sciPySparse == nullptr )
{
return nullptr;
}

PyObjectRef<> constructor = PyObject_GetAttrString( sciPySparse, "csr_matrix" );
if( constructor == nullptr )
{
return nullptr;
}

return PyObject_CallFunction( constructor,
"(OOO)(ll)",
Expand Down
Loading