ValueError when loading non-npz counts file with load_counts()

Issue #56 resolved
Thomas Gilgenast created an issue

lib5c.parsers.counts.load_counts() first tries to load the countsfile as an NPZ via counts = dict(np.load(countsfile)) and watches for IOError, which we expecte to be thrown when the countsfile is actually a plain text countsfile

we haven't been able to pin this down, but potentially due to changes in numpy it is possible to get

Failed example:
    counts = load_counts('test/test.counts', primermap)['Sox2']
Exception raised:
    Traceback (most recent call last):
      File "...\", line 1315, in __run
        compileflags, 1) in test.globs
      File "<doctest lib5c.plotters.extendable.extendable_heatmap.ExtendableHeatmap[9]>", line 1, in <module>
        counts = load_counts('test/test.counts', primermap)['Sox2']
      File "...\lib5c\parsers\", line 249, in load_counts
        counts = dict(np.load(countsfile))
      File "...\site-packages\numpy\lib\", line 451, in load
        raise ValueError("Cannot load file containing pickled data "
    ValueError: Cannot load file containing pickled data when allow_pickle=False

where instead of an IOError a ValueError is thrown and does not get caught by our except block

one solution could be to catch either ValueError or IOError here

Comments (1)

  1. Log in to comment