Search in sources :

Example 1 with ArrayTermVector

use of nars.subterm.ArrayTermVector in project narchy by automenta.

the class AnonTest method testMixedAnonVector.

@Test
public void testMixedAnonVector() {
    Term[] x = { $.varDep(1), $.varIndep(2), $.varQuery(3), Anom.the(4) };
    Random rng = new XoRoShiRo128PlusRandom(1);
    for (int i = 0; i < 4; i++) {
        ArrayUtils.shuffle(x, rng);
        assertEqual(new UnitSubterm(x[0]), new AnonVector(x[0]));
        assertEqual(new TermVector2(x[0], x[1]), new AnonVector(x[0], x[1]));
        assertEqual(new ArrayTermVector(x), new AnonVector(x));
    }
}
Also used : XoRoShiRo128PlusRandom(jcog.math.random.XoRoShiRo128PlusRandom) AnonVector(nars.term.anon.AnonVector) Random(java.util.Random) XoRoShiRo128PlusRandom(jcog.math.random.XoRoShiRo128PlusRandom) UnitSubterm(nars.subterm.UnitSubterm) ArrayTermVector(nars.subterm.ArrayTermVector) TermVector2(nars.subterm.TermVector2) Test(org.junit.jupiter.api.Test)

Example 2 with ArrayTermVector

use of nars.subterm.ArrayTermVector in project narchy by automenta.

the class TermTest method testHashConsistent.

@Test
public void testHashConsistent() {
    Term x = $.the("z");
    Subterms a = new UnitSubterm(x);
    Subterms b = new ArrayTermVector(x);
    assertEquals(a, b);
    assertEquals(a.hashCode(), b.hashCode());
    assertEquals(a.hashCodeSubterms(), b.hashCodeSubterms());
    assertEquals(a.toString(), b.toString());
}
Also used : Subterms(nars.subterm.Subterms) UnitSubterm(nars.subterm.UnitSubterm) ArrayTermVector(nars.subterm.ArrayTermVector) Test(org.junit.jupiter.api.Test)

Example 3 with ArrayTermVector

use of nars.subterm.ArrayTermVector in project narchy by automenta.

the class AnonTest method testAnomVectorNegations.

@Test
public void testAnomVectorNegations() {
    Term[] x = { Anom.the(3), Anom.the(1), Anom.the(2).neg() };
    AnonVector av = new AnonVector(x);
    assertEquals(new ArrayTermVector(x).toString(), av.toString());
    assertEqual(new ArrayTermVector(x), av);
    Term twoNeg = x[2];
    assertTrue(av.contains(twoNeg));
    assertFalse(av.containsNeg(twoNeg));
    assertTrue(av.containsRecursively(twoNeg));
    assertTrue(av.containsRecursively(twoNeg.neg()), () -> av + " containsRecursively " + twoNeg.neg());
// assertTrue(The.subterms(x) instanceof AnonVector );
}
Also used : AnonVector(nars.term.anon.AnonVector) ArrayTermVector(nars.subterm.ArrayTermVector) Test(org.junit.jupiter.api.Test)

Example 4 with ArrayTermVector

use of nars.subterm.ArrayTermVector in project narchy by automenta.

the class AnonTest method testAnomVector.

@Test
public void testAnomVector() {
    Term[] x = { Anom.the(3), Anom.the(1), Anom.the(2) };
    assertEqual(new UnitSubterm(x[0]), new AnonVector(x[0]));
    assertEqual(new TermVector2(x[0], x[1]), new AnonVector(x[0], x[1]));
    assertEqual(new ArrayTermVector(x), new AnonVector(x));
}
Also used : AnonVector(nars.term.anon.AnonVector) UnitSubterm(nars.subterm.UnitSubterm) ArrayTermVector(nars.subterm.ArrayTermVector) TermVector2(nars.subterm.TermVector2) Test(org.junit.jupiter.api.Test)

Aggregations

ArrayTermVector (nars.subterm.ArrayTermVector)4 Test (org.junit.jupiter.api.Test)4 UnitSubterm (nars.subterm.UnitSubterm)3 AnonVector (nars.term.anon.AnonVector)3 TermVector2 (nars.subterm.TermVector2)2 Random (java.util.Random)1 XoRoShiRo128PlusRandom (jcog.math.random.XoRoShiRo128PlusRandom)1 Subterms (nars.subterm.Subterms)1