Skip to content

Commit 9139799

Browse files
Merge pull request #10 from jwshi21/cache_fix
fix caching bug when changing tensor order in-place
2 parents 5e732b3 + 1e7067e commit 9139799

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

javascripts/demo.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,11 @@ function demo() {
234234
if (order > 0) {
235235
var listId = "dims" + t;
236236
var formatNameId = "format" + t;
237-
var formatName = tblFormatsView.namesCache.hasOwnProperty(t) ?
238-
tblFormatsView.namesCache[t] : "Dense array";
237+
var namesList = tblFormatsView.getFormatNamesList(order);
238+
239+
var nameCached = (cached && tblFormatsView.namesCache.hasOwnProperty(t) &&
240+
namesList.concat(["Custom"]).includes(tblFormatsView.namesCache[t]));
241+
var formatName = nameCached ? tblFormatsView.namesCache[t] : "Dense array";
239242

240243
listTensorsBody += "<tr>";
241244
listTensorsBody += "<td class=\"mdl-data-table__cell--non-numeric\" ";
@@ -265,7 +268,7 @@ function demo() {
265268
listTensorsBody += formatNameId;
266269
listTensorsBody += "\">";
267270

268-
for (var name of tblFormatsView.getFormatNamesList(order)) {
271+
for (var name of namesList) {
269272
listTensorsBody += "<li><a id=\"";
270273
listTensorsBody += formatNameId + "_" + name + "\" >";
271274
listTensorsBody += name + "</a></li>";
@@ -380,6 +383,7 @@ function demo() {
380383

381384
for (t in model.input.tensorOrders) {
382385
if (model.input.tensorOrders[t] > 0) {
386+
tblFormatsView.insertNamesCacheEntry(t, $("#format" + t).val());
383387
tblFormatsView.insertLevelsCacheEntry(t,
384388
tblFormatsView.createEntryFromId("dims" + t));
385389
}

0 commit comments

Comments
 (0)