MCPcopy Index your code
hub / github.com/javascriptdata/danfojs / $MathOps

Method $MathOps

src/danfojs-base/core/frame.ts:309–350  ·  view source on GitHub ↗
(tensors: typeof tensorflow.Tensor[], operation: string, inplace: boolean)

Source from the content-addressed store, hash-verified

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.

Callers 9

addMethod · 0.95
subMethod · 0.95
mulMethod · 0.95
divMethod · 0.95
divNoNanMethod · 0.95
powMethod · 0.95
modMethod · 0.95
pctChangeMethod · 0.95
diffMethod · 0.95

Calls 8

$setValuesMethod · 0.80
addMethod · 0.65
subMethod · 0.65
powMethod · 0.65
divMethod · 0.65
divNoNanMethod · 0.65
mulMethod · 0.65
modMethod · 0.65

Tested by

no test coverage detected