title: Using a python dictionary of arrays
body: <p>EDIT: I'm sorry, I realized that I didn't give the full question, this edit should contain the full question. I thougth that my previous question was similar enough to the full question that I could get the answer that way without having to add too many additional details, but I was wrong. </p>
  
  <p>I have a dictionary <code>params</code> in python, where each entry is a numpy array of some sort. But the arrays in this dictionary are not all of the same shape. Some are size (n,m), some are size (1,m), some still are totally different sizes. I can call a specific number in this dictionary via:
  <code>params[key][i,j]</code></p>
  
  <p>I need to loop over x of the keys in this dictionary, so I have a loop like:</p>
  
  <pre><code>for i in range(0,x):
      for j in range(0,(dim of 0th axis of array at key x)):
          for k in range(0,(dim of 1 axis of array at key x)):
              stuff = f(params['W'+str(i)][i,j])
  </code></pre>
  
  <p>I want to create a new dictionary <code>paramscheck</code> which will be contain the elements that I'm going to loop over, but the specific numbers in <code>paramscheck</code> will be some function of the corresponding numbers in params. </p>
  
  <p>I can't quite figure out the best way to do this. </p>
  
  <p>If I write code like:   </p>
  
  <pre><code>paramscheck = {}
  for i in range(0,x):
      for j in range(0,n):
          for k in range(0,m):
              paramscheck['W'+str(i)][i,j] = f(params['W'+str(i)][i,j])
  </code></pre>
  
  <p>Then I will get that I'm outside the range of the index of paramscheck since that dictionary started out empty. </p>
  
  <p>If I copy <code>params</code> to <code>paramscheck</code> first and then do the loop with a line like</p>
  
  <pre><code>paramscheck = params
  </code></pre>
  
  <p>Then, I won't have issue accessing any entry in paramscheck, but my params dictionary will be modified simultaneously (from what I understand of Python, dictionaries are not actually copied, it just makes an extra label that references to the one underlying dictionary).</p>
  
  <p>I've tried something like <code>paramscheck = params.copy()</code> and <code>paramscheck = dict(params)</code>, but still the params dictionary is being modified when I go to modify <code>paramscheck</code>. </p>
  
  <p>How should I accomplish this? </p>