DsoParams.jl
The DsoParams.jl file defines a container class specifically designed to manage DSO parameters. It acts as a wrapper around a standard Julia dictionary, providing enhanced accessibility through dot notation and seamless integration with common Julia collections functions.
DataScienceOperations.DsoParams — Type
DsoParamsContainer class for dso parameters
Fields
data::Dict: content of dso params file in dict format
Examples
Julia params = DsoParams(data::Dict{Symbol, Any})`
Key Features
1. Dot Notation Access
The DsoParams object overloads getproperty and setproperty!, allowing you to interact with dictionary keys as if they were object fields.
- Get:
params.keyretrieves the value associated with:key. - Set:
params.key = valueupdates or creates the entry for:key. - Safety: The underlying
datafield itself cannot be replaced via dot notation; attempting to do so will result in an error.
2. IDE Integration
- Autocompletion: The
propertynamesfunction is overloaded to ensure that keys stored within thedatadictionary appear in VS Code autocompletion suggestions
3. Collection & Iteration Support
DsoParams behaves like a standard Julia collection by overloading several Base methods:
- Indexing: Access data using
params[:key]or set it usingparams[:key] = val. - Iteration: You can loop over the object (e.g.,
for (k, v) in params) just like a dictionary. - Utility Functions: Supports
length(),keys(),values(), andhaskey().
Functions
Base.propertynames — Function
propertynames(obj::DsoParams, private::Bool=false)Function that permits autocompletion in VScode
Base.getproperty — Function
getproperty(obj::DsoParams, sym::Symbol)::AnyReturn the property of a specific symbol from data dict via dot notation.
Arguments
obj::DsoParams: Instance of DsoParamssym::Symbol: Key of requested property
Output
Any data stored under the kprovided key in data Dict
Examples
params = DsoParams(data::Dict{Symbol, Any})
property_value == params.keyBase.setproperty! — Function
setproperty!(obj::DsoParams, sym::Symbol, val::Any)::NothingSet the property of a specific symbol from data dict via dot notation.
Arguments
obj::DsoParams: Instance of DsoParamssym::Symbol: Key of the entry in the object's data Dict to be set.val:Any: Value that should be stored under the key of the object's data dict
Exapmles
params = DsoParams(data::Dict{Symbol, Any})
params.key = 1DataScienceOperations.get_keys — Function
get_keys(obj::DsoParams)::Vector{String}colletct the keys of the instance variable data.
Arguments
obj::DsoParams: An instance of the DsoParams object.
Output
Array of keys
params = DsoParams(data::Dict{Symbol, Any})
key_collection = get_keys(params)Base.show — Function
show(io::IO, ::MIME"text/plain", obj::DsoParams)::NothingPretty printing of DsoParams class
Arguments
obj::DsoParams: Instance of DsoParams class
Examples
params = DsoParams(data::Dict{Symbol, Any})
show(params)show(io::IO, obj::DsoParams)::NothingPretty printing of DsoParams class
Arguments
obj::DsoParams: Instance of DsoParams class
Examples
params = DsoParams(data::Dict{Symbol, Any})
show(params)Usage Example
# Initialize with a dictionary
data_dict = Dict(:alpha => 0.1, :beta => 20)
params = DsoParams(data_dict)
# Access via dot notation
println(params.alpha) # 0.1
# Update a value
params.beta = 30
# Use as a collection
if haskey(params, :alpha)
println("Length: ", length(params))
end