mpastell / Pweave

Pweave is a scientific report generator and a literate programming tool for Python. It can capture the results and plots from data analysis and works well with numpy, scipy and matplotlib.
http://mpastell.com/pweave
Other
435 stars 64 forks source link

No output when printing string 1-character long. #78

Closed chendaniely closed 7 years ago

chendaniely commented 7 years ago

It seems that when trying to slice the first letter in a string, the results are not being stored

The pweave file:

\documentclass{article}

\begin{document}

<<>>=
word = 'word'
print(word[0])
@

<<>>=
word = 'word'
print(word[0:1])
@

<<>>=
word = 'word'
print(word[0:2])
@

<<>>=
word = 'word'
f = word[0]
print(len(f))
@

\end{document}

commands to create and view the document

pweave -f tex pweave_print.texw
pdflatex pweave_print.tex
xdg-open pweave_print.pdf

Here is the PDF output I'm getting:

image

mpastell commented 7 years ago

Which version of Pweave? I don't have this error using master.

chendaniely commented 7 years ago
pweave --version
Pweave 0.25
chendaniely commented 7 years ago

I'm using anaconda under a conda environment and installed it via:

conda install -c conda-forge pweave

chendaniely commented 7 years ago

For the time being, I'm setting the chunks to evaluate=False and manually copy/pasting the results in the following block

\begin{minted}[fontsize=\small, xleftmargin=0.5em, mathescape, frame = leftline]{text}
# python code output

\end{minted}
mpastell commented 7 years ago

I don't have the time to fix it for 0.25 right now. I recommend you try using current master. Or wait for 0.30 release which is almost ready.

chendaniely commented 7 years ago

I'll tinker around with various build and installation methods and report back.

abukaj commented 7 years ago

It is not about the slicing. I found minimal failing example (pweave 0.24):

<<>>=
print('a')
@

weaves to:

\begin{verbatim}
print('a')
\end{verbatim}

Same is for small integers (like print(1))

mpastell commented 7 years ago

I added a reference to the fix if you want to backport it to 0.25. This is fixed in 0.30, which is now released so I'll close this issue.

chendaniely commented 7 years ago

Sorry, didn't realize 0.3.0 was realized on the channels. Everything seems to be in working order. Thanks!

mpastell commented 7 years ago

It wasn't when you opened the issue, glad that it's working