Closed anushka255 closed 10 months ago
Bug 1:
The bug seems to be coming from imbalance of test_data
size.
Based on line 30 & 31
with the following code:
nIterations = nFrames // chunkMaxSize
remaining frames = nFrames - nIterations * chunkMaxSize
This leads the size of iterations to always be 0 and the loop that does some reshaping to never run. The value of remainingframes
will always be equal to nFrames
.
Causes problem in line 50 brightness[-remainingframes - 1:-1] = np.average(frames, axis=1)
Fixed the bug by encapsulating the code into a try except
block.
Bug 2:
Based on line 30 & 31
with the following code:
nIterations = nFrames // chunkMaxSize
remainingframes = nFrames - nIterations * chunkMaxSize
The value of remainingframes
always be 0
in cases where the number of frames in .dat
file are exact multiple of 6 * chunk size
.
Fixed the bug by adding an if statement before the code deals with the last partial check. If the frames are exact multiples of 6 * chunk size
, then there will be no case of remaining frames.
The updated code looks like:
if remainingframes > 0:
# Last partial chunk
chunk = np.fromfile(f, dtype=np.uint16, count=remainingframes * 1024 * 512)
frames = chunk.reshape((remainingframes, 1024 * 512))
brightness[-remainingframes - 1:-1] = np.average(frames, axis=1)
stdev[-remainingframes - 1:-1] = np.std(frames.astype(np.float64), axis=1)
Full Iteration:
Reads specific number of 16-bit unsigned integers from a binary file and stores them in a NumPy array named chunk
.
Reshapes the 1D array chunk
into a 2D array, where the first dimension has a size of chunkMaxSize
, and the second dimension is a flattened array with 1024*512 elements
.
Computes the average value of each row in the frames array and then stores these averages in a specific segment of the brightness
array. The segment is determined by the current loop index i
and the size of each chunk, chunkMaxSize
.
(Perhaps is reducing a 2D dataset (video frames?) into a 1D representation (like average brightness values).
Calculates the standard deviation of each row in the frames array (after converting it to a higher precision data type) and stores these standard deviation values in a specific segment of the stdev array. The specific segment being updated is determined by the index I
and the size chunkMaxSize
.
(This operation is useful in signal processing, where you might want to assess the variability or spread of data within each segment of a larger dataset.)
Potential Bug 3:
After iterating through most of the data from binary file, there;s a section of code that calculates average value and standard deviation of each row in the frames array.
The code looks like:
brightness[-remainingframes - 1:-1] = np.average(frames, axis=1)
stdev[-remainingframes - 1:-1] = np.std(frames.astype(np.float64), axis=1)
This overwrites the value of brightness
in -remaining-1
index and leaves the last index empty.
There are at least 2 bugs in flash_finder.py, which have their own test cases. Once these bugs are removed, the test cases can be modified as well.