Skip to content

Commit

Permalink
🚧 Extract interface from Internals to components:
Browse files Browse the repository at this point in the history
- [x] Foodweb
- [x] Functional Response
- [x] Multiplex API
- [x] Nutrients
- [ ] Temperature response
  • Loading branch information
iago-lito committed Sep 18, 2023
1 parent ceda5ef commit caea31c
Show file tree
Hide file tree
Showing 28 changed files with 3,866 additions and 450 deletions.
42 changes: 40 additions & 2 deletions src/EcologicalNetworksDynamics.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
module EcologicalNetworksDynamics

# Improve APIs comfort.
using OrderedCollections
using SparseArrays

#-------------------------------------------------------------------------------------------
# Shared API internals.

# Common error to throw on user input error.
argerr(mess) = throw(ArgumentError(mess))

# Alias common types.
const Option{T} = Union{Nothing,T}
const SparseMatrix{T} = SparseMatrixCSC{T,Int64}

include("./aliasing_dicts.jl")
using .AliasingDicts

include("./multiplex_api/module.jl")
using .MultiplexApi

#-------------------------------------------------------------------------------------------
# "Inner" parts: legacy internals.

# The entire implementation has been brutally made private
# so that we can focus on constructing
# an implementation-independent API on top of it, from scratch.
# an implementation-independent n top of it, from scratch.
# Once this API is completed, we expect publishing the package,
# the associated article, and then only perform deep refactoring of the "Internals".
include("./Internals/Internals.jl")
Expand All @@ -16,9 +34,29 @@ include("./Internals/Internals.jl")
# but without re-exporting anything from Internals.
import .Internals

#-------------------------------------------------------------------------------------------
# "Abstract" parts: the framework for developing user API.

# The System/Components framework code used for the API is there.
# This module is needed for package component developers.
include("./Framework/Framework.jl")
using .Framework
export add!, properties, blueprints, components

include("./dedicate_framework_to_model.jl")

#-------------------------------------------------------------------------------------------
# "Outer" parts: develop user-facing stuff here.

# Factorize out common user input data preprocessing.
include("./graph_data_inputs.jl")
using .GraphDataInputs

# The actual user-facing components of the package are defined there,
# connecting them to the internals via the framework.
include("./components.jl")

# Additional exposed utils built on top of components.
include("./exposed.jl")

end
20 changes: 18 additions & 2 deletions src/Internals/Internals.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This legacy module is still what makes the whole program run.
# It needs to undergo some *very* deep refactoring before new features are added.
# And details of it are abstracted away through the outer System/Component interface.

"""
EcologicalNetworksDynamics
Expand Down Expand Up @@ -38,10 +42,22 @@ using Statistics
using Decimals
using SciMLBase

using ..AliasingDicts

const Solution = SciMLBase.AbstractODESolution

# NOTE: The "ModelParameters"
# value constitutes a tree of sub-values with no internal circular references.
# All fields and sub-fields are turned into Options{T}
# so that it can be constructed "empty"
# and managed by the outer "System/Component" framework.
# This makes this internal implementation a little bit more of a mess,
# but it should be all refactored soon
# before we add new features anyway.
const Option{T} = Union{Nothing,T}

# Since parts of the API is being extracted out of this module to survive,
# authorize using it here.
using ..EcologicalNetworksDynamics

include(joinpath(".", "macros.jl"))
include(joinpath(".", "inputs/foodwebs.jl"))
include(joinpath(".", "inputs/nontrophic_interactions.jl"))
Expand Down
Loading

0 comments on commit caea31c

Please sign in to comment.