You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
concatenating with empty list changes dtype to float64 #10135
The desired data-type for the array. If not given, then the type will be determined as the minimum type required to hold the objects in the sequence.
This doesn't seem to be the case here: A clearly smaller dtype than float64 is, e.g., int8. Taking int8 as default input type for empty arrays would also prevent the needless upcasting as described in the original post in most cases. The only time where this would fail is
Empty arrays are a special case that doesn't really fall under that rule (and is rare enough that that part of the docstring is probably just distracting rather than enlightening). The general default for an array where there are no values to inspect is float64. Compare to ones(), zeros(), etc.
Activity
pv commentedon Nov 30, 2017
nschloe commentedon Jan 12, 2018
Not sure why I closed this one here. The explanation makes sense, indeed
The
numpy.arraydocumentation says about the optionaldtypeargument tonumpy.array:This doesn't seem to be the case here: A clearly smaller dtype than
float64is, e.g.,int8. Takingint8as default input type for empty arrays would also prevent the needless upcasting as described in the original post in most cases. The only time where this would fail isrkern commentedon Jan 12, 2018
Empty arrays are a special case that doesn't really fall under that rule (and is rare enough that that part of the docstring is probably just distracting rather than enlightening). The general default for an array where there are no values to inspect is
float64. Compare toones(),zeros(), etc.eric-wieser commentedon Jan 12, 2018
I think @nschloe is questioning whether that's the right default for empty arrays, which IMO is:
nschloe commentedon Jan 14, 2018
Indeed. I'll open one.