Skip to content

Commit faa6f9d

Browse files
committed
showing inferenceType in simulationInfo tab
1 parent 330679e commit faa6f9d

4 files changed

Lines changed: 64 additions & 39 deletions

File tree

src/appController.coffee

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ socr.controller = (model, view) ->
194194
e.preventDefault()
195195

196196
if model.getSample(1) is false
197-
view.handleResponse "<h4 class=\"alert-heading\">No Random samples to infer From!</h4>Please generate some random samples. Click \"back\" button on the controller to go to the \"Generate Random Samples!\" button.", "error", "controller-content"
197+
view.handleResponse "<h4 class=\"alert-heading\">No Random samples to infer From!</h4>Please generate some random samples in Step 2. ", "error", "controller-content"
198198
else
199199
view.toggleControllerHandle "hide"
200200
PubSub.publish "toggleLoadingSpinner" ,{action:'show'}
@@ -248,7 +248,7 @@ socr.controller = (model, view) ->
248248
try
249249
model.generateSample() #generate one sample
250250
$(".removable").remove() #remove the previously generated canvas during animation
251-
PubSub.publish "randomSampleGenerationComplete"
251+
PubSub.publish "randomSampleGenerationComplete", {'sampleCount':model.getRSampleCount()}
252252
catch e
253253
console.log e
254254
view.enableButtons()
@@ -313,7 +313,7 @@ socr.controller = (model, view) ->
313313
d = Date()
314314
console.log "end" + _runsElapsed + d
315315

316-
PubSub.publish "randomSampleGenerationStopped"
316+
PubSub.publish "randomSampleGenerationStopped", {}
317317

318318
clearInterval _id #stop the setinterval function
319319
_runCount = 0
@@ -359,20 +359,11 @@ socr.controller = (model, view) ->
359359
precision = $('#result-precision').attr('checked')
360360
if precision is "checked"
361361
precision = 3
362-
#create dotplot
363-
console.log "setdotplot started"
364-
console.log "variable:" + $("#variable").val()
365-
view.createDotplot
362+
console.log "setdotplot started", "variable:" + $("#variable").val()
363+
model.setInferenceSettings
366364
variable: $("#variable").val()
367365
precision: precision
368366
index: index
369-
#setTimeout (->
370-
# PubSub.publish "Dotplot generated"
371-
# return
372-
#), 500
373-
PubSub.publish "toggleLoadingSpinner" ,{action:'hide'}
374-
375-
376367
return
377368

378369
###

src/appModel.coffee

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ socr.model = ->
1717
# Why there are keys and values? Its because in some form of data input (like coin toss), the "key" contains the symbolic meaningful reference whereas the "value" contains the mathematical equivalent value.
1818

1919
_kvStore = {}
20-
20+
_inferenceSettings =
21+
variable: null
22+
precision: null
23+
index: null
24+
2125
_stopCount = 1000
2226
_count = 0
2327
_n = []
@@ -920,4 +924,16 @@ socr.model = ->
920924
console.log "aboveThreshold : "+_sum
921925
return (_sum > MEM_THRESHOLD)
922926

927+
setInferenceSettings: (setting)->
928+
if setting.variable? or setting.precision? or ( setting.index? and !isNaN(setting.index))
929+
_inferenceSettings =
930+
variable: setting.variable
931+
precision: setting.precision
932+
index: setting.index
933+
PubSub.publish "setInferenceSettingComplete", _inferenceSettings
934+
return true
935+
else
936+
throw new Error("Incorrect arguments")
937+
getInferenceSettings: ->
938+
_inferenceSettings
923939
#return

src/appView.coffee

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ socr.view = (model) ->
5252
config.entries.push obj
5353
obj = {} #destroying the object
5454
i++
55-
$.get "partials/sampleList.tmpl", (data) ->
55+
$.get "dist/partials/sampleList.tmpl", (data) ->
5656
temp = Mustache.render(data, config)
5757
$("#sampleList").html temp
5858

@@ -238,7 +238,6 @@ socr.view = (model) ->
238238
socr.view.showSampleListLoader()
239239
socr.view.updateStatus "started"
240240

241-
242241
PubSub.subscribe "randomSampleGenerationComplete", (msg,data)->
243242
#updating controller view slider
244243
socr.view.updateCtrlMessage "samples generated sucessfully.", "success", 2000
@@ -256,6 +255,10 @@ socr.view = (model) ->
256255
PubSub.subscribe "toggleLoadingSpinner" ,(msg,data)->
257256
socr.view.toggleLoadingSpinner(data)
258257

258+
PubSub.subscribe "setInferenceSettingComplete", (msg, data)=>
259+
socr.view.createDotplot data
260+
socr.view.updateSimulationInfo()
261+
return true
259262
toggleControllerHandle: (action) ->
260263
console.log action
261264
$target = $("#slide-out-controller")
@@ -326,29 +329,40 @@ socr.view = (model) ->
326329
###
327330
@method - reset()
328331
@description: Clears all canvas and div. Resetting the view of the whole App
329-
@dependencies : none
332+
@parameter scope - Array
330333
###
331-
reset: (option) ->
332-
333-
#reset only the samples in the view.
334-
if option isnt "undefined" and option is "samples"
335-
$("#sampleList").html ""
336-
else
337-
338-
#$('#displayCount').html('0'); //resetting the count to 0
334+
reset: (scope=["app"]) ->
335+
_resetSampleScope = ->
339336
$("#sampleList").html "" #clear the sample List dive
340337
$("#showCount").html ""
341338
socr.view.updateSlider()
339+
$(".pagination").html ""
340+
341+
_resetDataScope = ->
342342
$("#dataPlot").html "" #clear dataPlot div
343343
$("#dotplot").empty() #clear dotPlot div
344+
_resetAccordion = ->
344345
$("#accordion").accordion "activate", 0
345-
$(".pagination").html ""
346346
$("#details").html ""
347-
$("#dataset").html ""
348-
349-
# $("#input").inputtable('clear');
350-
_currentValues = []
351-
$("#controller-content").html "<div class=\"alert alert-error\">From the \"data driven\" tab select an experiment or enter data the spreadsheet first!</div>"
347+
348+
scope.forEach (s)->
349+
switch
350+
when s is "sampleslistview"
351+
$("#sampleList").html ""
352+
when s is "randomsamples"
353+
_resetSampleScope()
354+
_resetDataScope()
355+
_resetAccordion()
356+
when s is "app"
357+
_resetSampleScope()
358+
_resetDataScope()
359+
_resetAccordion()
360+
_currentValues = []
361+
$("#controller-content").html "<div class=\"alert alert-error\">From the \"Input\" tab, select an experiment or enter sample data!</div>"
362+
else
363+
echo "."
364+
#$('#displayCount').html('0'); //resetting the count to 0
365+
# $("#input").inputtable('clear');
352366
return
353367

354368

@@ -477,7 +491,7 @@ socr.view = (model) ->
477491
index: _indexes
478492
showBack: showBack
479493

480-
$.get "partials/controller.tmpl", (data) ->
494+
$.get "dist/partials/controller.tmpl", (data) ->
481495
_output = Mustache.render(data, config)
482496
$("#controller-content").html _output
483497
socr.controller.initController()
@@ -592,7 +606,7 @@ socr.view = (model) ->
592606
@return : {boolean}
593607
###
594608
createDotplot: (setting) ->
595-
return false unless setting.variable?
609+
throw new Error("invalid arguments: settings") unless setting.variable?
596610
_currentVariable = setting.variable
597611
$("#accordion").accordion "activate", 2
598612

@@ -759,7 +773,7 @@ socr.view = (model) ->
759773
# }
760774
@updateCtrlMessage "Infer plot created.", "success"
761775
true
762-
776+
PubSub.publish "toggleLoadingSpinner" ,{action:'hide'}
763777

764778
###
765779
@method updateSimulationInfo
@@ -775,13 +789,13 @@ socr.view = (model) ->
775789
catch e
776790
name = "Data Driven Experiment"
777791
config =
792+
variable: socr.model.getInferenceSettings()['variable']
778793
name: name
779794
k: socr.model.getK()
780795
groups: []
781796
results: []
782797
rCount: model.getRSampleCount()
783798

784-
785799
#adding results
786800
if config.k > 1
787801
if socr.model.getPof("dataset") isnt false
@@ -805,9 +819,9 @@ socr.view = (model) ->
805819
i++
806820

807821
#console.log(config);
808-
$.get "partials/info.tmpl", ((data) ->
809-
temp = Mustache.render(data, config)
810-
$("#details").html temp
822+
$.get "dist/partials/info.tmpl", ((data) ->
823+
htmlContent = Mustache.render(data, config)
824+
$("#details").html htmlContent
811825
return
812826
),"html"
813827

src/partials/info.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<td>Experiment Name</td>
66
<td><strong>{{name}}</strong></td>
77
</tr>
8+
<tr>
9+
<td>Inference Type</td>
10+
<td><strong>{{variable}}</strong></td>
11+
</tr>
812
{{#results}}
913
<tr>
1014
<td>{{param}}</td>

0 commit comments

Comments
 (0)