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

Update the interface and ginga implementation to make some changes of the marker API #173

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

Conversation

mwcraig
Copy link
Member

@mwcraig mwcraig commented Jul 27, 2023

No description provided.

@mwcraig mwcraig added enhancement New feature or request API Issues that relate to the API itself rather than implementations backend: ginga labels Jul 27, 2023
Comment on lines 249 to 250
rng = np.random.default_rng(1234)
data = rng.integers(0, 100, (5, 2))
Copy link
Member

Choose a reason for hiding this comment

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

Is randomness really necessary here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, that is just what GitHub Copilot inserted 😬

Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

As discussed today, I will review this ignoring potential refactoring we need for regions support.

Not a fan of the recursion in Ginga implementation but that works for now. We might have to refactor again anyway.

I don't think you need np.random. The test data is small enough and the context is irrelevant, so something like np.arange(10).reshape((5, 2)) would work just as well.

astrowidgets/tests/widget_api_test.py Outdated Show resolved Hide resolved
self.image.add_markers(tab, marker_name='test2')

self.image.remove_markers(marker_name='all')
assert self.image.get_markers(marker_name='all') is None
Copy link
Member

Choose a reason for hiding this comment

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

If we return empty table instead, this test will need to be updated, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that is correct

self.image.add_markers(tab, marker_name='test2')

self.image.remove_markers(marker_name=['test1', 'test2'])
assert self.image.get_markers(marker_name='all') is None
Copy link
Member

Choose a reason for hiding this comment

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

If we return empty table instead, this test will need to be updated, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

Copy link
Member

Choose a reason for hiding this comment

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

Is the empty table thingy part of this PR or separate PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since we are meeting later today it may as well be part of this PR. If the next meeting was pretty far off I'd be inclined to keep it spearate.

mwcraig and others added 2 commits August 3, 2023 08:31
Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>
@mwcraig
Copy link
Member Author

mwcraig commented Aug 3, 2023

Thanks, @pllim -- I'll hold off on changing the return values until after today's meeting.

This behavior is tested in the widget API tests
Once upon a time, get_markers raised a ValueError if the marker_name
passed in doesn't match any existing marker name. Later, the API was
changed so that a warning was issued and None was returned if the
marker name was not found. In the most recent iteration of the API, an
empty table is to be returned with the proper column names.

It turns out three responses were being checked. In one case, the test
checked (and passed) if a warning was raised. In another, the test
passed if a ValueError was raised.

The setup for those cases remains but now the check is that the return
table has now rows and has the correct column names.
@mwcraig mwcraig requested review from eteq and pllim August 27, 2023 16:21
astrowidgets/ginga.py Outdated Show resolved Hide resolved
astrowidgets/interface_definition.py Outdated Show resolved Hide resolved
Comment on lines +149 to +150
with warnings.catch_warnings():
warnings.simplefilter("error")
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, won't setting pytest to turn all warnings into exceptions take care of this?


def test_remove_markers(self):
with pytest.raises(ValueError, match='arf'):
self.image.remove_markers(marker_name='arf')

def test_remove_markers_name_all(self):
rng = np.random.default_rng(1234)
Copy link
Member

Choose a reason for hiding this comment

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

There are remaining unnecessary random number generators that should be replaced with static arrays.

self._check_marker_table_return_properties(self.image.get_markers(marker_name='all'))

def test_remove_marker_accepts_list(self):
rng = np.random.default_rng(1234)
Copy link
Member

Choose a reason for hiding this comment

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

And here.

mwcraig and others added 4 commits August 30, 2023 08:49
@mwcraig
Copy link
Member Author

mwcraig commented Sep 8, 2023

Lights are green, so this is ready for another look

Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

In the light of spacetelescope/jdaviz#2410 , I find that the API will be significantly different if we were to go with Regions instead of Table.

So, do you want to merge this anyway and refactor again later, or wait for that discussion first?

@mwcraig
Copy link
Member Author

mwcraig commented Sep 8, 2023

Right, forgot about that. Let's wait until after the next meeting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Issues that relate to the API itself rather than implementations backend: ginga enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants