# -*- coding: utf-8 -*-
# -*- python -*-
#
# PropertyTopomesh
#
# Copyright 2015-2016 INRIA - CIRAD - INRA
#
# File author(s): Guillaume Cerutti <guillaume.cerutti@inria.fr>
#
# File contributor(s): Guillaume Cerutti <guillaume.cerutti@inria.fr>
#
# Distributed under the Cecill-C License.
# See accompanying file LICENSE.txt or copy at
# http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html
#
# OpenaleaLab Website : http://virtualplants.github.io/
#
###############################################################################
import numpy as np
from scipy import ndimage as nd
[docs]def array_unique(array,return_index=False):
_,unique_rows = np.unique(np.ascontiguousarray(array).view(np.dtype((np.void,array.dtype.itemsize * array.shape[1]))),return_index=True)
if return_index:
return array[unique_rows],unique_rows
else:
return array[unique_rows]
[docs]def where_list(array,values):
mask = nd.sum(np.ones_like(values),values,index=array)
return np.where(mask>0)
[docs]def array_difference(array,subarray):
import numpy as np
return np.array(list(set(array).difference(set(subarray))))