Skip to content

Commit

Permalink
conditional boxplot crashes with time-grouped variables GeoDaCenter#2279
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 committed Nov 21, 2020
1 parent 4760bdc commit 53890c3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
4 changes: 1 addition & 3 deletions Algorithms/redcap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ double FullOrderALKRedCap::UpdateClusterDist(int cur_id, int o_id, int d_id, boo
sumval_c_d += dist_matrix[clst_ids[i]] [clst_ids[j]];
}
}
new_dist = (d_c_o * clst_nodenum[o_id] * clst_nodenum[cur_id] + sumval_c_d) / ((clst_nodenum[o_id] + clst_nodenum[d_id]) * clst_nodenum[cur_id]);
new_dist = (d_c_o * clst_nodenum[o_id] + (sumval_c_d / clst_nodenum[cur_id])) / (clst_nodenum[o_id] + clst_nodenum[d_id]);

}
return new_dist;
Expand Down Expand Up @@ -1315,8 +1315,6 @@ void FullOrderWardRedCap::Clustering()
ids[i] = orig_id;
}
}
//ids[dest_id] = orig_id;
//std::cout <<"48-12:" << dist_matrix[48][12] << std::endl;
cluster_nodenum[orig_id] += cluster_nodenum[dest_id];
cluster_nodenum[dest_id] = 0; // no need to check with dest_id anymore?

Expand Down
37 changes: 35 additions & 2 deletions Explore/ConditionalBoxPlotView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,39 @@ ConditionalBoxPlotCanvas::~ConditionalBoxPlotCanvas()
{
}

void ConditionalBoxPlotCanvas::TimeChange()
{
LOG_MSG("Entering ConditionalNewCanvas::TimeChange");
if (!is_any_sync_with_global_time) return;

int cts = project->GetTimeState()->GetCurrTime();
int ref_time = var_info[ref_var_index].time;
int ref_time_min = var_info[ref_var_index].time_min;
int ref_time_max = var_info[ref_var_index].time_max;

if ((cts == ref_time) ||
(cts > ref_time_max && ref_time == ref_time_max) ||
(cts < ref_time_min && ref_time == ref_time_min)) return;
if (cts > ref_time_max) {
ref_time = ref_time_max;
} else if (cts < ref_time_min) {
ref_time = ref_time_min;
} else {
ref_time = cts;
}
for (size_t i=0; i<var_info.size(); i++) {
if (var_info[i].sync_with_global_time) {
var_info[i].time = ref_time + var_info[i].ref_time_offset;
}
}
UpdateNumVertHorizCats();
InitBoxPlot();
invalidateBms();
PopulateCanvas();
Refresh();
LOG_MSG("Exiting ConditionalNewCanvas::TimeChange");
}

void ConditionalBoxPlotCanvas::InitBoxPlot()
{
// Init box plots (data and stats) by rows and columns
Expand Down Expand Up @@ -125,7 +158,7 @@ void ConditionalBoxPlotCanvas::InitBoxPlot()
// undef is full with size = num_obs
std::vector<bool> undefs(num_obs, false);
for (int i=0; i<num_obs; i++) {
undefs[i] = undefs[i] || data_undef[BOX_VAR][t][i];
undefs[i] = undefs[i] || data_undef[BOX_VAR][dt][i];
}
// compute hinge stats for each cell
hinge_stats.clear();
Expand Down Expand Up @@ -726,7 +759,7 @@ void ConditionalBoxPlotFrame::UpdateContextMenuItems(wxMenu* menu)
/** Implementation of TimeStateObserver interface */
void ConditionalBoxPlotFrame::update(TimeState* o)
{
template_canvas->TimeChange();
((ConditionalBoxPlotCanvas*)template_canvas)->TimeChange();
UpdateTitle();
}

Expand Down
1 change: 1 addition & 0 deletions Explore/ConditionalBoxPlotView.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ConditionalBoxPlotCanvas : public ConditionalNewCanvas {
virtual wxString GetVariableNames();
virtual void SetCheckMarks(wxMenu* menu);
virtual void update(HLStateInt* o);
virtual void TimeChange();
virtual void ResizeSelectableShps(int virtual_scrn_w = 0,
int virtual_scrn_h = 0);
//virtual void UpdateSelection(bool shiftdown = false,
Expand Down

0 comments on commit 53890c3

Please sign in to comment.