numenta / htm.java

Hierarchical Temporal Memory implementation in Java - an official Community-Driven Java port of the Numenta Platform for Intelligent Computing (NuPIC).
GNU Affero General Public License v3.0
310 stars 160 forks source link

Tests failed #549

Open MaJeg opened 5 years ago

MaJeg commented 5 years ago

I cloned the git repository with git clone https://github.com/numenta/htm.java.git Then, when running gradle -Pskipbench check, I have two failed tests :

org.numenta.nupic.BitHistoryTest > testPFormatArray FAILED
    org.junit.ComparisonFailure at BitHistoryTest.java:22

org.numenta.nupic.monitor.mixin.MonitoredTemporalMemoryTest > test_mmPrettyPrintConnections FAILED
    java.lang.AssertionError at MonitoredTemporalMemoryTest.java:42
654 tests completed, 2 failed
:test FAILED 

I tested with java 8 and java 11 it didn't change anything, I have Ubuntu 18.04.

msche commented 5 years ago

I encountered a similar problem within this test and it seems to be caused by the locale settings. It expects that the decimal seperator is a . but for certain locales it is ,.

I quick fixed this locally by changing the test in BitHistory in

    @Test
    public void testPFormatArray() {
        BitHistory history = new BitHistory(null, 1, 1);
        Method m = null;
        try {
            m = BitHistory.class.getDeclaredMethod("pFormatArray", new Class[] {double[].class});
            m.setAccessible(true);
            double[] da = { 2.0, 4.0 };
            String output = (String)m.invoke(history, da);

            // Correct for locale
            DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance();
            char decimalSeparator = symbols.getDecimalSeparator();

            assertEquals("[ 2" +decimalSeparator + "00 4" + decimalSeparator + "00 ]", output);
        }catch(Exception e) {
            e.printStackTrace();
        }
    }

ps: saw just that there is already a pull request for fixing this issue: https://github.com/numenta/htm.java/pull/536