spedas / bleeding_edge

IDL-based Space Physics Environment Data Analysis Software (bleeding edge)
http://www.spedas.org
Other
7 stars 0 forks source link

spd_run_py_validation fails for multidimensional arrays #94

Open jameswilburlewis opened 1 year ago

jameswilburlewis commented 1 year ago

When comparing IDL and Python results using the mgunit framework in IDL, this bit of code is failing if the IDL result has too many dimensions:

  for var_idx=n_elements(vars)-1, 0, -1 do begin
    data = (var_table[vars[var_idx]])['data']
    for n=points_to_check-1, 0, -1 do begin
      idx = (var_table[vars[var_idx]])['ntimes']*n/points_to_check

      pyresult = spd_run_py_str_to_arr(pyoutput[-1-count])
      idlresult = data.Y[idx, *]

      matches = spd_run_py_compare(idlresult, pyresult, tolerance=tolerance)
      if matches eq 0 then begin
        dprint, dlevel=0, 'Error, python validation test failed for: ' + vars[var_idx] + ' (' + strcompress(string(idx), /rem) + ')'
        passed = 0b
      endif

      count += 1
    endfor

The failure occurs at the line:

idlresult = data.Y[idx,*]

We may also need some adjustments in the lines of code that get added to the Python script, to address similar issues on the Python side. Options might be to reform the arrays being tested to ensure a fixed number of dimensions, or adding logic to do the correct indexing based on the number of dimensions in the test output.