Yurie/Cluster
A Mathematica paclet for implementing a specific form of class composition.
Static
flowchart LR
PlanetCommonData(PlanetCommonData)
PlanetMergeData(PlanetMergeData)
StarList(StarList)
StarData(StarData)
starDefine{{starDefine}}
starReset{{starReset}}
starUnset{{starUnset}}
starMerge{{starMerge}}
starChange{{starChange}}
PlanetCommonData --- starDefine --> StarList & StarData
PlanetCommonData --- starReset --> StarData
starUnset --> StarList & StarData
PlanetMergeData --- starMerge --> StarData
starChange --> StarData
linkStyle 1,5 stroke:red;
linkStyle 2,4,6,8,9 stroke:blue;
linkStyle 0,3,7 stroke:green;
classDef data fill:#f3e9ff;
class PlanetCommonData,PlanetMergeData,StarList,StarData data;
Dynamic
flowchart LR
PlanetExtraData(PlanetExtraData)
StarDefaultList(StarDefaultList)
StarDefaultData(StarDefaultData)
starDefault{{starDefault}}
starUnset{{starUnset}}
starRMC{{starReset/starMerge/starChange}}
starUpdateDefault[[starUpdateDefault]]
starUpdateDefaultWhenUnset[[starUpdateDefaultWhenUnset]]
starDefault --> StarDefaultList
starDefault & starUnset & starRMC --- starUpdateDefault --> StarDefaultData
PlanetExtraData & StarDefaultList --- starUpdateDefault
starUnset --- starUpdateDefaultWhenUnset --> StarDefaultList
linkStyle 1,2,3 stroke:red;
linkStyle 0,6,7,8 stroke:blue;
linkStyle 5 stroke:green;
classDef data fill:#f3e9ff;
class PlanetExtraData,StarDefaultList,StarDefaultData data;
Attributes
-
cluster[data_Association]
- store the data with the following keys:-
"ClusterName"
- name of cluster. -
"PlanetList"
- list of planets. -
"PlanetCommonData"
- common data of planets across stars, determining the behaviors ofstarDefine
andstarReset
. -
"PlanetExtraData"
- extra data of planets, contributing to"StarDefaultData"
. -
"PlanetMergeData"
- core of methodstarMerge
, determining how to merge stars into the default star. -
"StarList"
- list of stars. -
"StarData"
- data of stars. -
"StarDefaultList"
- list of stars contributing to the default, changed bystarDefault
andstarUnset
, determining which part of"StarData"
contributing to"StarDefaultData"
. -
"StarDefaultData"
- data of default star. After star operations the default data will be updated automatically.
-
Methods
Cluster constructors
-
clusterQ[cluster_]
- check whether the input is a cluster. -
clusterInit[{clusterName_,context_},planetList_,commonList_,extraList_,mergeList_]
- initiate the cluster and bind it to the symbolcontext`clusterName
. The arguments are the name of cluster with context, then names, common values, extra values and merge methods of planets. -
clusterPropGet[cluster_,propertyOrItsList_]
- get property of the cluster. -
clusterPropSet[cluster_,propertyOrItsList_]
- set property of the cluster.
Public methods
-
starDefine[cluster_,starList_]
- define the stars. -
starDefault[cluster_,starList_]
- set the stars to default. -
starReset[cluster_,starList_]
- reset the stars. -
starUnset[cluster_,starList_]
- unset the stars, and update the default star list. -
starMerge[cluster_,starList_,planetData_]
- merge planet data to the stars. The third argument will be association-ized, hence rule, list of rules, association of rules are accepted. -
starChange[cluster_,starList_,planetData_,planetFunctionData_]
- change planet data to the stars by the functions.
Private methods
-
starDefineSplit[cluster_,starList_]
- split the list of stars into defined and undefined. -
starDefineCheck[__]
- check the input before calling public methods:-
starDefineCheck[cluster_,"starReportUndefAndReturnDef",starList_]
-
starDefineCheck[cluster_,"starReportDefAndReturnUndef",starList_]
-
starDefineCheck[cluster_,"planetAborUndeff",starList_]
-
-
starUpdateDefault[cluster_]
- update"StarDefaultData"
by"StarDefaultList"
afterstarDefault
,starReset
,starUnset
,starMerge
andstarChange
. -
starUpdateDefaultWhenUnset[cluster_,starList_]
- remove the stars in both the input and the default star list, used bystarUnset
. -
starPreIntercept|starPostIntercept
- modify the behaviors of star methods.