Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inheritance #91

Merged
merged 17 commits into from
Oct 22, 2024
Merged

Add inheritance #91

merged 17 commits into from
Oct 22, 2024

Conversation

viljarjf
Copy link
Contributor

Hello,
as per #90, this implements some basic base classes for a couple cases where they were appropriate.
I also expanded the testing suite slightly, although it was difficult to come up with ways to test things without an actual microscope available. Mock versions of the cameras could be useful for more testing, although a mock version of every camera might not be necessary. My idea was to make the cameras instantiable by overriding the connection to an actual camera.

I feel like the structure and expandability of the code could be improved further, but I would like to think and plan a little first. This will come later, and I am very open to suggestions/thoughts on this matter. I presume you might have ideas for this, @stefsmeets?

@stefsmeets
Copy link
Member

Thanks for this! I didn't manage to get to this this week, but I will have a look next week!

Copy link
Member

@stefsmeets stefsmeets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the careful refactoring and adding the base classes! This helps a lot to make the code more consistent! The additional tests are also very welcome.

A few things I want to point out:

  • Have you tried running the code on a live microscope? This continues to be my biggest fear when making sweeping changes and that is that I'd break something.
  • The code uses some typing features that are not supported by python 3.7. Some of these may be fixed by prepending from __future__ import annotations. It's important that the code is compatible with older versions of Python, because older microscopes may still run Windows 7 where 3.7 is the last supported version. See failing tests.
  • Just a heads-up, this code is configured to use autopep8 for code formatting (ruff didn't exist when this code was written 😅), please use that instead of ruff. You can use pre-commit run --files filename.py to run all the linting/formatting tools.

I fixed a bug in #92 that fixes the comtypes install in the tests. If you sort out the typing, and the tests pass I'm happy to merge this PR.

src/instamatic/TEMController/TEMController.py Outdated Show resolved Hide resolved
@stefsmeets
Copy link
Member

stefsmeets commented Oct 21, 2024

I feel like the structure and expandability of the code could be improved further, but I would like to think and plan a little first.

Completely agree. The code base is somewhat dated and there is a lot of opportunity to streamline and improve the quality of the code. I'm happy to discuss any ideas in an issue.

@viljarjf
Copy link
Contributor Author

Have you tried running the code on a live microscope? This continues to be my biggest fear when making sweeping changes and that is that I'd break something.

I have not, no. I could try to look into it, but I don't have training on our microscopes yet, and I have not looked into how instamatic is installed ect. My aim was to entirely avoid doing any changes that actually affected how the code was run, but I agree that it should be tested properly first

The code uses some typing features that are not supported by python 3.7. Some of these may be fixed by prepending from __future__ import annotations. It's important that the code is compatible with older versions of Python, because older microscopes may still run Windows 7 where 3.7 is the last supported version. See failing tests.

Done. A bit frustrating, but understandable, that the microscope computers don't keep up with updates, especially now as even 3.8 has reached end-of-life.

Just a heads-up, this code is configured to use autopep8 for code formatting (ruff didn't exist when this code was written 😅), please use that instead of ruff. You can use pre-commit run --files filename.py to run all the linting/formatting tools.

Will do moving forward. It did not work in python 3.7 unfortunately, seemingly due to some newer features introduced in versions without 3.7 support. I ran the hooks manually in 3.12 instead.

I fixed a bug in #92 that fixes the comtypes install in the tests.

I rebased on the newest main

@stefsmeets
Copy link
Member

Thanks, I also don't think the changes will affect anything, but it's always good to test it. Unfortunately, I don't have access to a TEM and it's impossible to test all configurations anyway.

I'm happy to switch to code formatting to ruff at some point, and add mypy for testing. I actually did a mypy run for fun just now and there are over 700 issues 😅

@stefsmeets
Copy link
Member

Since the tests passes I'm going to merge this, and I don't see any major issues. Let me know if you have a chance to run this on the microscope and run into issues.

I created some follow-up issues in #94 #93

@stefsmeets stefsmeets merged commit 2576993 into instamatic-dev:main Oct 22, 2024
5 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