Skip to content

Commit

Permalink
Support boolean not ! (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill authored Aug 7, 2024
1 parent 61cb867 commit c6d0648
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ end
# ∂²f/∂x² == 0
ops_1_to_1_z = (
round, floor, ceil, trunc,
sign,
sign, !
)
for op in ops_1_to_1_z
T = typeof(op)
Expand Down
4 changes: 4 additions & 0 deletions test/classification.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ random_input(::typeof(sincosd)) = 180 * rand()
random_first_input(op) = random_input(op)
random_second_input(op) = random_input(op)

## Skip tests on functions that don't support ForwardDiff's Dual numbers

correct_classification_1_to_1(op::typeof(!), x; atol) = true

## Derivatives and special cases

both_derivatives_1_to_1(op, x) = derivative(op, x), second_derivative(op, x)
Expand Down
1 change: 1 addition & 0 deletions test/test_gradient.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ NNLIB_ACTIVATIONS = union(NNLIB_ACTIVATIONS_S, NNLIB_ACTIVATIONS_F)
x = rand(2)
g(x) = [x[1] * x[2], ceil(x[1] * x[2]), x[1] * round(x[2])]
@test jacobian_sparsity(g, x, method) == [1 1; 0 0; 1 0]
@test jacobian_sparsity(!, true, method) [0;;]

# Code coverage
@test jacobian_sparsity(x -> [sincos(x)...], 1, method) [1; 1]
Expand Down

0 comments on commit c6d0648

Please sign in to comment.