Skip to content

multiple Grid __init__ calls can break extended Grid classes #73

@eloyfelix

Description

@eloyfelix

Grid __init__ is called twice if the grid is loaded from a file. AFAIK this is not a good practice and can break extended Grid classes. Example below:

from gridData import Grid

class NewGrid(Grid):

    def __init__(self, new_stuff=None, grid=None, edges=None, origin=None, delta=None,
                 metadata=None, interpolation_spline_order=3, file_format=None):

        if new_stuff:
            print('loading new stuff')
        else:
            print('crashing because new_stuff is None')

        super().__init__(grid, edges, origin, delta,
                         metadata, interpolation_spline_order, file_format)

aa = NewGrid('new_stuff', 'test_grid.pkl')

loading new stuff
crashing because new_stuff is None

Sending a PR to fix it soon.

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