Эх сурвалжийг харах

Minor fix for iglhelper and gitignore


Former-commit-id: 890360ca651d9abc88426dc8bbe8913f98af91cb
Zhongshi Jiang 7 жил өмнө
parent
commit
f9fa499e5a
2 өөрчлөгдсөн 9 нэмэгдсэн , 7 устгасан
  1. 2 0
      .gitignore
  2. 7 7
      python/iglhelpers.py

+ 2 - 0
.gitignore

@@ -98,3 +98,5 @@ python/builddebug
 tutorial/.idea
 python/buildstatic
 tutorial/cmake-build-debug
+.vscode/
+.idea/

+ 7 - 7
python/iglhelpers.py

@@ -11,15 +11,15 @@ import pyigl as igl
 
 def p2e(m):
     if isinstance(m, np.ndarray):
-        if not m.flags['C_CONTIGUOUS']:
-            raise TypeError("p2e only support C-contiguous order")
-        if m.dtype.type == np.int32:
-            return igl.eigen.MatrixXi(m)
-        elif m.dtype.type == np.float64:
-            return igl.eigen.MatrixXd(m)
+        if not (m.flags['C_CONTIGUOUS'] or m.flags['F_CONTIGUOUS']):
+            raise TypeError('p2e support either c-order or f-order')
+        if m.dtype.type in [np.int32, np.int64]:
+            return igl.eigen.MatrixXi(m.astype(np.int32))
+        elif m.dtype.type in [np.float64, np.float32]:
+            return igl.eigen.MatrixXd(m.astype(np.float64))
         elif m.dtype.type == np.bool:
             return igl.eigen.MatrixXb(m)
-        raise TypeError("p2e only support dtype float64, int32 and bool")
+        raise TypeError("p2e only support dtype float64/32, int64/32 and bool")
     if sparse.issparse(m):
         # convert in a dense matrix with triples
         coo = m.tocoo()