Skip to content

Commit

Permalink
enum support (#293)
Browse files Browse the repository at this point in the history
* enum support

* add test

* bump version
  • Loading branch information
mohamed82008 authored Oct 20, 2024
1 parent 50e8d9c commit faa6397
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Mooncake"
uuid = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
authors = ["Will Tebbutt, Hong Ge, and contributors"]
version = "0.4.13"
version = "0.4.14"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
5 changes: 3 additions & 2 deletions src/tangents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,9 @@ tangent_type(::Type{DimensionMismatch}) = NoTangent

tangent_type(::Type{Method}) = NoTangent

function tangent_type(::Type{P}) where {N, P<:Tuple{Vararg{Any, N}}}
tangent_type(::Type{<:Enum}) = NoTangent

function tangent_type(::Type{P}) where {N, P<:Tuple{Vararg{Any, N}}}
# As with other types, tangent type of Union is Union of tangent types.
P isa Union && return Union{tangent_type(P.a), tangent_type(P.b)}

Expand Down Expand Up @@ -374,7 +375,6 @@ function tangent_type(::Type{P}) where {N, P<:NamedTuple{N}}
end

@generated function tangent_type(::Type{P}) where {P}

# This method can only handle struct types. Tell user to implement tangent type
# directly for primitive types.
isprimitivetype(P) && throw(error(
Expand Down Expand Up @@ -950,6 +950,7 @@ function tangent_test_cases()
(a=randn(10), b=3),
(a=3, b=randn(10)),
(a=randn(10), b=randn(10)),
(Base.TOML.ErrorType(1), NoTangent()), # Enum
]
return vcat(
map(x -> (false, x...), abs_test_cases),
Expand Down

2 comments on commit faa6397

@willtebbutt
Copy link
Member

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@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/117681

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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 v0.4.14 -m "<description of version>" faa63971859a4758034a1e77e47014b8a0e95130
git push origin v0.4.14

Please sign in to comment.