Opened 8 years ago

Closed 8 years ago

#15923 closed defect (fixed)

Incorrect TypeError in FiniteStateMachine.add_from_transition_function

Reported by: cheuberg Owned by:
Priority: minor Milestone: sage-6.2
Component: combinatorics Keywords: finite_state_machine
Cc: Merged in:
Authors: Clemens Heuberger Reviewers: Daniel Krenn
Report Upstream: N/A Work issues:
Branch: 3c3589a (Commits, GitHub, GitLab) Commit: 3c3589ac31d2fb509f7e4e1f91a22d961403b01a
Dependencies: Stopgaps:

Status badges

Description

A TypeError? occurring in the callback function sage.combinat.finite_state_machine.FiniteStateMachine.add_from_transition_function is incorrectly caught and leads to a misleading ValueError?. Old behaviour:

sage: def transition(state, where):
sage: ...    return (vector([0,0]),1)
sage: Transducer(transition, input_alphabet=[0], initial_states=[0])
Traceback (click to the left of this block for traceback)
...
ValueError: The callback function for add_from_transition is expected to
return a pair (new_state, output_label) or a list of such pairs. For the
state 0 and the input letter 0, it however returned [((0, 0), 1)], which
is not acceptable.

New behaviour:

sage: def transition(state, where):
sage: ...    return (vector([0,0]),1)
sage: Transducer(transition, input_alphabet=[0], initial_states=[0])
Traceback (click to the left of this block for traceback)
...
TypeError: mutable vectors are unhashable

Change History (6)

comment:1 Changed 8 years ago by cheuberg

  • Status changed from new to needs_review

comment:2 Changed 8 years ago by dkrenn

  • Cc dkrenn removed
  • Reviewers set to Daniel Krenn

comment:3 Changed 8 years ago by dkrenn

  • Status changed from needs_review to positive_review

comment:4 Changed 8 years ago by dkrenn

  • Authors changed from Clemens Heuberger, Daniel Krenn to Clemens Heuberger

comment:5 Changed 8 years ago by dkrenn

everything looks fine, doctests pass, docu checked, coverage checked

comment:6 Changed 8 years ago by vbraun

  • Branch changed from u/cheuberg/fsm/add_from_transition_function to 3c3589ac31d2fb509f7e4e1f91a22d961403b01a
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.