Commit 548d61bb authored by Tiago Peixoto's avatar Tiago Peixoto

Fix get_array() for property maps

This includes the missing function declarations for edge and graph
properties.

Property maps of value type "string" do not return an array, since the
numpy string and std::string are different things.
parent 2586bae6
......@@ -432,12 +432,15 @@ public:
python::object GetArray(size_t size)
{
typedef typename mpl::or_<
is_same<PropertyMap,
GraphInterface::vertex_index_map_t>,
typename mpl::not_<typename mpl::has_key<numpy_types,
value_type>::type>::type>
::type is_vector_map;
return get_array(_pmap, size, is_vector_map());
typename mpl::or_<
is_same<PropertyMap,
GraphInterface::vertex_index_map_t>,
is_same<PropertyMap,
GraphInterface::edge_index_map_t> >::type,
typename mpl::not_<
typename mpl::has_key<numpy_types, value_type>::type >
::type>::type isnt_vector_map;
return get_array(_pmap, size, isnt_vector_map());
}
python::object get_array(PropertyMap pmap, size_t size, mpl::bool_<false>)
......
......@@ -131,7 +131,8 @@ struct export_edge_property_map
pclass.def("__hash__", &pmap_t::GetHash)
.def("value_type", &pmap_t::GetType)
.def("get_map", &pmap_t::GetMap)
.def("get_dynamic_map", &pmap_t::GetDynamicMap);
.def("get_dynamic_map", &pmap_t::GetDynamicMap)
.def("get_array", &pmap_t::GetArray);
typedef mpl::transform<graph_tool::detail::all_graph_views,
......@@ -173,7 +174,8 @@ struct export_graph_property_map
return_policy())
.def("__setitem__", &pmap_t::template SetValue<GraphInterface>)
.def("get_map", &pmap_t::GetMap)
.def("get_dynamic_map", &pmap_t::GetDynamicMap);
.def("get_dynamic_map", &pmap_t::GetDynamicMap)
.def("get_array", &pmap_t::GetArray);
}
string _name;
......
......@@ -50,8 +50,7 @@ typedef mpl::map<
mpl::pair<int64_t, mpl::int_<NPY_INT64> >,
mpl::pair<uint64_t, mpl::int_<NPY_UINT64> >,
mpl::pair<double, mpl::int_<NPY_DOUBLE> >,
mpl::pair<long double, mpl::int_<NPY_LONGDOUBLE> >,
mpl::pair<string, mpl::int_<NPY_STRING> > // not really used
mpl::pair<long double, mpl::int_<NPY_LONGDOUBLE> >
> numpy_types;
template <class ValueType>
......
Markdown is supported
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