Correlation, meaning Pearson correlation, is not defined for such a case. If you consider the definition $\text{cov}(x, y)/[\text{sd}(x) \text{sd}(y)]$ you can see that if either standard deviation is zero, the correlation is indeterminate: as school mathematics underlined, you cannot divide by zero.
This isn't a quirk of Python numerics; it's a generic problem.
A more arm-waving way to report the issue is that correlation measures the extent to which there is a linear relationship between variables. But if either variable is a constant, there is no kind of relationship between the variables.
In practice correlations for very small sample sizes are often unreliable any way. In most real situations collecting more data will solve the problem if there is any kind of relationship to quantify.
Uniform distribution is a misnomer in this case, unless a constant distribution is regarded as a degenerate uniform distribution.
As your close indicates, the problem is constant data, not uniform data. I've not edited the title or the question, but that emphasis is misleading, indeed wrong.
numpy division with RuntimeWarning: invalid value encountered in double_scalars
. So, have a look at this post if it helps. $\endgroup$