Skip to content

Commit

Permalink
Fixed problem with calmax and calmin methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokazama committed Feb 2, 2020
1 parent 8d111a5 commit fdbcbfe
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FieldProperties"
uuid = "127e4479-4c95-493a-afaa-609d38175b70"
authors = ["zchristensen "]
version = "0.4.0"
version = "0.4.1"

[deps]
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Expand Down
4 changes: 2 additions & 2 deletions src/general.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ Property providing name for parent structure.
Specifies maximum element for display purposes. If not specified returns the maximum value in the collection.
"""
@defprop CalibrationMaximum{:calmax}::(x::AbstractArray->eltype(x)) begin
@getproperty x -> maximum(x)
@getproperty x::AbstractArray -> maximum(x)
end

"""
Specifies minimum element for display purposes. If not specified returns the minimum value in the collection.
"""
@defprop CalibrationMinimum{:calmin}::(x::AbstractArray->eltype(x)) begin
@getproperty x -> minimum(x)
@getproperty x::AbstractArray -> minimum(x)
end

3 changes: 3 additions & 0 deletions test/metadata_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
@test get!(m, :a, 3) == 1

@test m.a == 1
m[:a] = 2
@test m.a == 2

@test m.b == 2
m.b = 3
@test m.b == 3
Expand Down
15 changes: 13 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,25 @@ t = TestStruct(1,2,3,4,5)

@test propertynames(t) == (:prop1,:prop2,:prop3,:prop4)


FieldProperties._fxnname(FieldProperties.Description{values}()) == "description(values)"


x = rand(4,4)
@test @inferred(calmin(x)) == minimum(x)
@test @inferred(calmax(x)) == maximum(x)

struct ArrayLike{T,N}
a::Array{T,N}
calmax::T
calmin::T
end

xdiff = -(extrema(x)...)
xmax = maximum(x) - .25 * xdiff
xmin = minimum(x) + .25 * xdiff
a = ArrayLike(x, xmax, xmin)
@test calmax(a) == xmax
@test calmin(a) == xmin

include("metadata_tests.jl")

@testset "FieldProperties docs" begin
Expand Down

2 comments on commit fdbcbfe

@Tokazama
Copy link
Owner 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/8752

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 Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.1 -m "<description of version>" fdbcbfec6ed3d78aad0005d91c1d24d14484302d
git push origin v0.4.1

Please sign in to comment.