tmontaigu / pylas

⚠️ pylas was merged into laspy 2.0 https://github.com/laspy/laspy⚠️
BSD 3-Clause "New" or "Revised" License
39 stars 13 forks source link

Improve/Fix Weird behaviour of sub fields #18

Closed tmontaigu closed 3 years ago

tmontaigu commented 4 years ago

Atm, sub fields are a bit weird to interact with. Example:

import pylas
las = pylas.read(som_file)

las.classification[:] = 0
assert np.all(las.classification == 0) # This will fail (unless the classification was already 0s)

The current way to work arround this is to do

import pylas
las = pylas.read(som_file)

classification = las.classification
classification[:] = 0
las.classification = classification
assert np.all(las.classification == 0) # This will work

All 'sub fields' have this behaviour, (classification, key_point, number_of_returns, return_number, etc), this is because when accessing these fields we return a new array with the valuesz.

The way to fix/improve this would be to return an object that act as a view into the array that holds the values and that view-object would take care of returning and setting the proper values using a bitmask.