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

do not differentiate through the construction of BitArray #506

Merged
merged 3 commits into from
Aug 19, 2021

Conversation

frankschae
Copy link
Contributor

Based on @oxinabox 's reply here: SciML/DiffEqFlux.jl#502 (comment) .

This solves also the issues with the callback construction in SciML/DiffEqFlux.jl#502.

Does it need a test? Should I maybe add one from SciML/DiffEqFlux.jl#502 (comment) in here: https://github.com/JuliaDiff/ChainRules.jl/blob/master/test/rulesets/Base/array.jl ?

@oxinabox
Copy link
Member

Cool, LGTM.
We don't generally test @non_differentiable rules,
because any bugs in them are not normally in the rule, but in the definition of the @non_differentiable macro.
And that has it's own tests.

Sometimes we test them, if we have had them defined wrong in the past.
But that is not the case here

@oxinabox
Copy link
Member

Will merge once CI passes.
(and I will bump the version and tag a release).
Or you can bump the version and make it easier for me to tag a release.
This is a new feature so it is a minor bump.

@frankschae
Copy link
Contributor Author

cool, Thanks a lot!

Project.toml Outdated Show resolved Hide resolved
@oxinabox oxinabox merged commit ea8a5a6 into JuliaDiff:master Aug 19, 2021
@@ -84,6 +84,7 @@
@non_differentiable Vector(::AbstractArray{Bool})

@non_differentiable Array(::AbstractArray{Bool})
@non_differentiable BitArray(::Any)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason we didn't splat this?

@non_differentiable BitArray(::Any...)

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't it only have 1 constructor?
I didn't actually check

Copy link
Member

Choose a reason for hiding this comment

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

julia> methods(BitArray)
# 6 methods for type constructor:
[1] BitArray(::UndefInitializer, dims::Integer...) in Base at bitarray.jl:69
[2] BitArray(::UndefInitializer, dims::Tuple{Vararg{Integer, N}}) where N in Base at bitarray.jl:71
[3] BitArray(x::BitArray) in Base at bitarray.jl:543
[4] BitArray(A::AbstractArray{var"#s79", N} where var"#s79") where N in Base at bitarray.jl:503
[5] (::Type{T})(x::T) where T<:BitArray in Base at bitarray.jl:542
[6] BitArray(itr) in Base at bitarray.jl:574

there seems to be more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I make another PR?

Copy link
Member

Choose a reason for hiding this comment

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

Please do, that would be great, thanks!

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

Successfully merging this pull request may close these issues.

3 participants