Skip to content

RangeSet: support ranges with zero padding of mixed lengths (#293) #473

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

Merged
merged 7 commits into from
Aug 8, 2022

Conversation

thiell
Copy link
Collaborator

@thiell thiell commented Jun 21, 2022

This patch adds support for mixed lengths 0-padding ranges by
using sets of strings instead of integers. No need to keep
track of padding length anymore, as this information is self
contained in the strings.

$ cluset -f bar002,bar01
bar[01,002]

Deprecated RangeSet.padding which is now a noop.

Closes #293 #442

@thiell thiell requested a review from degremont June 21, 2022 07:57
@thiell thiell self-assigned this Jun 21, 2022
@thiell thiell added this to the 1.9 milestone Jun 21, 2022
@degremont
Copy link
Collaborator

That's look great ! I did not review in details yet, waiting for a more final version, however, my 2 first comments are:

  • What about the performance? Worth trying the nodeset/rangeset benchmark we have.
  • Be careful about retro-compatibility. We need to be backward compatible with 1.8 IMO. That will make the patch is bit more complex, but we don't really have a choice :/ Additionally, should we raise DeprecationWarnings right away? (btw, we can add a patch to raise DeprecationWarnings for all the places we already have deprecated code already for a while).

Copy link
Collaborator

@degremont degremont left a comment

Choose a reason for hiding this comment

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

I'm worried by the compat breakage. I think this is too risky to release 1.9 with this RangeSet behavior change. (str vs int)
NodeSet is also behaving differently, now that the padding is not use the same way, but hopefully everybody will think this was a bug :)
Worth a beta?

)

This patch adds support for mixed lengths 0-padding ranges by
always using strings instead of integers in the inner set. No need to
keep track of padding length per set anymore, as this information is
self contained in the strings.

Old behavior (single padding length supported):

    $ cluset -f bar002,bar01,bar0
    bar[000-002]

New behavior (mixed padding lengths supported):

    $ cluset -f bar002,bar01,bar0
    bar[0,01,002]

RangeSet.padding is now available as a property. In case of zero padding
with mixed lengths, it returns the maximum padding length. It can also
still be used to force a fixed-length padding on the set.

Example:

    >>> r = RangeSet("0,01,002")
    >>> r
    0,01,002
    >>> r.padding
    3
    >>> r.padding = 4
    >>> r
    0000-0002
    >>> r.padding = None
    >>> r
    0-2

Older versions of RangeSet are automatically converted when unpickled.

Closes cea-hpc#293 cea-hpc#442
@thiell thiell force-pushed the b19_multipad293 branch from 8ba0ac4 to e36de54 Compare July 1, 2022 05:42
@thiell thiell merged commit 5a41bc0 into cea-hpc:master Aug 8, 2022
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.

strange behaviour when factorizing (new '0' issue with nodeset)
3 participants