Bladeren bron

fix: update Feature.__repr__ & add __eq__

Problems fixed:

 - Feature repr did not include feature_extractor since that API was changed
 - Intervals that were equivalent were not equal, so Features were not properly
   sorted or equal
main
Rob Hallam 3 maanden geleden
bovenliggende
commit
eaafb43a35
1 gewijzigde bestanden met toevoegingen van 10 en 1 verwijderingen
  1. +10
    -1
      pipeline/utils.py

+ 10
- 1
pipeline/utils.py Bestand weergeven

@@ -179,6 +179,9 @@ class Interval():
return self.end < other.end
return self.start < other.start

def __eq__(self, other):
return self.start == other.start and self.end == other.end

def to_json(self):
"""Return a dict representation of the interval for JSON encoding

@@ -268,7 +271,7 @@ class Feature():
feature_extractor=feature_extractor, score=score)

def __repr__(self):
return f"Feature({self.interval}, {self.source}, {self.score})"
return f"Feature({self.interval}, {self.source}, {self.feature_extractor}, {self.score})"

def __lt__(self, other):
"""Sort based on interval, then feature_extractor, then score"""
@@ -278,6 +281,12 @@ class Feature():
return self.feature_extractor < other.feature_extractor
return self.interval < other.interval

def __eq__(self, other):
return self.interval == other.interval \
and self.source == other.source \
and self.feature_extractor == other.feature_extractor \
and self.score == other.score

def to_json(self):
"""Return a dict representation of the feature for JSON encoding



Laden…
Annuleren
Opslaan