Skip to content

Commit

Permalink
Code clean up, add notes and todos
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed Jan 2, 2015
1 parent e65cd3b commit 5fb02f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/main/java/org/numenta/nupic/encoders/DateEncoder.java
Expand Up @@ -100,8 +100,7 @@ public class DateEncoder extends Encoder<Date> {
protected Tuple timeOfDay;
protected ScalarEncoder timeOfDayEncoder;

protected List<EncoderTuple> childEncoders = new ArrayList<EncoderTuple>();
protected List<Integer> customDaysList = new ArrayList<Integer>();
protected List<Integer> customDaysList = new ArrayList<>();

// Currently the only holiday we know about is December 25
// holidays is a list of holidays that occur on a fixed date every year
Expand Down Expand Up @@ -141,9 +140,12 @@ public void init() {

// Adapted from MultiEncoder
// TODO figure out why a initial EncoderTuple
encoders = new LinkedHashMap<EncoderTuple, List<EncoderTuple>>();
encoders = new LinkedHashMap<>();
encoders.put(new EncoderTuple("", this, 0), new ArrayList<EncoderTuple>());

// Note: The order of adding encoders matters, must be in the following
// season, dayOfWeek, weekend, customDays, holiday, timeOfDay

if(isValidEncoderPropertyTuple(season)) {
seasonEncoder = ScalarEncoder.builder()
.w((int) season.get(0))
Expand Down Expand Up @@ -414,10 +416,10 @@ public List<String> getEncodedValues(Date inputData) {
//TODO check null (if date is null, it acts like new DateTime())
if(inputData == null) {
//TODO return a proper fallback value
return new ArrayList<String>();
return new ArrayList<>();
}

List<String> values = new ArrayList<String>();
List<String> values = new ArrayList<>();

DateTime date = new DateTime(inputData);

Expand Down Expand Up @@ -503,6 +505,8 @@ public List<String> getEncodedValues(Date inputData) {
return values;
}

//TODO Should delegate Encoder.getScalarNames() to Encoder.getScalarNames(null) ?

@Override
public <S> List<S> getBucketValues(Class<S> returnType) {
return null;
Expand Down
Expand Up @@ -73,7 +73,7 @@ public void testDateEncoder() {
assertNotNull(descs);
// should be [("season", 0), ("day of week", 12), ("weekend", 19), ("time of day", 25)]

List<Tuple> expectedDescs = new ArrayList<Tuple>(Arrays.asList(
List<Tuple> expectedDescs = new ArrayList<>(Arrays.asList(
new Tuple(2, "season", 0),
new Tuple(2, "day of week", 12),
new Tuple(2, "weekend", 19),
Expand Down

0 comments on commit 5fb02f6

Please sign in to comment.