/ lib / numpy / ma / core.pyi
core.pyi
  1  from collections.abc import Callable
  2  from typing import Any, TypeVar
  3  from numpy import ndarray, dtype, float64
  4  
  5  from numpy import (
  6      amax as amax,
  7      amin as amin,
  8      bool_ as bool_,
  9      expand_dims as expand_dims,
 10      diff as diff,
 11      clip as clip,
 12      indices as indices,
 13      ones_like as ones_like,
 14      squeeze as squeeze,
 15      zeros_like as zeros_like,
 16  )
 17  
 18  from numpy.lib.function_base import (
 19      angle as angle,
 20  )
 21  
 22  # TODO: Set the `bound` to something more suitable once we
 23  # have proper shape support
 24  _ShapeType = TypeVar("_ShapeType", bound=Any)
 25  _DType_co = TypeVar("_DType_co", bound=dtype[Any], covariant=True)
 26  
 27  __all__: list[str]
 28  
 29  MaskType = bool_
 30  nomask: bool_
 31  
 32  class MaskedArrayFutureWarning(FutureWarning): ...
 33  class MAError(Exception): ...
 34  class MaskError(MAError): ...
 35  
 36  def default_fill_value(obj): ...
 37  def minimum_fill_value(obj): ...
 38  def maximum_fill_value(obj): ...
 39  def set_fill_value(a, fill_value): ...
 40  def common_fill_value(a, b): ...
 41  def filled(a, fill_value=...): ...
 42  def getdata(a, subok=...): ...
 43  get_data = getdata
 44  
 45  def fix_invalid(a, mask=..., copy=..., fill_value=...): ...
 46  
 47  class _MaskedUFunc:
 48      f: Any
 49      __doc__: Any
 50      __name__: Any
 51      def __init__(self, ufunc): ...
 52  
 53  class _MaskedUnaryOperation(_MaskedUFunc):
 54      fill: Any
 55      domain: Any
 56      def __init__(self, mufunc, fill=..., domain=...): ...
 57      def __call__(self, a, *args, **kwargs): ...
 58  
 59  class _MaskedBinaryOperation(_MaskedUFunc):
 60      fillx: Any
 61      filly: Any
 62      def __init__(self, mbfunc, fillx=..., filly=...): ...
 63      def __call__(self, a, b, *args, **kwargs): ...
 64      def reduce(self, target, axis=..., dtype=...): ...
 65      def outer(self, a, b): ...
 66      def accumulate(self, target, axis=...): ...
 67  
 68  class _DomainedBinaryOperation(_MaskedUFunc):
 69      domain: Any
 70      fillx: Any
 71      filly: Any
 72      def __init__(self, dbfunc, domain, fillx=..., filly=...): ...
 73      def __call__(self, a, b, *args, **kwargs): ...
 74  
 75  exp: _MaskedUnaryOperation
 76  conjugate: _MaskedUnaryOperation
 77  sin: _MaskedUnaryOperation
 78  cos: _MaskedUnaryOperation
 79  arctan: _MaskedUnaryOperation
 80  arcsinh: _MaskedUnaryOperation
 81  sinh: _MaskedUnaryOperation
 82  cosh: _MaskedUnaryOperation
 83  tanh: _MaskedUnaryOperation
 84  abs: _MaskedUnaryOperation
 85  absolute: _MaskedUnaryOperation
 86  fabs: _MaskedUnaryOperation
 87  negative: _MaskedUnaryOperation
 88  floor: _MaskedUnaryOperation
 89  ceil: _MaskedUnaryOperation
 90  around: _MaskedUnaryOperation
 91  logical_not: _MaskedUnaryOperation
 92  sqrt: _MaskedUnaryOperation
 93  log: _MaskedUnaryOperation
 94  log2: _MaskedUnaryOperation
 95  log10: _MaskedUnaryOperation
 96  tan: _MaskedUnaryOperation
 97  arcsin: _MaskedUnaryOperation
 98  arccos: _MaskedUnaryOperation
 99  arccosh: _MaskedUnaryOperation
100  arctanh: _MaskedUnaryOperation
101  
102  add: _MaskedBinaryOperation
103  subtract: _MaskedBinaryOperation
104  multiply: _MaskedBinaryOperation
105  arctan2: _MaskedBinaryOperation
106  equal: _MaskedBinaryOperation
107  not_equal: _MaskedBinaryOperation
108  less_equal: _MaskedBinaryOperation
109  greater_equal: _MaskedBinaryOperation
110  less: _MaskedBinaryOperation
111  greater: _MaskedBinaryOperation
112  logical_and: _MaskedBinaryOperation
113  alltrue: _MaskedBinaryOperation
114  logical_or: _MaskedBinaryOperation
115  sometrue: Callable[..., Any]
116  logical_xor: _MaskedBinaryOperation
117  bitwise_and: _MaskedBinaryOperation
118  bitwise_or: _MaskedBinaryOperation
119  bitwise_xor: _MaskedBinaryOperation
120  hypot: _MaskedBinaryOperation
121  divide: _MaskedBinaryOperation
122  true_divide: _MaskedBinaryOperation
123  floor_divide: _MaskedBinaryOperation
124  remainder: _MaskedBinaryOperation
125  fmod: _MaskedBinaryOperation
126  mod: _MaskedBinaryOperation
127  
128  def make_mask_descr(ndtype): ...
129  def getmask(a): ...
130  get_mask = getmask
131  
132  def getmaskarray(arr): ...
133  def is_mask(m): ...
134  def make_mask(m, copy=..., shrink=..., dtype=...): ...
135  def make_mask_none(newshape, dtype=...): ...
136  def mask_or(m1, m2, copy=..., shrink=...): ...
137  def flatten_mask(mask): ...
138  def masked_where(condition, a, copy=...): ...
139  def masked_greater(x, value, copy=...): ...
140  def masked_greater_equal(x, value, copy=...): ...
141  def masked_less(x, value, copy=...): ...
142  def masked_less_equal(x, value, copy=...): ...
143  def masked_not_equal(x, value, copy=...): ...
144  def masked_equal(x, value, copy=...): ...
145  def masked_inside(x, v1, v2, copy=...): ...
146  def masked_outside(x, v1, v2, copy=...): ...
147  def masked_object(x, value, copy=..., shrink=...): ...
148  def masked_values(x, value, rtol=..., atol=..., copy=..., shrink=...): ...
149  def masked_invalid(a, copy=...): ...
150  
151  class _MaskedPrintOption:
152      def __init__(self, display): ...
153      def display(self): ...
154      def set_display(self, s): ...
155      def enabled(self): ...
156      def enable(self, shrink=...): ...
157  
158  masked_print_option: _MaskedPrintOption
159  
160  def flatten_structured_array(a): ...
161  
162  class MaskedIterator:
163      ma: Any
164      dataiter: Any
165      maskiter: Any
166      def __init__(self, ma): ...
167      def __iter__(self): ...
168      def __getitem__(self, indx): ...
169      def __setitem__(self, index, value): ...
170      def __next__(self): ...
171  
172  class MaskedArray(ndarray[_ShapeType, _DType_co]):
173      __array_priority__: Any
174      def __new__(cls, data=..., mask=..., dtype=..., copy=..., subok=..., ndmin=..., fill_value=..., keep_mask=..., hard_mask=..., shrink=..., order=...): ...
175      def __array_finalize__(self, obj): ...
176      def __array_wrap__(self, obj, context=...): ...
177      def view(self, dtype=..., type=..., fill_value=...): ...
178      def __getitem__(self, indx): ...
179      def __setitem__(self, indx, value): ...
180      @property
181      def dtype(self): ...
182      @dtype.setter
183      def dtype(self, dtype): ...
184      @property
185      def shape(self): ...
186      @shape.setter
187      def shape(self, shape): ...
188      def __setmask__(self, mask, copy=...): ...
189      @property
190      def mask(self): ...
191      @mask.setter
192      def mask(self, value): ...
193      @property
194      def recordmask(self): ...
195      @recordmask.setter
196      def recordmask(self, mask): ...
197      def harden_mask(self): ...
198      def soften_mask(self): ...
199      @property
200      def hardmask(self): ...
201      def unshare_mask(self): ...
202      @property
203      def sharedmask(self): ...
204      def shrink_mask(self): ...
205      @property
206      def baseclass(self): ...
207      data: Any
208      @property
209      def flat(self): ...
210      @flat.setter
211      def flat(self, value): ...
212      @property
213      def fill_value(self): ...
214      @fill_value.setter
215      def fill_value(self, value=...): ...
216      get_fill_value: Any
217      set_fill_value: Any
218      def filled(self, fill_value=...): ...
219      def compressed(self): ...
220      def compress(self, condition, axis=..., out=...): ...
221      def __eq__(self, other): ...
222      def __ne__(self, other): ...
223      def __add__(self, other): ...
224      def __radd__(self, other): ...
225      def __sub__(self, other): ...
226      def __rsub__(self, other): ...
227      def __mul__(self, other): ...
228      def __rmul__(self, other): ...
229      def __div__(self, other): ...
230      def __truediv__(self, other): ...
231      def __rtruediv__(self, other): ...
232      def __floordiv__(self, other): ...
233      def __rfloordiv__(self, other): ...
234      def __pow__(self, other): ...
235      def __rpow__(self, other): ...
236      def __iadd__(self, other): ...
237      def __isub__(self, other): ...
238      def __imul__(self, other): ...
239      def __idiv__(self, other): ...
240      def __ifloordiv__(self, other): ...
241      def __itruediv__(self, other): ...
242      def __ipow__(self, other): ...
243      def __float__(self): ...
244      def __int__(self): ...
245      @property  # type: ignore[misc]
246      def imag(self): ...
247      get_imag: Any
248      @property  # type: ignore[misc]
249      def real(self): ...
250      get_real: Any
251      def count(self, axis=..., keepdims=...): ...
252      def ravel(self, order=...): ...
253      def reshape(self, *s, **kwargs): ...
254      def resize(self, newshape, refcheck=..., order=...): ...
255      def put(self, indices, values, mode=...): ...
256      def ids(self): ...
257      def iscontiguous(self): ...
258      def all(self, axis=..., out=..., keepdims=...): ...
259      def any(self, axis=..., out=..., keepdims=...): ...
260      def nonzero(self): ...
261      def trace(self, offset=..., axis1=..., axis2=..., dtype=..., out=...): ...
262      def dot(self, b, out=..., strict=...): ...
263      def sum(self, axis=..., dtype=..., out=..., keepdims=...): ...
264      def cumsum(self, axis=..., dtype=..., out=...): ...
265      def prod(self, axis=..., dtype=..., out=..., keepdims=...): ...
266      product: Any
267      def cumprod(self, axis=..., dtype=..., out=...): ...
268      def mean(self, axis=..., dtype=..., out=..., keepdims=...): ...
269      def anom(self, axis=..., dtype=...): ...
270      def var(self, axis=..., dtype=..., out=..., ddof=..., keepdims=...): ...
271      def std(self, axis=..., dtype=..., out=..., ddof=..., keepdims=...): ...
272      def round(self, decimals=..., out=...): ...
273      def argsort(self, axis=..., kind=..., order=..., endwith=..., fill_value=...): ...
274      def argmin(self, axis=..., fill_value=..., out=..., *, keepdims=...): ...
275      def argmax(self, axis=..., fill_value=..., out=..., *, keepdims=...): ...
276      def sort(self, axis=..., kind=..., order=..., endwith=..., fill_value=...): ...
277      def min(self, axis=..., out=..., fill_value=..., keepdims=...): ...
278      # NOTE: deprecated
279      # def tostring(self, fill_value=..., order=...): ...
280      def max(self, axis=..., out=..., fill_value=..., keepdims=...): ...
281      def ptp(self, axis=..., out=..., fill_value=..., keepdims=...): ...
282      def partition(self, *args, **kwargs): ...
283      def argpartition(self, *args, **kwargs): ...
284      def take(self, indices, axis=..., out=..., mode=...): ...
285      copy: Any
286      diagonal: Any
287      flatten: Any
288      repeat: Any
289      squeeze: Any
290      swapaxes: Any
291      T: Any
292      transpose: Any
293      def tolist(self, fill_value=...): ...
294      def tobytes(self, fill_value=..., order=...): ...
295      def tofile(self, fid, sep=..., format=...): ...
296      def toflex(self): ...
297      torecords: Any
298      def __reduce__(self): ...
299      def __deepcopy__(self, memo=...): ...
300  
301  class mvoid(MaskedArray[_ShapeType, _DType_co]):
302      def __new__(
303          self,
304          data,
305          mask=...,
306          dtype=...,
307          fill_value=...,
308          hardmask=...,
309          copy=...,
310          subok=...,
311      ): ...
312      def __getitem__(self, indx): ...
313      def __setitem__(self, indx, value): ...
314      def __iter__(self): ...
315      def __len__(self): ...
316      def filled(self, fill_value=...): ...
317      def tolist(self): ...
318  
319  def isMaskedArray(x): ...
320  isarray = isMaskedArray
321  isMA = isMaskedArray
322  
323  # 0D float64 array
324  class MaskedConstant(MaskedArray[Any, dtype[float64]]):
325      def __new__(cls): ...
326      __class__: Any
327      def __array_finalize__(self, obj): ...
328      def __array_prepare__(self, obj, context=...): ...
329      def __array_wrap__(self, obj, context=...): ...
330      def __format__(self, format_spec): ...
331      def __reduce__(self): ...
332      def __iop__(self, other): ...
333      __iadd__: Any
334      __isub__: Any
335      __imul__: Any
336      __ifloordiv__: Any
337      __itruediv__: Any
338      __ipow__: Any
339      def copy(self, *args, **kwargs): ...
340      def __copy__(self): ...
341      def __deepcopy__(self, memo): ...
342      def __setattr__(self, attr, value): ...
343  
344  masked: MaskedConstant
345  masked_singleton: MaskedConstant
346  masked_array = MaskedArray
347  
348  def array(
349      data,
350      dtype=...,
351      copy=...,
352      order=...,
353      mask=...,
354      fill_value=...,
355      keep_mask=...,
356      hard_mask=...,
357      shrink=...,
358      subok=...,
359      ndmin=...,
360  ): ...
361  def is_masked(x): ...
362  
363  class _extrema_operation(_MaskedUFunc):
364      compare: Any
365      fill_value_func: Any
366      def __init__(self, ufunc, compare, fill_value): ...
367      # NOTE: in practice `b` has a default value, but users should
368      # explicitly provide a value here as the default is deprecated
369      def __call__(self, a, b): ...
370      def reduce(self, target, axis=...): ...
371      def outer(self, a, b): ...
372  
373  def min(obj, axis=..., out=..., fill_value=..., keepdims=...): ...
374  def max(obj, axis=..., out=..., fill_value=..., keepdims=...): ...
375  def ptp(obj, axis=..., out=..., fill_value=..., keepdims=...): ...
376  
377  class _frommethod:
378      __name__: Any
379      __doc__: Any
380      reversed: Any
381      def __init__(self, methodname, reversed=...): ...
382      def getdoc(self): ...
383      def __call__(self, a, *args, **params): ...
384  
385  all: _frommethod
386  anomalies: _frommethod
387  anom: _frommethod
388  any: _frommethod
389  compress: _frommethod
390  cumprod: _frommethod
391  cumsum: _frommethod
392  copy: _frommethod
393  diagonal: _frommethod
394  harden_mask: _frommethod
395  ids: _frommethod
396  mean: _frommethod
397  nonzero: _frommethod
398  prod: _frommethod
399  product: _frommethod
400  ravel: _frommethod
401  repeat: _frommethod
402  soften_mask: _frommethod
403  std: _frommethod
404  sum: _frommethod
405  swapaxes: _frommethod
406  trace: _frommethod
407  var: _frommethod
408  count: _frommethod
409  argmin: _frommethod
410  argmax: _frommethod
411  
412  minimum: _extrema_operation
413  maximum: _extrema_operation
414  
415  def take(a, indices, axis=..., out=..., mode=...): ...
416  def power(a, b, third=...): ...
417  def argsort(a, axis=..., kind=..., order=..., endwith=..., fill_value=...): ...
418  def sort(a, axis=..., kind=..., order=..., endwith=..., fill_value=...): ...
419  def compressed(x): ...
420  def concatenate(arrays, axis=...): ...
421  def diag(v, k=...): ...
422  def left_shift(a, n): ...
423  def right_shift(a, n): ...
424  def put(a, indices, values, mode=...): ...
425  def putmask(a, mask, values): ...
426  def transpose(a, axes=...): ...
427  def reshape(a, new_shape, order=...): ...
428  def resize(x, new_shape): ...
429  def ndim(obj): ...
430  def shape(obj): ...
431  def size(obj, axis=...): ...
432  def where(condition, x=..., y=...): ...
433  def choose(indices, choices, out=..., mode=...): ...
434  def round_(a, decimals=..., out=...): ...
435  round = round_
436  
437  def inner(a, b): ...
438  innerproduct = inner
439  
440  def outer(a, b): ...
441  outerproduct = outer
442  
443  def correlate(a, v, mode=..., propagate_mask=...): ...
444  def convolve(a, v, mode=..., propagate_mask=...): ...
445  def allequal(a, b, fill_value=...): ...
446  def allclose(a, b, masked_equal=..., rtol=..., atol=...): ...
447  def asarray(a, dtype=..., order=...): ...
448  def asanyarray(a, dtype=...): ...
449  def fromflex(fxarray): ...
450  
451  class _convert2ma:
452      __doc__: Any
453      def __init__(self, funcname, params=...): ...
454      def getdoc(self): ...
455      def __call__(self, *args, **params): ...
456  
457  arange: _convert2ma
458  empty: _convert2ma
459  empty_like: _convert2ma
460  frombuffer: _convert2ma
461  fromfunction: _convert2ma
462  identity: _convert2ma
463  ones: _convert2ma
464  zeros: _convert2ma
465  
466  def append(a, b, axis=...): ...
467  def dot(a, b, strict=..., out=...): ...
468  def mask_rowcols(a, axis=...): ...