Skip to content

lag parameter silently wraps around for values >= buffer size #379

@GaneshPatil7517

Description

@GaneshPatil7517

In plotymlag.py:7-26:

size = 10
lag = concore.tryparam("lag", 0)
# ...
ym[cur] = concore.read(1,"ym",init_simtime_ym)
ymt.append(np.array(ym[(cur-lag) % size]).T)
cur = (cur+1) % size

The circular buffer has a fixed size of 10, but lag is user-configurable via tryparam. If a user passes lag=15, the modulo wraps it to effectively lag=5, producing silently wrong data. There should be a validation: lag = min(lag, size-1) with a warning if the requested lag exceeds the buffer.

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