Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Added TX branching measurement #106

Open
wants to merge 1 commit into
base: task_morphology
Choose a base branch
from

Conversation

portaloffreedom
Copy link
Member

@portaloffreedom portaloffreedom commented Aug 5, 2020

Adding new measurements

  • TX branching (old one was only X branching)
  • Folding

@@ -101,6 +102,7 @@ def test_measurements_body(self):
self.assertAlmostEqual(connectivity2_abs, m.extensiveness, 3)
# self.assertAlmostEqual(connectivity3, m., 3)
self.assertAlmostEqual(connectivity4, m.branching_modules_count, 3)
self.assertAlmostEqual(connectivity5, m.tx_branching_modules_count, 3)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not assertEqual?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because these are floating point values

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a counter a floating point value, can you count half branching modules?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, this is an integer counter :/

Copy link

@DaanZ DaanZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit confused about the is folding function:
Why the overwriting in CoreModule

I would think that it is not necessary to iterate the all the children to figure out if it is a folding point.
Check if the module has two childs, check that they are not opposite.
But maybe I am too short-sighted on this.

if child is None:
continue
# ignore TouchSensor and BrickSensor modules
if isinstance(child, TouchSensorModule) or \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could inherit TouchSensorModule from SensorModule (create new class) and inherit BrickSensorModule from SensorModule so you only have to do one check instead of two.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, good point. But I'm not going to touch that right now. It's out of scope and I'm afraid I'm going to break stuff

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could literaly do

class SensorModule:
pass

class TouchSensorModule(SensorModule):
....

class BrickSensorModule(SensorModule):
...

But yeah, that is up to you.

else:
# More than 2 children, this is not a fold
return False
if parent_slot is None or target_slot is None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always trigger when only the parent_slot is filled in the first iteration that a viable child is set as the parent_slot at line 348.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? This if will trigger if I've found both a first and a second child, at least that was my intention.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's say we are in the first iteration of this for loop and it found a viable child and we are saving the slot of this child at line 348. Then now we come to 354 and we say that this statement is true, since the target slot is still unfilled, then we return false, I do not think this is expected behavior.

return False
if parent_slot is None or target_slot is None:
return False
return parent_slot.opposite() != target_slot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only trigger after executing line 350 is executed, but this does not necessarily need to be opposite right? After that it cannot be changed since you already return that it is False.
Overall very confused by this entire function.

# The CoreModule does not have a parent module
return super(CoreModule, self).count_module_connections() - 1

def is_folding(self) -> bool:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does is_folding need to be overwritten by CoreModule?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in the other function I assume you always have one connection already, which is the connection to the parent. In this case the assumption is broken.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything we can reuse?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants