Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request #7

Open
cschwem2er opened this issue Jan 6, 2016 · 14 comments
Open

feature request #7

cschwem2er opened this issue Jan 6, 2016 · 14 comments

Comments

@cschwem2er
Copy link

Is it possible to toggle cell magic on/off for multiple cells? This would be cool because we wouldn't have to use %%stata for every cell.

@TiesdeKok
Copy link
Owner

I have been thinking about that as well, it would be a very convenient feature for sure. I will keep it in the back of my mind, maybe I can figure out a way to add it!

@cschwem2er
Copy link
Author

Do you think a notebook extension like RISE is necessary for this? Or could this be implemented in ipystata directly?

@TiesdeKok
Copy link
Owner

My limited research on this functionality does suggest that the best way would be to develop a notebook extension that allows the user to apply cell magic to a group of selected cells. The notebook 4.1 release adds multi-cells selection so I hope that someone with more knowledge of developing notebook extensions might be able to build on this and figure out a way to do it.

@cschwem2er
Copy link
Author

I tried to contact an expert: Carreau/jupytercontrib#1 (comment)

@mbaker21231
Copy link

Hello --

Another neat feature might be to have cell magic for mata. It's not a big deal, but instead of typing something like:

%%stata -s ses1
mata:
<mata code>
end

It would be nice to just be able to type

%%mata

This actually has a practical purpose - if one forgets to put the end in the cell, it runs forever. I'm ashamed to admit that I forget this all the time!

Matt

@TiesdeKok
Copy link
Owner

Would something like a -m / --mata argument help? Changing it to %%mata is a bit more complex as that would make it a new magic class.

Having a --mata argument that automatically wraps the cell code with mata: and end should however be pretty easy to implement.

@mbaker21231
Copy link

Ties --

What you suggest would be great. One thing to maybe also think about is the difference between starting a Mata session with mata: versus mata - I'm not exactly sure what the difference is, and I almost always use the colon, but I know the two are somehow different!

Matt

@TiesdeKok
Copy link
Owner

Hi Matt,

I have implemented the -m / --mata arguments and adjusted my log file processor to filter out the Mata commands. Could you test it for me to see whether it works with your code (I don't really use Mata that much) and see if you have any suggestions for improvement?

I have uploaded a development version to pip, you can install it using:
pip install ipystata==0.3.3.dev1 (You might have to pip uninstall ipystata first)

Using it is simple, you run for example:

%%stata --mata (or -m)
(1,2)\(3,4)

@mbaker21231
Copy link

Hi Ties --

First, thanks very much for doing all this! I've checked it out and it works great - and in retrospect, it's probably better to have a heading like stata --mata rather than just mata as it gives one a more accurate description as to what the cell is doing.

Thanks again!

Matt

@TiesdeKok
Copy link
Owner

Hi Matt,

Great, you are more than welcome! PyPi is having issues right now but I will push it as an official version somewhere this weekend. 😄

@mbaker21231
Copy link

This might already be possible, but I am curious if one can break lines within an ipystata cell, as one would use the /// characters in Stata.

@TiesdeKok
Copy link
Owner

This is not currently possible (see #9 for the reason why).

However, it is on my to-do list to write a pre-processor that will use Python to take the code contents of a cell and convert it into "valid" Stata code for the interactive window. This would allow the use of /// for line breaks (my code will essential interpret the /// and turn them into a single-line again before sending it to Stata, circumventing the problem).

I will try to look into it asap.

@TiesdeKok
Copy link
Owner

It actually turned out to be a very easy solution. As long as the /// is directly followed by a new line it should work now with version 0.3.5. You can update using pip install ipystata --upgrade --force-reinstall

@mbaker21231
Copy link

Ties --

Wonderful! I'll give it a try as soon as I get a chance, and thanks for the update!

Matt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants