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

Fixes for HomogeneousList #6773

Merged
merged 2 commits into from Oct 22, 2017
Merged

Fixes for HomogeneousList #6773

merged 2 commits into from Oct 22, 2017

Conversation

MSeifert04
Copy link
Contributor

I don't know how user-facing this class is but it's used in votable. However I noticed several very weird (and wrong) stuff in there.

Instead of using the hard-coded list.methodname calls we can use super() in astropy 3.x but that wouldn't work for 2.0.x. If this is merged one could consider a follow-up PR that uses super there.

@astropy-bot
Copy link

astropy-bot bot commented Oct 19, 2017

Hi there @MSeifert04 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labelled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃.

Everything looks good from my point of view! 👍

If there are any issues with this message, please report them here

@MSeifert04 MSeifert04 requested a review from pllim October 20, 2017 00:01
CHANGES.rst Outdated
``HomogeneousList``. [#6773]

- Make ``HomogeneousList`` work with iterators and generators when creating the
instance, extending it or using when setting a slice. [#6773]
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: Oxford comma!

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.

It is also used in test_logger.py although that test is marked as xfail.

I am nervous to port this back into 2.x. If things works in votable now, why risk unintended breakage (however small the risk might be). Why not just do your super thing here and set milestone to 3.0?

@MSeifert04 MSeifert04 modified the milestones: v2.0.3, v3.0.0 Oct 20, 2017
@MSeifert04
Copy link
Contributor Author

I changed the milestone to 3.0. But does it make sense to "fix" it at all given that current usage didn't suffer from the bugs and nobody else is using it (as far as we know).

@bsipocz
Copy link
Member

bsipocz commented Oct 20, 2017

@MSeifert04 - Fixing it in 3.0 makes sense to me even if the current usage doesn't run into any bugs. It fits nicely into the series of your other refactorings.

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.

I think it is good that we clean this up. If we put this in v3 and we get VO Table users complaining that this broke their code, then we can at least ask them to fall back to v2 until a fix can be made.

Let me take this for a spin with my Cone Search cronjob. If nothing blows up, I'll approve this next week.


def test_homogeneous_list_setitem_works_with_slice():
l = collections.HomogeneousList(int, [1, 2, 3])
l[0:1] = [10, 20, 30]
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the slice be [:] or [0:3]? Why is it set to [0:1]? (You can tell that I never used it, LoL)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The [0:1] replaces the first element with the sequence, [0:3] would replace the first, second and third element with the sequence and [:] would replace the whole sequence.

In this case the result is [10, 20, 30, 2, 3], for [0:3] it would be [10, 20, 30] and for [:] it would also be [10, 20, 30]. I have no preference which one should be tested, I just picked one (the one which I though of first) because all defers to lists method and it's just important to check that it gets there. :)

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, okay, that is fine. I was wondering why none of the tests check for the resultant values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, I can add result checks.

Copy link
Member

Choose a reason for hiding this comment

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

Why not? It doesn't take much more time to do the checks and makes the intent clear. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

better now? :)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, thanks! 😄



def test_homogeneous_list_works_with_generators():
hl = collections.HomogeneousList(int, (i for i in range(3)))
Copy link
Member

Choose a reason for hiding this comment

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

Does it not take generators as-is (without the list comprehension part)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does, but I changed it to use extend internally (which didn't work with generators), this was just to make sure it works.

@MSeifert04
Copy link
Contributor Author

Let me take this for a spin with my Cone Search cronjob. If nothing blows up, I'll approve this next week.

Sounds good to me :) Can the cron job pick up not-merged-PRs? 😄

@pllim
Copy link
Member

pllim commented Oct 20, 2017

Can the cron job pick up not-merged-PRs?

Yes. 😄

@mhvk
Copy link
Contributor

mhvk commented Oct 21, 2017

Looks all good to me (didn't know either we had this...)

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.

Cron job ran successfully two nights in a row. I'll take that as a good sign. Thanks!

@pllim pllim merged commit 566f823 into astropy:master Oct 22, 2017
@MSeifert04 MSeifert04 deleted the hl_setitem branch October 22, 2017 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants