fix buffer_npix method in gs#128
Conversation
Back to the original problem
Back to the original problem
Tests: npix, buffers Checking max pixels per buffer
Changed the payload size to ignore the final 12 dummy index values, which are (for some reason) getting into the frame
Comments for test to check for correct frame size.
Fixed size of buffer issue (buffer to array was taking wrong size, because it was taking in 384 bytes, not bits)
looking for read length fix, likely parent/child class not called correctly
comments to merge
Read length should be good, and also adding test for image verification
sneakers-the-rat
left a comment
There was a problem hiding this comment.
cool. so this should both merge the buffer_npix fixes as well as get the base branch partially back to a state it can be worked on. if we clean up as we go then we avoid piling a bunch of broken code on broken code and can actually make progress. if we just keep jamming our shit with a bunch of comments, tweaking things in a nonsystematic way, then that's how we get this project which should have taken a week, tops, taking >8 months.
| Convert a list of 1D pixel arrays into a full frame, stripping the leading "training" pixels | ||
| """ | ||
| pixels = np.concatenate(frame_data) # concatenates to 1xn | ||
| print(len(pixels)) |
There was a problem hiding this comment.
no print statements in code. no commented out blocks of code
| print(len(header_array), len(buffer[header_end:])) | ||
| # breakpoint() | ||
| payload = buffer_to_array( | ||
| buffer[header_end:-48] |
There was a problem hiding this comment.
this is not very robust and should be calculated based on the number of dummy words
| print(f"First few values of buffer 0: {full_buffers[0][:5]}") | ||
| print(f"First few values of partial buffer: {partial_buffer[:5]}") | ||
|
|
||
| from mio.devices.gs.config import GSDevConfig |
There was a problem hiding this comment.
put imports at the top. you only ever need to import something once per module. this is super cluttery
| def test_buffer_npix(gs_raw_buffers): | ||
| format = GSBufferHeaderFormat.from_id("gs-buffer-header") | ||
| config = GSDevConfig.from_id("MSUS") | ||
| frame_buffers = defaultdict(list) | ||
|
|
||
| for i, buffer in enumerate(gs_raw_buffers): | ||
| header, pixels = GSBufferHeader.from_buffer(buffer, header_fmt=format, config=config) | ||
| frame_buffers[header.frame_num].append(pixels) | ||
|
|
||
| # discard first and last which may be incomplete in the sample | ||
| frames = list(frame_buffers.keys()) | ||
| del frame_buffers[frames[0]] | ||
| del frame_buffers[frames[-1]] | ||
|
|
||
| for frame_num, pixels in frame_buffers.items(): | ||
| pixel_lengths = [len(p) for p in pixels] | ||
| assert pixel_lengths == config.buffer_npix |
There was a problem hiding this comment.
this is the only thing that this PR is about really, the rest is just getting the code to run again
man what even am i looking at
📚 Documentation preview 📚: https://miniscope-io--128.org.readthedocs.build/en/128/