Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Add interface for word related functions #57

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions libsemigroups_cppyy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ def cppyy_version():
cppyy.cppdef("#define HPCOMBI_CONSTEXPR_FUN_ARGS")

cppyy.include("libsemigroups/libsemigroups.hpp")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can fix this by doing:

if compare_version_numbers(libsemigroups_version(), "1.1.0") and not compare_version_numbers("1.3.0", libsemigroups_version()):

cppyy.include("libsemigroups/wilo.hpp")
cppyy.include("libsemigroups/wislo.hpp")
cppyy.include("libsemigroups/siso.hpp")

cppyy.gbl.libsemigroups

Expand All @@ -126,6 +129,7 @@ def cppyy_version():
from libsemigroups_cppyy.schreier_sims import SchreierSims
from libsemigroups_cppyy.transf import *
from libsemigroups_cppyy.todd_coxeter import ToddCoxeter
from libsemigroups_cppyy.word import number_of_words, cbegin_wilo, cend_wilo, wilo, cbegin_wislo, cend_wislo, wislo, cbegin_sislo, cend_sislo, sislo, cbegin_silo, cend_silo, silo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also put these lines inside an "if"


microseconds = cppyy.gbl.std.chrono.microseconds
milliseconds = cppyy.gbl.std.chrono.milliseconds
Expand Down
41 changes: 41 additions & 0 deletions libsemigroups_cppyy/word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
This file contains the interface to libsemigroups actions; see

https://libsemigroups.readthedocs.io/en/latest/words.html

for further details.
"""

import cppyy

from cppyy.gbl.libsemigroups import number_of_words

from libsemigroups_cppyy.detail import ForwardRange

from cppyy.gbl.libsemigroups import cbegin_wilo, cend_wilo

from cppyy.gbl.libsemigroups import cbegin_wislo, cend_wislo

from cppyy.gbl.libsemigroups import cbegin_sislo, cend_sislo

from cppyy.gbl.libsemigroups import cbegin_silo, cend_silo

def wilo(n, upper_bound, first, last):
return ForwardRange(
cppyy.gbl.libsemigroups.cbegin_wilo(n, upper_bound, first, last),
cppyy.gbl.libsemigroups.cend_wilo(n, upper_bound, first, last),)

def wislo(n, first, last):
return ForwardRange(
cppyy.gbl.libsemigroups.cbegin_wislo(n, first, last),
cppyy.gbl.libsemigroups.cend_wislo(n, first, last),)

def sislo(alphabet, first, last):
return ForwardRange(
cppyy.gbl.libsemigroups.cbegin_sislo(alphabet, first, last),
cppyy.gbl.libsemigroups.cend_sislo(alphabet, first, last),)

def silo(alphabet, upper_bound, first, last):
return ForwardRange(
cppyy.gbl.libsemigroups.cbegin_silo(alphabet, upper_bound, first, last),
cppyy.gbl.libsemigroups.cend_silo(alphabet, upper_bound, first, last),)