Hi Stephen,
I have now opened up derived_quantities and inspected. By searching
for n_ret=1, which seems to be what you are looking for, I was able to
identify the AngularMomentumVector quantity also has only one return
value. In that source code it returns an iterable of length 1. Based
on this, I am going to suggest:
return [ct.sum(),]
Because the derived quantity machinery goes to great lengths to
preserve some of its memory conservation and processr independence,
the source is usually a good place to look for examples and so on.
What happens is that the DQ function must return an iterable. When
you first returned ct, it was an iterable: so it worked. However,
because you told it to only take one value, it only took the leading
value. Now, returning ct.sum(), you are no longer providing an
iterable, so it dies. Returning it *as* an iterable with only one
important element should fix this issue.
-Matt
On Fri, Dec 10, 2010 at 4:06 PM, Stephen Skory
Matt,
But, I think you should be returning ct.sum() from _NumberOfStars.
With only that change to what I previously sent, I get this...
Traceback (most recent call last): File "analyze.py", line 19, in <module> print 'total', dd.quantities["NumberOfStars"]() File "/share/home/00649/tg457850/yt/lib/python2.6/site-packages/yt-2.0dev-py2.6-linux-x86_64.egg/yt/data_objects/derived_quantities.py", line 90, in __call__ return self._call_func_lazy(args, kwargs) File "/share/home/00649/tg457850/yt/lib/python2.6/site-packages/yt-2.0dev-py2.6-linux-x86_64.egg/yt/data_objects/derived_quantities.py", line 98, in _call_func_lazy for i in range(self.n_ret): self.retvals[i].append(rv[i]) IndexError: invalid index to scalar variable.
Stephen Skory stephenskory@yahoo.com http://stephenskory.com/ 510.621.3687 (google voice) _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org