I am quitenew to python and I am working on a python script I inherited from someone I work with, and I am getting this error:
expected a readable buffer object
The code causing this is:
self.y_NoShock_data = np.zeros((self.a_count+1,1,self.numberOfTags+1,lookback+forward,),dtype=enums.
self.y_data = np.zeros((self.a_count+1,len(self.SCL)+1,self.numberOfTags+1,lookback+forward,),dtype=enums.DataPoints)
self.y_NoShock_cum_data = np.zeros_like(self.y_NoShock_data)
self.y_cum_data = np.zeros_like(self.y_data)
enums.DataPoints looks like this:
enums.DataPoints = dtype([
('Amount','float32'),
])
The stack trace is as follows:
Internal Server
Error: /smCore/entity/1/runScenarioManager/
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/Users/bentaliadoros/Documents/workspace/LivingSvnAmmar/trunk/ScenarioManagerStandAlone/smCore/views/createScenario.py", line 445, in runScenarioManager
a = ScenarioExecutionController(sEA)
File "/Users/bentaliadoros/Documents/workspace/LivingSvnAmmar/trunk/ScenarioManagerStandAlone/smCore/models/scenarioExecutionController.py", line 176, in __init__
shockEventDataSet=[], lookback=self.lookback, forward=self.forward, period=self.period) #,
File "/Users/bentaliadoros/Documents/workspace/LivingSvnAmmar/trunk/ScenarioManagerStandAlone/smCore/models/scenarioExecution.py", line 307, in buildSeedScenarioObject
cls.updateScenarioParameters(shockContainerList,shockEventDataSet, shockEventDateList)
File "/Users/bentaliadoros/Documents/workspace/LivingSvnAmmar/trunk/ScenarioManagerStandAlone/smCore/models/scenarioExecution.py", line 130, in updateScenarioParameters
self.initialiseResultArrays()
File "/Users/bentaliadoros/Documents/workspace/LivingSvnAmmar/trunk/ScenarioManagerStandAlone/smCore/models/scenarioExecution.py", line 154, in initialiseResultArrays
self.y_NoShock_cum_data = np.zeros_like(self.y_NoShock_data,dtype=enums.DataPoints)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/numeric.py", line 116, in zeros_like
res.fill(0)
TypeError: expected a readable buffer object
He was working on a pc and I am on a Mac. I've been looking around but can't find a solution for this, can anyone point me in the right direction?
enums.DataPoints?dtypeis specified (as the type @Jaime has asked about), but not in the code you posted at the top. Be sure you've saved (and reloaded if interactive) your source file if you've made changes._p = np.empty(1, dtype=[('p', np.uint16), ('pr', np.uint16)])then_p[:]=1but not this:_p = np.empty(2, dtype=[('p', np.uint16), ('pr', np.uint16)])then_p[:]=1, looks like a bug to me (1.8.2)