Hi Jean-Romain,
In commit Fix LAD if not computable you added a few lines to return a 0 row data.frame when there is two layers or less for LAD.
I do not see the reason for that: a unique layer with points inside (and eventually below) should still give a gap fraction and thus a LAD, no?
In that pull-request, I made the changes to do so: in LAD() I only returned a 0 row data.frame when gap_fraction_profile was returning a 0 row data.frame.
By the way, I simplified several things in gap_fraction_profile(), with the gap fraction being the gf=N_out/N_in:
no need to compute gap fraction until min(z) if min(z)<z0 --> starting from z0 and considering the points below in a unique layer [-Inf, z0]
the only case I see that seq() returns one value, i.e. (length(brk)==1) is when z0==max(z), thus I changed the test.
dividing the counts by sum(counts) is canceled afterwards by shift(cs)/cs, thus I removed that first division
the supplementary layer with 0 counts does not bring anything (actually it is removed in the end) thus I removed it
i can be computed without the need of data.table::shift (unless it is much faster then 1:length(cs)?), thus I removed that dependency here.
if i=NaN, is.na(i) is TRUE thus i would be set to 0 before getting to is.nan(i) --> I removed it as I do not see any reason for a NaN to happen here (it would be the case of i=0/0, which would never happen I think). And as a consequence gap_fraction_profile() will never return an NA value thus I removed the anyNA test in LAD()
I removed the test [z > z0] at the end as I do not see any reason for it
Hi Jean-Romain, In commit Fix LAD if not computable you added a few lines to return a 0 row data.frame when there is two layers or less for LAD.
I do not see the reason for that: a unique layer with points inside (and eventually below) should still give a gap fraction and thus a LAD, no?
In that pull-request, I made the changes to do so: in LAD() I only returned a 0 row data.frame when gap_fraction_profile was returning a 0 row data.frame.
By the way, I simplified several things in
gap_fraction_profile()
, with the gap fraction being thegf=N_out/N_in
:min(z)
ifmin(z)<z0
--> starting fromz0
and considering the points below in a unique layer [-Inf, z0]seq()
returns one value, i.e. (length(brk)==1) is whenz0==max(z)
, thus I changed the test.sum(counts)
is canceled afterwards byshift(cs)/cs
, thus I removed that first divisioni
can be computed without the need of data.table::shift (unless it is much faster then1:length(cs)
?), thus I removed that dependency here.i=NaN
,is.na(i)
isTRUE
thusi
would be set to 0 before getting tois.nan(i)
--> I removed it as I do not see any reason for a NaN to happen here (it would be the case of i=0/0, which would never happen I think). And as a consequencegap_fraction_profile()
will never return anNA
value thus I removed theanyNA
test inLAD()
[z > z0]
at the end as I do not see any reason for itI hope I did not missed anything.