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

ENH: Add indent to image's matrix printing #4772

Merged

Conversation

blowekamp
Copy link
Member

Add Matrix::PrintSelf method which uses ITK's indent object to allow proper indenting of nested objects.

Fixes left aligned matrix values when printing the Image classes.

PR Checklist

  • No API changes were made (or the changes have been approved)
  • No major design changes were made (or the changes have been approved)
  • Added test (or behavior not changed)
  • Updated API documentation (or API not changed)
  • Added license to new files (if any)
  • Added Python wrapping to new files (if any) as described in ITK Software Guide Section 9.5
  • Added ITK examples for all new major features (if any)

Refer to the ITK Software Guide for
further development details if necessary.

@github-actions github-actions bot added type:Enhancement Improvement of existing methods or implementation area:Core Issues affecting the Core module labels Jul 10, 2024
@blowekamp
Copy link
Member Author

This was the print out style that Copilot made up. I am not sure if a numpy style with [[][][]] would be preferred, or the the generated matrix dimensions are desired. Please suggest/propose.

New printout from Image:

603:   Direction: 
603:   Matrix (2x2)
603:     1 0 
603:     0 1 
603:   IndexToPointMatrix: 
603:     Matrix (2x2)
603:       1 0 
603:       0 1 
603:   PointToIndexMatrix: 
603:     Matrix (2x2)
603:       1 0 
603:       0 1 
603:   Inverse Direction: 
603:     Matrix (2x2)
603:       1 0 
603:       0 1 

Old print out:


  Direction: 
1 0
0 1

  IndexToPointMatrix: 
1 0
0 1

  PointToIndexMatrix: 
1 0
0 1

  Inverse Direction: 
1 0
0 1

And a numpy identity matrix:

[[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]

@dzenanz
Copy link
Member

dzenanz commented Jul 10, 2024

I like it this way. I thought about whether to ask for before/after output 😄

Copy link
Member

@jhlegarreta jhlegarreta left a comment

Choose a reason for hiding this comment

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

Given the choice, maybe because I got used to it, I like Numpy's better (with the appropriate indentation, but I am fine with the current style improvement.

@blowekamp
Copy link
Member Author

blowekamp commented Jul 11, 2024

Note: the matrix in AffineTransform is printed correctly with in a CompositeTransform. The Transform classes should be consistent.

Add Matrix::PrintSelf method which uses ITK's indent object to allow
proper indenting of nested objects.

Add indenting to image's matrix printing.

Fixes left aligned matrix values when printing the Image classes.
@dzenanz
Copy link
Member

dzenanz commented Jul 15, 2024

/azp run ITK.Linux.Python

@dzenanz
Copy link
Member

dzenanz commented Jul 18, 2024

Is this ready to merge? Remove draft status?

@blowekamp blowekamp requested a review from thewtex July 19, 2024 12:41
@blowekamp
Copy link
Member Author

Let see if @thewtex has a comment about the preferred formatting of the output for the Matrix.

Copy link
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

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

👍 looks like a good improvement to me. @blowekamp thanks for taking the time to make the tweak.

@dzenanz
Copy link
Member

dzenanz commented Jul 19, 2024

@blowekamp time to merge?

@blowekamp blowekamp marked this pull request as ready for review July 19, 2024 14:12
@blowekamp blowekamp merged commit bc05eb1 into InsightSoftwareConsortium:master Jul 19, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Core Issues affecting the Core module type:Enhancement Improvement of existing methods or implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants