numere-org / NumeRe

Framework for numerical computations, data analysis and visualisation
https://www.numere.org
GNU General Public License v3.0
18 stars 6 forks source link

Column type conversion string->logical has problems #66

Closed numeredev closed 1 year ago

numeredev commented 1 year ago

DESCRIPTION

Describe the bug If one wants to convert a string column into a logical column in the table viewer and the column is only partly filled, then nan values are converted to true values.

To Reproduce Steps to reproduce the behavior:

  1. Create a table with a string column containing logical values encoded as string and empty cells
  2. Open this table in the table viewer
  3. Select the column and convert it to logical values
  4. See error

Expected behavior The empty cells should stay empty during this conversion

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

(Do not write below this line)


DEVS' SECTION

ANALYSIS

The problem is in the following section, which does not handle the case, when a value is nan and not behind the current the last element. It's detected in this context, because the whole array is pre-allocated in case of column type conversion.

void LogicalColumn::setValue(size_t elem, const mu::value_type& vValue)
{
    if (elem >= m_data.size() && mu::isnan(vValue))
        return;

    if (elem >= m_data.size())
        m_data.resize(elem+1, LOGICAL_NAN);

    m_data[elem] = vValue != 0.0 ? LOGICAL_TRUE : LOGICAL_FALSE;
}

IMPLEMENTATION STEPS

(see also our Wiki for implementation guidelines)

DOCUMENTATION STEPS

(see also our Wiki for further information)

PULL REQUEST