<jupyter_start><jupyter_text>TOC - [Introduction](0-introduction.ipynb) - [Simple Example](1-simple-example.ipynb) - [Simple Example Symbolic](2-simple-example-symblic.ipynb) - [Pythonic MOA Array Interface](3-lazy-arrays.ipynb) - [Benchmarks](4-benchmarks.ipynb) MOA "Array Interface"This is very much a work in progress. I want to see how far a python wrapper around a moa interface will take us. Everything can change since this is just a wrapper that generates an AST.<jupyter_code>from moa.frontend import LazyArray
A = LazyArray(name='A', shape=(3, 2))
B = LazyArray(name='B', shape=(4,))
C = LazyArray(name='C', shape=(3, 4))

expression = (((A.T)[0] - 1).outer('*', B) + C + 'n').transpose([1, 0])[0]
expression.visualize('shape')
print(expression.analysis())
print(expression.compile())
from moa.array import Array

A = Array(shape=(3, 2), value=(1, 2, 3, 4, 5, 6))
B = Array(shape=(4,), value=(13, 14, 15, 16))
C = Array(shape=(3, 4), value=(17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28))
n = Array(shape=(), value=(4,))

exec(expression.compile())

D = f(A=A, B=B, C=C, n=n)

print('shape', D.shape)
print('value', D.value)<jupyter_output>shape (3,)
value [21, 51, 81]
{'fraction_non_alphanumeric': 0.1939034716342083, 'fraction_numerical': 0.0558848433530906, 'mean_word_length': 5.459016393442623, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '546895', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 500, 'n_tokens_neox': 447, 'n_words': 127, 'path': 'notebooks/3-lazy-arrays.ipynb', 'repo_name': 'Quansight-Labs/python-moa', 'size': '1181'}