Skip to content

issues with _check_dataset_form #808

@mathause

Description

@mathause

The current version of _check_dataset_form has some issues

def _check_dataset_form(

  • requires_other_vars: bool is not granular enough.

    • there is no way to disallow additional variables
    • it's unclear if the additional variables can have any name or must have an explicit one

    I thought replacing requires_other_vars with:

    other_vars : "allowed" | "forbidden" | "explicit" | "required", default: "allowed"
        Behavior when additional variables are on the Dataset
          
        - "allowed": any number of additional variables may be on the Dataset
        - "forbidden": only variables listed in `required_vars` are allowed
        - "explicit": potential additional variables must be listed in `optional_vars`
        - "required": additional unspecified variables are required
    

    is that too much?

  • I am not so sure if the logic to check for additional variables is correct & the use of optional_vars seems strange

    • there is currently the following test:

      ds = xr.Dataset(data_vars={"var": ("x", [0])})

      with pytest.raises(ValueError, match="Expected additional variables on obj"):
      mesmer._core.utils._check_dataset_form(
      ds, optional_vars="var", requires_other_vars=True
      )

      why does this error? There is no required_var and there is an optional_vars named var -> so I think it should not error

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