@@ -199,101 +199,6 @@ def xindex(self, data):
199
199
def yindex (self , data ):
200
200
return self .index (data , "y" )
201
201
202
- def fill (self , datumx , datumy ):
203
- self .fillw (datumx ,datumy , 1.0 )
204
-
205
- def fillw (self , datumx , datumy , weight ):
206
- xnumbins = self .xnumbins
207
- xlow = self .xlow
208
- xhigh = self .xhigh
209
- ynumbins = self .ynumbins
210
- ylow = self .ylow
211
- yhigh = self .yhigh
212
-
213
- binx = self .index (datumx , "x" ) # get the x bin
214
- biny = self .index (datumy , "y" ) # get the y bin
215
-
216
- # translate biny,binx into index for self[index]
217
- bin = biny * (xnumbins + 2 ) + binx
218
- self [bin ] += weight
219
-
220
- def fillall (self , datax , datay ):
221
- self .fillallw (datax , datay , weights = None )
222
-
223
- def fillallw (self , datax , datay , weights ):
224
- xbins = self ._fXaxis ._fXbins
225
- xlow = self .xlow
226
- xhigh = self .xhigh
227
- ybins = self ._fYaxis ._fXbins
228
- ylow = self .ylow
229
- yhigh = self .yhigh
230
-
231
- if not xbins : xbins = self .xnumbins
232
- if not ybins : ybins = self .ynumbins
233
-
234
- if not isinstance (datax , numpy .ndarray ):
235
- datax = numpy .array (datax )
236
- if not isinstance (datay , numpy .ndarray ):
237
- datay = numpy .array (datay )
238
-
239
- if isinstance (weights , numbers .Real ):
240
- weights = numpy .full (datax .shape , weights )
241
-
242
- freq , xedges , yedges = numpy .histogram2d (datax ,
243
- datay ,
244
- bins = [xbins , ybins ],
245
- range = [[xlow , xhigh ], [ylow , yhigh ]],
246
- weights = weights ,
247
- normed = False )
248
- freq = freq .flatten ().tolist ()
249
- for i , x in enumerate (freq ):
250
- self [i + 1 ] += x
251
-
252
- # get all values for underflow
253
- data_xlow = numpy .where (datax < xlow )
254
- data_ylow = numpy .where (datay < ylow )
255
- data_low = numpy .unique (numpy .concatenate ((data_xlow ,data_ylow ),0 )) # indices for underflow
256
-
257
- # get all values for overflow
258
- data_xhigh = numpy .where (datax > xhigh )
259
- data_yhigh = numpy .where (datax > yhigh )
260
- data_high = numpy .unique (numpy .concatenate ((data_xhigh ,data_yhigh ),0 )) # indices for overflow
261
-
262
- # put all (unique) underflow and overflow values into an area
263
- data_uo = numpy .unique (numpy .concatenate ((data_low ,data_high ),0 )) # indices for under/overflow
264
-
265
- if weights is None :
266
- for d in data_uo :
267
- binx = self .index (datax [d ],'x' ) # get the x bin
268
- biny = self .index (datay [d ],'y' ) # get the y bin
269
-
270
- # translate biny,binx into index for self[index]
271
- bin = biny * (xnumbins + 2 ) + binx
272
- self [bin ] += 1
273
- else :
274
- for d in data_uo :
275
- binx = self .index (datax [d ],'x' ) # get the x bin
276
- biny = self .index (datay [d ],'y' ) # get the y bin
277
-
278
- # translate biny,binx into index for self[index]
279
- bin = biny * (xnumbins + 2 ) + binx
280
- self [bin ] += weights [d ]
281
-
282
- def __add__ (self , other ):
283
- if not isinstance (other , TH2Methods ) or self .numbins != other .numbins or self .low != other .low or self .high != other .high :
284
- raise TypeError ("TH2 histograms can only be combined with other TH2 histograms with the same binning" )
285
- return hist2d (self .xnumbins , self .xlow , self .xhigh , self .ynumbins , self .ylow , self .yhigh , name = (self .name if self .name is not None else other .name ), title = (self .title if self .title is not None else other .title ), allvalues = (numpy .array (self ) + numpy .array (other )))
286
-
287
- def __radd__ (self , other ):
288
- return self .__add__ (other )
289
-
290
- def __iadd__ (self , other ):
291
- if not isinstance (other , TH2Methods ) or self .numbins != other .numbins or self .low != other .low or self .high != other .high :
292
- raise TypeError ("TH2 histograms can only be combined with other TH2 histograms with the same binning" )
293
- for i in range (len (self )):
294
- self [i ] = other [i ]
295
- return self
296
-
297
202
@property
298
203
def ylabels (self ):
299
204
if self ._fYaxis ._fLabels is None :
0 commit comments