Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JASP configuration file feature + remote option #5062

Draft
wants to merge 38 commits into
base: stable
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6c46eaf
Implements a data mode
JorisGoosen May 21, 2021
003123c
SKF JASP postmerge and fix
JorisGoosen Sep 21, 2021
aa63d26
latest version of jaspProcessControl and other submodules
JorisGoosen Dec 1, 2021
82f7f86
post qt6 merge fixes
JorisGoosen Mar 10, 2022
825d474
post rebase fixes 10-11-22
JorisGoosen Nov 10, 2022
8a49630
post rebase fix 7-12-22
JorisGoosen Dec 7, 2022
3d71dac
(event)=>{}
JorisGoosen Dec 7, 2022
7edb7cd
Rebasing mistake
boutinb Jan 27, 2023
6349af9
Make sure editing is quick and analyses are hidden in dataMode (#5040)
JorisGoosen Mar 1, 2023
191709f
dirty fix for the resize dialog (#5042)
RensDofferhoff Mar 1, 2023
55fea62
odule shenanigans
JorisGoosen Mar 16, 2023
aba724b
start
RensDofferhoff Apr 3, 2023
5f2fb73
progress
RensDofferhoff Apr 4, 2023
bef03ee
progress
RensDofferhoff Apr 5, 2023
a6a1bf2
progress
RensDofferhoff Apr 5, 2023
a44a893
progress
RensDofferhoff Apr 6, 2023
84807bc
progress
RensDofferhoff Apr 7, 2023
f286ea0
before overhaul
RensDofferhoff Apr 10, 2023
b0c3a38
functional
RensDofferhoff Apr 12, 2023
72b965f
giant oops
RensDofferhoff Apr 12, 2023
6945cab
v1
RensDofferhoff Apr 12, 2023
c94ee85
enabled sounds better
RensDofferhoff Apr 13, 2023
53c39e4
oops
RensDofferhoff Apr 15, 2023
b20d6ae
oops
RensDofferhoff Apr 15, 2023
d71aaa2
oops
RensDofferhoff Apr 16, 2023
c826d3d
constant access improvements
RensDofferhoff Apr 18, 2023
2d54356
add option locking
RensDofferhoff Apr 18, 2023
d56c6d3
oops
RensDofferhoff May 11, 2023
0dd5bbf
progress
RensDofferhoff May 12, 2023
3ed5704
factory
RensDofferhoff May 12, 2023
bb506d6
more extendable this way
RensDofferhoff May 15, 2023
8d58dd8
a small comment never hurts
RensDofferhoff May 15, 2023
f431a57
add toml
RensDofferhoff May 16, 2023
8a8df43
forgot the parser lib
RensDofferhoff May 16, 2023
a58c026
Documentation for analysis writers
RensDofferhoff May 17, 2023
8a232b9
Update jasp-qml-guide.md
RensDofferhoff May 22, 2023
c976461
dont change the submodule commits
RensDofferhoff May 22, 2023
311866d
added local conf browser
RensDofferhoff May 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,12 @@
[submodule "Modules/jaspPower"]
path = Modules/jaspPower
url = https://github.com/jasp-stats/jaspPower
branch = master
[submodule "Modules/jaspPredictiveAnalytics"]
path = Modules/jaspPredictiveAnalytics
url = https://github.com/jasp-stats/jaspPredictiveAnalytics
branch = main
[submodule "Modules/jaspLearnStats"]
path = Modules/jaspLearnStats
url = https://github.com/jasp-stats/jaspLearnStats
branch = master
9 changes: 0 additions & 9 deletions Common/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@

using namespace std;

std::string Utils::doubleToString(double dbl, int precision)
{
std::stringstream conv; //Use this instead of std::to_string to make sure there are no trailing zeroes (and to get full precision)
conv << std::setprecision(precision);
conv << dbl;
return conv.str();
}

Utils::FileType Utils::getTypeFromFileName(const std::string &path)
{

Expand Down Expand Up @@ -229,7 +221,6 @@ void Utils::sleep(int ms)
#endif
}


bool Utils::isEqual(const double a, const double b)
{
if (isnan(a) || isnan(b)) return false;
Expand Down
5 changes: 2 additions & 3 deletions Common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <vector>
#include <limits>
#include <filesystem>
#include <set>
#include <map>
#include "timers.h"

enum class FileTypeBase;
Expand All @@ -44,15 +46,12 @@ class Utils
static bool renameOverwrite( const std::string &oldName, const std::string &newName);
static bool removeFile( const std::string &path);

static std::string doubleToString(double dbl, int precision = 10);

static std::filesystem::path osPath(const std::string &path);
static std::string osPath(const std::filesystem::path &path);

static void remove(std::vector<std::string> &target, const std::vector<std::string> &toRemove);
static void sleep(int ms);


static bool isEqual(const float a, const float b);
static bool isEqual(const double a, const double b);

Expand Down
98 changes: 70 additions & 28 deletions CommonData/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ bool Column::_resetEmptyValuesForScale(std::map<int, string> &emptyValuesMap)
// This value is now considered as empty
*doubles = NAN;
hasChanged = true;
emptyValuesMap.insert(make_pair(row, Utils::doubleToString(doubleValue)));
emptyValuesMap.insert(make_pair(row, ColumnUtils::doubleToString(doubleValue)));
}
row++;
}
Expand Down Expand Up @@ -525,7 +525,7 @@ columnTypeChangeResult Column::_changeColumnToNominalOrOrdinal(enum columnType n

for (double doubleValue : AsDoubles)
if (std::isnan(doubleValue)) values.push_back("");
else values.push_back(Utils::doubleToString(doubleValue));
else values.push_back(ColumnUtils::doubleToString(doubleValue));

setColumnAsNominalText(values);
return columnTypeChangeResult::changed;
Expand Down Expand Up @@ -1019,7 +1019,7 @@ string Column::_getScaleValue(int row, bool forDisplay)
if (v > std::numeric_limits<double>::max()) return "∞";
else if (v < std::numeric_limits<double>::lowest()) return "-∞";
else if (ColumnUtils::isEmptyValue(v)) return forDisplay ? ColumnUtils::emptyValue : "";
else return Utils::doubleToString(v);
else return ColumnUtils::doubleToString(v);
}

string Column::getOriginalValue(int row)
Expand Down Expand Up @@ -1071,6 +1071,8 @@ void Column::append(int rows)
if (rows == 0)
return;

size_t originalRowCount = _rowCount;

BlockMap::reverse_iterator itr = _blocks.rbegin();

if (itr == _blocks.rend()) // no blocks
Expand All @@ -1092,39 +1094,64 @@ void Column::append(int rows)
{
block->insert(rows);
_rowCount += rows;
return;
goto finishingUp; //yeah yeah this is a goto, no problem right?
}

block->insert(room);
_rowCount += room;

int newBlocksRequired = rowsLeft / DataBlock::capacity();
if (rowsLeft % DataBlock::capacity())
newBlocksRequired++;

for (int i = 0; i < newBlocksRequired; i++)
//Extra scope to avoid var init between goto and label
{
try {
block->insert(room);
_rowCount += room;

DataBlock *newBlock = _mem->construct<DataBlock>(anonymous_instance)();
int newBlocksRequired = rowsLeft / DataBlock::capacity();
if (rowsLeft % DataBlock::capacity())
newBlocksRequired++;

int toInsert = min(rowsLeft, DataBlock::capacity());
newBlock->insert(toInsert);
rowsLeft -= toInsert;
for (int i = 0; i < newBlocksRequired; i++)
{
try {

DataBlock *newBlock = _mem->construct<DataBlock>(anonymous_instance)();

int toInsert = min(rowsLeft, DataBlock::capacity());
newBlock->insert(toInsert);
rowsLeft -= toInsert;

id += DataBlock::capacity();
_blocks.insert(BlockEntry(id, newBlock));

_rowCount += toInsert;
}
catch (boost::interprocess::bad_alloc &e)
{
std::cout << e.what() << " ";
std::cout << "append column " << name() << ", append: " << rows << ", rowCount: " << _rowCount << std::endl;
throw e;
}
}
}

id += DataBlock::capacity();
_blocks.insert(BlockEntry(id, newBlock));
finishingUp:

_rowCount += toInsert;
//Make sure the new rows are empty looking
switch(_columnType)
{
case columnType::unknown:
case columnType::scale:
for(size_t r=originalRowCount; r<_rowCount; r++)
AsDoubles[r] = NAN;
break;

}
catch (boost::interprocess::bad_alloc &e)
{
std::cout << e.what() << " ";
std::cout << "append column " << name() << ", append: " << rows << ", rowCount: " << _rowCount << std::endl;
throw e;
}
case columnType::ordinal:
case columnType::nominal:
for(size_t r=originalRowCount; r<_rowCount; r++)
AsInts[r] = INT_MIN;
break;

case columnType::nominalText:
break;
}


}

void Column::truncate(int rows)
Expand All @@ -1138,6 +1165,8 @@ void Column::truncate(int rows)

if (rowsToDelete > _rowCount)
rowsToDelete = _rowCount;

std::vector<DataBlock*> destroyThese;

while (rowsToDelete > 0)
{
Expand All @@ -1152,7 +1181,7 @@ void Column::truncate(int rows)
rowsToDelete -= block->rowCount();
_rowCount -= block->rowCount();
block->erase(block->rowCount());
//_mem->destroy_ptr<DataBlock>(block);
destroyThese.push_back(block);
itr++;
if (itr == _blocks.rend())
{
Expand All @@ -1166,6 +1195,19 @@ void Column::truncate(int rows)
}
}
}

for(DataBlock * block : destroyThese)
{
_mem->destroy_ptr<DataBlock>(block);

for(const auto & keyval : _blocks)
if(keyval.second == block)
{
_blocks.erase(keyval.first);
break;
}
}

}

void Column::setColumnType(enum columnType columnType)
Expand Down
19 changes: 16 additions & 3 deletions CommonData/columns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,15 @@ void Columns::setRowCount(size_t rowCount)

void Columns::setColumnCount(size_t columnCount)
{
_columnStore.reserve(columnCount);
for (size_t i = _columnStore.size(); i < columnCount; i++)
_columnStore.push_back(Column(_mem));
if(columnCount > _columnStore.size())
{
_columnStore.reserve(columnCount);
for (size_t i = _columnStore.size(); i < columnCount; i++)
_columnStore.push_back(Column(_mem));
}
else
while(_columnStore.size() > columnCount)
_columnStore.erase(--_columnStore.end());
}


Expand All @@ -84,6 +90,13 @@ void Columns::removeColumn(std::string name)
}
}

void Columns::insertColumn(size_t index)
{
auto c = Column(_mem);
c._setRowCount(maxRowCount());
_columnStore.insert(_columnStore.begin() + index, c);
}


void Columns::setSharedMemory(boost::interprocess::managed_shared_memory *mem)
{
Expand Down
1 change: 1 addition & 0 deletions CommonData/columns.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Columns

void removeColumn(size_t index);
void removeColumn(std::string name);
void insertColumn(size_t index);

ColumnVector _columnStore;

Expand Down
70 changes: 68 additions & 2 deletions CommonData/columnutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ void ColumnUtils::processEmptyValues()
{
_currentDoubleEmptyValues.clear();

for (vector<string>::const_iterator it = _currentEmptyValues.begin(); it != _currentEmptyValues.end(); ++it)
for (const std::string & curEmptyVal : _currentEmptyValues)
{
double doubleValue;
if (ColumnUtils::getDoubleValue(*it, doubleValue))
if (ColumnUtils::getDoubleValue(curEmptyVal, doubleValue))
_currentDoubleEmptyValues.push_back(doubleValue);
}
}
Expand Down Expand Up @@ -167,6 +167,72 @@ bool ColumnUtils::convertValueToDoubleForImport(const std::string &strValue, dou
return true;
}

std::string ColumnUtils::doubleToString(double dbl, int precision)
{
std::stringstream conv; //Use this instead of std::to_string to make sure there are no trailing zeroes (and to get full precision)
conv << std::setprecision(precision);
conv << dbl;
return conv.str();
}


bool ColumnUtils::convertVecToInt(const std::vector<std::string> &values, std::vector<int> &intValues, std::set<int> &uniqueValues, std::map<int, std::string> &emptyValuesMap)
{
emptyValuesMap.clear();
uniqueValues.clear();
intValues.clear();
intValues.reserve(values.size());

int row = 0;

for (const std::string &value : values)
{
int intValue = std::numeric_limits<int>::lowest();

if (ColumnUtils::convertValueToIntForImport(value, intValue))
{
if (intValue != std::numeric_limits<int>::lowest()) uniqueValues.insert(intValue);
else if (!value.empty()) emptyValuesMap.insert(make_pair(row, value));

intValues.push_back(intValue);
}
else
return false;

row++;
}

return true;
}


bool ColumnUtils::convertVecToDouble(const std::vector<std::string> &values, std::vector<double> &doubleValues, std::map<int, std::string> &emptyValuesMap)
{
emptyValuesMap.clear();
doubleValues.clear();
doubleValues.reserve(values.size());

int row = 0;
for (const std::string &value : values)
{
double doubleValue = static_cast<double>(NAN);

if (ColumnUtils::convertValueToDoubleForImport(value, doubleValue))
{
doubleValues.push_back(doubleValue);

if (std::isnan(doubleValue) && value != ColumnUtils::emptyValue)
emptyValuesMap.insert(std::make_pair(row, value));
}
else
return false;

row++;
}

return true;
}

// hex should be 4 hexadecimals characters
std::string ColumnUtils::_convertEscapedUnicodeToUTF8(std::string hex)
{
Expand Down
8 changes: 7 additions & 1 deletion CommonData/columnutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

#include <string>
#include <vector>

#include <set>
#include <map>

class ColumnUtils
{
Expand All @@ -28,6 +29,11 @@ class ColumnUtils
static bool convertValueToDoubleForImport( const std::string &strValue, double &doubleValue);
static void convertEscapedUnicodeToUTF8( std::string &inputStr);

static bool convertVecToInt(const std::vector<std::string> &values, std::vector<int> &intValues, std::set<int> &uniqueValues, std::map<int, std::string> &emptyValuesMap);
static bool convertVecToDouble(const std::vector<std::string> &values, std::vector<double> &doubleValues, std::map<int, std::string> &emptyValuesMap);

static std::string doubleToString(double dbl, int precision = 10);

private:
static std::string _deEuropeaniseForImport( const std::string &value);
static std::string _convertEscapedUnicodeToUTF8( std::string hex);
Expand Down
4 changes: 2 additions & 2 deletions CommonData/labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ const Label &Labels::getLabelObjectFromKey(int index) const
return label;
}

Log::log() << "Cannot find entry " << index << std::endl;
/*Log::log() << "Cannot find entry " << index << std::endl;
for(const Label &label: _labels)
{
Log::log() << "Label Value: " << label.value() << ", Text: " << label.text() << std::endl;
}
}*/

throw labelNotFound("Cannot find this entry");
}
Expand Down
Loading