Skip to content

Commit ae8efcc

Browse files
FransMeerhoffFransMeerhoff
authored andcommitted
Merge branch 'development'
2 parents 7cbc541 + f0f5363 commit ae8efcc

File tree

195 files changed

+17229
-9370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+17229
-9370
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
## Environment (for bugs)
1+
## Template for bug reports
22
<!--- Include as many relevant details about the environment you experienced the bug in -->
3+
<!--- If possible please attach your data and/or JASP file to the issue -->
4+
<!--- Note that github requires you to zip the file -->
35
* JASP version:
46
* OS name and version:
57
* Analysis:
6-
## Environment (for enhancement requests)
8+
* Steps to reproduce:
9+
10+
## Template for enhancement requests
711
<!--- Give a short and clear description of your enhancement request -->
812
* Enhancement:
913
* Purpose:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ Resources/TestFiles
4444

4545

4646
JASP-Engine/JASP/R/.Rhistory
47+
*.autosave

CHANGES.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11

22
JASP Release Notes
33
==================
4-
4+
5+
Version 0.8.3
6+
-------------
7+
8+
New Features:
9+
10+
- Frequentist Logistic Regression
11+
- Hierarchical model testing for Linear and Logistic Regression
12+
- New Progressbar (implemented for Bayesian ANOVAs and Regression)
13+
- Preference menu - specify missing values and number of decimals
14+
- ANOVA - post-hoc tests, change y-axis label for descriptives plot
15+
- JASPTools package
16+
17+
Changes:
18+
19+
- Remove unused R packages
20+
- Additional Info for T-Test and Correlation Bayesian Pairs Robustness plots (Common module)
21+
22+
523
Version 0.5
624
-----------
725

Docs/development/jasp-adding-module.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ and connect the above slot with the triggered() signal in the `addHelpTab()` fun
9292

9393
connect(newModule, SIGNAL(triggered()), this, SLOT(toggleNewModule()));
9494

95+
Add a declaration of `toggleNewModule()` to the private slots of the TabBar class definition in `tabbar.h`
96+
97+
private slots:
98+
...
99+
void toggleSummaryStats();
100+
void toggleNewModule();
101+
95102

96103
##### Modify the tabChanged function in MainWindow.cpp
97104
`tabChanged()` in MainWindow.cpp contains an if-else ladder for the current Active tab. Add 'New Module' to it.

Docs/development/r-analyses-guide.md

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,38 @@ It is recommended to **only** use `.vf()` for display purposes. Using it to crea
105105

106106
JASP accepts images as SVGs encoded as base64 data URIs. The following functions are useful for creating images in this format.
107107

108-
`.beginSaveImage(width, height)`
109-
`.endSaveImage(descriptor)`
110-
111-
`.beginSaveImage()` starts the image capturing process, and returns a descriptor. Once the analysis has performed all the rendering it needs, it should call `.endSaveImage()`, passing in the descriptor provided by `.beginSaveImage()`. `.endSaveImage()` returns a descriptor which can be assigned to the image object described below.
108+
Recently, we moved to a new system for writing images, to support the saveImage functionality (saving JASP images to a file). Here is the quick overview:
112109

110+
1. Create a `ggplot2` plot in your code. If you're working with (deprecated) base-r plots, wrap your plotting routine in a function (don't choose this option):
111+
```r
112+
p <- ggplot2::ggplot(...)
113+
```
114+
__OR__
115+
```r
116+
.plotFunc() <- function() {
117+
# add plotting routine here
118+
plot(plotData, plotParameters)
119+
}
120+
```
121+
2. Write the image to an object using the function `.writeImage()`:
122+
```r
123+
imgObj <- .writeImage(width = options$plotWidth,
124+
height = options$plotHeight,
125+
plot = p)
126+
```
127+
__OR__
128+
```r
129+
imgObj <- .writeImage(width = options$plotWidth,
130+
height = options$plotHeight,
131+
plot = .plotFunc)
132+
```
133+
3. Extract the necessary information from the image object to your plot object that will go into the output:
134+
```r
135+
plot[["data"]] <- imgObj[["png"]]
136+
plot[["obj"]] <- imgObj[["obj"]]
137+
plot[["convertible"]] <- TRUE
138+
plot[["status"]] <- "complete"
139+
```
113140

114141
### Cleaning data
115142

@@ -200,7 +227,7 @@ An example of a results bundle might be:
200227
- `results` : a results object, descriped below
201228
- `status` : the status, this can be either `"inited"` (typically to be returned when `perform == "init"`) or `"complete"` (typically returned when `perform == "run"`)
202229
- `state` : arbitrary data that can be retrieved in a subsequent call of this analysis with a call to `.retrieveState()`, explained below
203-
- `keep` : a list of file descriptors (from `.endSaveImage()`). This instructs the temporary file system to keep these files, and not delete them.
230+
- `keep` : a list of file descriptors (from `.writeImage()`). This instructs the temporary file system to keep these files, and not delete them.
204231

205232
### Results
206233

@@ -449,7 +476,40 @@ It will return a named list with TRUE/FALSE values indicating which options have
449476

450477
# otherwise continue
451478

452-
### State
479+
Progress bar
480+
------------
481+
482+
If an analysis is going to run for a long time it's nice to give the user some reassurance that something is actually happening. Of course we have the spinner, but this provides no actual progress indication. To this purpose the `.newProgressbar` function can be used. The function takes the following arguments:
483+
484+
- `ticks`: integer specifying the number of times the progress bar needs to be updated to reach completion.
485+
- `callback`: callback function which is supplied to each analysis and described above.
486+
- `skim`: integer specifying the percentage that should be "skimmed" from the total 100%. The progress bar generally captures only some portion of an analysis. If the remainder might also take some time we can reserve a portion of the progress bar. Default percentage is `5`.
487+
- `response`: boolean, should the progressbar return the response of the callback? Default is `FALSE`.
488+
489+
Note that `.newProgressbar` itself returns a function. This function takes the optional arguments:
490+
491+
- `results`: results list. See above to read more about the results list structure.
492+
- `complete`: boolean specifying if the progress bar should be forced to immediate (premature) completion.
493+
494+
### Example:
495+
496+
A typical analysis that takes a while is the Bayesian ANOVA.
497+
Now, there are parts of this analysis that go quite quick; calculating descriptives or effects takes no time.
498+
The model calculation is slow, however, in this part of the code a progress indicator makes a lot sense.
499+
Say we have the number of models we will calculate stored in `nModels`. Before the first model is calculated we then run
500+
```
501+
progressbar <- .newProgressbar(ticks=nModels, callback=callback)
502+
```
503+
Now after each calculated model we simply call
504+
```
505+
progressbar()
506+
```
507+
to update the progress.
508+
509+
If we want to make the analysis responsive to user changes we can set `response` to `TRUE` and check the callback output as described above.
510+
511+
State
512+
-----
453513

454514
The state is a storage system. This storage can be used to transfer useful data between different calls to an analysis.
455515
The main goal of the state is to prevent recalculating things that were already calculated once (and thus make analyses quicker). Let's use the Bayesian ANOVA as an example of its practical relevance. This analysis may take up to several minutes to fully calculate its result -- which is not that unusual for a Bayesian analysis. Now if a user decides he would also like to see descriptive statistics the analysis will be run again. If we had no storage system in place it would take several minutes to give an additional table with descriptive statistics because the ANOVA has to be calculated all over again -- eventhough we already did this. With the state system it becomes possible to store the outcome of the ANOVA and then re-use it. Asking for additional output such as a descriptives table will now result in a very short calculation because the ANOVA calculation can be avoided. It may be clear that it is not always possible to re-use output from an earlier call to the analysis. For example, if the dependent variable of the ANOVA is swapped for a different one, the old results become unusable.
@@ -473,12 +533,10 @@ attr(state, "key") <- stateKey
473533
```
474534

475535
Now if the analysis is called again and e.g. `sampleMode` changes, only the plot will be returned.
476-
If there are state items you would like to keep indefinitely -- regardless of the options a user changes -- you may also specify this in the state, e.g.:
477-
```
478-
attr(state, "keep") <- c("model", "options")
479-
```
536+
If there are state items you would like to keep indefinitely -- regardless of the options a user changes -- you must omit these in the stateKey.
480537

481-
### Error handling
538+
Error handling
539+
--------------
482540

483541
#### Checking for errors
484542

JASP-Common/analysis.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,31 @@
2121
#include <boost/foreach.hpp>
2222

2323
#include "options/options.h"
24+
#include "tempfiles.h"
25+
#include "appinfo.h"
2426

2527
using namespace boost::uuids;
2628
using namespace boost;
2729
using namespace std;
2830

29-
Analysis::Analysis(int id, string name, Options *options, Version version, bool autorun, bool usedata)
31+
Analysis::Analysis(int id, string name, Options *options, const Version &version, bool autorun, bool usedata)
3032
{
3133
_id = id;
3234
_name = name;
3335
_options = options;
3436
_autorun = autorun;
3537
_usedata = usedata;
3638
_version = version;
37-
39+
_results = Json::nullValue;
40+
_imgResults = Json::nullValue;
41+
_userData = Json::nullValue;
42+
_saveImgOptions = Json::nullValue;
3843
_revision = 0;
3944

4045
_options->changed.connect(boost::bind(&Analysis::optionsChangedHandler, this, _1));
4146

4247
_status = Empty;
48+
_progress = -1;
4349
}
4450

4551
Analysis::~Analysis()
@@ -62,9 +68,10 @@ void Analysis::scheduleRun()
6268
optionsChanged(this);
6369
}
6470

65-
void Analysis::setResults(Json::Value results)
71+
void Analysis::setResults(Json::Value results, int progress)
6672
{
6773
_results = results;
74+
_progress = progress;
6875
resultsChanged(this);
6976
}
7077

@@ -124,6 +131,7 @@ Json::Value Analysis::asJSON() const
124131

125132
analysisAsJson["id"] = _id;
126133
analysisAsJson["name"] = _name;
134+
analysisAsJson["progress"] = _progress;
127135
analysisAsJson["version"] = _version.asString();
128136
analysisAsJson["results"] = _results;
129137

@@ -193,6 +201,11 @@ Analysis::Status Analysis::status() const
193201

194202
void Analysis::setStatus(Analysis::Status status)
195203
{
204+
if ((status == Analysis::Running || status == Analysis::Initing) && _version != AppInfo::version)
205+
{
206+
tempfiles_deleteList(tempfiles_retrieveList(_id));
207+
_version = AppInfo::version;
208+
}
196209
_status = status;
197210
}
198211

JASP-Common/analysis.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Analysis
3131

3232
enum Status { Empty, Initing, Inited, InitedAndWaiting, Running, Complete, Aborting, Aborted, Error, SaveImg, Exception };
3333

34-
Analysis(int id, std::string name, Options *options, Version version, bool isAutorun = true, bool usedata = true);
34+
Analysis(int id, std::string name, Options *options, const Version &version, bool isAutorun = true, bool usedata = true);
3535
virtual ~Analysis();
3636

3737
Options *options() const;
@@ -43,7 +43,7 @@ class Analysis
4343
boost::signals2::signal<void (Analysis *source)> resultsChanged;
4444
boost::signals2::signal<void (Analysis *source)> userDataLoaded;
4545

46-
void setResults(Json::Value results);
46+
void setResults(Json::Value results, int progress = -1);
4747
void setImageResults(Json::Value results);
4848
void setUserData(Json::Value userData, bool silient = false);
4949
const Json::Value &results() const;
@@ -89,6 +89,7 @@ class Analysis
8989
Json::Value _imgResults;
9090
Json::Value _userData;
9191
Json::Value _saveImgOptions;
92+
int _progress;
9293

9394
int callback(Json::Value results);
9495

JASP-Common/analysisloader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222

2323
#include "dirs.h"
2424
#include "version.h"
25+
#include "appinfo.h"
2526

2627
using namespace std;
2728
using namespace boost;
2829

29-
Analysis *AnalysisLoader::load(int id, string analysisName, Json::Value *data)
30+
Analysis *AnalysisLoader::load(int id, string analysisName, const Version &version, Json::Value *data)
3031
{
3132
Options *options = new Options();
3233

@@ -47,7 +48,6 @@ Analysis *AnalysisLoader::load(int id, string analysisName, Json::Value *data)
4748

4849
bool autorun = analysisDesc.get("autorun", false).asBool();
4950
bool usedata = analysisDesc.get("usedata", true).asBool();
50-
Version version = Version(analysisDesc.get("version", "0.00").asString());
5151

5252
if (data != NULL)
5353
options->set(*data);

JASP-Common/analysisloader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
#define ANALYSISLOADER_H
2020

2121
#include "analysis.h"
22+
#include "version.h"
2223

2324
class AnalysisLoader
2425
{
2526
public:
2627

27-
static Analysis *load(int id, std::string analysisName, Json::Value* data = NULL);
28+
static Analysis *load(int id, std::string analysisName, const Version& version, Json::Value* data = NULL);
2829

2930
};
3031

JASP-Common/appinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include "appinfo.h"
1919

20-
const Version AppInfo::version = Version(0, 8, 2, 255);
20+
const Version AppInfo::version = Version(0, 8, 3, 255);
2121
const std::string AppInfo::name = "JASP";
2222
const std::string AppInfo::builddate = __DATE__ " " __TIME__ " (Netherlands)" ;
2323

0 commit comments

Comments
 (0)