Adding initial MOA parser#74
Conversation
|
I think you should be able to use Lines 238 to 243 in c1542e4 and with_shape(unbound("A"), [Int(1), Int(2)])To get an an array named "A" with shape I would continue to based off of core. My PR is in a lot of flux and we should be able to move this over easily if we do end up merging it eventually. |
saulshanabrook
left a comment
There was a problem hiding this comment.
This looks good! Once you substitute in the real arrays and shapes, I am curious when you call replace on resulting ASTs, how the results look.
Also, it might be nice to have a little notebook just demoing what this is doing.
|
I will add a notebook to demonstrate the features! Perfect you gave me exactly what I needed to know. |
b849a2f to
8ab2602
Compare
|
Tests fail due to the following not being equal. |
3a301f0 to
c9dc585
Compare
|
@costrouc I would do something like: A = core.with_shape(core.unbound('j'), [moa.Int(1), moa.Int(2)])
B = core.with_shape(core.unbound('j'), [moa.Int(1), moa.Int(2)])
assert replace(Shape(A)) == replace(Shape(B))
idxs = vector_of(unbound("index_1"), unbound("index_2"))
assert replace(Index(idxs, A)) == replace(Index(idxs, B)) |
|
To make sure that shape is equal and indexed forms are equal |
|
Also, you might not need assertions for now. Even a notebook just showing off this functionality with no tests is useful! |
|
@saulshanabrook this is what I was thinking. For now I have the specific tests that test |
- tests are included with parser - adding notebook to demontrate parser
c9dc585 to
e700ac2
Compare
|
Added notebook and ready for merge. I think that in combination with the visualization writing expressions should be much easier |
|
Wow GIthub has a merge conflict UI now! Pretty sweet. |
|
Yeah it does! But be careful. At least from my experience I've had it duplicate code when I though I was editing a single line. |
@saulshanabrook what are your thoughts?
It can handle pretty much any moa expression. There are still a few symbols that need to be added but the fundamentals are covered. Additionally it will complain when it does not understand an expression.
Future vision of expressions.
<1 2> psi Acan be given an name likemy_indexand can be used in a later expression likemy_index * B.moa.eval('<1 2> psi A', {'A': np.random.random((2, 3, 4)))Currently pretty much any moa expression will evaluation but it will complain that uarray does not have support for the operation such as ('/' and '-').
Examples. Available tokens can be found in
lexer.py.