(tensors: typeof tensorflow.Tensor[], operation: string, inplace: boolean)
| 307 | } |
| 308 | |
| 309 | private $MathOps(tensors: typeof tensorflow.Tensor[], operation: string, inplace: boolean) { |
| 310 | let tensorResult |
| 311 | |
| 312 | switch (operation) { |
| 313 | case 'add': |
| 314 | tensorResult = tensors[0].add(tensors[1]) |
| 315 | break; |
| 316 | case 'sub': |
| 317 | tensorResult = tensors[0].sub(tensors[1]) |
| 318 | break; |
| 319 | case 'pow': |
| 320 | tensorResult = tensors[0].pow(tensors[1]) |
| 321 | break; |
| 322 | case 'div': |
| 323 | tensorResult = tensors[0].div(tensors[1]) |
| 324 | break; |
| 325 | case 'divNoNan': |
| 326 | tensorResult = tensors[0].divNoNan(tensors[1]) |
| 327 | break; |
| 328 | case 'mul': |
| 329 | tensorResult = tensors[0].mul(tensors[1]) |
| 330 | break; |
| 331 | case 'mod': |
| 332 | tensorResult = tensors[0].mod(tensors[1]) |
| 333 | break; |
| 334 | } |
| 335 | |
| 336 | if (inplace) { |
| 337 | const newData = tensorResult?.arraySync() as ArrayType2D |
| 338 | this.$setValues(newData) |
| 339 | } else { |
| 340 | return new DataFrame( |
| 341 | tensorResult, |
| 342 | { |
| 343 | index: [...this.index], |
| 344 | columns: [...this.columns], |
| 345 | dtypes: [...this.dtypes], |
| 346 | config: { ...this.config } |
| 347 | }) |
| 348 | |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * Purely integer-location based indexing for selection by position. |
no test coverage detected