def test_find_reln(self): o1 = PSObjectFromStructure(4) o2 = PSObjectFromStructure(8) self.assertTrue(o1.IsKnownAsInstanceOf(CategoryInteger())) self.assertIn(CategoryInteger(), o1.CategoriesSharedWith(o2)) r = o1.GetRelationTo(o2) r.FindCategories(end_category=CategoryInteger()) self.assertTrue(r.IsKnownAsInstanceOf(CategoryInteger.DeltaReln())) self.assertEqual( 4, r.DescribeAs( CategoryInteger.DeltaReln()).Attributes()['delta'].magnitude) self.assertTrue(r.IsKnownAsInstanceOf(CategoryInteger.RatioReln())) self.assertEqual( 2, r.DescribeAs( CategoryInteger.RatioReln()).Attributes()['ratio'].magnitude) o3 = PSObjectFromStructure(3) o4 = PSObjectFromStructure(12) r2 = o3.GetRelationTo(o4) r2.FindCategoriesUsingEndCategories() self.assertEqual( 9, r2.DescribeAs( CategoryInteger.DeltaReln()).Attributes()['delta'].magnitude) self.assertEqual( 4, r2.DescribeAs( CategoryInteger.RatioReln()).Attributes()['ratio'].magnitude)
def test_categories_on_logic(self): c1 = C.RepeatedIntegerCategory() o1 = PSObjectFromStructure((7, 7)) self.assertTrue(o1.DescribeAs(c1)) self.assertTrue(o1.IsKnownAsInstanceOf(c1)) logic = o1.DescribeAs(c1) logic.Attributes()['magnitude'].DescribeAs(CategoryPrime()) self.assertTrue(logic.Attributes()['magnitude'].IsKnownAsInstanceOf( CategoryPrime())) # Get it again, see that the inner categorization has "stuck". logic = o1.DescribeAs(c1) self.assertTrue(logic.Attributes()['magnitude'].IsKnownAsInstanceOf( CategoryPrime()))