keras-team / keras-preprocessing

Utilities for working with image data, text data, and sequence data.
Other
1.02k stars 444 forks source link

Minor optimization and dtype check #283

Closed jaketae closed 4 years ago

jaketae commented 4 years ago

Summary

  1. Robust dtype check np.isscalar() returns True for all scalars, not just floats or list/tuple of floats. Instead, use isinstance() to check dtype of zoom_range.

  2. Dictionary code optimization Use {} for dictionaries instead of dict() for readability and better performance.

Related Issues

N/A

PR Overview

Dref360 commented 4 years ago

Need to wait for https://github.com/keras-team/keras-preprocessing/pull/284 to be merged before I merge this. May take some times. Sorry for the delay.

jaketae commented 4 years ago

Need to wait for #284 to be merged before I merge this. May take some times. Sorry for the delay.

@Dref360 No problem, I appreciate the prompt feedback!

Dref360 commented 4 years ago

Seems like you have some pep8 errors to fix.

./keras_preprocessing/sequence.py:62:1: W293 blank line contains whitespace ./keras_preprocessing/sequence.py:65:1: W293 blank line contains whitespace ./keras_preprocessing/sequence.py:70:15: E111 indentation is not a multiple of four ./keras_preprocessing/sequence.py:71:15: E111 indentation is not a multiple of four ./keras_preprocessing/image/image_data_generator.py:327:39: W291 trailing whitespace

jaketae commented 4 years ago

@Dref360 Thank you for the heads up. I've made some fixes to resolve the PEP8 issues based on your comments.