Skip to content

Treat NaN as gap in ring buffer #601

@cwasicki

Description

@cwasicki

What's needed?

Currently a gap is defined as one or multiple consecutive samples with None values. If the value is NaN or inf, these are not treated as gaps.

Proposed solution

Include NaN in the definition of a gap.

Use cases

Using formula engine, NaN or inf are converted to None (see

if isnan(res) or isinf(res):
return Sample(metric_ts, None)
). In this case, which I assume covers most of our current applications, the behavior is not altered.

When data from the microgrid API is directly injected into the moving window, this behavior is not ensured and would be inconsistent. Also if data from other sources (e.g. trading data) is injected, NaN would not be treated in the gap.

Alternatives and workarounds

  • Leave it to the user to check.
  • Convert NaN to None when adding to the ring buffer.

Additional context

There was the discussion what to do with inf values. To keep it consistent with the logical meter these would also have to be converted. The same is even true for NaN, since they arise in different situations than Nones. However, inf values could be reasonable in certain context and transfer more information over None than NaNs do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    part:❓We need to figure out which part is affectedpriority:❓We need to figure out how soon this should be addressedtype:enhancementNew feature or enhancement visitble to users

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions