Skip to content

DOC: increase clarity of zerosum_axes description for py.ZeroSumNormal #6459

@drbenvincent

Description

@drbenvincent

Issue with current documentation:

Tagging @aseyboldt and @AlexAndorra

The current docs for the zerosum_axes kwarg for ZeroSumNormal is a little unclear, or perhaps slightly ambiguous, and could lead to incorrect parsing by readers.

Currently:

zerosum_axes: int, defaults to 1
Number of axes along which the zero-sum constraint is enforced, starting from the rightmost position. Defaults to 1, i.e the rightmost axis.

When I read this initially I parsed that as "Number of the axis along which the zero-sum constraint is enforced". Based on that (incorrect) reading of the sentence I then passed 0 to the zerosum_axes, which then resulted in an error.

I then thought that this might be an off by 1 error in how the zerosum_axes was processed. But then I got input from others that finally corrected my understanding.

The way how it works, by choosing the number of axes, counting from the last forwards, means that it is not possible to use this kwarg to state that you only want the first (of multiple) axes to have the zero sum constraint.

There is a relevant warning on the page at the moment:

zerosum_axes has to be > 0. If you want the behavior of zerosum_axes = 0, just use pm.Normal.

But I'm not convinced that's as accurate or as helpful as it could be. In my particular use case, I have a 2D ZeroSumNormal and want the sum to zero constraint to be applied only to the first (0th) dimension.

Idea or request for content:

  • The description of the kwarg could have clearer wording. It could be made more clear that it operates by saying how many of the axes (from the end, backwards) will have the zero sum constraint. There is a relevant warning on the page
  • There could be additional explanation that if a user wants to apply the zero sum constraint to the first dimension, or the first 2 of 3 dimensions etc, then the user will (currently) have to change the order of the dims and then transpose, or use moveaxis to get the dims in the order that a user needs.
  • A bonus would be to include an example of doing that.
  • An even bigger bonus would be to change the API to allow a user more freedom to specify the axes that the zero sum constraint applies to, without having to manually move the dimensions around. One example would be to allow a user to list a set of dimension indexes. Another idea would be to add a kwarg that toggles whether zerosum_axes operates from the first axis forward, or the final axis backwards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions