# Methods overloaded

To facilitate writing julian code, we have overloaded a number of methods from `Base`

. These methods should remove the need to interact with the `grid`

field directly, and also allow to set and get values using the geographic coordinates (as opposed to the grid positions).

## From `Base`

`Base.copy`

— Function`Base.copy(l::T) where {T <: SimpleSDMLayer}`

Returns a new copy of the layer, which has the same type.

`Base.collect`

— Function`Base.collect(l::T) where {T <: SimpleSDMLayer}`

Returns the non-`nothing`

values of a layer.

`Base.eltype`

— Function`Base.eltype(layer::SimpleSDMLayer{T}) where {T}`

Returns the type of the values stored in the grid, where the `Nothing`

type is omitted.

`Base.size`

— Function`Base.size(layer::T) where {T <: SimpleSDMLayer}`

Returns the size of the grid.

`Base.size(layer::T, i...) where {T <: SimpleSDMLayer}`

Returns the size of the grid alongside a dimension.

`Base.stride`

— Function`Base.stride(layer::T; dims::Union{Nothing,Integer}=nothing) where {T <: SimpleSDMLayer}`

Returns the stride, *i.e.* half the length, of cell dimensions, possibly alongside a side of the grid. The first position is the length of the *longitude* cells, the second the *latitude*.

`Base.eachindex`

— Function`Base.eachindex(layer::T) where {T <: SimpleSDMLayer}`

Returns the index of the grid.

`Base.similar`

— Function`Base.similar(layer::T, ::Type{TC}) where {TC <: Any, T <: SimpleSDMLayer}`

Returns a `SimpleSDMResponse`

of the same dimensions as the original layer, with `nothing`

in the same positions. The rest of the values are replaced by the output of `zero(TC)`

, which implies that there must be a way to get a zero for the type. If not, the same result can always be achieved through the use of `copy`

, manual update, and `convert`

.

`Base.similar(layer::T) where {T <: SimpleSDMLayer}`

Returns a `SimpleSDMResponse`

of the same dimensions as the original layer, with `nothing`

in the same positions. The rest of the values are replaced by the output of `zero(element_type)`

, which implies that there must be a way to get a zero for the type. If not, the same result can always be achieved through the use of `copy`

, manual update, and `convert`

.

`Base.sum`

— Function`Base.sum(l::SimpleSDMResponse{T}) where {T <: Number}`

Applies `sum`

(from `Base`

) to an object of type `SimpleSDMResponse`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Base.sum(l::SimpleSDMPredictor{T}) where {T <: Number}`

Applies `sum`

(from `Base`

) to an object of type `SimpleSDMPredictor`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Base.maximum`

— Function`Base.maximum(l::SimpleSDMResponse{T}) where {T <: Number}`

Applies `maximum`

(from `Base`

) to an object of type `SimpleSDMResponse`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Base.maximum(l::SimpleSDMPredictor{T}) where {T <: Number}`

Applies `maximum`

(from `Base`

) to an object of type `SimpleSDMPredictor`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Base.minimum`

— Function`Base.minimum(l::SimpleSDMResponse{T}) where {T <: Number}`

Applies `minimum`

(from `Base`

) to an object of type `SimpleSDMResponse`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Base.minimum(l::SimpleSDMPredictor{T}) where {T <: Number}`

Applies `minimum`

(from `Base`

) to an object of type `SimpleSDMPredictor`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Base.extrema`

— Function`Base.extrema(l::SimpleSDMResponse{T}) where {T <: Number}`

Applies `extrema`

(from `Base`

) to an object of type `SimpleSDMResponse`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Base.extrema(l::SimpleSDMPredictor{T}) where {T <: Number}`

Applies `extrema`

(from `Base`

) to an object of type `SimpleSDMPredictor`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Base.max`

— Function`Base.max(l1::SimpleSDMLayer, l2::SimpleSDMLayer)`

Applies `max`

(from `Base`

) to every pair of cells from two `SimpleSDMLayers`

and returns the result as a new `SimpleSDMResponse`

layer. Note that `max`

is only applied to the pairs without a `nothing`

element, and returns `nothing`

for the pairs with one. This function has been automatically generated.

`Base.min`

— Function`Base.min(l1::SimpleSDMLayer, l2::SimpleSDMLayer)`

Applies `min`

(from `Base`

) to every pair of cells from two `SimpleSDMLayers`

and returns the result as a new `SimpleSDMResponse`

layer. Note that `min`

is only applied to the pairs without a `nothing`

element, and returns `nothing`

for the pairs with one. This function has been automatically generated.

`Base.:+`

— Function`Base.+(l1::SimpleSDMLayer, l2::SimpleSDMLayer)`

Applies `+`

(from `Base`

) to every pair of cells from two `SimpleSDMLayers`

and returns the result as a new `SimpleSDMResponse`

layer. Note that `+`

is only applied to the pairs without a `nothing`

element, and returns `nothing`

for the pairs with one. This function has been automatically generated.

`Base.:-`

— Function`Base.-(l1::SimpleSDMLayer, l2::SimpleSDMLayer)`

Applies `-`

(from `Base`

) to every pair of cells from two `SimpleSDMLayers`

and returns the result as a new `SimpleSDMResponse`

layer. Note that `-`

is only applied to the pairs without a `nothing`

element, and returns `nothing`

for the pairs with one. This function has been automatically generated.

`Base.:*`

— Function`Base.*(l1::SimpleSDMLayer, l2::SimpleSDMLayer)`

Applies `*`

(from `Base`

) to every pair of cells from two `SimpleSDMLayers`

and returns the result as a new `SimpleSDMResponse`

layer. Note that `*`

is only applied to the pairs without a `nothing`

element, and returns `nothing`

for the pairs with one. This function has been automatically generated.

`Base.:/`

— Function`Base./(l1::SimpleSDMLayer, l2::SimpleSDMLayer)`

Applies `/`

(from `Base`

) to every pair of cells from two `SimpleSDMLayers`

and returns the result as a new `SimpleSDMResponse`

layer. Note that `/`

is only applied to the pairs without a `nothing`

element, and returns `nothing`

for the pairs with one. This function has been automatically generated.

`Base.:==`

— Function`==(layer1::SimpleSDMLayer, layer2::SimpleSDMLayer)`

Tests whether two `SimpleSDMLayer`

elements are equal. The layers are equal if all their fields (`grid`

, `left`

, `right`

, `bottom`

, `top`

) are equal, as verified with `==`

(e.g., `layer1.grid == layer2.grid`

).

`Base.isequal`

— Function`isequal(layer1::SimpleSDMLayer, layer2::SimpleSDMLayer)`

Tests whether two `SimpleSDMLayer`

elements are equal. The layers are equal if all their fields (`grid`

, `left`

, `right`

, `bottom`

, `top`

) are equal, as verified with `isequal`

(e.g., `isequal(layer1.grid, layer2.grid)`

).

## From `Broadcast`

## From `Statistics`

`Statistics.mean`

— Function`Statistics.mean(l::SimpleSDMResponse{T}) where {T <: Number}`

Applies `mean`

(from `Statistics`

) to an object of type `SimpleSDMResponse`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Statistics.mean(l::SimpleSDMPredictor{T}) where {T <: Number}`

Applies `mean`

(from `Statistics`

) to an object of type `SimpleSDMPredictor`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Statistics.mean(layers::Array{T}) where {T <: SimpleSDMLayer}`

Applies `mean`

(from `Statistics`

) to the elements in corresponding positions from the different layers (similar to `mean(a::Array{Matrix})`

) and returns the result as a new `SimpleSDMResponse`

layer. Note that `mean`

is only applied to the positions without a `nothing`

element and returns `nothing`

for the pairs with one. This function has been automatically generated.

`Statistics.median`

— Function`Statistics.median(l::SimpleSDMResponse{T}) where {T <: Number}`

Applies `median`

(from `Statistics`

) to an object of type `SimpleSDMResponse`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Statistics.median(l::SimpleSDMPredictor{T}) where {T <: Number}`

Applies `median`

(from `Statistics`

) to an object of type `SimpleSDMPredictor`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Statistics.std`

— Function`Statistics.std(l::SimpleSDMResponse{T}) where {T <: Number}`

Applies `std`

(from `Statistics`

) to an object of type `SimpleSDMResponse`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Statistics.std(l::SimpleSDMPredictor{T}) where {T <: Number}`

Applies `std`

(from `Statistics`

) to an object of type `SimpleSDMPredictor`

. This function has been automatically generated. Note that this function is only applied to the non-`nothing`

elements of the layer, and has no method to work on the `dims`

keyword; the grid itself can be extracted with `convert(Matrix, l)`

.

`Statistics.std(layers::Array{T}) where {T <: SimpleSDMLayer}`

Applies `std`

(from `Statistics`

) to the elements in corresponding positions from the different layers (similar to `mean(a::Array{Matrix})`

) and returns the result as a new `SimpleSDMResponse`

layer. Note that `std`

is only applied to the positions without a `nothing`

element and returns `nothing`

for the pairs with one. This function has been automatically generated.

`Statistics.quantile`

— Function`quantile(layer::T, p) where {T <: SimpleSDMLayer}`

Returns the quantiles of `layer`

at `p`

, using `Statistics.quantile`

.