lasio
lasio copied to clipboard
Remove side-effects from write()
At the moment there are side-effects to the lasio.writer.write()
function involving modifications to the LASFile objects' STRT, STOP and STEP values.
I should avoid these side-effects entirely - see previous discussion in #35. They would better belong in a LASFile.update_start_stop_step()
method, or something similar.
If #447 is accepted and merged then there are these next decisions and steps to completing this task:
-
Move
las.update_start_stop_step()
out ofwriter.write()
This means thatwriter.write()
will no-longer automatically change the format of STRT, STOP and STEP -
Update the tests that will break. Should these tests include
las.update_start_stop_step()
or not?
FAILED tests/test_wrapped.py::test_write_wrapped
FAILED tests/test_wrapped.py::test_write_unwrapped
FAILED tests/test_write.py::test_write_sect_widths_12
FAILED tests/test_write.py::test_write_sect_widths_20_narrow
FAILED tests/test_write.py::test_write_sect_widths_20_wide
FAILED tests/test_write.py::test_df_curve_addition_on_export
FAILED tests/test_write.py::test_multi_curve_mnemonics_rewrite
FAILED tests/test_write.py::test_multi_curve_missing_mnemonics_rewrite
FAILED tests/test_write.py::test_write_units
FAILED tests/test_write.py::test_rename_and_write_curve_mnemonic
FAILED tests/test_write.py::test_write_single_step
FAILED tests/test_write.py::test_write_12_to_20_ver_in_mem_is_12
FAILED tests/test_write.py::test_write_12_to_20_ver
FAILED tests/test_write.py::test_write_20_to_12_ver_in_mem_is_20
FAILED tests/test_write.py::test_step_unchanged_by_write
FAILED tests/test_write.py::test_step_unchanged_by_write_2
-
New tests for using
las.update_start_stop_step()
-
Update documentation
- include
las.update_start_stop_step()
documentation/examples - update
writer.write()
documentation
- include
Hmm my feeling is that maybe we should track, in LASFile, whether the user has modified the index curve. If they have, then LASFile.write should call update_start_stop_step() - if they haven't, it shouldn't....?
Okay, thinking how to do track changes to the index curve. I'll work on that next.
Notes:
# get index curve name
idx_name = las.curves[0].mnemonic
#copy the original index. right after reading.
idx_org = las[idx_name].copy()
# in writer.write() test if curve was modified
if ((idx_org==las[idx_name]).all()):
las.update_start_stop_step()