1. The yt Project
  2. Untitled project
  3. yt-doc

Commits

Matthew Turk  committed a8809ea

Thanks to nscudder for pointing out an extra sum() here!

  • Participants
  • Parent commits d4865fc
  • Branches default

Comments (0)

Files changed (1)

File source/orientation/first_steps.rst

View file
 sphere do not have to be in memory.  For instance, to calculate the center of
 mass, one could imagine doing something like this::
 
-   >>> M_i = my_sphere["CellMassMsun"].sum()
+   >>> M_i = my_sphere["CellMassMsun"]
    >>> M = M_i.sum()
-   >>> com_x = (my_sphere["x"] * M_i)/M
-   >>> com_y = (my_sphere["y"] * M_i)/M
-   >>> com_z = (my_sphere["z"] * M_i)/M
+   >>> com_x = (my_sphere["x"] * M_i).sum()/M
+   >>> com_y = (my_sphere["y"] * M_i).sum()/M
+   >>> com_z = (my_sphere["z"] * M_i).sum()/M
 
 But for this to work, all of the arrays listed would have to be held in memory,
 even though the algorithm operates on each element individually.  Clearly, the