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.DsoParamsType
DsoParams

Container class for dso parameters

Fields

  • data::Dict: content of dso params file in dict format

Examples

Julia params = DsoParams(data::Dict{Symbol, Any})`

source

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.key retrieves the value associated with :key.
  • Set: params.key = value updates or creates the entry for :key.
  • Safety: The underlying data field itself cannot be replaced via dot notation; attempting to do so will result in an error.

2. IDE Integration

  • Autocompletion: The propertynames function is overloaded to ensure that keys stored within the data dictionary 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 using params[: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(), and haskey().

Functions

Base.propertynamesFunction
propertynames(obj::DsoParams, private::Bool=false)

Function that permits autocompletion in VScode

source
Base.getpropertyFunction
getproperty(obj::DsoParams, sym::Symbol)::Any

Return the property of a specific symbol from data dict via dot notation.

Arguments

  • obj::DsoParams: Instance of DsoParams
  • sym::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.key
source
Base.setproperty!Function
setproperty!(obj::DsoParams, sym::Symbol, val::Any)::Nothing

Set the property of a specific symbol from data dict via dot notation.

Arguments

  • obj::DsoParams: Instance of DsoParams
  • sym::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 = 1
source
DataScienceOperations.get_keysFunction
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)
source
Base.showFunction
show(io::IO, ::MIME"text/plain", obj::DsoParams)::Nothing

Pretty printing of DsoParams class

Arguments

  • obj::DsoParams: Instance of DsoParams class

Examples

params = DsoParams(data::Dict{Symbol, Any})
show(params)
source
show(io::IO, obj::DsoParams)::Nothing

Pretty printing of DsoParams class

Arguments

  • obj::DsoParams: Instance of DsoParams class

Examples

params = DsoParams(data::Dict{Symbol, Any})
show(params)
source

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