SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(8)
2
3
4
(1)
5
(2)
6
(7)
7
(3)
8
(7)
9
(3)
10
(2)
11
(4)
12
(9)
13
14
15
16
17
(5)
18
(1)
19
20
21
22
23
24
25
26
27
28





Showing 2 results of 2

From: <ef...@us...> - 2011年02月05日 21:57:30
Revision: 8947
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8947&view=rev
Author: efiring
Date: 2011年02月05日 21:57:21 +0000 (2011年2月05日)
Log Message:
-----------
cbook.report_memory: add Windows support via "tasklist"
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/lib/matplotlib/cbook.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2011年02月05日 20:56:02 UTC (rev 8946)
+++ trunk/matplotlib/CHANGELOG	2011年02月05日 21:57:21 UTC (rev 8947)
@@ -1,3 +1,6 @@
+2011年02月05日 Add cbook memory monitoring for Windows, using
+ tasklist. - EF
+
 2011年02月05日 Speed up Normalize and LogNorm by using in-place
 operations and by using float32 for float32 inputs
 and for ints of 2 bytes or shorter; based on
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py	2011年02月05日 20:56:02 UTC (rev 8946)
+++ trunk/matplotlib/lib/matplotlib/cbook.py	2011年02月05日 21:57:21 UTC (rev 8947)
@@ -1233,7 +1233,7 @@
 
 def report_memory(i=0): # argument may go away
 'return the memory consumed by process'
- from subprocess import Popen, PIPE
+ from subprocess import Popen, PIPE, check_output
 pid = os.getpid()
 if sys.platform=='sunos5':
 a2 = Popen('ps -p %d -o osz' % pid, shell=True,
@@ -1247,7 +1247,12 @@
 a2 = Popen('ps -p %d -o rss,vsz' % pid, shell=True,
 stdout=PIPE).stdout.readlines()
 mem = int(a2[1].split()[0])
-
+ elif sys.platform.startswith('win'):
+ a2 = check_output(["tasklist", "/nh", "/fi", "pid eq %d" % pid])
+ mem = int(a2.strip().split()[-2].replace(',',''))
+ else:
+ raise NotImplementedError(
+ "We don't have a memory monitor for %s" % sys.platform)
 return mem
 
 _safezip_msg = 'In safezip, len(args[0])=%d but len(args[%d])=%d'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2011年02月05日 20:56:08
Revision: 8946
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8946&view=rev
Author: efiring
Date: 2011年02月05日 20:56:02 +0000 (2011年2月05日)
Log Message:
-----------
speed up Normalize, LogNorm, colormapping; modified patch by C. Gohlke
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/examples/pylab_examples/image_slices_viewer.py
 trunk/matplotlib/lib/matplotlib/colors.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2011年02月04日 19:18:57 UTC (rev 8945)
+++ trunk/matplotlib/CHANGELOG	2011年02月05日 20:56:02 UTC (rev 8946)
@@ -1,3 +1,8 @@
+2011年02月05日 Speed up Normalize and LogNorm by using in-place
+ operations and by using float32 for float32 inputs
+ and for ints of 2 bytes or shorter; based on
+ patch by Christoph Gohlke. - EF
+
 2011年02月04日 Changed imshow to use rgba as uint8 from start to
 finish, instead of going through an intermediate
 step as double precision; thanks to Christoph Gohlke. - EF
Modified: trunk/matplotlib/examples/pylab_examples/image_slices_viewer.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/image_slices_viewer.py	2011年02月04日 19:18:57 UTC (rev 8945)
+++ trunk/matplotlib/examples/pylab_examples/image_slices_viewer.py	2011年02月05日 20:56:02 UTC (rev 8946)
@@ -1,5 +1,5 @@
 import numpy
-from pylab import figure, show
+from matplotlib.pyplot import figure, show
 
 
 
@@ -7,7 +7,7 @@
 class IndexTracker:
 def __init__(self, ax, X):
 self.ax = ax
- ax.set_title('use scroll wheen to navigate images')
+ ax.set_title('use scroll wheel to navigate images')
 
 self.X = X
 rows,cols,self.slices = X.shape
@@ -28,7 +28,7 @@
 
 def update(self):
 self.im.set_data(self.X[:,:,self.ind])
- ax.set_ylabel('slice %s'%self.ind) 
+ ax.set_ylabel('slice %s'%self.ind)
 self.im.axes.figure.canvas.draw()
 
 
Modified: trunk/matplotlib/lib/matplotlib/colors.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colors.py	2011年02月04日 19:18:57 UTC (rev 8945)
+++ trunk/matplotlib/lib/matplotlib/colors.py	2011年02月05日 20:56:02 UTC (rev 8946)
@@ -509,20 +509,22 @@
 xa = np.array([X])
 else:
 vtype = 'array'
- # force a copy here -- the ma.array and filled functions
- # do force a cop of the data by default - JDH
- xma = ma.array(X, copy=True)
- xa = xma.filled(0)
- mask_bad = ma.getmask(xma)
+ xma = ma.array(X, copy=False)
+ mask_bad = xma.mask
+ xa = xma.data.copy() # Copy here to avoid side effects.
+ del xma
+ # masked values are substituted below; no need to fill them here
+
 if xa.dtype.char in np.typecodes['Float']:
 np.putmask(xa, xa==1.0, 0.9999999) #Treat 1.0 as slightly less than 1.
 # The following clip is fast, and prevents possible
 # conversion of large positive values to negative integers.
 
+ xa *= self.N
 if NP_CLIP_OUT:
- np.clip(xa * self.N, -1, self.N, out=xa)
+ np.clip(xa, -1, self.N, out=xa)
 else:
- xa = np.clip(xa * self.N, -1, self.N)
+ xa = np.clip(xa, -1, self.N)
 
 # ensure that all 'under' values will still have negative
 # value after casting to int
@@ -532,8 +534,11 @@
 # otherwise the under-range values get converted to over-range.
 np.putmask(xa, xa>self.N-1, self._i_over)
 np.putmask(xa, xa<0, self._i_under)
- if mask_bad is not None and mask_bad.shape == xa.shape:
- np.putmask(xa, mask_bad, self._i_bad)
+ if mask_bad is not None:
+ if mask_bad.shape == xa.shape:
+ np.putmask(xa, mask_bad, self._i_bad)
+ elif mask_bad:
+ xa.fill(self._i_bad)
 if bytes:
 lut = (self._lut * 255).astype(np.uint8)
 else:
@@ -797,32 +802,60 @@
 self.vmax = vmax
 self.clip = clip
 
+ @staticmethod
+ def process_value(value):
+ """
+ Homogenize the input *value* for easy and efficient normalization.
+
+ *value* can be a scalar or sequence.
+
+ Returns *result*, *is_scalar*, where *result* is a
+ masked array matching *value*. Float dtypes are preserved;
+ integer types with two bytes or smaller are converted to
+ np.float32, and larger types are converted to np.float.
+ Preserving float32 when possible, and using in-place operations,
+ can greatly improve speed for large arrays.
+
+ Experimental; we may want to add an option to force the
+ use of float32.
+ """
+ if cbook.iterable(value):
+ is_scalar = False
+ result = ma.asarray(value)
+ if result.dtype.kind == 'f':
+ if isinstance(value, np.ndarray):
+ result = result.copy()
+ elif result.dtype.itemsize > 2:
+ result = result.astype(np.float)
+ else:
+ result = result.astype(np.float32)
+ else:
+ is_scalar = True
+ result = ma.array([value]).astype(np.float)
+ return result, is_scalar
+
 def __call__(self, value, clip=None):
 if clip is None:
 clip = self.clip
 
- if cbook.iterable(value):
- vtype = 'array'
- val = ma.asarray(value).astype(np.float)
- else:
- vtype = 'scalar'
- val = ma.array([value]).astype(np.float)
+ result, is_scalar = self.process_value(value)
 
- self.autoscale_None(val)
+ self.autoscale_None(result)
 vmin, vmax = self.vmin, self.vmax
 if vmin > vmax:
 raise ValueError("minvalue must be less than or equal to maxvalue")
- elif vmin==vmax:
- result = 0.0 * val
+ elif vmin == vmax:
+ result.fill(0) # Or should it be all masked? Or 0.5?
 else:
 vmin = float(vmin)
 vmax = float(vmax)
 if clip:
- mask = ma.getmask(val)
- val = ma.array(np.clip(val.filled(vmax), vmin, vmax),
- mask=mask)
- result = (val-vmin) / (vmax-vmin)
- if vtype == 'scalar':
+ mask = ma.getmask(result)
+ result = ma.array(np.clip(result.filled(vmax), vmin, vmax),
+ mask=mask)
+ result -= vmin
+ result /= vmax - vmin
+ if is_scalar:
 result = result[0]
 return result
 
@@ -847,8 +880,10 @@
 
 def autoscale_None(self, A):
 ' autoscale only None-valued vmin or vmax'
- if self.vmin is None: self.vmin = ma.min(A)
- if self.vmax is None: self.vmax = ma.max(A)
+ if self.vmin is None:
+ self.vmin = ma.min(A)
+ if self.vmax is None:
+ self.vmax = ma.max(A)
 
 def scaled(self):
 'return true if vmin and vmax set'
@@ -862,30 +897,29 @@
 if clip is None:
 clip = self.clip
 
- if cbook.iterable(value):
- vtype = 'array'
- val = ma.asarray(value).astype(np.float)
- else:
- vtype = 'scalar'
- val = ma.array([value]).astype(np.float)
+ result, is_scalar = self.process_value(value)
 
- val = ma.masked_less_equal(val, 0, copy=False)
+ result = ma.masked_less_equal(result, 0, copy=False)
 
- self.autoscale_None(val)
+ self.autoscale_None(result)
 vmin, vmax = self.vmin, self.vmax
 if vmin > vmax:
 raise ValueError("minvalue must be less than or equal to maxvalue")
 elif vmin<=0:
 raise ValueError("values must all be positive")
 elif vmin==vmax:
- result = 0.0 * val
+ result.fill(0)
 else:
 if clip:
- mask = ma.getmask(val)
- val = ma.array(np.clip(val.filled(vmax), vmin, vmax),
+ mask = ma.getmask(result)
+ val = ma.array(np.clip(result.filled(vmax), vmin, vmax),
 mask=mask)
- result = (ma.log(val)-np.log(vmin))/(np.log(vmax)-np.log(vmin))
- if vtype == 'scalar':
+ #result = (ma.log(result)-np.log(vmin))/(np.log(vmax)-np.log(vmin))
+ # in-place equivalent of above can be much faster
+ np.ma.log(result, result)
+ result -= np.log(vmin)
+ result /= (np.log(vmax) - np.log(vmin))
+ if is_scalar:
 result = result[0]
 return result
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 2 results of 2

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /