-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print one based in the parser (#3009)
* broadcasting * Simplified broadcasting * Updated for broadcasting * Changed to camel case * Camel case and auto formating * Added comments * Skip if matrices have the same size * Fixed issue with undefined variable missing dot in `A._size` * Implemented broadcasting in all functions * Added helper functions * Added function to check for broadcasting rules * Tests for broadcasted arithmetic * Fixed issue with matrix the size of a vector * Documented and updated broadcasting * Included broadcast.test * Included math to syntax when missing * Added print transform and tests * Simplify conditional * Included regex in an util --------- Co-authored-by: David Contreras <[email protected]> Co-authored-by: Jos de Jong <[email protected]>
- Loading branch information
1 parent
08bf93b
commit c35a801
Showing
7 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,7 @@ Evan Miller <[email protected]> | |
Timur <[email protected]> | ||
Ari Markowitz <[email protected]> | ||
Jay Wang <[email protected]> | ||
David Contreras <[email protected] | ||
Jaeu Jeong <[email protected]> | ||
cyavictor88 <[email protected]> | ||
David Contreras <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { createPrint } from '../../function/string/print.js' | ||
import { factory } from '../../utils/factory.js' | ||
import { printTemplate } from '../../utils/print.js' | ||
|
||
const name = 'print' | ||
const dependencies = ['typed', 'matrix', 'zeros', 'add'] | ||
|
||
export const createPrintTransform = /* #__PURE__ */ factory(name, dependencies, ({ typed, matrix, zeros, add }) => { | ||
const print = createPrint({ typed, matrix, zeros, add }) | ||
return typed(name, { | ||
'string, Object | Array': function (template, values) { return print(_convertTemplateToZeroBasedIndex(template), values) }, | ||
'string, Object | Array, number | Object': function (template, values, options) { return print(_convertTemplateToZeroBasedIndex(template), values, options) } | ||
}) | ||
|
||
function _convertTemplateToZeroBasedIndex (template) { | ||
return template.replace(printTemplate, (x) => { | ||
const parts = x.slice(1).split('.') | ||
const result = parts.map(function (part) { | ||
if (!isNaN(part) && part.length > 0) { | ||
return parseInt(part) - 1 | ||
} else { | ||
return part | ||
} | ||
}) | ||
return '$' + result.join('.') | ||
}) | ||
} | ||
}, { isTransformFunction: true }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const printTemplate = /\$([\w.]+)/g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters