anthony-nouy / tensap

Tensor Approximation Package: a Python package for the approximation of functions and tensors.
https://anthony-nouy.github.io/sphinx/tensap/master/
Other
20 stars 11 forks source link

Some tutorials fail with missing dependencies #3

Closed regislebrun closed 4 years ago

regislebrun commented 4 years ago

In addition to tensorflow, networkx is also used in some tutorials. I also noted a bug with numpy 1.16.5 & 1.17.5, triggered by tutorial_tensor_learning_TreeBasedTensorLearning.py:

  File "tutorial_tensor_learning_TreeBasedTensorLearning.py", line 157, in <module>
    F, OUTPUT = SOLVER.solve()
  File "/usr/local/lib/python3.7/site-packages/tensap-1.0-py3.7.egg/tensap/approximation/tensor_approximation/tensor_learning/tensor_learning.py", line 264, in solve
  File "/usr/local/lib/python3.7/site-packages/tensap-1.0-py3.7.egg/tensap/approximation/tensor_approximation/tensor_learning/tensor_learning.py", line 507, in _solve_adaptation
  File "/usr/local/lib/python3.7/site-packages/tensap-1.0-py3.7.egg/tensap/approximation/tensor_approximation/tensor_learning/tensor_learning.py", line 277, in solve
  File "/usr/local/lib/python3.7/site-packages/tensap-1.0-py3.7.egg/tensap/approximation/tensor_approximation/tensor_learning/tensor_learning.py", line 389, in _solve_standard
  File "/usr/local/lib/python3.7/site-packages/tensap-1.0-py3.7.egg/tensap/approximation/tensor_approximation/tensor_learning/tree_based_tensor_learning.py", line 201, in prepare_alternating_minimization_system
  File "/usr/local/lib/python3.7/site-packages/tensap-1.0-py3.7.egg/tensap/approximation/tensor_approximation/tensor_learning/tree_based_tensor_learning.py", line 421, in create_basis_adaptation_path
  File "<__array_function__ internals>", line 6, in expand_dims
  File "/usr/local/lib64/python3.7/site-packages/numpy/lib/shape_base.py", line 577, in expand_dims
    if axis > a.ndim or axis < -a.ndim - 1:
TypeError: '>' not supported between instances of 'list' and 'int'

This issue is solved if I upgrade to numpy 1.18.5. It may be tested in setup.py

jschueller commented 4 years ago

tutorials dependencies can be bigger than the core package, they're meant to be examples

regislebrun commented 4 years ago

Yes but I was planning to turn the tutorials into tests, waiting for a better solution. The issue with numpy is worth noting as numpy1.18.5 may not be available for some users.

egrelier commented 4 years ago

The package networkx is imported in the method plot_with_labels_at_nodes of DimensionTree, which is used only for display purposes and hence should not be necessary in tests.

As for the issue with numpy, I agree that it should be added as a requirement in setup.py. I do not replicate the bug with numpy 1.18.2, I need to find from which version the bug has been fixed.

jschueller commented 4 years ago

it works from 1.18.0, 1.17.5 is the latest from 1.17.x and does not work requiring 1.18 is a bit high, as it was only published in december, it could be cool to enable 1.17

egrelier commented 4 years ago

The issue with numpy's expand_dims function, due do the use of a list in second argument which was not supported before v1.18.0, will be fixed in the next commit to be compatible with previous versions.