Moves dummies from coords_src to coords_dest. ! This function only works for dummies placed as placeholders that are completing programs. ! -> Does not work for moved tokens that have sibling relationships to each others and does not update dummies' chil
(self, coords_src, coords_dest, do_update_relationships_pos = True, do_fill_with_void = True)
| 1283 | # -------- MISCELLANEOUS-------- |
| 1284 | |
| 1285 | def move_dummies (self, coords_src, coords_dest, do_update_relationships_pos = True, do_fill_with_void = True): |
| 1286 | """ |
| 1287 | Moves dummies from coords_src to coords_dest. |
| 1288 | ! This function only works for dummies placed as placeholders that are completing programs. ! |
| 1289 | -> Does not work for moved tokens that have sibling relationships to each others |
| 1290 | and does not update dummies' children nor their ancestors. This function works for |
| 1291 | dummies completing programs as they do not have children, do not have parent dummies |
| 1292 | nor sibling dummies. |
| 1293 | Parameters |
| 1294 | ---------- |
| 1295 | coords_src : numpy.array of shape (2, ?) of int |
| 1296 | Coords of tokens to move, 0th array in batch dim and 1th array in time dim. |
| 1297 | coords_dest : numpy.array of shape (2, ?) of int |
| 1298 | Coords where to move tokens, 0th array in batch dim and 1th array in time dim. |
| 1299 | do_update_relationships_pos : bool |
| 1300 | If True, updates position of moved tokens in other tokens representing family relationships |
| 1301 | (parent, siblings,). |
| 1302 | ! Does not update siblings relationships between moved tokens and does not update children. ! |
| 1303 | do_fill_with_void : bool |
| 1304 | If True, fills coords_src with void of invalid tokens after move where there is no overlap |
| 1305 | between src and dest. |
| 1306 | """ |
| 1307 | |
| 1308 | # ---------------------------------------------------------------- |
| 1309 | # ------------------------ COPYING TOKENS ------------------------ |
| 1310 | # ---------------------------------------------------------------- |
| 1311 | |
| 1312 | # ------------ Index in library ------------ |
| 1313 | self.tokens.idx [tuple(coords_dest)] = self.tokens.idx [tuple(coords_src)] |
| 1314 | # ------------ non_positional properties ------------ |
| 1315 | self.tokens.arity [tuple(coords_dest)] = self.tokens.arity [tuple(coords_src)] |
| 1316 | self.tokens.complexity [tuple(coords_dest)] = self.tokens.complexity [tuple(coords_src)] |
| 1317 | self.tokens.var_type [tuple(coords_dest)] = self.tokens.var_type [tuple(coords_src)] |
| 1318 | self.tokens.var_id [tuple(coords_dest)] = self.tokens.var_id [tuple(coords_src)] |
| 1319 | self.tokens.behavior_id [tuple(coords_dest)] = self.tokens.behavior_id [tuple(coords_src)] |
| 1320 | self.tokens.is_power [tuple(coords_dest)] = self.tokens.is_power [tuple(coords_src)] |
| 1321 | self.tokens.power [tuple(coords_dest)] = self.tokens.power [tuple(coords_src)] |
| 1322 | |
| 1323 | # ------------ semi_positional properties ------------ |
| 1324 | self.tokens.is_constraining_phy_units [tuple(coords_dest)] = self.tokens.is_constraining_phy_units [tuple(coords_src)] |
| 1325 | self.tokens.phy_units [tuple(coords_dest)] = self.tokens.phy_units [tuple(coords_src)] |
| 1326 | |
| 1327 | # ------------ Positional properties ------------ |
| 1328 | # Must not be copied |
| 1329 | #self.tokens.pos [tuple(coords_dest)] = self.tokens.pos [tuple(coords_src)] |
| 1330 | #self.tokens.pos_batch [tuple(coords_dest)] = self.tokens.pos_batch [tuple(coords_src)] |
| 1331 | # ---- Depth ---- |
| 1332 | self.tokens.depth [tuple(coords_dest)] = self.tokens.depth [tuple(coords_src)] |
| 1333 | # ---- Family relationships ---- |
| 1334 | # Token family relationships: family mask |
| 1335 | self.tokens.has_parent_mask [tuple(coords_dest)] = self.tokens.has_parent_mask [tuple(coords_src)] |
| 1336 | self.tokens.has_siblings_mask [tuple(coords_dest)] = self.tokens.has_siblings_mask [tuple(coords_src)] |
| 1337 | self.tokens.has_children_mask [tuple(coords_dest)] = self.tokens.has_children_mask [tuple(coords_src)] |
| 1338 | self.tokens.has_ancestors_mask [tuple(coords_dest)] = self.tokens.has_ancestors_mask [tuple(coords_src)] |
| 1339 | # Token family relationships: pos |
| 1340 | self.tokens.parent_pos [tuple(coords_dest)] = self.tokens.parent_pos [tuple(coords_src)] |
| 1341 | self.tokens.siblings_pos [tuple(coords_dest)] = self.tokens.siblings_pos [tuple(coords_src)] |
| 1342 | self.tokens.children_pos [tuple(coords_dest)] = self.tokens.children_pos [tuple(coords_src)] |
no test coverage detected