Skip to content

covert shape-getting to method #70

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

eteq
Copy link
Member

@eteq eteq commented Jun 27, 2025

As diuscussed with @mwcraig out-of-band, we realized image_height and image_width shouldn't be attributes since it may be label dependent. This changes them to be method-accessible instead of attributes

@eteq eteq requested a review from mwcraig June 29, 2025 21:24
Copy link
Member

@mwcraig mwcraig left a comment

Choose a reason for hiding this comment

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

Just one minor change and a longer, rambling question...

def test_width_height(self, data: np.ndarray):
self.image.load_image(NDData(data=data))
assert self.image.get_shape().width == 150
assert self.image.get_shape().height == 100
Copy link
Member

Choose a reason for hiding this comment

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

Can you please also add a test that get_shape returns an ImageShape?

]

ImageShape = namedtuple("ImageShape", ["width", "height"])
Copy link
Member

Choose a reason for hiding this comment

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

Thinking out loud here...is there any way to avoid declaring ImageShape as something that needs to be imported by backends? For type hinting we could have get_shape(..) -> tuple[int, int] and then have get_shape return an ImgeShape that is defined inside of get_shape.

Or, I suppose, we could follow the Array API specification and just return a plain tuple...

Not against named tuples, but trying to think of ways to minimize the imports for backends.

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