1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from evaluator import *

DESCRIPTION = "Test if a model correctly understands how advanced indexing works in numpy."

TAGS = ['explain', 'python']

question = """
What will this program print:

```python
import numpy as np

array = np.zeros((10, 20, 30))
idxs = [1, 2, 3]

print("The array shape is", array[0, :, idxs].shape)
```
"""

TestNumpyAdvancedIndex = question >> LLMRun() >> SubstringEvaluator("The array shape is (3, 20)")

question = """
Consider this program

```python
import numpy as np

array = np.zeros((10, 20, 30))
idxs = [1, 2, 3]

print("The first array shape is", array[0][:, idxs].shape)
print("The second array shape is", array[0, :, idxs].shape)
```

Tell me what this program will print, and then explain why the two print statements don't print the same thing
"""

TestNumpyAdvancedIndexEasier = question >> LLMRun() >> (SubstringEvaluator("(3, 20)") & SubstringEvaluator("(20, 3)") & SubstringEvaluator("dvanced indexing"))

if __name__ == "__main__":
    print(run_test(TestNumpyAdvancedIndexEasier))