n_entries = 0x101
# compress the transition table
+ dist = numpy.sum(
+ transitions[:, numpy.newaxis, :] != transitions[numpy.newaxis, :, :],
+ 2
+ )
while n_states < n_accept:
# find most similar/earliest existing state to use as default
- mask = (
- transitions[n_states:n_states + 1, :] !=
- transitions[:n_states, :]
- )
- default_state = numpy.argmin(numpy.sum(mask, 1), 0)
- indices = numpy.nonzero(mask[default_state, :])[0]
+ default_state = numpy.argmin(dist[:n_states, n_states], 0)
+ indices = numpy.nonzero(
+ transitions[n_states] != transitions[default_state]
+ )[0]
if indices.shape[0] == 0:
# when copying another state, need to have the same base, though
# the base will not matter since there will be no entries, it is