v8.0.0
Automata v8 is a performance and polish-focused release, providing improvements
under the hood that should improve the quality of life for most package users.
Huge thanks to @khoda81, and @EduardoGoulart1 for the new features in this release!
New Features
Jupyter Notebook Integration (#129)
All finite automata (subclasses of the FA class) now have native support for diagram
creation in Jupyter notebooks! This is enabled by installing the optional visual
dependency, which includes the
pygraphviz
and coloraide
dependencies used in the show_diagram()
methods for DFAs/NFAs.
The styling for the diagrams has been changed from previous releases and is
modeled after the diagrams used in the
visual automata package.
The show_diagram()
now returns an AGraph
corresponding to the given FA,
and the FA will render a diagram automatically inside of a Juyter notebook. See the
FA documentation for more details.
Type Hints (#131)
Type annotations have been added to the library, providing greater information
when using code completion tools like Pylance. This also makes it easier to type-check
application code using the library.
Better Partial DFA Support (#147)
Methods in the DFA class now have greater support for partial DFAs (ones with
some missing transitions), including support for more efficient binary operations
with partial DFAs. Partial DFAs have smaller description complexity, and thus
some algorithms are more efficient when operating on them.
In addition, the from_prefix
, from_finite_language
, and from_nfa
DFA creation
functions now return partial DFAs by default. The new to_partial
and to_complete
methods can be used to convert a DFA into an equivalent partial or complete DFA
respectively.
my_dfa.to_partial() # get equivalent partial DFA
my_dfa.to_complete() # get equivalent partial DFA
Please see the DFA documentation for the full details on these new
methods (outlined below).
Smaller Changes
Regex Changes
- Quantifiers were added to the regular expression parsing, representing the repetition
of the preceding expression. For example, the regexa{1,2}
would matcha
between 1
and 2 times (#121). - A pair of parenthesis
()
can now be used to represent the empty string (#136). - The default set of input symbols for
NFA.from_regex
was changed to all ascii letters and digits (#121). - State names of NFAs constructed from regexes no longer persist between runs of the regex engine (#130).
Pickling Support (#125)
All automata now natively support pickling.
Examples (#146)
A section has been added to the documentation demonstrating example uses of the package, can
be found here.
Breaking Changes
Dependency Changes
Python 3.7 support has been dropped. Please upgrade to Python 3.8 or later to
use Automata v8.
Diagrams are no longer being generated using pydot
; this dependency has been
dropped in favor of using the visual
optional dependency, which will install
pygraphviz
and coloraide
used for generating figures. You should install
this optional dependency if you wish to generate figures. This change was to
allow for native support for displaying finite automaton in Jupyter notebooks.
The style of the diagrams has been lifted from the visual automata package,
so you should take a look at the diagrams generated and see if they are still
satisfactory.
Other new dependencies have been added, but these will be installed automatically
along with v8 of the package.
Greater Support for Partial DFAs
There is now greater support for partial DFAs, which included changing the
DFA.from_nfa()
function to return a partial DFA instead of a complete one.
To obtain a complete DFA, you must now call DFA.from_nfa().to_complete(trap_state_name)
,
where trap_state_name
will be used as the name for a trap state if one needs to
be added.
Type Hints
Type hints have now been added, meaning that code which previously called functions
with incorrect types may not have been flagged. See output from your typechecker
for more information.
NFA.from_regex default input symbols
The default set of input symbols for NFA.from_regex
was changed to all ASCII letters and digits.
If needing to use a specific set of input symbols, use the input_symbols
parameter.