Skip to content

Commit 417b4b3

Browse files
refactor with list comprehension
refactoring code with truth value test list comprehension which is more pythonic, concise, readable and efficient; how do think this change which has practical value?
1 parent 537cefb commit 417b4b3

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

tensorflow_model_optimization/python/core/quantization/keras/experimental/default_n_bit/default_n_bit_quantize_registry.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,7 @@ def get_activations_and_quantizers(self, layer):
451451
return activations_quantizers
452452

453453
def _flatten(self, list_of_lists):
454-
flat_list = []
455-
for sublist in list_of_lists:
456-
for item in sublist:
457-
flat_list.append(item)
454+
flat_list = [item for sublist in list_of_lists for item in sublist]
458455
return flat_list
459456

460457
def set_quantize_weights(self, layer, quantize_weights):

0 commit comments

Comments
 (0)