Open ideabucket opened 2 years ago
I have added a new option echo
. Setting it to True
in the configuration file should give you the desired effect.
pip install git+https://github.com/ticoneva/pystata-kernel.git
python -m pystata-kernel.install --conf-file
echo
to True
in the configuration file:
[pystata-kernel]
...
echo = True
Let me know if it works or not.
Thanks for the quick response—this produces consistent behaviour, in that all cells now echo back the command, but it's the opposite of what I wanted. I'd like to suppress the echo in multi-command cells (which was the stata_kernel behaviour). In other words:
sysuse auto
tab foreign rep78
(1978 Automobile Data) Repair | Record | Car type 1978 | Domestic Foreign | Total -----------+----------------------+---------- 1 | 2 0 | 2 2 | 8 0 | 8 3 | 27 3 | 30 4 | 9 9 | 18 5 | 2 9 | 11 -----------+----------------------+---------- Total | 48 21 | 69
Unfortunately, there appears to be no way to do that directly through pystata—or Stata, for that matter. The workaround is to use a combination of quietly
and noisily
:
quietly {
noisily: sysuse auto
noisily: tab foreign rep 78
}
I spoke too soon. There is a way and it will be incorporated in the next version.
Version 0.1.20 accepts echo = None
, which suppresses all commands.
Handling multi-line commands requires porting stata_kernel
's CodeManager
class with significant changes. Since this will take significant effort, I am removing this feature until it actually works.
Thanks so much for writing this!
If you have a cell that contains more than one command, the output from Stata contains the full console, including each command. For example, here's what you get if you run two commands from one cell:
But if you break up the commands to one per cell you don't get the echo:
Based on the documentation forpystata.stata.run
it looks like the way to fix this is to wrap what's passed as itscode
parameter in"""
, which will make Stata treat the cell like a do-file.I'd write a PR for this but I don't know Python. Sorry!