From 3b5d0031fb0b5d8111406b3fb11514293e556252 Mon Sep 17 00:00:00 2001 From: Nina Miolane Date: Fri, 28 Dec 2018 14:28:51 +0100 Subject: [PATCH] Add message for examples in TF --- examples/plot_geodesics_h2.py | 10 +++++++--- examples/plot_geodesics_s2.py | 10 +++++++--- examples/plot_geodesics_se3.py | 10 +++++++--- examples/plot_geodesics_so3.py | 10 +++++++--- examples/plot_grid_h2.py | 10 +++++++--- examples/plot_quantization_s1.py | 9 ++++++++- examples/plot_quantization_s2.py | 9 ++++++++- examples/plot_square_h2_klein_disk.py | 10 +++++++--- examples/plot_square_h2_poincare_disk.py | 10 +++++++--- examples/plot_square_h2_poincare_half_plane.py | 10 +++++++--- tests/test_examples.py | 2 +- 11 files changed, 73 insertions(+), 27 deletions(-) diff --git a/examples/plot_geodesics_h2.py b/examples/plot_geodesics_h2.py index 768437fd93..127712e400 100644 --- a/examples/plot_geodesics_h2.py +++ b/examples/plot_geodesics_h2.py @@ -6,8 +6,6 @@ import matplotlib.pyplot as plt import numpy as np import os -# Examples with visualizations are only implemented with numpy -os.environ['GEOMSTATS_BACKEND'] = 'numpy' # NOQA import geomstats.visualization as visualization @@ -64,4 +62,10 @@ def main(): if __name__ == "__main__": - main() + if os.environ['GEOMSTATS_BACKEND'] == 'tensorflow': + print('Examples with visualizations are only implemented ' + 'with numpy backend.\n' + 'To change backend, write: ' + 'export GEOMSTATS_BACKEND = \'numpy\'.') + else: + main() diff --git a/examples/plot_geodesics_s2.py b/examples/plot_geodesics_s2.py index 9587cfff43..84fa0d6cb7 100644 --- a/examples/plot_geodesics_s2.py +++ b/examples/plot_geodesics_s2.py @@ -5,8 +5,6 @@ import matplotlib.pyplot as plt import numpy as np import os -# Examples with visualizations are only implemented with numpy -os.environ['GEOMSTATS_BACKEND'] = 'numpy' # NOQA import geomstats.visualization as visualization @@ -33,4 +31,10 @@ def main(): if __name__ == "__main__": - main() + if os.environ['GEOMSTATS_BACKEND'] == 'tensorflow': + print('Examples with visualizations are only implemented ' + 'with numpy backend.\n' + 'To change backend, write: ' + 'export GEOMSTATS_BACKEND = \'numpy\'.') + else: + main() diff --git a/examples/plot_geodesics_se3.py b/examples/plot_geodesics_se3.py index 66eab0e2c6..d8b238cfa8 100644 --- a/examples/plot_geodesics_se3.py +++ b/examples/plot_geodesics_se3.py @@ -6,8 +6,6 @@ import matplotlib.pyplot as plt import numpy as np import os -# Examples with visualizations are only implemented with numpy -os.environ['GEOMSTATS_BACKEND'] = 'numpy' # NOQA import geomstats.visualization as visualization @@ -33,4 +31,10 @@ def main(): if __name__ == "__main__": - main() + if os.environ['GEOMSTATS_BACKEND'] == 'tensorflow': + print('Examples with visualizations are only implemented ' + 'with numpy backend.\n' + 'To change backend, write: ' + 'export GEOMSTATS_BACKEND = \'numpy\'.') + else: + main() diff --git a/examples/plot_geodesics_so3.py b/examples/plot_geodesics_so3.py index 4cbda8e2e0..1a4ebb037c 100644 --- a/examples/plot_geodesics_so3.py +++ b/examples/plot_geodesics_so3.py @@ -6,8 +6,6 @@ import matplotlib.pyplot as plt import numpy as np import os -# Examples with visualizations are only implemented with numpy -os.environ['GEOMSTATS_BACKEND'] = 'numpy' # NOQA import geomstats.visualization as visualization @@ -32,4 +30,10 @@ def main(): if __name__ == "__main__": - main() + if os.environ['GEOMSTATS_BACKEND'] == 'tensorflow': + print('Examples with visualizations are only implemented ' + 'with numpy backend.\n' + 'To change backend, write: ' + 'export GEOMSTATS_BACKEND = \'numpy\'.') + else: + main() diff --git a/examples/plot_grid_h2.py b/examples/plot_grid_h2.py index abec5db06a..d383ff483f 100644 --- a/examples/plot_grid_h2.py +++ b/examples/plot_grid_h2.py @@ -6,8 +6,6 @@ import matplotlib.pyplot as plt import numpy as np import os -# Examples with visualizations are only implemented with numpy -os.environ['GEOMSTATS_BACKEND'] = 'numpy' # NOQA import geomstats.visualization as visualization @@ -46,4 +44,10 @@ def main(left=-128, if __name__ == "__main__": - main() + if os.environ['GEOMSTATS_BACKEND'] == 'tensorflow': + print('Examples with visualizations are only implemented ' + 'with numpy backend.\n' + 'To change backend, write: ' + 'export GEOMSTATS_BACKEND = \'numpy\'.') + else: + main() diff --git a/examples/plot_quantization_s1.py b/examples/plot_quantization_s1.py index 8e73cc11ee..0dc5019efc 100644 --- a/examples/plot_quantization_s1.py +++ b/examples/plot_quantization_s1.py @@ -4,6 +4,7 @@ """ import matplotlib.pyplot as plt +import os import geomstats.visualization as visualization @@ -39,4 +40,10 @@ def main(): if __name__ == "__main__": - main() + if os.environ['GEOMSTATS_BACKEND'] == 'tensorflow': + print('Examples with visualizations are only implemented ' + 'with numpy backend.\n' + 'To change backend, write: ' + 'export GEOMSTATS_BACKEND = \'numpy\'.') + else: + main() diff --git a/examples/plot_quantization_s2.py b/examples/plot_quantization_s2.py index 739c049978..b073caed32 100644 --- a/examples/plot_quantization_s2.py +++ b/examples/plot_quantization_s2.py @@ -4,6 +4,7 @@ """ import matplotlib.pyplot as plt +import os import geomstats.visualization as visualization @@ -40,4 +41,10 @@ def main(): if __name__ == "__main__": - main() + if os.environ['GEOMSTATS_BACKEND'] == 'tensorflow': + print('Examples with visualizations are only implemented ' + 'with numpy backend.\n' + 'To change backend, write: ' + 'export GEOMSTATS_BACKEND = \'numpy\'.') + else: + main() diff --git a/examples/plot_square_h2_klein_disk.py b/examples/plot_square_h2_klein_disk.py index 9c58322c69..3ccac45da5 100644 --- a/examples/plot_square_h2_klein_disk.py +++ b/examples/plot_square_h2_klein_disk.py @@ -5,8 +5,6 @@ import matplotlib.pyplot as plt import numpy as np import os -# Examples with visualizations are only implemented with numpy -os.environ['GEOMSTATS_BACKEND'] = 'numpy' # NOQA import geomstats.visualization as visualization @@ -45,4 +43,10 @@ def main(): if __name__ == "__main__": - main() + if os.environ['GEOMSTATS_BACKEND'] == 'tensorflow': + print('Examples with visualizations are only implemented ' + 'with numpy backend.\n' + 'To change backend, write: ' + 'export GEOMSTATS_BACKEND = \'numpy\'.') + else: + main() diff --git a/examples/plot_square_h2_poincare_disk.py b/examples/plot_square_h2_poincare_disk.py index 8e541a0c59..09ebebaffd 100644 --- a/examples/plot_square_h2_poincare_disk.py +++ b/examples/plot_square_h2_poincare_disk.py @@ -5,8 +5,6 @@ import matplotlib.pyplot as plt import numpy as np import os -# Examples with visualizations are only implemented with numpy -os.environ['GEOMSTATS_BACKEND'] = 'numpy' # NOQA import geomstats.visualization as visualization @@ -47,4 +45,10 @@ def main(): if __name__ == "__main__": - main() + if os.environ['GEOMSTATS_BACKEND'] == 'tensorflow': + print('Examples with visualizations are only implemented ' + 'with numpy backend.\n' + 'To change backend, write: ' + 'export GEOMSTATS_BACKEND = \'numpy\'.') + else: + main() diff --git a/examples/plot_square_h2_poincare_half_plane.py b/examples/plot_square_h2_poincare_half_plane.py index 5bb7ffad87..e9f64530e8 100644 --- a/examples/plot_square_h2_poincare_half_plane.py +++ b/examples/plot_square_h2_poincare_half_plane.py @@ -5,8 +5,6 @@ import matplotlib.pyplot as plt import numpy as np import os -# Examples with visualizations are only implemented with numpy -os.environ['GEOMSTATS_BACKEND'] = 'numpy' # NOQA import geomstats.visualization as visualization @@ -47,4 +45,10 @@ def main(): if __name__ == "__main__": - main() + if os.environ['GEOMSTATS_BACKEND'] == 'tensorflow': + print('Examples with visualizations are only implemented ' + 'with numpy backend.\n' + 'To change backend, write: ' + 'export GEOMSTATS_BACKEND = \'numpy\'.') + else: + main() diff --git a/tests/test_examples.py b/tests/test_examples.py index 5e5f172d9d..72f9a33934 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -20,9 +20,9 @@ import examples.plot_square_h2_poincare_disk as plot_square_h2_poincare_disk import examples.plot_square_h2_poincare_half_plane as plot_square_h2_poincare_half_plane # NOQA import examples.plot_square_h2_klein_disk as plot_square_h2_klein_disk -import examples.tangent_pca_so3 as tangent_pca_so3 import examples.plot_quantization_s1 as plot_quantization_s1 import examples.plot_quantization_s2 as plot_quantization_s2 +import examples.tangent_pca_so3 as tangent_pca_so3 import geomstats.tests