dRELTools API
Types
DrelTools.DynamicDDLmRC
— TypeDynamicDDLmRC(ds, dict::AbstractCifDictionary)
Create a DynamicDDLmRC
object from ds
with relational structure defined by dict
. If dict
includes dREL methods describing mathematical relationships between data names, use these to derive and cache missing values.
ds
should provide the DataSource
trait.
A DynamicDDLmRC
is itself a DataSource
.
Methods
DrelTools.define_dict_funcs!
— Methoddefine_dict_funcs!(dict)
Find and transform to Julia all dREL functions defined in dict
. This must be called in order for these functions to be available to dREL methods defined in dict
.
DrelTools.empty_cache!
— Methodempty_cache!(d)
Remove all cached data name values computed for d
.
Base.keys
— Methodkeys(d::DynamicDDLmRC)
Return all data names that have associated values in d
. If multiple namespaces are present, some data names may be duplicated. If calculations have been performed to derive data name values, those data names will be included.
Base.haskey
— Methodhaskey(d::DynamicDDLmRC,s)
true
if any instance found of s
in d
.
Base.haskey
— Methodhaskey(d::DynamicDDLmRC,s,n)
true
if any instance found of s
from namespace n
in d
.
Base.getindex
— Methodgetindex(d::DynamicDDLmRC,s)
d[s]
returns all values for that data name in the same order as the key values, so that they may be interpreted as a column of values in correct order, deriving missing values from dREL methods if available.
If s
appears in multiple namespaces within d
, an error is raised.
Base.getindex
— Methodgetindex(d::DynamicDDLmRC,s,nspace)
d[s,nspace]
returns the values of dataname s
from namespace nspace
in d
, with derivation of missing values. Values are returned in an order corresponding to the order in which key data name values are provided, meaning that the returned values can be assembled into a table without further manipulation.
Base.setindex!
— Methodsetindex!(d::DynamicDDLmRC,v,s)
Set the value of s
in d
to v
. The underlying data source is not changed, instead values are set in the cache and will be deleted by empty_cache!
.
Base.setindex!
— Methodsetindex!(d::DynamicDDLmRC,v,s,nspace)
Set the value of s
from namespace nspace
in d
to v
. The underlying data source is not changed, instead values are set in the cache and will be deleted by empty_cache!
.
CrystalInfoFramework.DataContainer.get_category
— Methodget_category(d::DynamicDDLmRC,s::AbstractString,nspace::String)
Return a CifCategory
named s
in namespace nspace
from d
, creating the category using dREL category methods if missing. If s
is already present, no further data names from that category are derived.
CrystalInfoFramework.DataContainer.get_category
— Methodget_category(d::DynamicDDLmRC,s)
Return a CifCategory
named s
from d
, creating the category using dREL category methods if missing. If s
is already present, no further data names from that category are derived. If s
is ambiguous because it is present in multiple namespaces, an error is raised.
DrelTools.derive
— Methodderive(b::DynamicRelationalContainer,dataname,nspace)
Derive values for dataname
in nspace
missing from b
. Return missing
if the category itself is missing, otherwise return an Array potentially containing missing values with one value for each row in the category.
For developers
DrelTools.make_julia_code
— Methodmake_julia_code(drel_text,dataname,dict; reserved=[])
Define a Julia method from dREL code contained in drel_text
which calculates the value of dataname
defined in dict
. All category names in dict
and any additional names in reserved
are recognised as categories.
DrelTools.add_definition_func!
— Methodadd_definition_func!(dictionary,dataname)
Add a method that adjusts the definition of dataname by defining a DDLm attribute.
Drel runtime functions
The following methods are defined to be used within Julia code generated from dREL in order to support dREl semantics and recursive calculation.
DrelTools.drelvector
— TypeA drelvector
is a vector which adopts the correct dimension (column or row) to allow pre or post multiplication without explicit transposition.
DrelTools.DrelTable
— TypeA DrelTable
is almost like a Julia Dict
, but it must allow CaselessString
comparisons with String
, and the types of the keys are restricted.
DrelTools.drel_property_access
— Methoddrel_property_access(cp,obj,datablock)
This call corresponds to cp.obj
in dREL code. If obj
is not a property of cp
, datablock
is used to try to derive a value, returning missing
for all failures and caching the result in datablock
if successful.