mwxlib 1.2.3__py3-none-any.whl → 1.2.4__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/framework.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #! python3
2
2
  """mwxlib framework.
3
3
  """
4
- __version__ = "1.2.3"
4
+ __version__ = "1.2.4"
5
5
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
6
6
 
7
7
  from contextlib import contextmanager
mwx/matplot2g.py CHANGED
@@ -73,20 +73,18 @@ def _to_image(src, cutoff=0, threshold=None, binning=1):
73
73
  if src.dtype in (np.complex64, np.complex128): # maybe fft pattern
74
74
  src = np.log(1 + abs(src))
75
75
 
76
- bins = binning
77
76
  if threshold:
78
- ## Converted to <uint8(=1byte)> finally, binning should be reduced by itemsize.
79
- n = int(np.sqrt(src.nbytes / threshold / src.itemsize)) + 1
80
- if bins < n:
81
- bins = n # binning or threshold; Select the larger one.
82
-
83
- if bins > 1:
84
- ## src = src[::bins,::bins]
77
+ ## Reduce the binning by itemsize before finally converting to <uint8>.
78
+ ## Select the larger value between binning and threshold.
79
+ n = max(binning, int(np.sqrt(src.nbytes / threshold / src.itemsize)) + 1)
80
+ else:
81
+ n = binning
82
+ if n > 1:
85
83
  src = _to_cvtype(src)
86
- src = cv2.resize(src, None, fx=1/bins, fy=1/bins, interpolation=cv2.INTER_AREA)
84
+ src = cv2.resize(src, None, fx=1/n, fy=1/n, interpolation=cv2.INTER_AREA)
87
85
 
88
86
  if src.dtype == np.uint8: # RGB or gray image <uint8>
89
- return bins, (0, 255), src
87
+ return n, (0, 255), src
90
88
 
91
89
  if hasattr(cutoff, '__iter__'): # cutoff vlim: (vmin, vmax) is specified.
92
90
  a, b = cutoff
@@ -99,10 +97,10 @@ def _to_image(src, cutoff=0, threshold=None, binning=1):
99
97
 
100
98
  r = (255 / (b - a)) if a < b else 1
101
99
  ## img = cv2.convertScaleAbs(src, alpha=r, beta=-r*a) # 負数は絶対値になるので以下に変更
102
- img = np.uint8((src - a) * r) # copy buffer
100
+ img = np.uint8((src - a) * r)
103
101
  img[src < a] = 0
104
102
  img[src > b] = 255
105
- return bins, (a, b), img
103
+ return n, (a, b), img
106
104
 
107
105
 
108
106
  def _Property(name):
@@ -155,6 +153,7 @@ class AxesImagePhantom:
155
153
  return getattr(self.__art, attr)
156
154
 
157
155
  def __eq__(self, x):
156
+ ## Called in `on_pick` and `__contains__` to check objects in.
158
157
  return x is self.__art
159
158
 
160
159
  def update_attributes(self, attr=None, **kwargs):
@@ -221,7 +220,7 @@ class AxesImagePhantom:
221
220
 
222
221
  image = property(
223
222
  lambda self: self.__art.get_array(),
224
- doc="A displayed image array<uint8>.")
223
+ doc="Displayed image array<uint8>.")
225
224
 
226
225
  clim = property(
227
226
  lambda self: self.__art.get_clim(),
@@ -235,7 +234,7 @@ class AxesImagePhantom:
235
234
  pathname = property(
236
235
  lambda self: self.__attributes.get('pathname'),
237
236
  lambda self,v: self.update_attributes({'pathname': v}),
238
- doc="A fullpath of buffer, when bounds to file.")
237
+ doc="Fullpath of the buffer, if bound to a file.")
239
238
 
240
239
  annotation = property(
241
240
  lambda self: self.__attributes.get('annotation', ''),
@@ -631,6 +630,10 @@ class GraphPlot(MatplotPanel):
631
630
  if isinstance(buf, str):
632
631
  buf = Image.open(buf)
633
632
 
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
+
634
637
  pathname = kwargs.get('pathname')
635
638
  paths = [art.pathname for art in self.__Arts]
636
639
  names = [art.name for art in self.__Arts]
@@ -829,8 +832,8 @@ class GraphPlot(MatplotPanel):
829
832
  self.canvas.draw_idle()
830
833
 
831
834
  def kill_buffer(self):
832
- if self.buffer is not None:
833
- del self.buffer
835
+ if self.frame:
836
+ del self[self.__index]
834
837
 
835
838
  def kill_buffer_all(self):
836
839
  del self[:]
mwx/wxpdb.py CHANGED
@@ -53,7 +53,6 @@ class Debugger(Pdb):
53
53
  use_rawinput = False
54
54
  prompt = property(lambda self: self.indents + '(Pdb) ',
55
55
  lambda self,v: None) # fake setter
56
- parent = property(lambda self: self.__shellframe)
57
56
  handler = property(lambda self: self.__handler)
58
57
 
59
58
  @property
@@ -90,12 +89,12 @@ class Debugger(Pdb):
90
89
  def __init__(self, parent, *args, **kwargs):
91
90
  Pdb.__init__(self, *args, **kwargs)
92
91
 
93
- self.__shellframe = parent
94
- self.__hookpoint = None
92
+ self.parent = parent
95
93
  self.indents = ' ' * 2
96
94
  self.interactive_shell = parent.rootshell
97
95
  self.editor = None
98
96
  self.code = None
97
+ self.__hookpoint = None
99
98
 
100
99
  def _input(msg):
101
100
  ## redirects input such as cl(ear)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 1.2.3
3
+ Version: 1.2.4
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,18 +1,18 @@
1
1
  mwx/__init__.py,sha256=pS7ZG8QKRypiFFiaWAq_opBB6I_1viZ0zUMk2TbjzE0,667
2
2
  mwx/bookshelf.py,sha256=b_TMDaNIzLHoL0xbbqb3tt0BnRvhLAqaCn_pBdrigZw,7523
3
3
  mwx/controls.py,sha256=X4zx2h6oggUsQxi2PRk4RUsJieYTmcAPIvWwaz-ysTI,48107
4
- mwx/framework.py,sha256=wXI4nzQcG0NV3c5ne4io9HJ1y7jd7xbjB_cOao8HKsU,76125
4
+ mwx/framework.py,sha256=8Vh1Tkqod9sWp81ObY5Ofcqto_UJerT_VtEgA97huoA,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=tShPGy7whj51yvANja-MDmjfxiLubQ1C6rCsBZ0DAnY,64473
8
+ mwx/matplot2g.py,sha256=tp0KD_dqDgupTVROY4YFZyfvHS_d21w4uS3x0Sd_zSA,64643
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
13
  mwx/utilus.py,sha256=HFvP682SyeSp8yNfUrdUXPhWdLuWVlsUSg6LqNBJOT8,37451
14
14
  mwx/wxmon.py,sha256=yzWqrbY6LzpfRwQeytYUeqFhFuLVm_XEvrVAL_k0HBQ,12756
15
- mwx/wxpdb.py,sha256=AObuf4JLAmlQLj-yf0_mkBBd-Bhhz2Vb8hbTVcHEZOs,18875
15
+ mwx/wxpdb.py,sha256=ge4hNfeigHGcpnioU1B_BJX_QZjNdtnokUrcZOxcEcI,18814
16
16
  mwx/wxwil.py,sha256=hhyB1lPrF9ixeObxCOKQv0Theu-B-kpJg_yVU3EGSNg,5406
17
17
  mwx/wxwit.py,sha256=1hHtMi2YEy2T_LnUpwdmrIdtCuvxMOFyykqnbq6jLP0,7294
18
18
  mwx/plugins/__init__.py,sha256=jnJ-Sl9XJ_7BFDslD_r7dsbxsOT57q_IaEriV53XIGY,41
@@ -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.3.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
26
- mwxlib-1.2.3.dist-info/METADATA,sha256=2sSF51qYRi78w0McPUzYn2yr9H1ISRKXMfvWSB-ATls,7258
27
- mwxlib-1.2.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
28
- mwxlib-1.2.3.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
29
- mwxlib-1.2.3.dist-info/RECORD,,
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,,
File without changes