TL DR : Yes, returning 0 is the only right way. (But see Conclusion.)
Math background
In real analysis (i.e., not for complex numbers), when the logarithms are considered, we traditionally believe that the domain log are real positive numbers. We have the identity:
x = exp(log(x)), for x>0.
It can be naturally extended to x=0 , since the limit of the expression on the right side is well defined at x->0+ and is 0. Moreover, it has the right to set log(0)=-inf and exp(-inf)=0 (again: only for real, not complicated numbers). Formally, we expand the set of real numbers by adding two elements -inf , +inf and defining consistent arithmetic, etc. (For our purposes, we need to have inf + x = inf , x * inf = inf for real x, inf + inf = inf , etc. ..)
Another identity x = log(exp(x)) less problematic and holds for all real numbers (and even x=-inf or +inf ).
Geometric mean
The geometric mean can be determined for non-negative numbers (possibly equal to zeros). For two numbers a , b (it naturally generalizes to a larger number of numbers, so I will use only two others), this
gm(a,b) = sqrt(a*b), for a,b >= 0.
Of course, gm(0,b)=0 . Taking log, we get:
log(gm(a,b)) = (log(a) + log(b))/2
and this is well defined if a or b is zero. (We can connect log(0) = -inf , and the identity still holds true thanks to the extended arithmetic we defined earlier.)
Interpretation
It is not surprising that the concept of geometric mean comes from geometry and was originally (in ancient Greece) used for strictly positive numbers.
Suppose we have a rectangle with sides of lengths a and b . Find a square with an area equal to the area of ββthe rectangle. It is easy to see that the side of the square is the geometric mean of a and b .
Now, if we take a = 0 , then we really do not have a rectangle, and this geometric interpretation breaks. Similar problems may arise with other interpretations. We can mitigate this by considering, for example, degenerate rectangles and squares, but this may not always be a plausible approach.
Conclusion
This is for the user (mathematician, engineer, programmer), as she understands that the value of the geometric mean is zero. If this causes serious problems with the interpretation of the results or breaks the computer program, then, firstly, it is possible that the choice of the geometric mean value was not justified as a mathematical model.
Python
As mentioned in other answers, python has infinity. When np.exp(np.log(0)) is executed, it causes a warning about execution (division by zero), but the result of the operation is correct.