In [1]:
import RFigure,os
filepath_testfile = "Test.rfig3"
if "tests" in os.listdir():
filepath_testfile = os.path.join("tests",filepath_testfile)
assert os.path.exists(filepath_testfile)
In [2]:
%reload_ext RFigure.RFigureMagics
In [3]:
import numpy as np
X = np.arange(0,10,.1)
Y = np.cos(X)
c = "This is a comment"
d = dict(X=X,Y=1/X) # another variable dictionary
In [4]:
%%rfig_save -h
pass
Out[4]:
In [5]:
%%rfig_save Test.rfig3
# search the variables in the instructions, no comment and save in pdf
plt.plot(X,Y)
In [6]:
%%rfig_save -c c Test.rfig3
# search the variables in the instructions, put the comment of the variable `c`
plt.plot(X,Y)
In [7]:
%%rfig_save -c c -d d Test.rfig3
# search the variables in the instructions, put the comment of the variable `c`
plt.plot(X,Y)
In [8]:
%%rfig_save -c "'This is another comment'" Test.rfig3
# search the variables in the instructions, put the comment of the variable `c`
plt.plot(X,Y)
In [9]:
%%rfig_save -c "'This is another comment'" -fn Test.rfig3
# search the variables in the instructions, put the comment of the variable `c`
plt.plot(X,Y)
In [10]:
# Assert the files with formated name and removes it
import os
from RFigure.RFigureMisc import RDateDisplay
f = "Figure_%s_Test"%RDateDisplay.cur_date()
print(f)
assert os.path.exists(f+".pdf")
os.remove(f+".pdf")
assert os.path.exists(f+".rfig3")
os.remove(f+".rfig3")
In [11]:
%%rfig_save -c "'This is another comment'" -ft eps Test.rfig3
# search the variables in the instructions, put the comment of the variable `c`
plt.plot(X,Y)
In [12]:
# Assert the eps files has been created and remove it
assert os.path.exists("Test.eps")
os.remove("Test.eps")
In [13]:
%rfig_load -h
Out[13]:
In [14]:
%rfig_load -i iii -c ccc Test.rfig3
In [15]:
# Assert that the comments and the instructions have been upload
assert ccc == 'This is another comment'
assert iii == '%pylab\n# search the variables in the instructions, put the comment of the variable `c`\nplt.plot(X,Y)'
In [16]:
%%rfig_list_var -h
pass
Out[16]:
In [17]:
%%rfig_list_var
plot(X,Y)
In [18]:
%%rfig_list_var a_dict
plot(X,Y)
In [19]:
assert set(a_dict.keys())=={'X','Y'}
In [1]:
In [ ]: