lasio icon indicating copy to clipboard operation
lasio copied to clipboard

Remove side-effects from write()

Open kinverarity1 opened this issue 5 years ago • 3 comments

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.

kinverarity1 avatar Feb 23 '19 23:02 kinverarity1

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 of writer.write() This means that writer.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

dcslagel avatar Apr 16 '21 19:04 dcslagel

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....?

kinverarity1 avatar Apr 17 '21 12:04 kinverarity1

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()

dcslagel avatar Apr 17 '21 13:04 dcslagel