Skip to content

Commit

Permalink
add nothing as a noop correction strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
bvdmitri committed Sep 25, 2023
1 parent a030857 commit d599686
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MatrixCorrectionTools"
uuid = "41f81499-25de-46de-b591-c3cfc21e9eaf"
authors = ["Bagaev Dmitry <[email protected]>"]
version = "1.1.0"
version = "1.2.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
3 changes: 3 additions & 0 deletions src/MatrixCorrectionTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ abstract type AbstractCorrectionStrategy end
Modifies the `input` in-place using a specified correction strategy.
The `input` can be either a matrix or a number.
Certain strategies may require the input to satisfy specific properties beforehand, e.g., the input must be a square matrix.
The `nothing` is a special correction strategy that does nothing and simply returns its input.
"""
function correction! end

correction!(::Nothing, input) = input

"""
correction(strategy, input)
Expand Down
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ MatrixCorrectionTools.correction!(::CustomStrategyAddsOneWithAbstractType, input

end

@testset "`nothing` strategy" begin

@test correction!(nothing, 0) === 0

for n in (3, 4, 5)
local A = rand(n, n)
@test correction!(nothing, A) == deepcopy(A)
@test correction!(nothing, A) === A
end

end

@testset "`NoCorrection` strategy" begin
import MatrixCorrectionTools: NoCorrection

Expand Down

2 comments on commit d599686

@bvdmitri
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/92161

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.2.0 -m "<description of version>" d5996866dd18955b9658ff8777549f7a79d2ee97
git push origin v1.2.0

Please sign in to comment.