From 31cea2ead0d959bb351a1cf761c0ef9707791c19 Mon Sep 17 00:00:00 2001 From: Zach Carmichael Date: Wed, 30 Oct 2024 11:48:21 -0700 Subject: [PATCH] Resolve C417 in tcav.py (#1426) Summary: Pull Request resolved: https://github.com/pytorch/captum/pull/1426 Resolve flake8 lint ``` >>> Lint for fbcode/pytorch/captum/captum/concept/_core/tcav.py: Advice (FLAKE8) C417 Unnecessary use of map - use a list comprehension instead. See https://github.com/adamchainz/flake8-comprehensions#rules 694 # Retrieves the lengths of the experimental sets so that we can sort 695 # them by the length and compute TCAV scores in batches. 696 exp_set_lens = np.array( >>> 697 list(map(lambda exp_set: len(exp_set), experimental_sets)), dtype=object 698 ) 699 exp_set_lens_arg_sort = np.argsort(exp_set_lens) ``` Differential Revision: D65178563 --- captum/concept/_core/tcav.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/captum/concept/_core/tcav.py b/captum/concept/_core/tcav.py index daea9f939..ebb053bd2 100644 --- a/captum/concept/_core/tcav.py +++ b/captum/concept/_core/tcav.py @@ -694,7 +694,7 @@ def interpret( # Retrieves the lengths of the experimental sets so that we can sort # them by the length and compute TCAV scores in batches. exp_set_lens = np.array( - list(map(lambda exp_set: len(exp_set), experimental_sets)), dtype=object + [len(exp_set) for exp_set in experimental_sets], dtype=object ) exp_set_lens_arg_sort = np.argsort(exp_set_lens)