-
Notifications
You must be signed in to change notification settings - Fork 41
implement open_datatree context manager #114
Conversation
Did you get a This seems good though. For testing xarray must have some tests for this type of opening that we could copy. I'm trying to think if there are any other gotchas with tree structures... subtree = open_datatree(file)
dt = DataTree(children={"folder1": subtree})
dt["folder1"].close()
print(dt) |
Yes, which made me realise that I don't think closing parents is the right thing to do. I.e., to close everything users must close from root.
That's what I thought too, but I couldn't find anything. I'll take a better look next week, but let me know if you know where I can find those tests.
Good point - I'll think about this as well! |
@TomNicholas I've added |
Hmmm... that seems a bit janky to me, especially as I remember talking about this problem briefly with @jhamman - perhaps he has some suggestions as to how to handle multiple file handles? |
Closing in favour of linked upstream issue |
pre-commit run --all-files
api.rst
docs/source/whats-new.rst
I haven't added any test, but the io tests now use the context manager. Not sure if there's a better way to test this functionality.