aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Dan Mané <danmane@gmail.com>2016-03-10 13:45:48 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-03-10 14:41:51 -0800
commit6d05cdb80b089ccbf05151101eb4943ffbbb529d (patch)
tree17e5b0279c44dcf99a6eb7530d2bac0204c52d8b
parent7cc6ba76176b84c828dd6b40ec5d2bc0d481f46a (diff)
Ensure that tf-image-dashboard always sorts both runs and tags.
Change: 116904157
-rw-r--r--tensorflow/tensorboard/components/tf-image-dashboard/test/index.html40
-rw-r--r--tensorflow/tensorboard/components/tf-image-dashboard/tf-image-grid.html15
2 files changed, 45 insertions, 10 deletions
diff --git a/tensorflow/tensorboard/components/tf-image-dashboard/test/index.html b/tensorflow/tensorboard/components/tf-image-dashboard/test/index.html
new file mode 100644
index 0000000000..e9658fbd44
--- /dev/null
+++ b/tensorflow/tensorboard/components/tf-image-dashboard/test/index.html
@@ -0,0 +1,40 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <script src="../../webcomponentsjs/webcomponents-lite.min.js"></script>
+ <script src="../../web-component-tester/browser.js"></script>
+ <link rel="import" href="../../polymer/polymer.html">
+ <link rel="import" href="../tf-image-grid.html">
+</head>
+<body>
+ <test-fixture id="imageGridFixture">
+ <template>
+ <tf-image-grid id="test"></tf-image-grid>
+ </template>
+ </test-fixture>
+
+ <script>
+ var assert = chai.assert;
+ describe("tf-image-grid", function() {
+ var imageGrid;
+ var runToImages = {
+ 'run1': ['_', 'foo', 'zzx', '99', 'a', 'aaa', 'azx'],
+ 'aaa': ['a', 'ba', 'ab', 'z'],
+ 'zzz': ['aaa', 'zqx', 'xzx'],
+ };
+ beforeEach(function() {
+ imageGrid = fixture("imageGridFixture")
+ });
+ it("sorts tags", function() {
+ imageGrid.runToImages = runToImages;
+ assert.deepEqual(imageGrid._tags, ["99", "_", "a", "aaa", "ab", "azx", "ba", "foo", "xzx", "z", "zqx", "zzx"]);
+ });
+ it("sorts runs", function() {
+ imageGrid.runToImages = runToImages;
+ assert.deepEqual(imageGrid._runs, ['aaa', 'run1', 'zzz']);
+ });
+ });
+ </script>
+</body>
+</html>
diff --git a/tensorflow/tensorboard/components/tf-image-dashboard/tf-image-grid.html b/tensorflow/tensorboard/components/tf-image-dashboard/tf-image-grid.html
index 0df9b6d080..8aa4848653 100644
--- a/tensorflow/tensorboard/components/tf-image-dashboard/tf-image-grid.html
+++ b/tensorflow/tensorboard/components/tf-image-dashboard/tf-image-grid.html
@@ -39,7 +39,6 @@ is high)
<template
is="dom-repeat"
items="[[_runs]]"
- sort="_sort"
as="run"
>
<div class="run-name-cell noshrink">
@@ -51,7 +50,6 @@ is high)
<template
is="dom-repeat"
items="[[_tags]]"
- sort="_sort"
as="tag"
>
<div class="image-row container noshrink">
@@ -61,7 +59,6 @@ is high)
<template
is="dom-repeat"
items="[[_runs]]"
- sort="_sort"
as="run"
>
<div class="image-cell noshrink">
@@ -153,18 +150,16 @@ is high)
individualImageGenerator: Function,
},
_getTags: function(runToImages) {
- return _.chain(runToImages.base).values().flatten().union().value();
+ var r2i = runToImages.base;
+ return _.chain(r2i).values().flatten().union().value().sort();
},
_getRuns: function(runToImages) {
var r2i = runToImages.base;
- return _.keys(r2i).filter(function(x) {return r2i[x].length > 0;});
+ return _.keys(r2i).filter((x) => r2i[x].length > 0).sort();
},
_exists: function (run, tag, runToImages) {
- runToImages = runToImages.base;
- return runToImages[run].indexOf(tag) !== -1;
- },
- _sort: function(a, b) {
- return a > b;
+ var r2i = runToImages.base;
+ return r2i[run].indexOf(tag) !== -1;
},
});
</script>