You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
generate_candidate_edge in spans.py should be a class CandidateEdge, and rather than returning None as the silent negative case if a negative if statement (awful double negative!) it should set a property is_valid based on the three test conditions
in fact, is_valid can be a method which hides the 3 conditions out of the control flow of the init method
...and then the init method should end with a simple if self.is_valid(): before setting value (if not valid then the value was initialised as None)
set value as None at the class level to make it default
check generate_candidate_edge is only used in spans.assemble_spans
rather than if edge is not None (which itself could just be if edge), use a listcomp
in fact the whole block could be passed to the method at once rather than repeatedly looping in and passing the same parameters, so the listcomp will probably have a couple of layers
The syntax for this is [x for x in top_level_list for sublist in top_level_list] so here it’d be:
However this instantiates the Edge class twice! This could in fact be a good use for the walrus operator, though it’d technically become a generator expression within a listcomp (the listcomp is just the is_valid filter part)
Also think about renaming cinfo_list to contours? Double check what’s actually in the variable (it’s been named to emphasise it’s a list but type annotations could do that)
The text was updated successfully, but these errors were encountered:
generate_candidate_edge
inspans.py
should be a classCandidateEdge
, and rather than returningNone
as the silent negative case if a negative if statement (awful double negative!) it should set a propertyis_valid
based on the three test conditionsis_valid
can be a method which hides the 3 conditions out of the control flow of the init method...and then the init method should end with a simple
if self.is_valid():
before settingvalue
(if not valid then the value was initialised as None)value
asNone
at the class level to make it defaultgenerate_candidate_edge
is only used inspans.assemble_spans
if edge is not None
(which itself could just beif edge
), use a listcompThe syntax for this is
[x for x in top_level_list for sublist in top_level_list]
so here it’d be:However this instantiates the Edge class twice! This could in fact be a good use for the walrus operator, though it’d technically become a generator expression within a listcomp (the listcomp is just the
is_valid
filter part)cinfo_list
tocontours
? Double check what’s actually in the variable (it’s been named to emphasise it’s a list but type annotations could do that)The text was updated successfully, but these errors were encountered: