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

Create generic iterable flattener

    XMLWordPrintable

Details

    • Improvement
    • Status: Won't Fix
    • Resolution: Done
    • None
    • utils
    • None
    • 1
    • AP S19-3, AP S19-4
    • Alert Production

    Description

      In the review to DM-16535, Parejkoj 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

          krzys Krzysztof Findeisen added a comment - - edited

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

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

          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.

          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.

          Hi Parejkoj, can you please review this? Thanks!

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

          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.

          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.
          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., Parejkoj) 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!)

          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., Parejkoj ) 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

            krzys Krzysztof Findeisen
            krzys Krzysztof Findeisen
            John Parejko
            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.