StollLab / EasySpin

MATLAB toolbox for Electron Paramagnetic Resonance (EPR) spectroscopy
http://easyspin.org
MIT License
48 stars 25 forks source link

Spell checker for input fields #339

Open cerium1925 opened 1 month ago

cerium1925 commented 1 month ago

If a user enters a field that doesn't exist, the current development version of EasySpin lacks a validity check and simply loads the default parameters. For instance, if Opt.GridSize is mistakenly input as Opt.GridSiz, EasySpin won't provide a reminder or error message (as it has already loaded the default value). This also applies to arbitrarily defined fields like Sys.T, or other illegal or undefined fields. These will always exist in fields such as Sys, Exp, or Opt. While EasySpin doesn't flag an error, it could potentially lead to bugs or calculation errors.

Screenshot 2024-05-23 171856

test code: tic

clear,clc,clf Sys.S = 3/2; Sys.Nucs = 'Mn'; Sys.g = [1.998 1.997]; Sys.A = [110 120]; Sys.T = [0 0 0]; D = -529979; Sys.D = [D 0.01D]; Sys.lw = 2.5;

Exp.mwFreq = 9.8; Exp.Range = [0 2000]; Exp.nPoints = 1e4; Opt.GridSize = [1e2 1e1]; Opt.Verbosity = 2; Exp.Temperature = 0.4; [x,y] = pepper(Sys,Exp,Opt); plot(x,y);

toc

Screenshot 2024-05-23 171948
stestoll commented 1 month ago

Agreed, it would be nice to have spell checker for this. We've been considering adding one, but it hasn't been a high enough priority.

Can you provide, or point to, an efficient implementation for such a spell checker?

There are two downsides of this though: (1) A spell checker slows down simulation functions. (2) The dictionary of field names needs to be maintained so it doesn't slip out of sync with the fields that are actually being used.