Replaces scale factors in expressions with their value in scientific notation: :param txt: Expression or number with scale factors :type txt: str :return: out: Text in which scale factors are replaced with their corresponding scientific notation. :rtype: str
(txt)
| 214 | t.lexer.skip(1) |
| 215 | |
| 216 | def _replaceScaleFactors(txt): |
| 217 | """ |
| 218 | Replaces scale factors in expressions with their value in scientific |
| 219 | notation: |
| 220 | |
| 221 | :param txt: Expression or number with scale factors |
| 222 | :type txt: str |
| 223 | |
| 224 | :return: out: Text in which scale factors are replaced with their |
| 225 | corresponding scientific notation. |
| 226 | :rtype: str |
| 227 | |
| 228 | :Example: |
| 229 | |
| 230 | >>> _replaceScaleFactors('sin(2*pi*1M)') |
| 231 | 'sin(2*pi*1E6)' |
| 232 | """ |
| 233 | pos = 0 |
| 234 | out = '' |
| 235 | for m in re.finditer(r'\d+\.?\d*([yzafpnumkMGTP])', txt): |
| 236 | out += txt[pos: m.end()-1] + 'e' + _SCALEFACTORS[m.group(0)[-1]] |
| 237 | pos = m.end() |
| 238 | out += txt[pos:] |
| 239 | return out |
| 240 | |
| 241 | def _tokenize(netlist): |
| 242 | """ |
no test coverage detected