giotto-ai / pyflagser

Python bindings and API for the flagser C++ library (https://github.com/luetge/flagser).
Other
13 stars 15 forks source link

Computations following an interrupted call fail #15

Closed wreise closed 4 years ago

wreise commented 4 years ago

Description

When run, the flagser function creates an output (output_flagser_file) file that is deleted at termination. However, if, one computation terminates early (for example it is interrupted), and a subsequent one is launched, in the same way, it fails: The output file already exists, aborting.

Steps/Code to Reproduce

  1. Run
    import numpy as np
    from pyflagser import flagser
    dist = np.loadtxt('dist_eight.txt')
    phs = flagser(dist, min_dimension=0, max_dimension=3, directed=True, coeff=2, approximation=20)
  2. Interrupt after some time(computations take several minutes on my local machine).
  3. Run in the same directory.
    import numpy as np
    from pyflagser import flagser
    dist = np.array([[0.        , 0.        , 2.98500989, 4.35619449],
             [3.35619449, 0.        , 0.        , 4.91401302],
             [3.77040805, 2.57079633, 0.        , 0.        ],
             [3.57079633, 4.27051191, 2.19961173, 0.        ]])
    phs = flagser(dist, min_dimension=0, max_dimension=3, directed=True, coeff=2, approximation=20)

Expected Results

Terminating without an error.

Actual Results

The output file already exists, aborting

Versions

Darwin-19.3.0-x86_64-i386-64bit Python 3.7.6 (default, Dec 30 2019, 19:38:26) [Clang 11.0.0 (clang-1100.0.33.16)] pyflagser 0.1.0

gtauzin commented 4 years ago

On my mac, the results of the computations of the example given in 3 is instantaneous.

As for 1. I have now pushed a fix for the output file to be removed systematically before flagser computations.

wreise commented 4 years ago

Yes, the computations in 3 are instanteaneous. Sorry, I forgot to load the input matrix that i use for the call in 1. dist_eight.txt

gtauzin commented 4 years ago

I have run it using saveflag and the compiled C++ version of flagser. It takes a while and my computer sounds like it is suffering. Having the max dim to 3 might be just too much when you have a fully connected graph even if there are just 50 vertices. The approximate option will not help here because it shortens the reduction, but the code takes a long time indexing higher order simplices.

With max dim = 2 it takes a few seconds using the C++ code.

wreise commented 4 years ago

Thanks, @gtauzin ! This might belong more in #17 though.

gtauzin commented 4 years ago

Agreed. I will close this issue.