Skip to content

Commit

Permalink
fix "ResourceWarning: unclosed..."
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh committed Aug 28, 2024
1 parent 023a619 commit 90c891f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions rednose/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ def write_code(folder, name, code, header):
if not os.path.exists(folder):
os.mkdir(folder)

open(os.path.join(folder, f"{name}.cpp"), 'w', encoding='utf-8').write(code)
open(os.path.join(folder, f"{name}.h"), 'w', encoding='utf-8').write(header)
with open(os.path.join(folder, f"{name}.cpp"), 'w', encoding='utf-8') as f:
f.write(code)
with open(os.path.join(folder, f"{name}.h"), 'w', encoding='utf-8') as f:
f.write(header)


def load_code(folder, name):
Expand Down
6 changes: 4 additions & 2 deletions rednose/helpers/ekf_sym.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ def gen_code(folder, name, f_sym, dt_sym, x_sym, obs_eqs, dim_x, dim_err, eskf_p
if not os.path.exists(folder):
os.mkdir(folder)

open(os.path.join(folder, f"{name}.h"), 'w', encoding='utf-8').write(header) # header is used for ffi import
open(os.path.join(folder, f"{name}.cpp"), 'w', encoding='utf-8').write(code)
with open(os.path.join(folder, f"{name}.h"), 'w', encoding='utf-8') as f:
f.write(header) # header is used for ffi import
with open(os.path.join(folder, f"{name}.cpp"), 'w', encoding='utf-8') as f:
f.write(code)


class EKF_sym():
Expand Down

0 comments on commit 90c891f

Please sign in to comment.