Open asongtoruin opened 4 months ago
Yes good point - are you using custom segments in landuse (meaning this is a critical issue), or is this just something you've noticed to fix in future? I'll try to get to it today either way but I've got lots of meetings.
Yes we're using custom segments in Land-Use - that was the original suggested approach we were given, from memory?
Yes that's no problem, I'll try and get that fixed now, sorry all of this is very much making adjustments in half hour spurts between other stuff!
@isaac-tfn I think this is again only in the rewrite_exclusions branch, though I'm not certain here.
At present when we do any process that uses
DVector._generic_dunder
, non-matching segmentation results inDVector.expand_to_other
being called:https://github.com/Transport-for-the-North/caf.core/blob/3f0deab3c85d814f058c5a8bfb131b3a24ed690d/src/caf/core/data_structures.py#L633-L634
This in turn calls
DVector.add_segment
with the results ofother.segmentation - self.segmentation
:https://github.com/Transport-for-the-North/caf.core/blob/3f0deab3c85d814f058c5a8bfb131b3a24ed690d/src/caf/core/data_structures.py#L922-L927
Which in turn calls
Segmentation.add_segment
:https://github.com/Transport-for-the-North/caf.core/blob/3f0deab3c85d814f058c5a8bfb131b3a24ed690d/src/caf/core/data_structures.py#L908
Which looks like this:
https://github.com/Transport-for-the-North/caf.core/blob/3f0deab3c85d814f058c5a8bfb131b3a24ed690d/src/caf/core/segmentation.py#L539-L587
The issue here is that
other.segmentation - self.segmentation
always returns strings, as defined throughSegmentation.__sub__
:https://github.com/Transport-for-the-North/caf.core/blob/3f0deab3c85d814f058c5a8bfb131b3a24ed690d/src/caf/core/segmentation.py#L477-L478
So any
DVector
with a custom segment will immediately throw an error, because it can't be found throughSegmentSuper
. What we really need is forexpand_to_other
to actually pass through theSegment
objects, rather than just their name. Maybe something like: