Skip to content

process.py: filtering of observations by time requires a guard #151

@rod-glover

Description

@rod-glover

process.py, lines 130ff are

    observations = list(
        # Note: filter(None, <collection>) removes falsy values from <collection>,
        # in this case possible None values returned by align.
        filter(
            None,
            (
                align(sesh, row, is_diagnostic)
                for row in rows
                if start_date <= row.time <= end_date
            ),
        )
    )

and needs a guard on row.time to prevent errors:

    observations = list(
        # Note: filter(None, <collection>) removes falsy values from <collection>,
        # in this case possible None values returned by align.
        filter(
            None,
            (
                align(sesh, row, is_diagnostic)
                for row in rows
                if row.time is not None and (start_date <= row.time <= end_date)
            ),
        )
    )

or else revert to checking time after align has been called on the row. The original idea was to not cause it to do extra work on values that would be filtered out by time. This is still true but may be slightly on the side of over-optimization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions