Skip to content

Conversation

@CSSFrancis
Copy link
Member

This pull request refactors and improves the image acquisition result handling in the deapi client. The main changes include introducing a new Result class to encapsulate image results, refactoring the get_result method for clarity and flexibility, and adding helper methods for pixel format conversions. These changes enhance code maintainability, usability, and plotting capabilities.

Result encapsulation and usability improvements:

  • Introduced a new Result class (in deapi/data_types.py) to encapsulate the image, pixel format, attributes, and histogram returned from get_result, including a rich plot method for visualization and a custom __repr__ for easier debugging.
  • Updated the return value of get_result in deapi/client.py to return a Result object instead of a tuple, simplifying downstream usage.

Refactoring and flexibility in get_result:

  • Refactored the get_result method in deapi/client.py for clarity: simplified the parsing and assignment of attribute fields, improved histogram extraction, and replaced repetitive code with a loop over field names.
  • Added support for additional keyword arguments (**kwargs) to customize attributes such as window size, zoom, and stretch parameters, making the API more flexible.

Pixel format handling improvements:

  • Added to_numpy_dtype and from_numpy_dtype helper methods to the PixelFormat enum for seamless conversion between enum values and numpy data types, and used these methods in get_result. [1] [2]

Logging and code cleanup:

  • Improved debug logging for transfer times and result summaries, and removed redundant or unreachable code. [1] [2]

Miscellaneous:

  • Added or improved __repr__ methods for Attributes and Histogram for better debugging output. [1] [2]

@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 37.37864% with 129 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
deapi/data_types.py 13.82% 81 Missing ⚠️
deapi/client.py 65.55% 31 Missing ⚠️
deapi/simulated_server/fake_server.py 0.00% 17 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions
Copy link

github-actions bot commented Oct 3, 2025

Preview for PR #25
View the preview here
(Built from a fork branch and deployed to PreviewDE/deapi-preview)

@CSSFrancis
Copy link
Member Author

pre-commit.ci autofix

@CSSFrancis CSSFrancis merged commit 81870c8 into directelectron:main Oct 3, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants