Skip to content

sum_back/sum_forward partition-checking is unreachable, and the docstring claims by= works #57

Description

@FBumann

What happened?

dimensions.py runs full partition-checking for the windows:

if node.name in ('shift', 'sum_back', 'sum_forward'):
    ...
    partition = node.kwargs.get('by')
    if partition is not None:
        # two carefully-worded DimensionErrors about partitioning

Neither window's Builtin has lookup_kwargs, so call_shape_error rejects by= first and that code can never run:

constraints:
  c:
    foreach: [unit, hour]
    expression: sum_back(x, over=hour, within=3, by=day_of) <= 1
SchemaError: Constraint 'c': sum_back() expects sum_back(<expr>, over=<dim>, within=<n|parameter>[, edge='wrap'])

The module docstring in operators.py also states the opposite of what the signature allows:

by= on shift and sum_back partitions the axis the operator walks, which is the same lookup in a different position

What it should be

One of three, and the choice is a design decision rather than a cleanup:

  1. Support it — add lookup_kwargs=('by',)/optional_kwargs=('by',) to both windows and the existing checks light up. "The next n hours inside this representative day" is a real ask, and it is the same by= as shift's.
  2. Refuse it — drop the dead branch and correct the docstring.
  3. Support it on neither and say why in the docstring.

Worth settling for the pair at once rather than twice. Whichever way it goes, the docstring and the signature should agree.

Version

v0.0.0-alpha.10 (and sum_forward inherits it — #56)

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug: conformanceCode and the documented spec disagreebug: silentFails without an error — loads clean, wrong or undefined meaning

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions