forked from jzwick/ghc2024-vectorization-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
q1.py
34 lines (24 loc) · 869 Bytes
/
q1.py
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
"""Unoptimized functions to be vectorized."""
import math
import time
import numpy as np
import pandas as pd
from util import print_time_results, time_funcs
# Q1: Convert a list to np.array
def convert_list_to_array(input_list: list):
pass # insert your code here
def make_test_list(size: int = 100):
return [i for i in range(size)]
def test_convert_list(size: int = 1000):
print("\n\nQ1: Running test_convert_list...\n")
input = make_test_list(size)
output = convert_list_to_array(input)
if output is not None:
assert (
type(output) == np.ndarray
and len(input) == len(output)
and np.all([input[i] == output[i] for i in range(len(input))])
), "Whoops! input and output do not match"
print(" Success!")
else:
print(" convert_list_to_array is not implemented")