File tree Expand file tree Collapse file tree 2 files changed +45
-6
lines changed
Expand file tree Collapse file tree 2 files changed +45
-6
lines changed Original file line number Diff line number Diff line change 1212 "collapsed" : false ,
1313 "input" : [
1414 " import os\n " ,
15+ " import numpy as np\n " ,
1516 " import pymatbridge as pymat\n " ,
1617 " reload(pymat)"
1718 ],
179180 ],
180181 "prompt_number" : 7
181182 },
183+ {
184+ "cell_type" : " code" ,
185+ "collapsed" : false ,
186+ "input" : [
187+ " %%matlab -o cmpl\n " ,
188+ " a = linspace(0.01,6*pi,100);\n " ,
189+ " cmpl = exp(1i * a);"
190+ ],
191+ "language" : " python" ,
192+ "metadata" : {},
193+ "outputs" : [],
194+ "prompt_number" : 8
195+ },
196+ {
197+ "cell_type" : " code" ,
198+ "collapsed" : false ,
199+ "input" : [
200+ " cmpl[2] # complex data works also"
201+ ],
202+ "language" : " python" ,
203+ "metadata" : {},
204+ "outputs" : [
205+ {
206+ "metadata" : {},
207+ "output_type" : " pyout" ,
208+ "prompt_number" : 9 ,
209+ "text" : [
210+ " array([ 0.92468189+0.3807406j])"
211+ ]
212+ }
213+ ],
214+ "prompt_number" : 9
215+ },
182216 {
183217 "cell_type" : " code" ,
184218 "collapsed" : false ,
185219 "input" : [],
186220 "language" : " python" ,
187221 "metadata" : {},
188- "outputs" : []
222+ "outputs" : [],
223+ "prompt_number" : 9
189224 }
190225 ],
191226 "metadata" : {}
Original file line number Diff line number Diff line change 2121
2222import numpy as np
2323try :
24- import tables
24+ import h5py
2525 import scipy .io as sio
2626 has_io = True
2727except ImportError :
2828 has_io = False
29- no_io_str = "Must have pytables and scipy.io to perform i/o"
29+ no_io_str = "Must have h5py and scipy.io to perform i/o"
3030 no_io_str += "operations with the Matlab session"
3131
3232from IPython .core .displaypub import publish_display_data
@@ -62,11 +62,15 @@ def __str__(self):
6262
6363def loadmat (fname ):
6464 """
65- Use pytables to read a variable from a v7.3 mat file
65+ Use h5py to read a variable from a v7.3 mat file
6666 """
6767
68- f = tables .File (fname )
69- return f .root .__getattr__ (f .root .__members__ [0 ])
68+ f = h5py .File (fname )
69+ data = f .values ()[0 ][:]
70+ if len (data .dtype ) > 0 :
71+ # must be complex data
72+ data = data ['real' ] + 1j * data ['imag' ]
73+ return data
7074
7175
7276def matlab_converter (matlab , key ):
You can’t perform that action at this time.
0 commit comments