2a1bd4c93a998d16516d82893401b346d66a95e9,imgaug/dtypes.py,,get_minimal_dtype,#Any#Any#,58
Before Change
def get_minimal_dtype(arrays, increase_itemsize_factor=1):
input_dts = [array.dtype if not isinstance(array, np.dtype) else array
for array in arrays]
promoted_dt = np.promote_types(*input_dts)
if increase_itemsize_factor > 1:
promoted_dt_highres = "%s%d" % (promoted_dt.kind, promoted_dt.itemsize * increase_itemsize_factor)
try:
promoted_dt_highres = np.dtype(promoted_dt_highres)
return promoted_dt_highres
except TypeError:
raise TypeError(
("Unable to create a numpy dtype matching the name "%s". "
+ "This error was caused when trying to find a minimal dtype covering the dtypes "%s" (which was "
+ "determined to be "%s") and then increasing its resolution (aka itemsize) by a factor of %d. "
+ "This error can be avoided by choosing arrays with lower resolution dtypes as inputs, e.g. by "
+ "reducing float32 to float16.") % (
promoted_dt_highres,
", ".join([input_dt.name for input_dt in input_dts]),
promoted_dt.name,
increase_itemsize_factor
)
)
return promoted_dt
def get_minimal_dtype_for_values(values, allowed_kinds, default, allow_bool_as_intlike=True):
After Change
assert isinstance(promoted_dt, np.dtype), (
"Expected numpy.dtype output from numpy.promote_dtypes, got type "
"%s." % (type(promoted_dt),))
return increase_itemsize_of_dtype(promoted_dt,
increase_itemsize_factor)
return promoted_dt
// TODO rename to: promote_arrays_to_minimal_dtype_
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 7
Instances
Project Name: aleju/imgaug
Commit Name: 2a1bd4c93a998d16516d82893401b346d66a95e9
Time: 2019-07-19
Author: kontakt@ajung.name
File Name: imgaug/dtypes.py
Class Name:
Method Name: get_minimal_dtype
Project Name: tensorlayer/tensorlayer
Commit Name: 5aab2436c4548d51b6dde2fc7867a6804d6380fd
Time: 2019-01-08
Author: jingqing.zhang15@imperial.ac.uk
File Name: tensorlayer/layers/dense/base_dense.py
Class Name: Dense
Method Name: build
Project Name: ray-project/ray
Commit Name: 5cfa1934e4a2157d07ef534e1033a3f0e5bc1082
Time: 2020-12-18
Author: me@barakmich.com
File Name: python/ray/experimental/client/server/server.py
Class Name: RayletServicer
Method Name: GetObject
Project Name: aleju/imgaug
Commit Name: 2a1bd4c93a998d16516d82893401b346d66a95e9
Time: 2019-07-19
Author: kontakt@ajung.name
File Name: imgaug/dtypes.py
Class Name:
Method Name: get_minimal_dtype