British-Oceanographic-Data-Centre / COAsT

A Coastal Ocean Assessment Tool built as an extendable python framework for nemo models
https://british-oceanographic-data-centre.github.io/COAsT/
MIT License
24 stars 11 forks source link

Fixed dangling file openings #582

Closed ledm closed 1 year ago

ledm commented 1 year ago

Pull request checklist

close #581.

Minor change to the loading method to "with as" instead of file = load_file(). This makes it more error proof and safely closes netcdf files correctly, even if we get an exception or seg fault along the way.

Please check if your PR fulfills the following requirements:

Pull request type

Please check the type of change your PR introduces: - [x] Bugfix - [ ] Feature - [x] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): Updated loading method to "with as" instead of `file = load_file()`. This makes it more error proof and safely closes netcdf files correctly, even if we get an exception or seg fault along the way. ## What is the current behavior?

Issue URL: #581

What is the new behavior?

-

Checklist

Does this introduce a breaking change?

Other information

ledm commented 1 year ago

Note that I've only changed the coast.py so far. This should probably be changed in:

jpolton commented 1 year ago

Failed test is due to GitAction not being able to commit to Forked branch. It regenerates unit_testing/unit_test_contents.txt. But no changes are needed. And associate ticket is created #591 .