def words_amount_needed(self) -> int:
        """Calculate the needed amount of words to satisfy the entropy number.

        This is for the given wordlist.

        """
        if (
                self.entropy_bits_req is None
                or self.amount_n is None
                or not self.wordlist
        ):
            raise ValueError("Can't calculate the words amount needed: "
                             "wordlist is empty or entropy_bits_req or "
                             "amount_n isn't set")

        # Thanks to @julianor for this tip to calculate default amount of
        # entropy: minbitlen/log2(len(wordlist)).
        # I set the minimum entropy bits and calculate the amount of words
        # needed, cosidering the entropy of the wordlist.
        # Then: entropy_w * amount_w + entropy_n * amount_n >= ENTROPY_BITS_MIN
        entropy_n = self.entropy_bits((self.randnum_min, self.randnum_max))

        # The entropy for EFF Large Wordlist is ~12.9, no need to calculate
        entropy_w = self._wordlist_entropy_bits \
            if self._wordlist_entropy_bits \
            else self.entropy_bits(self.wordlist)

        return calc_words_amount_needed(
            self.entropy_bits_req,
            entropy_w,
            entropy_n,
            self.amount_n
        )
def words_amount_needed ( self ) -> int : if ( self . entropy_bits_req is None or self . amount_n is None or not self . wordlist ) : raise ValueError ( "Can't calculate the words amount needed: " "wordlist is empty or entropy_bits_req or " "amount_n isn't set" ) entropy_n = self . entropy_bits ( ( self . randnum_min , self . randnum_max ) ) entropy_w = self . _wordlist_entropy_bits if self . _wordlist_entropy_bits else self . entropy_bits ( self . wordlist ) return calc_words_amount_needed ( self . entropy_bits_req , entropy_w , entropy_n , self . amount_n )
Calculate the needed amount of words to satisfy the entropy number.

        This is for the given wordlist.