瀏覽代碼

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 2 月之前
父節點
當前提交
eaafb43a35
共有 1 個文件被更改,包括 10 次插入1 次删除
  1. +10
    -1
      pipeline/utils.py

+ 10
- 1
pipeline/utils.py 查看文件

@@ -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



Loading…
取消
儲存