Skip to content

Consider refactoring validate() #932

@danielhuppmann

Description

@danielhuppmann

@phackstock suggests to refactor the IamDataFrame.validate() function to only every return a pandas dataframe. If all data points satisfy the criteria, then an empty data frame should be returned instead of None. Dealing with two different return types usually makes for awkward code downstream and I'd consider it an anti-pattern.
If validate() would always return a pandas data frame, you would do something more readable like:

if not_valid.empty:
    # do something if everything's valid

or

if not not_valid.empty:
    # do something if there are some invalid data points

Originally posted by @phackstock in #930 (comment)

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