获取可比较的数值(用于排序、筛选等) Args: amount: 用量 unit: 单位 Returns: 可比较的数值,None表示无法比较
(self, amount: str, unit: str = "")
| 158 | return normalized, "", estimated |
| 159 | |
| 160 | def get_comparable_value(self, amount: str, unit: str = "") -> Optional[float]: |
| 161 | """ |
| 162 | 获取可比较的数值(用于排序、筛选等) |
| 163 | |
| 164 | Args: |
| 165 | amount: 用量 |
| 166 | unit: 单位 |
| 167 | |
| 168 | Returns: |
| 169 | 可比较的数值,None表示无法比较 |
| 170 | """ |
| 171 | # 尝试解析为数字 |
| 172 | try: |
| 173 | return float(amount) |
| 174 | except ValueError: |
| 175 | pass |
| 176 | |
| 177 | # 使用估算值 |
| 178 | normalized, estimated = self.normalize_amount(amount, unit) |
| 179 | return estimated |
| 180 | |
| 181 | def format_for_display(self, amount: str, unit: str = "") -> str: |
| 182 | """ |
nothing calls this directly
no test coverage detected