File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -239,12 +239,20 @@ def full(
239239
240240 _check_device (device )
241241 _check_valid_dtype (dtype , device )
242- if dtype is None :
243- dtype = get_default_dtypes (device )["real floating" ]
244242
245243 if not isinstance (fill_value , bool | int | float | complex ):
246244 msg = f"Expected Python scalar fill_value, got type { type (fill_value )} "
247245 raise TypeError (msg )
246+
247+ if dtype is None :
248+ if type (fill_value ) == bool :
249+ dtype = bool
250+ else :
251+ kind = {
252+ int : "integral" , float : "real floating" , complex : "complex floating"
253+ }[type (fill_value )]
254+ dtype = get_default_dtypes (device )[kind ]
255+
248256 res = np .full (shape , fill_value , dtype = _np_dtype (dtype ))
249257 if DType (res .dtype ) not in _all_dtypes :
250258 # This will happen if the fill value is not something that NumPy
You can’t perform that action at this time.
0 commit comments