Skip to content

Conversation

@jojoelfe
Copy link
Collaborator

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?

@jojoelfe jojoelfe requested review from alisterburt and Copilot March 31, 2025 01:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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):

Copy link
Collaborator

@alisterburt alisterburt left a comment

Choose a reason for hiding this comment

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

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

😍

jojoelfe and others added 4 commits March 31, 2025 13:41
Co-authored-by: alisterburt <alisterburt@gmail.com>
Co-authored-by: alisterburt <alisterburt@gmail.com>
Co-authored-by: alisterburt <alisterburt@gmail.com>
@jojoelfe jojoelfe merged commit 577c952 into teamtomo:main Apr 4, 2025
6 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