- Implemented using arraylist, so append is O(n)
- Thus, use python lists until you know for sure when the array won’t grow anymore, and convert to numpy array.
{python}arr = np.zeros()
or {python}arr = np.empty()
to initialize.
- !
np.arrange(3)
initializes an int
, while np.arrange(3.)
initilizes a float.
{python}arr = np.zeros_like(ref_arr)
will initiallize arr
with the same dimensions and datatype as ref_arr
:
- Sequence based initialization:
- Linspace vs arrange differences. Conclusion: linspace is better:
- Indexing arrays (is a pointer, except the “fancy indexing”)