Fix unguarded gudhi.tensorflow import crashing data_assimilation on plain install (#197)#198
Merged
Merged
Conversation
khasawn3
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
data_assimilation.pyhadfrom gudhi.tensorflow import RipsLayerat the top of the file (line 3), outside any try/except block. Sincegudhi.tensorflowinternally imports TensorFlow, this caused the entire module to crash on import when TensorFlow was not installed, even though TensorFlow is an optional dependency only needed byTADA.The fix moves the import inside the existing try/except block and replaces the bareexceptwithexcept ImportError. Instead of raising immediately at module load time, a flag_tensorflow_availableis set and checked at the start ofTADA. This means:rafdacan be imported and used on a plainpip install teaspoonwith no TensorFlowTADAwithout TensorFlow raises a clearImportErrorpointing the user topip install 'teaspoon[full]'Motivation and Context
Closes #197. " teaspoon.DAF.data_assimilation crashes on import after plain "pip install teaspoon" => unguarded from gudhi.tensorflow import RipsLayer on line 3 defeats the developer's own tensorflow try/except #197 "
How has this been tested?
from teaspoon.DAF.data_assimilation import rafdasucceeds without TensorFlow installed.from teaspoon.DAF.data_assimilation import TADAsucceeds without TensorFlow installed.TADA(...)without TensorFlow raisesImportErrorwith the message"TADA requires TensorFlow. Install with: pip install 'teaspoon[full]'".RipsLayeris no longer imported at the module top level.tests/test_DAF.py) — 1 skipped (expected: the test correctly skips itself when TensorFlow is not available).Types of changes
Checklist
make clean)make tests)