ilastik / lazyflow

lazy parallel ondemand zero copy numpy array data flows with caching and dirty propagation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

testOpFormattedDataExport fails sometimes

jakirkham opened this issue · comments

The main test in testOpFormattedDataExport, testBasic, fails here sometimes. As this test takes random data (

data = numpy.random.random( (100,100) ).astype( numpy.float32 ) * 100
) and is asserting the validity of that data (
assert (numpy.abs(difference_from_expected) <= 1).all(), "Read data didn't match exported data!"
), it is possible that some types of random values are not acceptable. It would be nice to figure out the cause of this and fix it.

Actually, the cause seems to be rather straightforward. As the type we are using is unsigned (

expected_data = expected_data.astype(numpy.uint8)
), we are getting a rollover error (i.e. sometimes we get 255), which is not less than or equal to 1 even though the two values may have been (i.e. 1 and 2 ), but had their difference taken in a non-positive direction.

This can be easily resolved several ways. We could simply promote the type before subtraction. Alternatively, if we need to maintain the same type, we could ensure we have the larger values in one array and the smaller ones in the other.