This block fails with "ValueError: setting an array element with a sequence."
class MyFactor(CustomFactor):
window_length = 1
inputs = [BuybackAuthorizations.previous_unit,BuybackAuthorizations.previous_amount]
def compute(self, today, assets, out, buyback_unit, buyback_amount):
out[:] = buyback_unit[0]
This one works fine:
class MyFactor(CustomFactor):
window_length = 1
inputs = [BuybackAuthorizations.previous_unit,BuybackAuthorizations.previous_amount]
def compute(self, today, assets, out, buyback_unit, buyback_amount):
out[:] = buyback_amount[0]
Why is one a sequence and one not?
Using array2string() shows that BuybackAuthorizations.previous_unit seems to be giving me a giant array which looks like this:
[None None u'$M' ..., None None None]
How can I grab just the u'$M' (or whatever) and convert it to a scalar?
My end goal is to be able to run:
if buyback_unit[0] == '$M':
<do something>
But it is complaining about comparing an array to a string...
Would appreciate any help!