Skip to content

Commit

Permalink
Merge pull request #357 from cogmission/v0.6.5-alpha-prep
Browse files Browse the repository at this point in the history
prep for new version
  • Loading branch information
rhyolight committed Nov 11, 2015
2 parents b2fcf6a + 81a77f2 commit 3f0d9f7
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ apply plugin: 'eclipse'
apply plugin: 'signing'

group = 'org.numenta'
version = '0.6.5-SNAPSHOT'
version = '0.6.5'
archivesBaseName = 'htm.java'

sourceCompatibility = 1.8
targetCompatibility = 1.8

jar {
manifest {
attributes 'Implementation-Title': 'htm.java', 'Implementation-Version': '0.6.5-SNAPSHOT'
attributes 'Implementation-Title': 'htm.java', 'Implementation-Version': '0.6.5'
}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.numenta</groupId>
<artifactId>htm.java</artifactId>
<version>0.6.5-SNAPSHOT</version>
<version>0.6.5</version>
<name>htm.java</name>
<description>The Java version of Numenta's HTM technology</description>

Expand Down
109 changes: 109 additions & 0 deletions src/test/java/org/numenta/nupic/network/LayerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,115 @@ public void onNext(Inference i) {
e.printStackTrace();
}
}

@Test
public void testMissingEncoderMap() {
Parameters p = NetworkTestHarness.getParameters().copy();
//p = p.union(NetworkTestHarness.getHotGymTestEncoderParams());
p.setParameterByKey(KEY.RANDOM, new MersenneTwister(42));
p.setParameterByKey(KEY.COLUMN_DIMENSIONS, new int[] { 2048 });
p.setParameterByKey(KEY.POTENTIAL_RADIUS, 200);
p.setParameterByKey(KEY.INHIBITION_RADIUS, 50);
p.setParameterByKey(KEY.GLOBAL_INHIBITIONS, true);

// System.out.println(p);

Map<String, Object> params = new HashMap<>();
params.put(KEY_MODE, Mode.PURE);
params.put(KEY_WINDOW_SIZE, 3);
params.put(KEY_USE_MOVING_AVG, true);
Anomaly anomalyComputer = Anomaly.create(params);

Layer<?> l = Network.createLayer("TestLayer", p)
.alterParameter(KEY.AUTO_CLASSIFY, true)
.add(anomalyComputer)
.add(new TemporalMemory())
.add(new SpatialPooler())
.add(Sensor.create(
FileSensor::create,
SensorParams.create(
Keys::path, "", ResourceLocator.path("rec-center-hourly-small.csv"))));

l.getConnections().printParameters();

l.subscribe(new Observer<Inference>() {
@Override public void onCompleted() {}
@Override public void onError(Throwable e) { System.out.println("error: " + e.getMessage()); e.printStackTrace();}
@Override
public void onNext(Inference i) {
if(flowReceived) return; // No need to set this value multiple times

flowReceived = i.getClassifiers().size() == 4 &&
i.getClassifiers().get("timestamp") != null &&
i.getClassifiers().get("consumption") != null;
}
});

try {
l.close();
fail();
}catch(Exception e) {
assertEquals("Cannot initialize this Sensor's MultiEncoder with a null settings", e.getMessage());
}

try {
assertFalse(flowReceived);
}catch(Exception e) {
e.printStackTrace();
}

////////////////// Test catch with no Sensor ////////////////////

p = NetworkTestHarness.getParameters().copy();
//p = p.union(NetworkTestHarness.getHotGymTestEncoderParams());
p.setParameterByKey(KEY.RANDOM, new MersenneTwister(42));
p.setParameterByKey(KEY.COLUMN_DIMENSIONS, new int[] { 2048 });
p.setParameterByKey(KEY.POTENTIAL_RADIUS, 200);
p.setParameterByKey(KEY.INHIBITION_RADIUS, 50);
p.setParameterByKey(KEY.GLOBAL_INHIBITIONS, true);

params = new HashMap<>();
params.put(KEY_MODE, Mode.PURE);
params.put(KEY_WINDOW_SIZE, 3);
params.put(KEY_USE_MOVING_AVG, true);
anomalyComputer = Anomaly.create(params);

l = Network.createLayer("TestLayer", p)
.alterParameter(KEY.AUTO_CLASSIFY, true)
.add(anomalyComputer)
.add(new TemporalMemory())
.add(new SpatialPooler())
.add(anomalyComputer)
.add(MultiEncoder.builder().name("").build());

l.getConnections().printParameters();

l.subscribe(new Observer<Inference>() {
@Override public void onCompleted() {}
@Override public void onError(Throwable e) { System.out.println("error: " + e.getMessage()); e.printStackTrace();}
@Override
public void onNext(Inference i) {
if(flowReceived) return; // No need to set this value multiple times

flowReceived = i.getClassifiers().size() == 4 &&
i.getClassifiers().get("timestamp") != null &&
i.getClassifiers().get("consumption") != null;
}
});

try {
l.close();
fail();
}catch(Exception e) {
assertEquals("No field encoding map found for specified MultiEncoder", e.getMessage());
}

try {
assertFalse(flowReceived);
}catch(Exception e) {
e.printStackTrace();
}
}

private Parameters getArrayTestParams() {
Map<String, Map<String, Object>> fieldEncodings = setupMap(
Expand Down
2 changes: 2 additions & 0 deletions vocabulary.dictionary
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,5 @@ depolarisation
feedforward
favour
geo
menuitem
jfxtras

0 comments on commit 3f0d9f7

Please sign in to comment.