Skip to content

Commit

Permalink
suppressed wx.FRAME_TOOL_WINDOW due to the issues on virtualbox, wind…
Browse files Browse the repository at this point in the history
…ows, Mac
  • Loading branch information
sshiraiwa committed Jan 23, 2024
1 parent d7a5110 commit 388071c
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 10 deletions.
54 changes: 54 additions & 0 deletions petram/helper/matrix_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,60 @@ def read_matvec(file, all=False, verbose=False, complex=False, skip=0):
return np.vstack(ret)


def read_coo_matrix(file, all=False, verbose=False, complex=False, skip=0):
'''
read coo matrix file
If all is on, read all files with same basename ('matrix.0000, matrix.0001...')
'''
import scipy.sparse
from scipy.sparse import coo_matrix

if not all:
files = [file]
else:
dir = os.path.dirname(file)
base = os.path.basename(file)
files = []
for x in os.listdir(dir):
if x.find(base) != -1:
files.append(x)
files = sorted(files)
files = [os.path.join(dir, f) for f in files]
if verbose:
six.print_(files)

if len(files) == 0:
return

retall = []
for file in files:
ret = []
fid = open(file, "r")
xx = [x.strip().split() for x in fid.readlines()]
xx = xx[skip:]
if complex:
xxx = [[np.complex(x) for x in y] for y in xx]
else:
xxx = [[np.float(x) for x in y] for y in xx]
fid.close()
ret.append(np.array(xxx))
retall.append(np.vstack(ret))

w = int(np.max([np.max(x[:, 1]) for x in retall]))+1
h = [int(np.max(x[:, 0]))+1 for x in retall]

if len(retall[0][0]) == 4:
mats = [coo_matrix((m[0][:, 2]+m[:, 3]*1j, (m[0][:, 0].astype(int), m[0][:, 1].astype(int))), shape=(hh, w))
for hh, m in zip(h, retall)]
elif len(retall[0][0]) == 3:
mats = [coo_matrix((m[0][:, 2], (m[0][:, 0].astype(int), m[0][:, 1].astype(int))), shape=(hh, w))
for hh, m in zip(h, retall)]

mat = scipy.sparse.vstack(mats)

return mat


def write_matrix(file, m):
from petram.mfem_config import use_parallel
if use_parallel:
Expand Down
4 changes: 2 additions & 2 deletions petram/pi/dlg_edit_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def __init__(self, parent, id, title, model=None):
wx.CLOSE_BOX |
wx.MINIMIZE_BOX |
wx.RESIZE_BORDER |
wx.FRAME_FLOAT_ON_PARENT |
wx.FRAME_TOOL_WINDOW)
wx.FRAME_FLOAT_ON_PARENT)
# wx.FRAME_TOOL_WINDOW this style may not work on Mac/Windows

#style = wx.RESIZE_BORDER
super(DlgEditModel, self).__init__(parent, id, title, style=style)
Expand Down
4 changes: 2 additions & 2 deletions petram/pi/dlg_plot_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def __init__(self, parent, id = wx.ID_ANY, title = 'Plot Expression', **kwargs):
wx.CLOSE_BOX|
wx.MINIMIZE_BOX|
wx.RESIZE_BORDER|
wx.FRAME_FLOAT_ON_PARENT|
wx.FRAME_TOOL_WINDOW)
wx.FRAME_FLOAT_ON_PARENT)
# wx.FRAME_TOOL_WINDOW : this styles may not work on Windows/Mac
super(DlgPlotExpr, self).__init__(parent, id, title, style=style, **kwargs)

self.parent = parent
Expand Down
4 changes: 2 additions & 2 deletions petram/pi/dlg_plot_sol.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def __init__(self, parent, id=wx.ID_ANY, title='Plot Solution', **kwargs):
wx.CLOSE_BOX |
wx.MINIMIZE_BOX |
wx.RESIZE_BORDER |
wx.FRAME_FLOAT_ON_PARENT |
wx.FRAME_TOOL_WINDOW)
wx.FRAME_FLOAT_ON_PARENT)
# wx.FRAME_TOOL_WINDOW : this styles may not work on Windows/Mac

from petram.sol.evaluators import def_config
self.config = def_config
Expand Down
6 changes: 3 additions & 3 deletions petram/pi/selection_palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ def __init__(self, parent, id, title, model = None):
wx.CLOSE_BOX|
wx.MINIMIZE_BOX|
wx.RESIZE_BORDER|
wx.FRAME_FLOAT_ON_PARENT|
wx.FRAME_TOOL_WINDOW)
wx.FRAME_FLOAT_ON_PARENT)
# wx.FRAME_TOOL_WINDOW : this styles may not work on Windows/Mac

#style = wx.RESIZE_BORDER
super(SelectionPalette, self).__init__(parent, id, title, style=style)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
setup(
name='PetraM_Base',

version='2.1.28',
version='2.1.29',

description='PetraM base package',
long_description=long_description,
Expand Down

0 comments on commit 388071c

Please sign in to comment.