MODFLOW-USGS / modflow-devtools

Python tools for MODFLOW 6 development
https://modflow-devtools.readthedocs.io/en/latest/
Other
2 stars 5 forks source link

feat(snapshots): add snapshot fixtures, remove pandas fixture #151

Closed wpbonelli closed 4 months ago

wpbonelli commented 4 months ago
wpbonelli commented 4 months ago

@mwtoews I was mainly wondering what you thought of the optional import decision here. But I think it's probably best to keep using import_optional_dependency(), will update to do so unless you disagree

mwtoews commented 4 months ago

@wpbonelli no strong opinions so far, I'm just finding time to look further at the methods. One further idea is to also support compressed array ".npz" using numpy.savez_compressed.

wpbonelli commented 4 months ago

Thanks @mwtoews for the suggestion, savez_compressed() also allows snapshots of multiple arrays at once. I pushed a commit drafting support for multiple arrays e.g.

def my_test(multi_array_snapshot):
    ...
    arrays = {
        "head": ...
        "budget": ...
    }
    assert arrays == multi_array_snapshot

which is consistent with np.load() returning a dict for multi-array .npz files.

wpbonelli commented 4 months ago

Looks like with npz files we get inconsistent binary encodings. Strange that it's only npz files and not npy files.

wpbonelli commented 4 months ago

I will merge as-is so we can use this for PRT tests, but would be ideal to support snapshots of multiple arrays eventually.