Finalize Imodmodel writing + documentation#33
Merged
jojoelfe merged 7 commits intoteamtomo:mainfrom Apr 4, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR finalizes writing support for IMOD models and updates the associated documentation and tests.
- Adds a write function and corresponding tests for writing IMOD models from pandas DataFrames.
- Introduces a new class method from_dataframe in the models to construct a model from DataFrame input.
- Updates documentation, pyproject settings, and CI configuration to reflect these new features.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_functional_api.py | Adds tests for writing and reading back an IMOD model file. |
| src/imodmodel/models.py | Adds from_dataframe method for constructing models from DataFrames. |
| src/imodmodel/functions.py | Implements a write function that utilizes the new from_dataframe method. |
| src/imodmodel/init.py | Exposes the write function in the public API. |
| pyproject.toml | Updates Python version requirements and target version for linting. |
| docs/*.md | Updates documentation to include write support and adjustments to links. |
| .github/workflows/test_and_deploy.yml | Updates CI configuration with additional python versions. |
Comments suppressed due to low confidence (1)
src/imodmodel/models.py:499
- [nitpick] Consider renaming the parameter 'type' to avoid shadowing Python's built-in function, for example to 'contour_type'.
def from_dataframe(cls, dataframe: pd.DataFrame, type: ContourType = ContourType.SCATTERED):
alisterburt
approved these changes
Mar 31, 2025
Collaborator
alisterburt
left a comment
There was a problem hiding this comment.
about to jump on a plane but here are some first comments - please merge when you're happy and push a release when it works for you! 🙂 ping if you need any guidance on that process
Comment on lines
+38
to
+47
| def test_write(two_contour_model_file,tmp_path): | ||
| """Check that a model can be written to a file.""" | ||
| # Read the original model | ||
| original_model = imodmodel.read(two_contour_model_file) | ||
| # Write the model to a new file | ||
| imodmodel.write(original_model, tmp_path / "test_model.imod") | ||
| # Read the new model | ||
| new_model = imodmodel.read(tmp_path / "test_model.imod") | ||
| # Check that the new model matches the original | ||
| assert original_model.equals(new_model) |
Co-authored-by: alisterburt <alisterburt@gmail.com>
Co-authored-by: alisterburt <alisterburt@gmail.com>
Co-authored-by: alisterburt <alisterburt@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These are some minor things to finish up the Imodmodel write support + documentation, addressing #9, #21, and #25.
I decided on a very simple write method for now, mostly mirroring the simplicity of the writing.
Would be good for someone to double-check the note I wrote on the coordinate system origin that IMOD uses (at least for point annotation). Maybe everybody was already aware of that, but I've stumbled there a few times.
Maybe we can make a 0.1.0 or 1.0.0 release soon?