Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
error w/ record function

If I uncomment this line:

record(dv_z_current = dv_z_current) #error if uncommented  

I get this error:

29  Error   Runtime exception: TypeError: Non-numeric value [] specified to 'record'  

However, the output of "print dv_z_current" is:

2013-08-27PRINT[ 8.07261278]
2013-08-28PRINT[ 7.82974299]
2013-08-28PRINT[ 7.29566574]
2013-08-28PRINT[ 6.66455298]
2013-08-28PRINT[ 5.26739156]
2013-08-28PRINT[ 1.63823295]
2013-08-28PRINT[ 1.22651928]
2013-08-28PRINT[ 1.34282819]
2013-08-28PRINT[ 1.34461773]
2013-08-28PRINT[ 1.96211626]
2013-08-28PRINT[ 1.92934353]
etc.

All of the output is numeric. Any idea what's going on?

Thanks,

Grant

5 responses

Seems like it's a list you are recording, what happens when you do: record(dv_z_current = dv_z_current[0]) #error if uncommented

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Hello Grant,

I don't fully understand this so I cheated:

dv_z_current = dv_z[-1:,0].sum()  
# print dv_z_current  
record(dv_z_current = dv_z_current) #error if uncommented  

P.

When I log the type of the data your trying to record, I get

<type 'numpy.ndarray'>  

So we can convert that array to a list with a.tolist(). I tried doing this to convert it to a nice float:

float(''.join(str(dv_z_current.tolist())))  

But it's giving me an error, and I'm confused as to why. Hopefully that helps, though. Interesting error.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

My first thought was that it's a 0-d array but I'm not sure. Is this relevant?

http://stackoverflow.com/questions/773030/why-are-0d-arrays-in-numpy-not-considered-scalar

P.

Peter's "cheat" works, but I can't seem to find a more elegant approach. Any ideas?