diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index c8e5d7d..883bca8 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-11-03T13:06:12","documenter_version":"1.1.2"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-11-03T13:57:08","documenter_version":"1.1.2"}} \ No newline at end of file diff --git a/dev/advanced/index.html b/dev/advanced/index.html index db8a30e..de992e4 100644 --- a/dev/advanced/index.html +++ b/dev/advanced/index.html @@ -31,9 +31,9 @@ end;
Let's try to see if our favorite number types do indeed behave like a group.
Group.neutral(::Type{N}) where {N<:Number} = one(N)
Group.multiplication(x::Number, y::Number) = x * y
Group.inversion(x::Number) = inv(x)
First, we check it for floating point numbers, giving a list of Arguments
objects with the proper fields to the test
function.
float_pairs = [Arguments(x = 2.0, y = 1.0)]
-Interfaces.test(Group.GroupInterface, Float64, float_pairs)
true
We can thus declare proudly
@implements Group.GroupInterface Float64
Now we check it for integer numbers. The reason it fails is because for an integer x
, the inverse 1/x
is no longer an integer! Thus integer numbers are not a multiplicative group.
int_pairs = [Arguments(x = 2, y = 1)]
+Interfaces.test(Group.GroupInterface, Float64, float_pairs)
true
We can thus declare proudly
@implements Group.GroupInterface Float64 [Arguments(x = 2.0, y = 1.0)]
Now we check it for integer numbers. The reason it fails is because for an integer x
, the inverse 1/x
is no longer an integer! Thus integer numbers are not a multiplicative group.
int_pairs = [Arguments(x = 2, y = 1)]
Interfaces.test(Group.GroupInterface, Int, int_pairs)
false
What happens if we give an input whose field types (Int
) are not coherent with the type we are testing (Float64
)?
try
Interfaces.test(Group.GroupInterface, Float64, int_pairs)
catch e
print(e.msg)
-end
Each tested object must either be an instance of `Float64` or an instance of `Arguments` whose field types include at least one subtype of `Float64`. You provided a `Arguments{(:x, :y), Tuple{Int64, Int64}}` instead.
In summary, there are two things to remember:
Interfaces.@interface
should accept a single object of type Arguments
and then work with its named fields. These fields should be listed in the docstring.Interface.test
must all be of type Arguments
, with the right named fields. At least one field must have the type you are testing.This page was generated using Literate.jl.
Settings
This document was generated with Documenter.jl version 1.1.2 on Friday 3 November 2023. Using Julia version 1.9.3.