CoCalc Public Filesvcsn.ipynbOpen in with one click!
Authors: Akim Demaille, Dominique SOUDIERE, Harald Schilly, William A. Stein
Views : 28
Description: Jupyter notebook vcsn.ipynb
In [1]:
import sys sys.path.append('/usr/local/lib/python3.4/site-packages') import os #os.environ['LD_LIBRARY_PATH'] = '/usr/local/lib' # os.environ['VCSN_VERBOSE'] = '1' # os.environ['VCSN_PYTHON'] = 'python3' # os.environ['PYTHONPATH'] = '/usr/local/lib/python3.4/site-packages' # del os.environ['PYTHONHOME'] import vcsn
In [2]:
dict(os.environ)
{'AR': 'ar', 'AS': 'as', 'CC': 'gcc', 'CCACHE_BASEDIR': '/projects/sage/sage-7.5', 'CHMOD': 'chmod', 'CLICOLOR': '1', 'CP': 'cp', 'CPATH': '/projects/sage/sage-7.5/local/include:/usr/include/x86_64-linux-gnu', 'CXX': 'g++', 'CYSIGNALS_CRASH_DAYS': '7', 'CYSIGNALS_CRASH_LOGS': '/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//crash_logs', 'DOT_SAGE': '/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage/', 'ECLDIR': '/projects/sage/sage-7.5/local/lib/ecl/', 'F77': 'gfortran', 'F90': 'gfortran', 'F95': 'gfortran', 'FC': 'gfortran', 'GIT_PAGER': 'cat', 'GPDOCDIR': '/projects/sage/sage-7.5/local/share/pari/doc', 'GPHELP': '/projects/sage/sage-7.5/local/bin/gphelp', 'GP_DATA_DIR': '/projects/sage/sage-7.5/local/share/pari', 'HOME': '/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c', 'IPYTHONDIR': '/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//ipython-5.0.0', 'ISOCHRONES': '/projects/data/isochrones', 'JPY_PARENT_PID': '6673', 'JULIA_PKGDIR': '/usr/local/share/julia/site', 'JUPYTER_CONFIG_DIR': '/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//jupyter-4.1', 'LANG': 'en_US.UTF-8', 'LD': 'ld', 'LDFLAGS': '-L/projects/sage/sage-7.5/local/lib -Wl,-rpath,/projects/sage/sage-7.5/local/lib ', 'LD_LIBRARY_PATH': '/usr/lib:/usr/local/lib', 'LIBRARY_PATH': '/projects/sage/sage-7.5/local/lib:/usr/lib/x86_64-linux-gnu', 'LN': 'ln', 'LOGNAME': 'e56b574d17c044e78cc179643e0a4c2c', 'MAIL': '/var/mail/e56b574d17c044e78cc179643e0a4c2c', 'MAKE': 'make', 'MAXIMA_PREFIX': '/projects/sage/sage-7.5/local', 'MKDIR': 'mkdir', 'MPLBACKEND': 'module://ipykernel.pylab.backend_inline', 'MPLCONFIGDIR': '/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//matplotlib-1.5.1', 'MV': 'mv', 'NLTK_DATA': '/projects/data/nltk_data', 'PAGER': 'cat', 'PATH': '/projects/sage/sage-7.5/build/bin:/projects/sage/sage-7.5/src/bin:/projects/sage/sage-7.5/local/bin:/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'PERL5LIB': '/projects/sage/sage-7.5/local/lib/perl5:', 'PIP_INSTALL': 'sage-pip-install', 'PWD': '/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c', 'PYTHONPATH': '/usr/lib/python3.4:/usr/lib/python3.4/plat-x86_64-linux-gnu:/usr/lib/python3.4/lib-dynload:/usr/local/lib/python3.4/dist-packages:/usr/lib/python3/dist-packages:/usr/local/lib/python3.4/site-packages', 'PYTHON_EGG_CACHE': '/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//.python-eggs', 'RANLIB': 'ranlib', 'R_MAKEVARS_SITE': '/projects/sage/sage-7.5/local/lib/R/share/Makevars.site', 'R_MAKEVARS_USER': '/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//R/Makevars.user', 'SAGE64': 'no', 'SAGE_DATA': '/projects/sage/sage-7.5/local/share', 'SAGE_DISTFILES': '/projects/sage/sage-7.5/upstream', 'SAGE_DOC': '/projects/sage/sage-7.5/local/share/doc/sage', 'SAGE_DOC_MATHJAX': 'True', 'SAGE_DOC_SRC': '/projects/sage/sage-7.5/src/doc', 'SAGE_ENV_SOURCED': '4', 'SAGE_ETC': '/projects/sage/sage-7.5/local/etc', 'SAGE_EXTCODE': '/projects/sage/sage-7.5/local/share/sage/ext', 'SAGE_LOCAL': '/projects/sage/sage-7.5/local', 'SAGE_LOGS': '/projects/sage/sage-7.5/logs/pkgs', 'SAGE_NUM_THREADS': '1', 'SAGE_NUM_THREADS_PARALLEL': '8', 'SAGE_ORIG_PATH': '/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'SAGE_ORIG_PATH_SET': 'True', 'SAGE_REPO_ANONYMOUS': 'git://trac.sagemath.org/sage.git', 'SAGE_REPO_AUTHENTICATED': 'ssh://[email protected]:2222/sage.git', 'SAGE_ROOT': '/projects/sage/sage-7.5', 'SAGE_SCRIPTS_DIR': '/projects/sage/sage-7.5/src/bin', 'SAGE_SHARE': '/projects/sage/sage-7.5/local/share', 'SAGE_SPKG_INST': '/projects/sage/sage-7.5/local/var/lib/sage/installed', 'SAGE_SRC': '/projects/sage/sage-7.5/src', 'SAGE_STARTUP_FILE': '/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//init.sage', 'SHELL': '/bin/bash', 'SHLVL': '0', 'SINGULARPATH': '/projects/sage/sage-7.5/local/share/singular', 'SINGULAR_EXECUTABLE': '/projects/sage/sage-7.5/local/bin/Singular', 'SMC': '/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.smc', 'SMC_BASE_URL': '', 'TERM': 'xterm-color', 'TERMINFO': '/projects/sage/sage-7.5/local/share/terminfo', 'TOUCH': 'touch', 'UNAME': 'Linux', 'USER': 'e56b574d17c044e78cc179643e0a4c2c', 'USERNAME': 'e56b574d17c044e78cc179643e0a4c2c', '_JAVA_OPTIONS': '-Xms64m', '__sage__': ''}
In [2]:
vcsn.B
{}B\{\ldots\}\to\mathbb{B}
In [3]:
vcsn.B.expression('a')
aa
In [4]:
a = vcsn.B.expression('a+a*').automaton() a
In [5]:
a.determinize()
In [6]:
vcsn.context('lal, f2').expression('a+a*').automaton().determinize()
In [7]:
vcsn.context('lal, zmin').expression('<2>a+<3>a*').automaton().determinize()
In [ ]:
! echo 'int main(){}' > /tmp/tt.cc
In [ ]:
! PYTHON=/usr/bin/python3 PYTHONHOME= PYTHONPATH=/usr/local/lib/python3.4/site-packages sh -x /usr/local/bin/vcsn compile /tmp/foo.cc
In [8]:
! unset PYTHONHOME=; PYTHONPATH=/usr/local/lib/python3.4/site-packages /usr/local/libexec/vcsn/vcsn-compile -vvv /tmp/foo.cc
/usr/local/lib/python3.4/site-packages/vcsn_tools/demangle.py:11: UserWarning: you should install regex for Python warnings.warn('you should install regex for Python') args: ccache: ccache color: auto cppflags: -I/usr/local/include cxx: g++ -Wl,--no-as-needed cxxflags: -g -O2 -std=c++17 datadir: /usr/local/share/vcsn force: False includedir: /usr/local/include input: /tmp/foo.cc ipython: ipython3 ldflags: -L/usr/local/lib/vcsn -lrt -pthread -lboost_filesystem -lboost_system libdir: /usr/local/lib/vcsn plain: False pyexecdir: /usr/local/lib/python3.4/site-packages python: python3 quiet: False shared: False vars: [] verbose: 4 version: 2.4-116-gd434d8ea /usr/local/libexec/vcsn/vcsn-compile: compilation not needed
In [9]:
! unset PYTHONHOME=; /usr/local/libexec/vcsn/vcsn-compile -vvv /tmp/foo.cc
Traceback (most recent call last): File "/usr/local/libexec/vcsn/vcsn-compile", line 13, in <module> from vcsn_cxx import configuration ImportError: No module named 'vcsn_cxx'
In [6]:
! unset PYTHONHOME; export PYTHONPATH=/usr/local/lib/python3.4/site-packages; /usr/local/libexec/vcsn/vcsn-score --version
/usr/local/libexec/vcsn/vcsn-score:21: UserWarning: not compiled with -DNDEBUG, benches are irrelevant warnings.warn('not compiled with -DNDEBUG, benches are irrelevant') /usr/local/libexec/vcsn/vcsn-score:23: UserWarning: not compiled with -O3, benches are irrelevant warnings.warn('not compiled with -O3, benches are irrelevant') usage: vcsn-score [-h] [-O RE] [-r NUM] [-v] [--check] vcsn-score: error: unrecognized arguments: --version
In [37]:
! unset PYTHONHOME; /usr/bin/python3 -c 'print("foof")'
foof
In [39]:
! env | sort
AR=ar AS=as CCACHE_BASEDIR=/projects/sage/sage-7.5 CC=gcc CHMOD=chmod CLICOLOR=1 CPATH=/projects/sage/sage-7.5/local/include:/usr/include/x86_64-linux-gnu CP=cp CXX=g++ CYSIGNALS_CRASH_DAYS=7 CYSIGNALS_CRASH_LOGS=/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//crash_logs DOT_SAGE=/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage/ ECLDIR=/projects/sage/sage-7.5/local/lib/ecl/ F77=gfortran F90=gfortran F95=gfortran FC=gfortran GIT_PAGER=cat GP_DATA_DIR=/projects/sage/sage-7.5/local/share/pari GPDOCDIR=/projects/sage/sage-7.5/local/share/pari/doc GPHELP=/projects/sage/sage-7.5/local/bin/gphelp HOME=/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c IPYTHONDIR=/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//ipython-5.0.0 ISOCHRONES=/projects/data/isochrones _JAVA_OPTIONS=-Xms64m JPY_PARENT_PID=28978 JULIA_PKGDIR=/usr/local/share/julia/site JUPYTER_CONFIG_DIR=/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//jupyter-4.1 LANG=en_US.UTF-8 LDFLAGS=-L/projects/sage/sage-7.5/local/lib -Wl,-rpath,/projects/sage/sage-7.5/local/lib LD=ld LD_LIBRARY_PATH=/usr/local/lib LIBRARY_PATH=/projects/sage/sage-7.5/local/lib:/usr/lib/x86_64-linux-gnu LN=ln LOGNAME=e56b574d17c044e78cc179643e0a4c2c MAIL=/var/mail/e56b574d17c044e78cc179643e0a4c2c MAKE=make MAXIMA_PREFIX=/projects/sage/sage-7.5/local MKDIR=mkdir MPLBACKEND=module://ipykernel.pylab.backend_inline MPLCONFIGDIR=/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//matplotlib-1.5.1 MV=mv NLTK_DATA=/projects/data/nltk_data PAGER=cat PATH=/projects/sage/sage-7.5/build/bin:/projects/sage/sage-7.5/src/bin:/projects/sage/sage-7.5/local/bin:/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PERL5LIB=/projects/sage/sage-7.5/local/lib/perl5: PIP_INSTALL=sage-pip-install PWD=/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c PYTHON_EGG_CACHE=/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//.python-eggs PYTHONHOME=/projects/sage/sage-7.5/local RANLIB=ranlib R_MAKEVARS_SITE=/projects/sage/sage-7.5/local/lib/R/share/Makevars.site R_MAKEVARS_USER=/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//R/Makevars.user __sage__= SAGE64=no SAGE_DATA=/projects/sage/sage-7.5/local/share SAGE_DISTFILES=/projects/sage/sage-7.5/upstream SAGE_DOC_MATHJAX=True SAGE_DOC=/projects/sage/sage-7.5/local/share/doc/sage SAGE_DOC_SRC=/projects/sage/sage-7.5/src/doc SAGE_ENV_SOURCED=4 SAGE_ETC=/projects/sage/sage-7.5/local/etc SAGE_EXTCODE=/projects/sage/sage-7.5/local/share/sage/ext SAGE_LOCAL=/projects/sage/sage-7.5/local SAGE_LOGS=/projects/sage/sage-7.5/logs/pkgs SAGE_NUM_THREADS=1 SAGE_NUM_THREADS_PARALLEL=8 SAGE_ORIG_PATH=/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin SAGE_ORIG_PATH_SET=True SAGE_REPO_ANONYMOUS=git://trac.sagemath.org/sage.git SAGE_REPO_AUTHENTICATED=ssh://[email protected]:2222/sage.git SAGE_ROOT=/projects/sage/sage-7.5 SAGE_SCRIPTS_DIR=/projects/sage/sage-7.5/src/bin SAGE_SHARE=/projects/sage/sage-7.5/local/share SAGE_SPKG_INST=/projects/sage/sage-7.5/local/var/lib/sage/installed SAGE_SRC=/projects/sage/sage-7.5/src SAGE_STARTUP_FILE=/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.sage//init.sage SHELL=/bin/bash SHLVL=0 SINGULAR_EXECUTABLE=/projects/sage/sage-7.5/local/bin/Singular SINGULARPATH=/projects/sage/sage-7.5/local/share/singular SMC_BASE_URL= SMC=/projects/e56b574d-17c0-44e7-8cc1-79643e0a4c2c/.smc TERMINFO=/projects/sage/sage-7.5/local/share/terminfo TERM=xterm-color TOUCH=touch UNAME=Linux USER=e56b574d17c044e78cc179643e0a4c2c USERNAME=e56b574d17c044e78cc179643e0a4c2c VCSN_PYTHON=python3 VCSN_VERBOSE=1
In [13]:
sys.version
'3.4.3+ (default, Oct 14 2015, 16:03:50) \n[GCC 5.2.1 20151010]'
In [14]:
sys.executable
'/usr/bin/python3'