Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commented out tests #6

Open
evetion opened this issue May 24, 2023 · 10 comments
Open

Commented out tests #6

evetion opened this issue May 24, 2023 · 10 comments

Comments

@evetion
Copy link

evetion commented May 24, 2023

Is it correct that since 2.0 most of the API tests are commented out? See https://github.com/emmt/LocalFilters.jl/blob/master/test/runtests.jl#L20-L133 and https://github.com/emmt/LocalFilters.jl/blob/master/test/runtests.jl#L303-L610

@emmt
Copy link
Owner

emmt commented May 25, 2023

Yes the 2.0 branch is still a work in progress. It is not yet registered and I have disabled lots of tests because some editing is needed before let them run again. Please, let me know if you are using API 2.0.

@evetion
Copy link
Author

evetion commented May 26, 2023

I'm still pinned to the pre-2.0 version, but note that 2.0 is actually already registered (7af1b0e#commitcomment-99608912).

@emmt
Copy link
Owner

emmt commented May 26, 2023

Oops you are right. I need to do some cleanup. I have also noticed that the doc. is the old one...

BTW why are you still pinned to version 1? Version 2 introduces many changes under the hood, but relatively few for the end-user (at high level) and some methods are mich faster. Moving from LocalFilters v1 to v2 may require a few edits (see these guidelines).

@evetion
Copy link
Author

evetion commented May 27, 2023

BTW why are you still pinned to version 1? Version 2 introduces many changes under the hood, but relatively few for the end-user (at high level) and some methods are much faster. Moving from LocalFilters v1 to v2 may require a few edits (see these guidelines).

I always use pin/compat my code/packages, I just didn't have the time to update to 2.0 yet. My compliments on the migration guide :)

@evetion
Copy link
Author

evetion commented Mar 27, 2024

Today I tried to update to LocalFilters v2, but I think some of the functionality I use extensively in v1 is gone. For example, given the following function:

"""Largest difference to centre cell."""
function roughness(dem::AbstractMatrix{<:Real})
    dst = copy(dem)

    initial(a) = (zero(a), a)
    update(v, a, _) = (max(v[1], abs(a - v[2])), v[2])
    store!(d, i, v) = @inbounds d[i] = v[1]

    return localfilter!(dst, dem, 3, initial, update, store!)
end

I use initial to get the actual value of a cell, and use it to compare to all other values. How would this pattern work in v2?

@emmt
Copy link
Owner

emmt commented Mar 27, 2024

You are right, such a filter is no longer possible with initial being the initial value of the state variable of the local filter. I have fixed this in cb36447 so that initial can also be a function. Your filter would then write:

function roughness(dem::AbstractMatrix{<:Real}, B=3)
    initial(a) = (zero(a), a)
    update(v, a, _) = (max(v[1], abs(a - v[2])), v[2])
    final(v) = v[1]
    return localfilter!(similar(dst), dem, B, initial, update, final)
end

Notes:

  • You do not need to copy the source, similar is sufficient.
  • I have added the possibility to use another neighborhood B.
  • In version 2 of LocalFilters, the update! method has been replaced by a simpler final one which extracts the result from the state variable.
  • You may consider reading the top of NEWS.md for general rules to convert to the new version of LocalFilters. Let me known if these are not clear enough.

I let you check that the new version works as you expected before making a new release. You'll have to stick to the master version in the mean time...

@emmt
Copy link
Owner

emmt commented Mar 28, 2024

As you pointed, the documentation is not up to date. I am working on this.

Would you mind if I supply your roughness function as an example of use?

@evetion
Copy link
Author

evetion commented Mar 28, 2024

Thanks for the quick replies and fixes! 🎉 I will test whether the master branch works later this weekend.

In the meantime, feel free to use the example, you could also link to the package that uses it: https://github.com/Deltares/Geomorphometry.jl/blob/main/src/terrain.jl (MIT license).

You could consider using a namedtuple for readability:

function roughness(dem::AbstractMatrix{<:Real}, B=3)
    initial(a) = (;result=zero(a), center=a)
    update(v, a, _) = (;result=max(v.result, abs(a - v.center)), center=v.center)
    final(v) = v.result
    return localfilter!(similar(dem), dem, B, initial, update, final)
end

@emmt
Copy link
Owner

emmt commented Mar 30, 2024

In the meantime, feel free to use the example, you could also link to the package that uses it: https://github.com/Deltares/Geomorphometry.jl/blob/main/src/terrain.jl (MIT license).

Sure I'll do that.

You could consider using a namedtuple for readability:

Excellent idea, that makes the code clearer!

@emmt
Copy link
Owner

emmt commented Apr 2, 2024

I have changed the API of LocalFilters as detailed in the top of NEWS.md. The last master version should work for you. Almost all changes in the public API are backward compatible with version 2.0.0.

I have mostly done rewriting/updating the doc which is built by GitHub Action as you can see here.

Next step before an official 2.1.0 (not 2.0.1 due to the substancially augmented API) release is to re-activate tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants