Commits

Anonymous committed afea839 Merge

Merge branch 'master' of bitbucket.org:scicompanat/pyca

Comments (0)

Files changed (3)

 #-----------------------------------------------------------------------------
 # If OpenMP is available, always use it by default
 include(CheckCCompilerFlag)
-# clang style
-check_c_compiler_flag(-openmp HAS_OPENMP)
 check_c_compiler_flag(-fopenmp HAS_FOPENMP)
 check_c_compiler_flag(/openmp HAS_SLASHOPENMP)
-if (HAS_OPENMP)
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -openmp")
 # gcc style
-elseif (HAS_FOPENMP)
+if (HAS_FOPENMP)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
 # msvc style
 elseif (HAS_SLASHOPENMP)

Code/Python/Display/PyCADisplay.py

     plt.xticks([])
     plt.yticks([])
     plt.draw()
+
+def SampleCMap(nSamples, cmap=matplotlib.cm.jet):
+    """
+    Evenly sample a colormap.  Used to create easy index-to-color
+    mappings.
+    """
+    norm = matplotlib.colors.Normalize(vmin=0, vmax=nSamples)
+    sm = matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap)
+    colors = sm.to_rgba(np.arange(nSamples))
+    return colors
+
+    

Code/Python/Parallel/PyCAParallel.py

 
 import numpy as np
 
-from mpi4py import MPI
+try:
+   from mpi4py import MPI
+   hasMPI = True
+except:
+   hasMPI = False
 
-def Reduce(A, hA, op=MPI.SUM):
+def Reduce(A, hA, op=None):
     """Reduce PyCA Image3D or Field3D over MPI
 
     A can live anywhere but hA needs to be of mType MEM_HOST
 
     """
+    if not hasMPI:
+      raise Exception("mpi4py required for Reduce operations: not found")
+
+    if op is None:
+      op = MPI.SUM
+
     if A.memType() == ca.MEM_HOST:
         # can do this in place without using hA
         if isinstance(A, ca.Image3D):
         ca.Copy(A, hA)  # upload
 
 
-def ReduceFloat(f, op=MPI.SUM):
+def ReduceFloat(f, op=None):
     """Reduce a single float value over MPI"""
+    if not hasMPI:
+      raise Exception("mpi4py required for Reduce operations: not found")
+
+    if op is None:
+      op = MPI.SUM
+
     fa = np.array([f])  # can only reduce over numpy arrays
     MPI.COMM_WORLD.Allreduce(MPI.IN_PLACE,
                              fa,