mwxlib 1.2.4__py3-none-any.whl → 1.2.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mwxlib might be problematic. Click here for more details.

mwx/controls.py CHANGED
@@ -770,6 +770,7 @@ class Clipboard:
770
770
  return text
771
771
  else:
772
772
  print("- Unable to open clipboard.")
773
+ return None
773
774
 
774
775
  @staticmethod
775
776
  def write(text, verbose=False):
@@ -792,7 +793,7 @@ class Clipboard:
792
793
  bmp = do.GetBitmap()
793
794
  else:
794
795
  print("- Unable to open clipboard.")
795
- return
796
+ return None
796
797
  try:
797
798
  ## Convert bmp --> buf
798
799
  img = bmp.ConvertToImage()
@@ -802,7 +803,8 @@ class Clipboard:
802
803
  w, h = img.GetSize()
803
804
  return buf.reshape(h, w, 3)
804
805
  except Exception:
805
- print("- The contents of the clipboard are not images.")
806
+ print("- Contents of the clipboard are not images.")
807
+ return None
806
808
 
807
809
  @staticmethod
808
810
  def imwrite(buf, verbose=False):
@@ -815,7 +817,7 @@ class Clipboard:
815
817
  img = wx.Image(w, h, buf.tobytes())
816
818
  bmp = img.ConvertToBitmap()
817
819
  except Exception:
818
- print("- The contents of the clipboard are not images.")
820
+ print("- Argument 'buf' is not a 2d array.")
819
821
  return
820
822
  do = wx.BitmapDataObject(bmp)
821
823
  if wx.TheClipboard.Open():
mwx/framework.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #! python3
2
2
  """mwxlib framework.
3
3
  """
4
- __version__ = "1.2.4"
4
+ __version__ = "1.2.5"
5
5
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
6
6
 
7
7
  from contextlib import contextmanager
mwx/matplot2g.py CHANGED
@@ -1,7 +1,6 @@
1
1
  #! python3
2
2
  """mwxlib graph plot for images.
3
3
  """
4
- import traceback
5
4
  import wx
6
5
 
7
6
  from matplotlib import cm
@@ -49,6 +48,11 @@ def _to_buffer(img):
49
48
  w, h = img.GetSize()
50
49
  img = np.frombuffer(img.GetDataBuffer(), dtype='uint8').reshape(h, w, 3)
51
50
 
51
+ if not isinstance(img, np.ndarray):
52
+ raise ValueError("targets must be arrays or images.")
53
+
54
+ assert img.ndim > 1, "targets must be 2d arrays."
55
+
52
56
  if img.ndim > 2:
53
57
  return cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
54
58
  return img
@@ -630,10 +634,6 @@ class GraphPlot(MatplotPanel):
630
634
  if isinstance(buf, str):
631
635
  buf = Image.open(buf)
632
636
 
633
- if not isinstance(buf, (np.ndarray, Image.Image, wx.Bitmap, wx.Image)):
634
- warn("Load targets must be either arrays or images.")
635
- return None
636
-
637
637
  pathname = kwargs.get('pathname')
638
638
  paths = [art.pathname for art in self.__Arts]
639
639
  names = [art.name for art in self.__Arts]
@@ -700,22 +700,19 @@ class GraphPlot(MatplotPanel):
700
700
  return buffers[j] # j can also be slicing
701
701
 
702
702
  def __setitem__(self, j, v):
703
+ if v is None:
704
+ raise ValueError("values must be buffers, not NoneType.")
705
+
703
706
  if isinstance(j, str):
704
- try:
705
- j = self.index(j) # overwrite buffer
706
- except ValueError:
707
- return self.load(v, name=j) # new buffer
707
+ return self.load(v, name=j) # update buffer or new buffer
708
708
 
709
709
  if isinstance(j, slice):
710
710
  raise ValueError("attempt to assign buffers via slicing")
711
711
 
712
- if v is None:
713
- raise ValueError("values must be buffers, not NoneType.")
714
- else:
715
- art = self.__Arts[j]
716
- art.update_buffer(v) # update buffer
717
- art.update_extent()
718
- self.select(j)
712
+ art = self.__Arts[j]
713
+ art.update_buffer(v) # update buffer
714
+ art.update_extent()
715
+ self.select(j)
719
716
 
720
717
  def __delitem__(self, j):
721
718
  if isinstance(j, str):
@@ -962,34 +959,28 @@ class GraphPlot(MatplotPanel):
962
959
  if not frame:
963
960
  self.message("No frame")
964
961
  return
965
- try:
966
- name = frame.name
967
- data = frame.roi
968
- GraphPlot.clipboard_name = name
969
- GraphPlot.clipboard_data = data
970
- bins, vlim, img = _to_image(data, frame.cuts)
971
- Clipboard.imwrite(img)
972
- self.message("Write buffer to clipboard.")
973
- except Exception as e:
974
- traceback.print_exc()
975
- self.message("- Failed to write to clipboard.", e)
962
+
963
+ name = frame.name
964
+ data = frame.roi
965
+ GraphPlot.clipboard_name = name
966
+ GraphPlot.clipboard_data = data
967
+ bins, vlim, img = _to_image(data, frame.cuts)
968
+ Clipboard.imwrite(img)
969
+ self.message("Write buffer to clipboard.")
976
970
 
977
971
  def read_buffer_from_clipboard(self):
978
972
  """Read buffer data from clipboard."""
979
- try:
980
- name = GraphPlot.clipboard_name
981
- data = GraphPlot.clipboard_data
982
- if name:
983
- self.message("Read buffer from clipboard.")
984
- GraphPlot.clipboard_name = None
985
- GraphPlot.clipboard_data = None
986
- else:
987
- self.message("Read image from clipboard.")
988
- data = Clipboard.imread()
973
+ name = GraphPlot.clipboard_name
974
+ data = GraphPlot.clipboard_data
975
+ if name:
976
+ self.message("Read buffer from clipboard.")
977
+ GraphPlot.clipboard_name = None
978
+ GraphPlot.clipboard_data = None
979
+ else:
980
+ self.message("Read image from clipboard.")
981
+ data = Clipboard.imread()
982
+ if data is not None:
989
983
  self.load(data)
990
- except Exception as e:
991
- traceback.print_exc()
992
- self.message("- No data in clipboard.", e)
993
984
 
994
985
  def destroy_colorbar(self):
995
986
  if self.cbar:
mwx/utilus.py CHANGED
@@ -37,15 +37,16 @@ def ignore(*category):
37
37
  yield
38
38
 
39
39
 
40
- def warn(message, category=None):
41
- frame = inspect.currentframe().f_back # previous call stack frame
42
- skip = [frame.f_code.co_filename]
43
- stacklevel = 1
44
- while frame.f_code.co_filename in skip:
45
- frame = frame.f_back
46
- if not frame:
47
- break
48
- stacklevel += 1
40
+ def warn(message, category=None, stacklevel=None):
41
+ if stacklevel is None:
42
+ frame = inspect.currentframe().f_back # previous call stack frame
43
+ skip = [frame.f_code.co_filename]
44
+ stacklevel = 1
45
+ while frame.f_code.co_filename in skip:
46
+ frame = frame.f_back
47
+ if not frame:
48
+ break
49
+ stacklevel += 1
49
50
  return warnings.warn(message, category, stacklevel+1)
50
51
 
51
52
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: A wrapper of matplotlib and wxPython (phoenix)
5
5
  Home-page: https://github.com/komoto48g/mwxlib
6
6
  Author: Kazuya O'moto
@@ -1,16 +1,16 @@
1
1
  mwx/__init__.py,sha256=pS7ZG8QKRypiFFiaWAq_opBB6I_1viZ0zUMk2TbjzE0,667
2
2
  mwx/bookshelf.py,sha256=b_TMDaNIzLHoL0xbbqb3tt0BnRvhLAqaCn_pBdrigZw,7523
3
- mwx/controls.py,sha256=X4zx2h6oggUsQxi2PRk4RUsJieYTmcAPIvWwaz-ysTI,48107
4
- mwx/framework.py,sha256=8Vh1Tkqod9sWp81ObY5Ofcqto_UJerT_VtEgA97huoA,76125
3
+ mwx/controls.py,sha256=5PCy3zguDRuwYl89P9tOCUU7xAGUETs944qZBy5MS9g,48146
4
+ mwx/framework.py,sha256=c0o6IXrdgvfpnPXHPNYU7isqzOydXwtiMY7-qRXMFyQ,76125
5
5
  mwx/graphman.py,sha256=RqD0W9I2BvJ3Q2kyMiyyg4n-T4-_x7PDuCI5bGAg5k4,70110
6
6
  mwx/images.py,sha256=oxCn0P-emiWujSS2gUgU5TUnr5cPjix2jBcjOBDr24I,48701
7
7
  mwx/matplot2.py,sha256=Zwte-wwzCg_OHzsBniVgKdaNLzsvJaa1gc0n7VdAqxw,33150
8
- mwx/matplot2g.py,sha256=tp0KD_dqDgupTVROY4YFZyfvHS_d21w4uS3x0Sd_zSA,64643
8
+ mwx/matplot2g.py,sha256=ywvu5-QAIgv4jc1kalNYgVGcl4RoY9Y1Dx1qtteaqXk,64195
9
9
  mwx/matplot2lg.py,sha256=JRWjWnLJUytbSq6wxs4P0gbVUr3xoLSF6Wwqd5V_pJI,27404
10
10
  mwx/mgplt.py,sha256=8mXbHpCmm7lz3XbAxOg7IVC7DaSGBEby1UfTlMl9kjk,5604
11
11
  mwx/nutshell.py,sha256=7nQ7UUFM9kvjDjHNUEdOkkeqZPiU6zOERwamqBdJpQs,140856
12
12
  mwx/testsuite.py,sha256=kiM3-BVhr42LRRN7xG7pYl3at8o2vnypWSxD8KRvA7c,1228
13
- mwx/utilus.py,sha256=HFvP682SyeSp8yNfUrdUXPhWdLuWVlsUSg6LqNBJOT8,37451
13
+ mwx/utilus.py,sha256=bDeooo2bOcZwvkIdi0ElkT-qoblqzHNFsIveb72NFOo,37528
14
14
  mwx/wxmon.py,sha256=yzWqrbY6LzpfRwQeytYUeqFhFuLVm_XEvrVAL_k0HBQ,12756
15
15
  mwx/wxpdb.py,sha256=ge4hNfeigHGcpnioU1B_BJX_QZjNdtnokUrcZOxcEcI,18814
16
16
  mwx/wxwil.py,sha256=hhyB1lPrF9ixeObxCOKQv0Theu-B-kpJg_yVU3EGSNg,5406
@@ -22,8 +22,8 @@ mwx/plugins/frame_listview.py,sha256=gowjQ-ARNonMkDSXkQgPKq4U9YBJ-vQ0jK2krBVOdCs
22
22
  mwx/plugins/line_profile.py,sha256=zzm6_7lnAnNepLbh07ordp3nRWDFQJtu719ZVjrVf8s,819
23
23
  mwx/py/__init__.py,sha256=xykgfOytOwNuvXsfkLoumFZSTN-iBsHOjczYXngjmUE,12
24
24
  mwx/py/filling.py,sha256=fumUG1F5M9TL-Dfqni4G85uk7TmvnUunTbdcPDV0vfo,16857
25
- mwxlib-1.2.4.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
26
- mwxlib-1.2.4.dist-info/METADATA,sha256=jgZUZOULgdBFRgLPPjGzxfiPOsz4xdibdZgiXipWvK0,7258
27
- mwxlib-1.2.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
28
- mwxlib-1.2.4.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
29
- mwxlib-1.2.4.dist-info/RECORD,,
25
+ mwxlib-1.2.5.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
26
+ mwxlib-1.2.5.dist-info/METADATA,sha256=HZpDkw3rpf_1eFrLWB4UFT2sGfuJQ0nDV7cUyWuot-w,7258
27
+ mwxlib-1.2.5.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
28
+ mwxlib-1.2.5.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
29
+ mwxlib-1.2.5.dist-info/RECORD,,
File without changes