Open TobyDunneAbyss opened 2 months ago
Hello, thank you very much for this - it looks like a great fix for this problem. Would you be able to provide a test or sample code for it as well ?
I tried adding this test to the repo but all except the name work even without this fix - can you suggest a better way to test it?
def test_read_write_default_values(e57_path, temp_e57_write):
e57 = pye57.E57(e57_path)
default_values = {"rotation": [1, 0, 0, 0],
"translation": [0, 0, 0],
"temperature": 0,
"relativeHumidity": 0,
"atmosphericPressure": 0,
"name": "Scan 4",
}
with pye57.E57(temp_e57_write, mode="w") as e57_write:
raw_data_0 = e57.read_scan_raw(0)
e57_write.write_scan_raw(raw_data_0)
written = pye57.E57(temp_e57_write)
written_header = written.get_header(0)
assert np.allclose(written_header.rotation, default_values["rotation"])
assert np.allclose(written_header.translation, default_values["translation"])
assert written_header.temperature == default_values["temperature"]
assert written_header.relativeHumidity == default_values["relativeHumidity"]
assert written_header.atmosphericPressure == default_values["atmosphericPressure"]
assert written_header.name == default_values["name"]
Also if you can recreate the PR from a branch, not from master, and allow me to make modifications, that will make merging easier - otherwise I think I will need to create a separate branch from my own account
When reading an e57 file with missing headers, writing will fail.
The
gettattr
function does not use the default value provided and instead raises an exception. This wrapper function provided the expected behaviour, i.e. returning the default value on error.