Skip to content

Commit

Permalink
API Redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
gottacatchenall committed Dec 20, 2024
1 parent 5ee09b6 commit 78f006b
Show file tree
Hide file tree
Showing 40 changed files with 510 additions and 364 deletions.
17 changes: 14 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,47 @@ authors = ["michael catchen <michael.catchen@colorado.edu>"]
version = "0.2.1"

[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5"
DelaunayTriangulation = "927a84f5-c5f4-47a5-9785-b46e178433df"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
GeometryOps = "3251bfac-6a57-4b6d-aa61-ac1fef2975ab"
HaltonSequences = "13907d55-377f-55d6-a9d6-25ac19e11b95"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MultivariateStats = "6f286f6a-111f-5878-ab1e-185364afe411"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SimpleSDMLayers = "2c645270-77db-11e9-22c3-0f302a89c64c"
SliceMap = "82cb661a-3f19-5665-9e27-df437c7e54c8"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
SpeciesDistributionToolkit = "72b53823-5c0b-4575-ad0e-8e97227ad13b"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Term = "22787eb5-b846-44ae-b979-8e399b8463ab"
TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe"

[weakdeps]
NeutralLandscapes = "71847384-8354-4223-ac08-659a5128069f"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"

[extensions]
BONsMakieExt = "Makie"

[compat]
Clustering = "0.15.7"
DelaunayTriangulation = "1.6.3"
Distributions = "0.25"
GeoInterface = "1.4.0"
GeometryOps = "0.1.13"
HaltonSequences = "0.2"
HiGHS = "1.5"
JuMP = "1.11"
MultivariateStats = "0.10.3"
ProgressMeter = "1.7.2"
Requires = "1.3"
SliceMap = "0.2.7"
SpecialFunctions = "2.1"
SpeciesDistributionToolkit = "1.2.0"
StatsBase = "0.34"
julia = "1.9"
68 changes: 68 additions & 0 deletions _OLD/src/BiodiversityObservationNetworks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module BiodiversityObservationNetworks

using SimpleSDMLayers
using Distributions
using Random
using HaltonSequences
using StatsBase
using SpecialFunctions
using ProgressMeter
using SliceMap
using JuMP
using HiGHS
using LinearAlgebra
using Term
using TestItems

include("types.jl")
export BONSampler
export Sites, numsites, pool
export LayerType, DataLayer, InclusionProbability
export Layer, Stack

include("sample.jl")
export sample

include("exceptions.jl")
export BONException, TooFewSites, TooManySites

include("simplerandom.jl")
export SimpleRandom

include("spatialstratified.jl")
export SpatiallyStratified

include("balancedacceptance.jl")
export BalancedAcceptance

include("weightedbas.jl")
export WeightedBalancedAcceptance

include("adaptivehotspot.jl")
export AdaptiveHotspot

include("cubesampling.jl")
export CubeSampling

include("fractaltriad.jl")
export FractalTriad

include("grts.jl")
export GeneralizedRandomTessellatedStratified

include("uniqueness.jl")
export Uniqueness

#include("seed.jl")
#export seed, seed!

#include("refine.jl")
#export refine, refine!

include("entropize.jl")
export entropize, entropize!

include("utils.jl")
export stack

end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions _OLD/src/new_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@





SDMLayer
Matrix

struct Layer{T}
layer::T
end

struct Stack{T}
stack::Vector{Layer{T}}
end



abstract type InclusionType end
struct CategoricalInclusion <: InclusionType
layer::Layer
inclusion_probability::Dict
end
struct ContinuousInclusion <: InclusionType
layer::Layer
end



struct InclusionProbability{<:InclusionType}

end
File renamed without changes.
26 changes: 26 additions & 0 deletions _OLD/src/sample.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

function sample(alg::BONSampler)
_sample!(
_allocate_sites(numsites(alg)),
_default_pool(alg),
alg
)
end


function sample(alg::BONSampler, l::L) where L<:Layer
_sample!(
_allocate_sites(numsites(alg)),
l,
alg
)
end


function sample(alg::BONSampler, candidates::C) where C<:Sites
_sample!(
_allocate_sites(numsites(alg)),
candidates,
alg
)
end
File renamed without changes.
1 change: 0 additions & 1 deletion src/spatialstratified.jl → _OLD/src/spatialstratified.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ function _default_strata(sz)
mat[begin:x, :] .= 1
mat[(x + 1):end, begin:y] .= 2
mat[(x + 1):end, (y + 1):end] .= 3

return Layer(mat)
end

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using BiodiversityObservationNetworks
bib = CitationBibliography(joinpath(@__DIR__, "BONs.bib"))

makedocs(
sitename = "BiodiversityObservationNetwork.jl",
sitename = "BiodiversityObservationNetworks.jl",
authors = "Michael D. Catchen, Timothée Poisot, Kari Norman, Hana Mayall, Tom Malpas",
modules = [BiodiversityObservationNetworks],
format = DocumenterVitepress.MarkdownVitepress(
Expand Down
44 changes: 1 addition & 43 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,7 @@ The purpose of this package is to provide a high-level, extensible, modular
interface to the selection of sampling point for biodiversity processes in
space. It is based around a collection of types representing point selection
algorithms, used to select the most informative sampling points based on raster
data. Specifically, many algorithms work from a layer indicating *entropy* of a
model based prediction at each location.
data.

!!! warning "This package is in development"
The `BiodiversityObservationNetworks.jl` package is currently under development. The API is not expected to change a lot, but it may change in order to facilitate the integration of new features.

## High-level types

```@docs
BONSampler
BONSeeder
BONRefiner
```

## Seeder and refiner functions

```@docs
seed
seed!
```

```@docs
refine
refine!
```

## Seeder algorithms

```@docs
BalancedAcceptance
```

## Refiner algorithms

```@docs
AdaptiveSpatial
Uniqueness
```

## Helper functions

```@docs
squish
entropize!
entropize
```
11 changes: 11 additions & 0 deletions ext/BONsMakieExt/BONsMakieExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module BONsMakieExt

@info "Loading Makie Extension for BiodiversityObservationNetworks.jl..."

@static if isdefined(Base, :get_extension)
using Makie, BiodiversityObservationNetworks
else
using ..Makie, ..BiodiversityObservationNetworks
end

end
4 changes: 0 additions & 4 deletions ext/SDTExt.jl

This file was deleted.

107 changes: 40 additions & 67 deletions src/BiodiversityObservationNetworks.jl
Original file line number Diff line number Diff line change
@@ -1,68 +1,41 @@
module BiodiversityObservationNetworks

using SimpleSDMLayers
using Distributions
using Random
using HaltonSequences
using StatsBase
using SpecialFunctions
using ProgressMeter
using SliceMap
using JuMP
using HiGHS
using LinearAlgebra
using Term
using TestItems

include("types.jl")
export BONSampler
export Sites, numsites, pool
export LayerType, DataLayer, InclusionProbability
export Layer, Stack

include("sample.jl")
export sample

include("exceptions.jl")
export BONException, TooFewSites, TooManySites

include("simplerandom.jl")
export SimpleRandom

include("spatialstratified.jl")
export SpatiallyStratified

include("balancedacceptance.jl")
export BalancedAcceptance

include("weightedbas.jl")
export WeightedBalancedAcceptance

include("adaptivehotspot.jl")
export AdaptiveHotspot

include("cubesampling.jl")
export CubeSampling

include("fractaltriad.jl")
export FractalTriad

include("grts.jl")
export GeneralizedRandomTessellatedStratified

include("uniqueness.jl")
export Uniqueness

#include("seed.jl")
#export seed, seed!

#include("refine.jl")
#export refine, refine!

include("entropize.jl")
export entropize, entropize!

include("utils.jl")
export stack

end
using Clustering
using DelaunayTriangulation
using Distributions
using GeometryOps
using GeoInterface
using MultivariateStats
using SpeciesDistributionToolkit
using Random

import GeoInterface as GI
import GeometryOps as GO
import SpeciesDistributionToolkit as SDT
import SpeciesDistributionToolkit.GeoJSON as GJSON

export BiodiversityObservationNetwork
export Node
export Polygon
export Raster
export RasterStack

export BONSampler
export SimpleRandom, Grid, KMeans, SpatiallyStratified
export sample
export datatype
export nonempty
export is_polygonizable, is_rasterizable, is_bonifyable

include(joinpath("geometry", "bon.jl"))
include(joinpath("geometry", "polygon.jl"))
include(joinpath("geometry", "raster.jl"))
include(joinpath("geometry", "stack.jl"))

include("sample.jl")
include(joinpath("samplers", "simplerandom.jl"))
include(joinpath("samplers", "grid.jl"))
include(joinpath("samplers", "kmeans.jl"))
include(joinpath("samplers", "spatiallystratified.jl"))


end
Loading

0 comments on commit 78f006b

Please sign in to comment.