diff --git a/build.gradle b/build.gradle index 26e7d169..f6b5c836 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'eclipse' apply plugin: 'signing' group = 'org.numenta' -version = '0.6.5-SNAPSHOT' +version = '0.6.5' archivesBaseName = 'htm.java' sourceCompatibility = 1.8 @@ -12,7 +12,7 @@ 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' } } diff --git a/pom.xml b/pom.xml index e3a33599..aaacedf3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.numenta htm.java - 0.6.5-SNAPSHOT + 0.6.5 htm.java The Java version of Numenta's HTM technology diff --git a/src/test/java/org/numenta/nupic/network/LayerTest.java b/src/test/java/org/numenta/nupic/network/LayerTest.java index 308b3ab2..11a5c881 100644 --- a/src/test/java/org/numenta/nupic/network/LayerTest.java +++ b/src/test/java/org/numenta/nupic/network/LayerTest.java @@ -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 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() { + @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() { + @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> fieldEncodings = setupMap( diff --git a/vocabulary.dictionary b/vocabulary.dictionary index 2058d137..45573a1a 100644 --- a/vocabulary.dictionary +++ b/vocabulary.dictionary @@ -214,3 +214,5 @@ depolarisation feedforward favour geo +menuitem +jfxtras