-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug where heatmap filtering would rely on array equality
- Loading branch information
August Toman-Yih and Samuel James Serrano
committed
Nov 9, 2013
1 parent
45cc6e3
commit 9aaf971
Showing
10 changed files
with
132 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
describe('dc.filters', function () { | ||
describe('RangedFilter', function () { | ||
var filter; | ||
beforeEach(function () { | ||
filter = dc.filters.RangedFilter(0, 10); | ||
}); | ||
|
||
it('should act like an array', function () { | ||
expect([filter[0], filter[1]]).toEqual([0, 10]); | ||
}); | ||
|
||
describe("isFiltered", function () { | ||
it('should return false when the number is out of range', function () { | ||
expect(filter.isFiltered(1234)).toBeFalsy(); | ||
}); | ||
|
||
it('should return true when the number is in range', function () { | ||
expect(filter.isFiltered(8.1)).toBeTruthy(); | ||
}); | ||
|
||
it('should include the left bounds', function () { | ||
expect(filter.isFiltered(0)).toBeTruthy(); | ||
}); | ||
|
||
it('should exclude the right bounds', function () { | ||
expect(filter.isFiltered(10)).toBeFalsy(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('TwoDimensionalFilter', function () { | ||
var filter; | ||
beforeEach(function () { | ||
filter = dc.filters.TwoDimensionalFilter([1,2]); | ||
}); | ||
|
||
describe('isFiltered', function () { | ||
it('should return true if both dimensions are equal', function () { | ||
expect(filter.isFiltered([1,2])).toBeTruthy(); | ||
}); | ||
|
||
it('should return false if either dimension is not equal to the filter', function () { | ||
expect(filter.isFiltered([1,5])).toBeFalsy(); | ||
}); | ||
|
||
it('should return false if the dimensionality is less', function () { | ||
expect(filter.isFiltered([1])).toBeFalsy(); | ||
}); | ||
|
||
it('should return false if the dimensionality is more', function () { | ||
expect(filter.isFiltered([1,2,3])).toBeFalsy(); | ||
}); | ||
|
||
it('should return false if the value is not an array', function () { | ||
expect(filter.isFiltered(1)).toBeFalsy(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
dc.filters = {}; | ||
|
||
dc.filters.RangedFilter = function(low, high) { | ||
var range = Array(low, high); | ||
range.isFiltered = function(value) { | ||
return value >= this[0] && value < this[1]; | ||
}; | ||
|
||
return range; | ||
}; | ||
|
||
dc.filters.TwoDimensionalFilter = function(array) { | ||
var filter = array; | ||
filter.isFiltered = function(value) { | ||
return value.length && value.length == filter.length && | ||
value[0] == filter[0] && value[1] == filter[1]; | ||
}; | ||
|
||
return filter; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters