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

grass.jupyter: importing display function from IPython.display #4476

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

Conversation

rohannallamadge
Copy link
Contributor

@rohannallamadge rohannallamadge commented Oct 8, 2024

importing display function from IPython.display to display the map image

Fixes #4340.

@github-actions github-actions bot added Python Related code is in Python libraries notebook labels Oct 8, 2024
@rohannallamadge rohannallamadge changed the title importing display function from IPython.display grass.jupyter: importing display function from IPython.display #4340 Oct 8, 2024
@wenzeslaus wenzeslaus changed the title grass.jupyter: importing display function from IPython.display #4340 grass.jupyter: importing display function from IPython.display Oct 14, 2024
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

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

Thank you. This is great. It looks like it is addressing the original idea in #4340.

I left two comments and I also modified the title to make it valid (there was a leading space) and I moved the referenced issue to the text.


return Image(self._filename)
return display(Image(self._filename))
Copy link
Member

Choose a reason for hiding this comment

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

Is return needed here? What does IPython.display.display function return?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is return needed here? What does IPython.display.display function return?

No. We are not setting a display_id parameter, so IPython.display.display will return None.

python/grass/jupyter/map.py Outdated Show resolved Hide resolved
Copy link
Contributor

@cwhite911 cwhite911 left a comment

Choose a reason for hiding this comment

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

Nice job working on this PR.

@rohannallamadge
Copy link
Contributor Author

rohannallamadge commented Oct 17, 2024

  • Added _repr_pretty_ method to provide a custom pretty representation in IPython environments
  • Ensures proper handling of recursive cycles by displaying "Map(...)" as a fallback

@rohannallamadge
Copy link
Contributor Author

rohannallamadge commented Oct 17, 2024

sir, is this correct PR ?

@rohannallamadge
Copy link
Contributor Author

Removed the return statement from the show() method
Now using display() directly to handle image rendering inline, without returning an Image object

@echoix
Copy link
Member

echoix commented Oct 19, 2024

Seems like some basic code formatting and checking is still missing. Let us know once ready ;)

Image,
display,
) # pylint: disable=import-outside-toplevel

Copy link
Contributor

Choose a reason for hiding this comment

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

[ruff] reported by reviewdog 🐶

Suggested change

@rohannallamadge
Copy link
Contributor Author

sir, error
Screenshot 2024-10-19 234659

Image,
display, # pylint: disable=import-outside-toplevel
)
display(Image(self._filename))
Copy link
Contributor

Choose a reason for hiding this comment

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

[black] reported by reviewdog 🐶

Suggested change
display(Image(self._filename))
display(Image(self._filename))

.pylintrc Outdated
@@ -652,5 +652,6 @@ min-public-methods=1

# Exceptions that will emit a warning when being caught. Defaults to
# "BaseException, Exception".
overgeneral-exceptions=BaseException,
Exception
overgeneral-exceptions=BaseException,Exception
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a need for this change

.pylintrc Outdated
@@ -654,3 +654,5 @@ min-public-methods=1
# "BaseException, Exception".
overgeneral-exceptions=BaseException,
Exception

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove extra lines.


return Image(self._filename)
from IPython.display import (
Image,
Copy link
Contributor

Choose a reason for hiding this comment

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

[black] reported by reviewdog 🐶

Suggested change
Image,
Image,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libraries notebook Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] grass.jupyter: map.show
5 participants