Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-17534

Create generic iterable flattener

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Won't Fix
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: utils
    • Labels:
      None
    • Story Points:
      1
    • Sprint:
      AP S19-3, AP S19-4
    • Team:
      Alert Production

      Description

      In the review to DM-16535, John Parejko requested that the flatten function, which converts an iterable of mixed scalars and iterables to a list of scalars, be made a public function in utils so that it could be used elsewhere.

      Given that "flatten" is a very common name in the Stack, perhaps we should choose a different name to avoid confusion.

        Attachments

          Activity

          Hide
          krzys Krzysztof Findeisen added a comment - - edited

          Question for John Parejko: should lsst.utils.flatten stick to returning a sequence, or would making it a generator be useful?

          Show
          krzys Krzysztof Findeisen added a comment - - edited Question for John Parejko : should lsst.utils.flatten stick to returning a sequence, or would making it a generator be useful?
          Hide
          Parejkoj John Parejko added a comment -

          Good question. My first thought is returning a sequence (list is the simplest). I suspect, but am not certain, the situations where we would like to use this would not involve much memory pressure.

          I would ask for broader input (say, slack#dm) on that question.

          Show
          Parejkoj John Parejko added a comment - Good question. My first thought is returning a sequence (list is the simplest). I suspect, but am not certain, the situations where we would like to use this would not involve much memory pressure. I would ask for broader input (say, slack#dm) on that question.
          Hide
          krzys Krzysztof Findeisen added a comment -

          Hi John Parejko, can you please review this? Thanks!

          Show
          krzys Krzysztof Findeisen added a comment - Hi John Parejko , can you please review this? Thanks!
          Hide
          Parejkoj John Parejko added a comment -

          See comments (from me and others) on the PR: at least fix the infinite string iteration. It may well be worth making it use a generator; see my stackoverflow link.

          Show
          Parejkoj John Parejko added a comment - See comments (from me and others) on the PR: at least fix the infinite string iteration. It may well be worth making it use a generator; see my stackoverflow link.
          Hide
          krzys Krzysztof Findeisen added a comment - - edited

          As recommended in the review, I decided not to merge these changes because lsst.verify.gen2tasks is the only client. If somebody else (e.g., John Parejko) finds they also need this functionality, then we can create a new ticket and re-submit the commits there.

          (Before closing the PR I both fixed the infinite recursion on strings, and explicitly disallowed mapping types. Many thanks for catching those bugs!)

          Show
          krzys Krzysztof Findeisen added a comment - - edited As recommended in the review, I decided not to merge these changes because lsst.verify.gen2tasks is the only client. If somebody else (e.g., John Parejko ) finds they also need this functionality, then we can create a new ticket and re-submit the commits there. (Before closing the PR I both fixed the infinite recursion on strings, and explicitly disallowed mapping types. Many thanks for catching those bugs!)

            People

            Assignee:
            krzys Krzysztof Findeisen
            Reporter:
            krzys Krzysztof Findeisen
            Reviewers:
            John Parejko
            Watchers:
            John Parejko, Kian-Tat Lim, Krzysztof Findeisen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Jenkins

                No builds found.