Skip to content

Instantly share code, notes, and snippets.

@wolkym
Created February 25, 2015 10:39
Show Gist options
  • Save wolkym/e1dce1346d1a481a9a5e to your computer and use it in GitHub Desktop.
Save wolkym/e1dce1346d1a481a9a5e to your computer and use it in GitHub Desktop.
I am building data simulation framework with numpy ORM, where it is much more convenient to work with classes and objects instead of numpy arrays directly. Nevertheless, output of the simulation should be numpy array. Also blockz is quite interesting as a backend here. I would like to map all object attributes to numpy arrays. Thus, numpy arrays…
a = np.arange(10)
class Case():
def __init__(self, gcv_pointer):
self.gcv = gcv_pointer
def gcv(self):
return(self.gcv)
def gcv_set(self, value):
self.gcv[:] = value
pass
#===============================================================================
# NumPy
#===============================================================================
caseList = []
for i in range(1, 10):
case = Case(a[i-1:i])
caseList.append(case)
gcvs = [case.GetGCV() for case in caseList]
caseList[1].SetGCV(5)
caseList[1].SetGCV(13)
caseList[1].gcv[:] = 6
setattr(caseList[1], 'dpd', a[5:6])
caseList[1].dpd
caseList[1].dpd[:] = 888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment