index int64 0 731k | package stringlengths 2 98 ⌀ | name stringlengths 1 76 | docstring stringlengths 0 281k ⌀ | code stringlengths 4 8.19k | signature stringlengths 2 42.8k ⌀ | embed_func_code listlengths 768 768 |
|---|---|---|---|---|---|---|
724,601 | scipy.sparse._base | __repr__ | null | def __repr__(self):
_, format_name = _formats[self.format]
sparse_cls = 'array' if isinstance(self, sparray) else 'matrix'
shape_str = 'x'.join(str(x) for x in self.shape)
return (
f"<{shape_str} sparse {sparse_cls} of type '{self.dtype.type}'\n"
f"\twith {self.nnz} stored elements in {f... | (self) | [
0.04611409828066826,
-0.027052883058786392,
0.06537330150604248,
-0.007028710097074509,
0.0707370787858963,
-0.04082231596112251,
-0.008153663948178291,
-0.03338862210512161,
0.03137270733714104,
-0.001554685877636075,
-0.026980886235833168,
-0.01602833904325962,
-0.00982759427279234,
-0.0... |
724,602 | scipy.sparse._base | __rmatmul__ | null | def __rmatmul__(self, other):
if isscalarlike(other):
raise ValueError("Scalar operands are not allowed, "
"use '*' instead")
return self._rmatmul_dispatch(other)
| (self, other) | [
-0.01809155009686947,
-0.046029310673475266,
0.06778737157583237,
0.07622206211090088,
-0.03817988559603691,
-0.08117958903312683,
-0.051640961319208145,
-0.02508029341697693,
0.009958098642528057,
0.019434215500950813,
-0.00402584346011281,
0.0035008268896490335,
0.04723426699638367,
0.09... |
724,603 | scipy.sparse._matrix | __rmul__ | null | def __rmul__(self, other):
return self._rmatmul_dispatch(other)
| (self, other) | [
-0.03592856973409653,
-0.013420991599559784,
0.05894095450639725,
0.09211917966604233,
-0.057687632739543915,
-0.08056076616048813,
-0.06618237495422363,
-0.025588661432266235,
0.01960056647658348,
0.019252421334385872,
-0.009687135927379131,
-0.026406802237033844,
0.04832253232598305,
0.1... |
724,604 | scipy.sparse._data | __round__ | null | def __round__(self, ndigits=0):
return self._with_data(np.around(self._deduped_data(), decimals=ndigits))
| (self, ndigits=0) | [
-0.039735615253448486,
-0.021384170278906822,
0.03711644187569618,
0.05658792704343796,
0.012389378622174263,
-0.030568508431315422,
-0.007487044204026461,
-0.032412268221378326,
-0.012527229264378548,
-0.0010144987609237432,
-0.006013759411871433,
0.02119462564587593,
0.02851797081530094,
... |
724,605 | scipy.sparse._base | __rsub__ | null | def __rsub__(self,other): # other - self
if isscalarlike(other):
if other == 0:
return -self.copy()
raise NotImplementedError('subtracting a sparse array from a '
'nonzero scalar is not supported')
elif isdense(other):
other = np.broadcast_t... | (self, other) | [
-0.001957024447619915,
-0.03423326089978218,
0.028356753289699554,
0.028860950842499733,
-0.029312988743185997,
-0.07288259267807007,
-0.02425362914800644,
0.028287207707762718,
0.06140775606036186,
-0.041100773960351944,
-0.03058217465877533,
-0.009553669951856136,
0.016655897721648216,
0... |
724,606 | scipy.sparse._base | __rtruediv__ | null | def __rtruediv__(self, other):
# Implementing this as the inverse would be too magical -- bail out
return NotImplemented
| (self, other) | [
-0.04680617153644562,
-0.03715093806385994,
0.02928309142589569,
0.06862232834100723,
-0.021264903247356415,
-0.06277573108673096,
-0.02530740574002266,
-0.02819729410111904,
0.002461834345012903,
-0.00006838428816990927,
0.0510491319000721,
0.006853044964373112,
0.029316499829292297,
0.02... |
724,607 | scipy.sparse._index | __setitem__ | null | def __setitem__(self, key, x):
row, col = self._validate_indices(key)
if isinstance(row, INT_TYPES) and isinstance(col, INT_TYPES):
x = np.asarray(x, dtype=self.dtype)
if x.size != 1:
raise ValueError('Trying to assign a sequence to an item')
self._set_intXint(row, col, x.fla... | (self, key, x) | [
0.044421110302209854,
-0.02127373032271862,
-0.0025274751242250204,
0.06866145133972168,
0.002407932421192527,
-0.01738005131483078,
-0.03866354003548622,
0.03878064081072807,
0.05367225408554077,
-0.02915867231786251,
-0.039561331272125244,
-0.0061479127034544945,
0.05082274600863457,
0.0... |
724,608 | scipy.sparse._base | __str__ | null | def __str__(self):
maxprint = self._getmaxprint()
A = self.tocoo()
# helper function, outputs "(i,j) v"
def tostr(row, col, data):
triples = zip(list(zip(row, col)), data)
return '\n'.join([(' {}\t{}'.format(*t)) for t in triples])
if self.nnz > maxprint:
half = maxprint //... | (self) | [
0.027734261006116867,
0.022552939131855965,
0.03277362883090973,
-0.0005134741659276187,
0.04840631037950516,
-0.06654093414545059,
-0.0010158582590520382,
-0.04968389496207237,
0.010442490689456463,
-0.05660415440797806,
-0.03832757845520973,
-0.006024172529578209,
-0.007017850410193205,
... |
724,609 | scipy.sparse._base | __sub__ | null | def __sub__(self, other): # self - other
if isscalarlike(other):
if other == 0:
return self.copy()
raise NotImplementedError('subtracting a nonzero scalar from a '
'sparse array is not supported')
elif issparse(other):
if other.shape != self... | (self, other) | [
0.011372090317308903,
-0.040056392550468445,
0.02018589898943901,
0.020974410697817802,
-0.042859990149736404,
-0.058770403265953064,
-0.015130662359297276,
0.010662429966032505,
0.056071940809488297,
-0.03169816732406616,
-0.029875829815864563,
-0.019187116995453835,
0.010662429966032505,
... |
724,610 | scipy.sparse._base | __truediv__ | null | def __truediv__(self, other):
return self._divide(other, true_divide=True)
| (self, other) | [
-0.048515383154153824,
-0.0328793004155159,
0.046205125749111176,
0.07017821818590164,
0.018800128251314163,
-0.03960917517542839,
-0.01814723014831543,
-0.05588141456246376,
-0.00598490284755826,
0.04352656751871109,
0.059765323996543884,
-0.018364863470196724,
0.048950646072626114,
0.025... |
724,611 | scipy.sparse._compressed | _add_dense | null | def _add_dense(self, other):
if other.shape != self.shape:
raise ValueError(f'Incompatible shapes ({self.shape} and {other.shape})')
dtype = upcast_char(self.dtype.char, other.dtype.char)
order = self._swap('CF')[0]
result = np.array(other, dtype=dtype, order=order, copy=True)
M, N = self._s... | (self, other) | [
-0.019942523911595345,
-0.014626896008849144,
0.019157666712999344,
0.04773362725973129,
-0.008691408671438694,
-0.03924288973212242,
-0.05658111348748207,
0.020245764404535294,
0.07748687267303467,
-0.03524725139141083,
-0.020138738676905632,
-0.04587850719690323,
0.0036344267427921295,
0... |
724,612 | scipy.sparse._compressed | _add_sparse | null | def _add_sparse(self, other):
return self._binopt(other, '_plus_')
| (self, other) | [
-0.049399442970752716,
-0.01959456317126751,
0.05607415363192558,
0.08564773201942444,
-0.006629273295402527,
-0.024617115035653114,
-0.04150214046239853,
-0.002740512602031231,
0.04622730612754822,
-0.0686635747551918,
-0.01852066069841385,
-0.016356337815523148,
0.033555276691913605,
0.0... |
724,613 | scipy.sparse._data | _arg_min_or_max | null | def _arg_min_or_max(self, axis, out, argmin_or_argmax, compare):
if out is not None:
raise ValueError("Sparse types do not support an 'out' parameter.")
validateaxis(axis)
if self.ndim == 1:
if axis not in (None, 0, -1):
raise ValueError("axis out of range")
axis = None ... | (self, axis, out, argmin_or_argmax, compare) | [
0.02044740878045559,
-0.037990354001522064,
0.040236473083496094,
0.009623448364436626,
0.04991801083087921,
-0.011743705719709396,
0.025384992361068726,
0.028792893514037132,
0.020718490704894066,
-0.04391545429825783,
-0.02083466947078705,
0.04802042618393898,
-0.03506653010845184,
-0.04... |
724,614 | scipy.sparse._data | _arg_min_or_max_axis | null | def _arg_min_or_max_axis(self, axis, argmin_or_argmax, compare):
if self.shape[axis] == 0:
raise ValueError("Cannot apply the operation along a zero-sized dimension.")
if axis < 0:
axis += 2
zero = self.dtype.type(0)
mat = self.tocsc() if axis == 0 else self.tocsr()
mat.sum_duplicate... | (self, axis, argmin_or_argmax, compare) | [
0.02916233241558075,
-0.010838254354894161,
0.010057290084660053,
0.020514586940407753,
0.016476431861519814,
-0.014124016277492046,
0.03200047090649605,
0.02001934126019478,
0.02954328991472721,
-0.02474321983754635,
0.023524153977632523,
0.015381177887320518,
-0.01768597401678562,
-0.062... |
724,615 | scipy.sparse._base | _asfptype | Upcast array to a floating point format (if necessary) | def _asfptype(self):
"""Upcast array to a floating point format (if necessary)"""
fp_types = ['f', 'd', 'F', 'D']
if self.dtype.char in fp_types:
return self
else:
for fp_type in fp_types:
if self.dtype <= np.dtype(fp_type):
return self.astype(fp_type)
... | (self) | [
0.019123181700706482,
0.006068446673452854,
0.015006261877715588,
0.031634341925382614,
-0.0016997888451442122,
-0.019461803138256073,
-0.00025201652897521853,
-0.004397619049996138,
-0.016654811799526215,
0.014516152441501617,
-0.00023920685634948313,
-0.0464802011847496,
0.0131527567282319... |
724,616 | scipy.sparse._index | _asindices | Convert `idx` to a valid index for an axis with a given length.
Subclasses that need special validation can override this method.
| def _asindices(self, idx, length):
"""Convert `idx` to a valid index for an axis with a given length.
Subclasses that need special validation can override this method.
"""
try:
x = np.asarray(idx)
except (ValueError, TypeError, MemoryError) as e:
raise IndexError('invalid index') fro... | (self, idx, length) | [
-0.026492267847061157,
0.024408401921391487,
-0.04468531534075737,
-0.008394352160394192,
0.03241769224405289,
0.025604359805583954,
-0.00678615178912878,
0.03598744422197342,
-0.003338714363053441,
-0.036730386316776276,
0.012204200960695744,
-0.022125210613012314,
0.037835743278265,
-0.0... |
724,617 | scipy.sparse._compressed | _binopt | apply the binary operation fn to two sparse matrices. | def _binopt(self, other, op):
"""apply the binary operation fn to two sparse matrices."""
other = self.__class__(other)
# e.g. csr_plus_csr, csr_minus_csr, etc.
fn = getattr(_sparsetools, self.format + op + self.format)
maxnnz = self.nnz + other.nnz
idx_dtype = self._get_index_dtype((self.indptr... | (self, other, op) | [
-0.010592939332127571,
-0.04623357951641083,
0.08214490860700607,
0.028765153139829636,
-0.03836556896567345,
-0.05511215701699257,
-0.04587266221642494,
0.007209334522485733,
0.02795308828353882,
-0.05724157392978668,
-0.031490083783864975,
-0.008062003180384636,
0.04792989417910576,
0.00... |
724,618 | scipy.sparse._data | _deduped_data | null | def _deduped_data(self):
if hasattr(self, 'sum_duplicates'):
self.sum_duplicates()
return self.data
| (self) | [
0.030731797218322754,
-0.03003719635307789,
-0.005057023838162422,
0.017924057319760323,
0.01660262420773506,
-0.03168051689863205,
0.0034624096006155014,
-0.05519525706768036,
0.05451759696006775,
-0.002653455128893256,
-0.023074259981513023,
-0.02039751037955284,
-0.007928600534796715,
-... |
724,619 | scipy.sparse._base | _divide | null | def _divide(self, other, true_divide=False, rdivide=False):
if isscalarlike(other):
if rdivide:
if true_divide:
return np.true_divide(other, self.todense())
else:
return np.divide(other, self.todense())
if true_divide and np.can_cast(self.dtype... | (self, other, true_divide=False, rdivide=False) | [
-0.02966577559709549,
-0.06347683072090149,
0.03155818581581116,
0.07137088477611542,
0.012949489988386631,
-0.0449492372572422,
-0.00010447678505443037,
-0.04022722318768501,
-0.0020050532184541225,
0.037019141018390656,
0.028764627873897552,
-0.0381365604698658,
0.060521066188812256,
0.0... |
724,620 | scipy.sparse._compressed | _divide_sparse |
Divide this matrix by a second sparse matrix.
| def _divide_sparse(self, other):
"""
Divide this matrix by a second sparse matrix.
"""
if other.shape != self.shape:
raise ValueError('inconsistent shapes')
r = self._binopt(other, '_eldiv_')
if np.issubdtype(r.dtype, np.inexact):
# Eldiv leaves entries outside the combined spars... | (self, other) | [
-0.003713277168571949,
-0.0017745649674907327,
0.022199807688593864,
0.0532369501888752,
0.01728426292538643,
-0.036698002368211746,
0.0006582526839338243,
-0.012395336292684078,
0.009298720397055149,
0.01347782090306282,
-0.029493270441889763,
-0.05504700541496277,
0.0266184750944376,
0.0... |
724,621 | scipy.sparse._compressed | _get_arrayXarray | null | def _get_arrayXarray(self, row, col):
# inner indexing
idx_dtype = self.indices.dtype
M, N = self._swap(self.shape)
major, minor = self._swap((row, col))
major = np.asarray(major, dtype=idx_dtype)
minor = np.asarray(minor, dtype=idx_dtype)
val = np.empty(major.size, dtype=self.dtype)
csr... | (self, row, col) | [
0.04975481331348419,
-0.04390560835599899,
0.0028903307393193245,
0.050303176045417786,
0.03365121781826019,
-0.010519432835280895,
0.02202591858804226,
0.02977611869573593,
0.05242351442575455,
-0.04906022176146507,
0.009760864078998566,
-0.026705283671617508,
-0.002691549016162753,
-0.01... |
724,622 | scipy.sparse._csc | _get_arrayXint | null | def _get_arrayXint(self, row, col):
return self._get_submatrix(major=col)._minor_index_fancy(row)
| (self, row, col) | [
0.024015972390770912,
-0.02230054698884487,
0.03777335584163666,
0.09144412726163864,
0.07846803218126297,
-0.020975761115550995,
0.03249119967222214,
0.06369158625602722,
-0.007570806425064802,
-0.07282920181751251,
0.009757550433278084,
-0.04545031487941742,
0.004040169529616833,
-0.0528... |
724,623 | scipy.sparse._csc | _get_arrayXslice | null | def _get_arrayXslice(self, row, col):
return self._major_slice(col)._minor_index_fancy(row)
| (self, row, col) | [
0.013460910879075527,
-0.029104212298989296,
-0.015310827642679214,
0.08565879613161087,
0.05329804867506027,
-0.007894112728536129,
0.03491823375225067,
0.031593501567840576,
0.02322199009358883,
-0.061106909066438675,
0.05677622929215431,
-0.033605389297008514,
-0.0059546842239797115,
-0... |
724,624 | scipy.sparse._compressed | _get_columnXarray | null | def _get_columnXarray(self, row, col):
# outer indexing
major, minor = self._swap((row, col))
return self._major_index_fancy(major)._minor_index_fancy(minor)
| (self, row, col) | [
0.04727941006422043,
0.011570560745894909,
0.017639517784118652,
0.07729753851890564,
0.06199619919061661,
-0.03916454315185547,
0.04679802060127258,
0.05377817898988724,
0.0027916342951357365,
-0.07069560885429382,
0.03596673533320427,
-0.030826175585389137,
-0.02712978422641754,
-0.03288... |
724,625 | scipy.sparse._base | _get_index_dtype |
Determine index dtype for array.
This wraps _sputils.get_index_dtype, providing compatibility for both
array and matrix API sparse matrices. Matrix API sparse matrices would
attempt to downcast the indices - which can be computationally
expensive and undesirable for users. The ... | def _get_index_dtype(self, arrays=(), maxval=None, check_contents=False):
"""
Determine index dtype for array.
This wraps _sputils.get_index_dtype, providing compatibility for both
array and matrix API sparse matrices. Matrix API sparse matrices would
attempt to downcast the indices - which can be c... | (self, arrays=(), maxval=None, check_contents=False) | [
0.023159896954894066,
0.018050827085971832,
0.029904965311288834,
0.04058009013533592,
0.03798442333936691,
0.032884493470191956,
-0.0360102578997612,
-0.0032697131391614676,
0.003050361294299364,
-0.012356819584965706,
-0.011808440089225769,
-0.049500394612550735,
-0.001863348064944148,
-... |
724,626 | scipy.sparse._csc | _get_intXarray | null | def _get_intXarray(self, row, col):
return self._major_index_fancy(col)._get_submatrix(minor=row)
| (self, row, col) | [
0.006518535315990448,
-0.0268234945833683,
0.03637776896357536,
0.06338860094547272,
0.0784778818488121,
-0.002006439957767725,
0.03848958760499954,
0.0440075621008873,
0.011368053033947945,
-0.06468294560909271,
0.019619470462203026,
-0.04547221213579178,
-0.002939940197393298,
-0.0391367... |
724,627 | scipy.sparse._compressed | _get_intXint | null | def _get_intXint(self, row, col):
M, N = self._swap(self.shape)
major, minor = self._swap((row, col))
indptr, indices, data = get_csr_submatrix(
M, N, self.indptr, self.indices, self.data,
major, major + 1, minor, minor + 1)
return data.sum(dtype=self.dtype)
| (self, row, col) | [
0.004437027033418417,
-0.05904144421219826,
0.05839930474758148,
0.07662902027368546,
0.09332472831010818,
-0.014885222539305687,
0.057578787207603455,
0.07220537215471268,
0.011977743357419968,
-0.053547557443380356,
-0.022367967292666435,
-0.03710157424211502,
0.0026599864941090345,
-0.0... |
724,628 | scipy.sparse._csc | _get_intXslice | null | def _get_intXslice(self, row, col):
if col.step in (1, None):
return self._get_submatrix(major=col, minor=row, copy=True)
return self._major_slice(col)._get_submatrix(minor=row)
| (self, row, col) | [
-0.00560664851218462,
-0.02979901432991028,
-0.00019883731147274375,
0.05942617729306221,
0.06351623684167862,
0.0018828457687050104,
0.07650819420814514,
0.030314568430185318,
0.007471235003322363,
-0.048633918166160583,
0.018611494451761246,
-0.01370514091104269,
-0.02014097198843956,
-0... |
724,629 | scipy.sparse._csc | _get_sliceXarray | null | def _get_sliceXarray(self, row, col):
return self._major_index_fancy(col)._minor_slice(row)
| (self, row, col) | [
0.007444314192980528,
-0.021928591653704643,
-0.02504422329366207,
0.0610186904668808,
0.03457839414477348,
-0.007550722453743219,
0.03371010348200798,
0.02977725677192211,
0.027036182582378387,
-0.0504630021750927,
0.06742020696401596,
-0.03396548330783844,
-0.008678648620843887,
-0.04603... |
724,630 | scipy.sparse._csc | _get_sliceXint | null | def _get_sliceXint(self, row, col):
if row.step in (1, None):
return self._get_submatrix(major=col, minor=row, copy=True)
return self._get_submatrix(major=col)._minor_slice(row)
| (self, row, col) | [
0.013013710267841816,
-0.02668198011815548,
-0.0007401493494398892,
0.07151941955089569,
0.04643939435482025,
-0.011627073399722576,
0.07138162106275558,
0.04061724245548248,
-0.0051159122958779335,
-0.05146918073296547,
0.019998567178845406,
-0.01190267875790596,
-0.027060937136411667,
-0... |
724,631 | scipy.sparse._compressed | _get_sliceXslice | null | def _get_sliceXslice(self, row, col):
major, minor = self._swap((row, col))
if major.step in (1, None) and minor.step in (1, None):
return self._get_submatrix(major, minor, copy=True)
return self._major_slice(major)._minor_slice(minor)
| (self, row, col) | [
0.023267557844519615,
-0.03036467917263508,
-0.04278893768787384,
0.04993760958313942,
0.023130083456635475,
-0.012011833488941193,
0.05852976441383362,
0.018834006041288376,
0.01739911548793316,
-0.05543658882379532,
0.04766928032040596,
-0.009614622220396996,
-0.03550278767943382,
-0.029... |
724,632 | scipy.sparse._compressed | _get_submatrix | Return a submatrix of this matrix.
major, minor: None, int, or slice with step 1
| def _get_submatrix(self, major=None, minor=None, copy=False):
"""Return a submatrix of this matrix.
major, minor: None, int, or slice with step 1
"""
M, N = self._swap(self.shape)
i0, i1 = _process_slice(major, M)
j0, j1 = _process_slice(minor, N)
if i0 == 0 and j0 == 0 and i1 == M and j1 ==... | (self, major=None, minor=None, copy=False) | [
0.03368958830833435,
-0.018193434923887253,
0.0019612594041973352,
0.011300379410386086,
-0.04393221065402031,
-0.05151280760765076,
0.021525371819734573,
0.03631635382771492,
-0.0013651687186211348,
-0.044425830245018005,
-0.033724844455718994,
0.012067253701388836,
-0.04354436323046684,
... |
724,633 | scipy.sparse._csc | _getcol | Returns a copy of column i of the matrix, as a (m x 1)
CSC matrix (column vector).
| def _getcol(self, i):
"""Returns a copy of column i of the matrix, as a (m x 1)
CSC matrix (column vector).
"""
M, N = self.shape
i = int(i)
if i < 0:
i += N
if i < 0 or i >= N:
raise IndexError('index (%d) out of range' % i)
return self._get_submatrix(major=i, copy=True)... | (self, i) | [
0.010700162500143051,
0.019748739898204803,
-0.008758671581745148,
0.04318718984723091,
0.04417111352086067,
-0.027971524745225906,
0.05755949392914772,
0.03536851704120636,
0.008899232372641563,
-0.04747428372502327,
-0.003362468909472227,
0.02923656813800335,
-0.03724851459264755,
-0.021... |
724,634 | scipy.sparse._base | _getmaxprint | Maximum number of elements to display when printed. | def _getmaxprint(self):
"""Maximum number of elements to display when printed."""
return self.maxprint
| (self) | [
0.015912748873233795,
0.009747962467372417,
-0.01702655665576458,
0.03750677406787872,
0.0038659432902932167,
0.04009702056646347,
0.02586793154478073,
-0.040925901383161545,
-0.004869664087891579,
-0.052392058074474335,
-0.028216421604156494,
-0.04869664087891579,
-0.02355397865176201,
-0... |
724,635 | scipy.sparse._compressed | _getnnz | Number of stored values, including explicit zeros.
Parameters
----------
axis : None, 0, or 1
Select between the number of values across the whole array, in
each column, or in each row.
See also
--------
count_nonzero : Number of non-zero entries... | def _getnnz(self, axis=None):
if axis is None:
return int(self.indptr[-1])
else:
if axis < 0:
axis += 2
axis, _ = self._swap((axis, 1 - axis))
_, N = self._swap(self.shape)
if axis == 0:
return np.bincount(downcast_intp_index(self.indices),
... | (self, axis=None) | [
-0.06093613803386688,
0.002532277023419738,
0.020365877076983452,
0.0356537401676178,
0.04087530076503754,
0.040982961654663086,
-0.017620520666241646,
0.06158210337162018,
0.04636601358652115,
-0.019935231655836105,
-0.004120276775211096,
-0.029929764568805695,
-0.00987789873033762,
-0.05... |
724,636 | scipy.sparse._csc | _getrow | Returns a copy of row i of the matrix, as a (1 x n)
CSR matrix (row vector).
| def _getrow(self, i):
"""Returns a copy of row i of the matrix, as a (1 x n)
CSR matrix (row vector).
"""
M, N = self.shape
i = int(i)
if i < 0:
i += M
if i < 0 or i >= M:
raise IndexError('index (%d) out of range' % i)
return self._get_submatrix(minor=i).tocsr()
| (self, i) | [
0.029041193425655365,
0.004315746482461691,
0.0056342026218771935,
0.05829333886504173,
-0.0006888933130539954,
-0.02475181594491005,
0.014081111177802086,
0.04932783916592598,
0.011874894611537457,
-0.03248675912618637,
-0.012912080623209476,
0.006161584984511137,
-0.02315208874642849,
0.... |
724,637 | scipy.sparse._data | _imag | null | def _imag(self):
return self._with_data(self.data.imag)
| (self) | [
0.0824924185872078,
-0.053942520171403885,
0.07261751592159271,
0.08202219009399414,
0.019514696672558784,
-0.03283238783478737,
0.022487245500087738,
-0.029826249927282333,
0.012553559616208076,
0.035670582205057144,
0.06589989364147186,
0.01802002638578415,
0.002903273096308112,
-0.00296... |
724,638 | scipy.sparse._compressed | _inequality | null | def _inequality(self, other, op, op_name, bad_scalar_msg):
# Scalar other.
if isscalarlike(other):
if 0 == other and op_name in ('_le_', '_ge_'):
raise NotImplementedError(" >= and <= don't work with 0.")
elif op(0, other):
warn(bad_scalar_msg, SparseEfficiencyWarning, st... | (self, other, op, op_name, bad_scalar_msg) | [
-0.021192332729697227,
-0.08138737827539444,
0.021302614361047745,
0.04815603792667389,
-0.013491042889654636,
-0.04054664820432663,
-0.022901687771081924,
-0.04300959035754204,
-0.0162480678409338,
-0.0661318451166153,
0.02150479517877102,
0.0019057935569435358,
0.07524840533733368,
-0.02... |
724,639 | scipy.sparse._compressed | _insert_many | Inserts new nonzero at each (i, j) with value x
Here (i,j) index major and minor respectively.
i, j and x must be non-empty, 1d arrays.
Inserts each major group (e.g. all entries per row) at a time.
Maintains has_sorted_indices property.
Modifies i, j, x in place.
| def _insert_many(self, i, j, x):
"""Inserts new nonzero at each (i, j) with value x
Here (i,j) index major and minor respectively.
i, j and x must be non-empty, 1d arrays.
Inserts each major group (e.g. all entries per row) at a time.
Maintains has_sorted_indices property.
Modifies i, j, x in pl... | (self, i, j, x) | [
-0.0320284403860569,
-0.013553474098443985,
-0.03799622878432274,
0.07851133495569229,
0.03392728045582771,
-0.01912405900657177,
-0.058515358716249466,
0.03799622878432274,
-0.02365802973508835,
-0.05064872279763222,
-0.053748875856399536,
-0.023173632100224495,
-0.009106694720685482,
-0.... |
724,640 | scipy.sparse._compressed | _major_index_fancy | Index along the major axis where idx is an array of ints.
| def _major_index_fancy(self, idx):
"""Index along the major axis where idx is an array of ints.
"""
idx_dtype = self._get_index_dtype((self.indptr, self.indices))
indices = np.asarray(idx, dtype=idx_dtype).ravel()
_, N = self._swap(self.shape)
M = len(indices)
new_shape = self._swap((M, N))
... | (self, idx) | [
-0.01874879188835621,
-0.009218234568834305,
-0.022430406883358955,
0.05587726831436157,
0.0523565448820591,
-0.009076270274817944,
-0.026594702154397964,
0.05288654565811157,
-0.037289369851350784,
-0.03333329036831856,
-0.014972533099353313,
-0.03749758377671242,
0.04062080383300781,
-0.... |
724,641 | scipy.sparse._compressed | _major_slice | Index along the major axis where idx is a slice object.
| def _major_slice(self, idx, copy=False):
"""Index along the major axis where idx is a slice object.
"""
if idx == slice(None):
return self.copy() if copy else self
M, N = self._swap(self.shape)
start, stop, step = idx.indices(M)
M = len(range(start, stop, step))
new_shape = self._swa... | (self, idx, copy=False) | [
-0.034359607845544815,
-0.006180943455547094,
-0.04638073965907097,
0.03824044391512871,
0.01488916389644146,
0.0013050498673692346,
0.00725053995847702,
0.03884623572230339,
-0.012361886911094189,
-0.029399709776043892,
0.010336278937757015,
-0.00701863644644618,
0.015192057937383652,
-0.... |
724,642 | scipy.sparse._base | _matmul_dispatch | np.array-like matmul & `np.matrix`-like mul, i.e. `dot` or `NotImplemented`
interpret other and call one of the following
self._mul_scalar()
self._matmul_vector()
self._matmul_multivector()
self._matmul_sparse()
| def _matmul_dispatch(self, other):
"""np.array-like matmul & `np.matrix`-like mul, i.e. `dot` or `NotImplemented`
interpret other and call one of the following
self._mul_scalar()
self._matmul_vector()
self._matmul_multivector()
self._matmul_sparse()
"""
# This method has to be different ... | (self, other) | [
-0.002075338503345847,
-0.03785378113389015,
0.05107318237423897,
0.06233125180006027,
-0.04546376317739487,
-0.07037273049354553,
-0.0476212315261364,
-0.013425343669950962,
0.01971142552793026,
0.009880228899419308,
-0.03163634613156319,
-0.02765483409166336,
0.03571592643857002,
0.03106... |
724,643 | scipy.sparse._compressed | _matmul_multivector | null | def _matmul_multivector(self, other):
M, N = self.shape
n_vecs = other.shape[1] # number of column vectors
result = np.zeros((M, n_vecs),
dtype=upcast_char(self.dtype.char, other.dtype.char))
# csr_matvecs or csc_matvecs
fn = getattr(_sparsetools, self.format + '_matvecs')
... | (self, other) | [
0.03141029551625252,
-0.023266220465302467,
0.05266740545630455,
0.05578870326280594,
-0.04025397077202797,
-0.06285646557807922,
-0.019176244735717773,
0.0030136662535369396,
0.02610050141811371,
0.0379219651222229,
-0.03713267296552658,
-0.018799535930156708,
-0.015032454393804073,
0.027... |
724,644 | scipy.sparse._compressed | _matmul_sparse | null | def _matmul_sparse(self, other):
M, K1 = self.shape
K2, N = other.shape
major_axis = self._swap((M, N))[0]
other = self.__class__(other) # convert to this format
idx_dtype = self._get_index_dtype((self.indptr, self.indices,
other.indptr, other.indices))
fn = get... | (self, other) | [
0.0013603090774267912,
-0.035861220210790634,
0.06990715116262436,
0.04086252674460411,
-0.03497209772467613,
-0.0702035203576088,
-0.05742240697145462,
0.014040704816579819,
0.030415352433919907,
-0.009257047437131405,
-0.06668408215045929,
-0.031360045075416565,
0.019838515669107437,
0.0... |
724,645 | scipy.sparse._compressed | _matmul_vector | null | def _matmul_vector(self, other):
M, N = self.shape
# output array
result = np.zeros(M, dtype=upcast_char(self.dtype.char,
other.dtype.char))
# csr_matvec or csc_matvec
fn = getattr(_sparsetools, self.format + '_matvec')
fn(M, N, self.indptr, self.indice... | (self, other) | [
0.023683633655309677,
-0.021528957411646843,
0.04245246946811676,
0.036754149943590164,
-0.033637885004282,
-0.0785655602812767,
-0.04669059440493584,
0.010684345848858356,
0.04117034748196602,
0.0279395654797554,
-0.03570352494716644,
-0.012082214467227459,
0.026301298290491104,
0.0320530... |
724,646 | scipy.sparse._compressed | _maximum_minimum | null | def _maximum_minimum(self, other, npop, op_name, dense_check):
if isscalarlike(other):
if dense_check(other):
warn("Taking maximum (minimum) with > 0 (< 0) number results"
" to a dense matrix.", SparseEfficiencyWarning,
stacklevel=3)
other_arr = np.e... | (self, other, npop, op_name, dense_check) | [
0.0456707738339901,
-0.008426683954894543,
0.05956090986728668,
0.013982738368213177,
-0.016936708241701126,
-0.05281956493854523,
-0.016436662524938583,
0.0024238291662186384,
0.055486470460891724,
-0.07756253331899643,
-0.019464712589979172,
0.03376229479908943,
-0.02085372619330883,
-0.... |
724,647 | scipy.sparse._data | _min_or_max | null | def _min_or_max(self, axis, out, min_or_max):
if out is not None:
raise ValueError("Sparse arrays do not support an 'out' parameter.")
validateaxis(axis)
if self.ndim == 1:
if axis not in (None, 0, -1):
raise ValueError("axis out of range")
axis = None # avoid calling sp... | (self, axis, out, min_or_max) | [
0.031982842832803726,
0.00046240873052738607,
0.012362809851765633,
0.015234701335430145,
-0.005944359581917524,
-0.0012912115780636668,
0.007977476343512535,
-0.009121675044298172,
0.04350687935948372,
-0.03880244866013527,
0.021716970950365067,
0.014851782470941544,
-0.027132537215948105,
... |
724,648 | scipy.sparse._data | _min_or_max_axis | null | def _min_or_max_axis(self, axis, min_or_max):
N = self.shape[axis]
if N == 0:
raise ValueError("zero-size array to reduction operation")
M = self.shape[1 - axis]
idx_dtype = self._get_index_dtype(maxval=M)
mat = self.tocsc() if axis == 0 else self.tocsr()
mat.sum_duplicates()
major_i... | (self, axis, min_or_max) | [
0.03370337560772896,
-0.006723508704453707,
0.003066110657528043,
0.01735714264214039,
0.024853140115737915,
-0.011644545011222363,
0.015430690720677376,
-0.011863892897963524,
0.03683147579431534,
-0.023060204461216927,
0.017900746315717697,
0.024776844307780266,
-0.006933320313692093,
-0... |
724,649 | scipy.sparse._compressed | _minor_index_fancy | Index along the minor axis where idx is an array of ints.
| def _minor_index_fancy(self, idx):
"""Index along the minor axis where idx is an array of ints.
"""
idx_dtype = self._get_index_dtype((self.indices, self.indptr))
indices = self.indices.astype(idx_dtype, copy=False)
indptr = self.indptr.astype(idx_dtype, copy=False)
idx = np.asarray(idx, dtype=i... | (self, idx) | [
0.01640505902469158,
0.002766187069937587,
-0.02486523427069187,
0.07225346565246582,
0.0063755810260772705,
-0.05205397307872772,
-0.020649200305342674,
0.06374644488096237,
-0.046732399612665176,
-0.06134798750281334,
-0.016461273655295372,
-0.008375855162739754,
0.010277755558490753,
-0... |
724,650 | scipy.sparse._compressed | _minor_reduce | Reduce nonzeros with a ufunc over the minor axis when non-empty
Can be applied to a function of self.data by supplying data parameter.
Warning: this does not call sum_duplicates()
Returns
-------
major_index : array of ints
Major indices where nonzero
valu... | def _minor_reduce(self, ufunc, data=None):
"""Reduce nonzeros with a ufunc over the minor axis when non-empty
Can be applied to a function of self.data by supplying data parameter.
Warning: this does not call sum_duplicates()
Returns
-------
major_index : array of ints
Major indices wher... | (self, ufunc, data=None) | [
-0.009186235256493092,
0.01893031969666481,
0.012565342709422112,
0.06774676591157913,
0.04239660128951073,
-0.03255649283528328,
-0.008701545186340809,
-0.007878487929701805,
-0.0012883134186267853,
-0.03427576646208763,
-0.0036145937629044056,
0.007617853116244078,
-0.002789250109344721,
... |
724,651 | scipy.sparse._compressed | _minor_slice | Index along the minor axis where idx is a slice object.
| def _minor_slice(self, idx, copy=False):
"""Index along the minor axis where idx is a slice object.
"""
if idx == slice(None):
return self.copy() if copy else self
M, N = self._swap(self.shape)
start, stop, step = idx.indices(N)
N = len(range(start, stop, step))
if N == 0:
re... | (self, idx, copy=False) | [
0.018614711239933968,
0.022785786539316177,
-0.0492255724966526,
0.05077679827809334,
-0.04460636526346207,
-0.046226534992456436,
0.015417463146150112,
0.0534655898809433,
-0.053120873868465424,
-0.03988374397158623,
0.020786428824067116,
0.02321668341755867,
-0.040607649832963943,
-0.039... |
724,652 | scipy.sparse._data | _mul_scalar | null | def _mul_scalar(self, other):
return self._with_data(self.data * other)
| (self, other) | [
0.006056164391338825,
-0.06394634395837784,
0.07211688905954361,
0.09446772187948227,
-0.02250276505947113,
-0.040852732956409454,
-0.012416192330420017,
-0.029947416856884956,
0.02410648763179779,
0.02879948727786541,
0.013597882352769375,
-0.01055080909281969,
0.061549197882413864,
0.052... |
724,653 | scipy.sparse._compressed | _prepare_indices | null | def _prepare_indices(self, i, j):
M, N = self._swap(self.shape)
def check_bounds(indices, bound):
idx = indices.max()
if idx >= bound:
raise IndexError('index (%d) out of range (>= %d)' %
(idx, bound))
idx = indices.min()
if idx < -bound:
... | (self, i, j) | [
-0.010615847073495388,
-0.04242715612053871,
-0.024981660768389702,
-0.0013677413808181882,
-0.050832878798246384,
-0.023007040843367577,
0.018677370622754097,
0.04626770317554474,
-0.0472097247838974,
-0.03710111975669861,
0.00745011493563652,
0.025162819772958755,
0.006657549180090427,
-... |
724,654 | scipy.sparse._base | _process_toarray_args | null | def _process_toarray_args(self, order, out):
if out is not None:
if order is not None:
raise ValueError('order cannot be specified if out '
'is not None')
if out.shape != self.shape or out.dtype != self.dtype:
raise ValueError('out array must be s... | (self, order, out) | [
-0.05890396609902382,
0.01651771366596222,
-0.0180776696652174,
-0.017730021849274635,
0.022606000304222107,
-0.015724362805485725,
-0.04342919588088989,
0.049169834703207016,
0.07516317069530487,
-0.05391210317611694,
-0.0033583638723939657,
-0.008361367508769035,
0.014030695892870426,
-0... |
724,655 | scipy.sparse._index | _raise_on_1d_array_slice | We do not currently support 1D sparse arrays.
This function is called each time that a 1D array would
result, raising an error instead.
Once 1D sparse arrays are implemented, it should be removed.
| def _raise_on_1d_array_slice(self):
"""We do not currently support 1D sparse arrays.
This function is called each time that a 1D array would
result, raising an error instead.
Once 1D sparse arrays are implemented, it should be removed.
"""
from scipy.sparse import sparray
if isinstance(self,... | (self) | [
-0.04124923422932625,
0.0106143057346344,
0.00552920950576663,
0.07297668606042862,
-0.004079179838299751,
-0.02025156281888485,
-0.017391473054885864,
0.03437436372041702,
0.030270757153630257,
-0.022845184430480003,
0.024248581379652023,
-0.0006706109270453453,
0.01257728599011898,
-0.04... |
724,656 | scipy.sparse._data | _real | null | def _real(self):
return self._with_data(self.data.real)
| (self) | [
0.04951923340559006,
-0.01334645040333271,
0.0537588931620121,
0.10243019461631775,
0.04029373079538345,
-0.029253656044602394,
-0.036121904850006104,
-0.017535235732793808,
0.03235708922147751,
0.018518837168812752,
0.03256059065461159,
0.017552193254232407,
-0.01743348315358162,
0.001465... |
724,657 | scipy.sparse._base | _rmatmul_dispatch | null | def _rmatmul_dispatch(self, other):
if isscalarlike(other):
return self._mul_scalar(other)
else:
# Don't use asarray unless we have to
try:
tr = other.transpose()
except AttributeError:
tr = np.asarray(other).transpose()
ret = self.transpose()._mat... | (self, other) | [
-0.005419379565864801,
-0.027240775525569916,
0.0358908548951149,
0.07275833189487457,
-0.05838803946971893,
-0.08894234895706177,
-0.050330907106399536,
0.0023281967733055353,
-0.007067428901791573,
0.004804631229490042,
0.013960461132228374,
-0.01257400680333376,
0.0399019792675972,
0.06... |
724,658 | scipy.sparse._base | _rsub_dense | null | def _rsub_dense(self, other):
# note: this can't be replaced by other + (-self) for unsigned types
return other - self.todense()
| (self, other) | [
-0.016578277572989464,
-0.014262257143855095,
0.049930669367313385,
0.06631311029195786,
0.002939727855846286,
-0.06723270565271378,
-0.0056282696314156055,
0.022444959729909897,
0.035319309681653976,
-0.03206666186451912,
-0.0005970989586785436,
0.007356769870966673,
0.04386814683675766,
... |
724,659 | scipy.sparse._compressed | _scalar_binopt | Scalar version of self._binopt, for cases in which no new nonzeros
are added. Produces a new sparse array in canonical form.
| def _scalar_binopt(self, other, op):
"""Scalar version of self._binopt, for cases in which no new nonzeros
are added. Produces a new sparse array in canonical form.
"""
self.sum_duplicates()
res = self._with_data(op(self.data, other), copy=True)
res.eliminate_zeros()
return res
| (self, other, op) | [
-0.023766856640577316,
-0.045874353498220444,
0.07059188187122345,
0.033083464950323105,
-0.0024825562722980976,
-0.029851172119379044,
-0.01799366995692253,
-0.03840724006295204,
0.08331363648176193,
-0.07370318472385406,
-0.020897548645734787,
0.009800586849451065,
0.04030858725309372,
-... |
724,660 | scipy.sparse._compressed | _set_arrayXarray | null | def _set_arrayXarray(self, row, col, x):
i, j = self._swap((row, col))
self._set_many(i, j, x)
| (self, row, col, x) | [
0.02180159091949463,
0.0018004636513069272,
0.001974117709323764,
0.09402468800544739,
-0.002299053594470024,
-0.01844356581568718,
-0.04159177467226982,
-0.004721689037978649,
0.0247675608843565,
-0.03835307061672211,
-0.003905621124431491,
-0.06685366481542587,
0.03559165075421333,
0.016... |
724,661 | scipy.sparse._compressed | _set_arrayXarray_sparse | null | def _set_arrayXarray_sparse(self, row, col, x):
# clear entries that will be overwritten
self._zero_many(*self._swap((row, col)))
M, N = row.shape # matches col.shape
broadcast_row = M != 1 and x.shape[0] == 1
broadcast_col = N != 1 and x.shape[1] == 1
r, c = x.row, x.col
x = np.asarray(x.d... | (self, row, col, x) | [
0.03933776170015335,
0.006526734214276075,
0.017939651384949684,
0.09846855700016022,
0.014126477763056755,
-0.029618604108691216,
-0.028093334287405014,
0.00667748786509037,
0.05263953283429146,
-0.041111331433057785,
-0.0404728464782238,
-0.06540922820568085,
0.024599403142929077,
0.0003... |
724,662 | scipy.sparse._compressed | _set_intXint | null | def _set_intXint(self, row, col, x):
i, j = self._swap((row, col))
self._set_many(i, j, x)
| (self, row, col, x) | [
0.016733475029468536,
-0.012237152084708214,
0.04455447569489479,
0.09292401373386383,
0.028766250237822533,
-0.014723755419254303,
0.015881899744272232,
0.04050097241997719,
-0.018104514107108116,
-0.04925517737865448,
-0.02753997966647148,
-0.037435296922922134,
0.024951187893748283,
0.0... |
724,663 | scipy.sparse._compressed | _set_many | Sets value at each (i, j) to x
Here (i,j) index major and minor respectively, and must not contain
duplicate entries.
| def _set_many(self, i, j, x):
"""Sets value at each (i, j) to x
Here (i,j) index major and minor respectively, and must not contain
duplicate entries.
"""
i, j, M, N = self._prepare_indices(i, j)
x = np.atleast_1d(np.asarray(x, dtype=self.dtype)).ravel()
n_samples = x.size
offsets = np.e... | (self, i, j, x) | [
0.02533610351383686,
-0.026843296363949776,
0.0008787984261289239,
0.07906085252761841,
0.0017397108022123575,
0.000275295227766037,
-0.02598476968705654,
0.025278868153691292,
-0.019097469747066498,
0.017199169844388962,
-0.0763135626912117,
0.009100392460823059,
0.02789260819554329,
0.04... |
724,664 | scipy.sparse._compressed | _setdiag | null | def _setdiag(self, values, k):
if 0 in self.shape:
return
M, N = self.shape
broadcast = (values.ndim == 0)
if k < 0:
if broadcast:
max_index = min(M + k, N)
else:
max_index = min(M + k, N, len(values))
i = np.arange(-k, max_index - k, dtype=self.in... | (self, values, k) | [
-0.012828601524233818,
-0.01808689534664154,
0.01033756136894226,
-0.0057084206491708755,
-0.03952927887439728,
-0.005335020367056131,
-0.004974408075213432,
0.026066409423947334,
-0.0035191697534173727,
0.0033964079339057207,
-0.05061875656247139,
0.04636301472783089,
0.059539441019296646,
... |
724,665 | scipy.sparse._base | _sub_dense | null | def _sub_dense(self, other):
return self.todense() - other
| (self, other) | [
0.015431204810738564,
-0.019085964187979698,
0.06697007268667221,
0.051708072423934937,
-0.02510954812169075,
-0.0640598013997078,
-0.01754622720181942,
0.0064338985830545425,
0.05164039134979248,
-0.01783386990427971,
-0.037292078137397766,
-0.012520933523774147,
0.024280458688735962,
-0.... |
724,666 | scipy.sparse._compressed | _sub_sparse | null | def _sub_sparse(self, other):
return self._binopt(other, '_minus_')
| (self, other) | [
0.012884357012808323,
-0.0022771877702325583,
0.04403514415025711,
0.03627191111445427,
-0.032276131212711334,
-0.056104037910699844,
-0.008586853742599487,
0.016415324062108994,
0.05861567333340645,
-0.08239465206861496,
-0.019783196970820427,
0.022278521209955215,
0.016178838908672333,
-... |
724,667 | scipy.sparse._csc | _swap | swap the members of x if this is a column-oriented matrix
| @staticmethod
def _swap(x):
"""swap the members of x if this is a column-oriented matrix
"""
return x[1], x[0]
| (x) | [
-0.009384744800627232,
-0.00881597213447094,
0.013499457389116287,
0.018271813169121742,
-0.06459121406078339,
-0.08083678036928177,
-0.03682801499962807,
0.06508889049291611,
0.0097224535420537,
-0.02913181111216545,
-0.033859733492136,
-0.05573969706892967,
0.0032882154919207096,
0.05399... |
724,668 | scipy.sparse._index | _validate_indices | null | def _validate_indices(self, key):
# First, check if indexing with single boolean matrix.
from ._base import _spbase
if (isinstance(key, (_spbase, np.ndarray)) and
key.ndim == 2 and key.dtype.kind == 'b'):
if key.shape != self.shape:
raise IndexError('boolean index shape does ... | (self, key) | [
-0.01410562451928854,
-0.06474286317825317,
-0.04995935410261154,
0.06050839275121689,
-0.02782123163342476,
-0.01720719039440155,
-0.014142769388854504,
0.05508529767394066,
-0.023141024634242058,
-0.07209748029708862,
-0.017402200028300285,
0.0379616804420948,
0.02117236517369747,
-0.006... |
724,669 | scipy.sparse._compressed | _with_data | Returns a matrix with the same sparsity structure as self,
but with different data. By default the structure arrays
(i.e. .indptr and .indices) are copied.
| def _with_data(self, data, copy=True):
"""Returns a matrix with the same sparsity structure as self,
but with different data. By default the structure arrays
(i.e. .indptr and .indices) are copied.
"""
if copy:
return self.__class__((data, self.indices.copy(),
... | (self, data, copy=True) | [
0.0361068919301033,
-0.04620129242539406,
0.05622510239481926,
0.015926916152238846,
-0.041365861892700195,
-0.013729795813560486,
0.012485642917454243,
0.016976945102214813,
0.03458920121192932,
0.014638644643127918,
-0.04627188295125961,
-0.04704837501049042,
-0.04281296208500862,
0.0393... |
724,670 | scipy.sparse._compressed | _zero_many | Sets value at each (i, j) to zero, preserving sparsity structure.
Here (i,j) index major and minor respectively.
| def _zero_many(self, i, j):
"""Sets value at each (i, j) to zero, preserving sparsity structure.
Here (i,j) index major and minor respectively.
"""
i, j, M, N = self._prepare_indices(i, j)
n_samples = len(i)
offsets = np.empty(n_samples, dtype=self.indices.dtype)
ret = csr_sample_offsets(M, ... | (self, i, j) | [
0.015420189127326012,
-0.00894242711365223,
-0.01784820482134819,
0.02902623824775219,
-0.016803698614239693,
-0.013322017155587673,
-0.027065500617027283,
0.031591687351465225,
-0.0007959767826832831,
0.050356123596429825,
-0.06391636282205582,
0.04507862776517868,
0.033442478626966476,
0... |
724,671 | scipy.sparse._data | arcsin | Element-wise arcsin.
See `numpy.arcsin` for more information. | def _create_method(op):
def method(self):
result = op(self._deduped_data())
return self._with_data(result, copy=True)
method.__doc__ = (f"Element-wise {name}.\n\n"
f"See `numpy.{name}` for more information.")
method.__name__ = name
return method
| (self) | [
0.02686699666082859,
-0.09872221946716309,
0.05016572028398514,
-0.018103739246726036,
-0.02989303320646286,
-0.018750924617052078,
-0.01798129826784134,
-0.0048451549373567104,
0.01626712828874588,
-0.0005717545282095671,
0.023438656702637672,
-0.014308075420558453,
0.0821402445435524,
-0... |
724,672 | scipy.sparse._data | arcsinh | Element-wise arcsinh.
See `numpy.arcsinh` for more information. | def _create_method(op):
def method(self):
result = op(self._deduped_data())
return self._with_data(result, copy=True)
method.__doc__ = (f"Element-wise {name}.\n\n"
f"See `numpy.{name}` for more information.")
method.__name__ = name
return method
| (self) | [
0.02686699666082859,
-0.09872221946716309,
0.05016572028398514,
-0.018103739246726036,
-0.02989303320646286,
-0.018750924617052078,
-0.01798129826784134,
-0.0048451549373567104,
0.01626712828874588,
-0.0005717545282095671,
0.023438656702637672,
-0.014308075420558453,
0.0821402445435524,
-0... |
724,673 | scipy.sparse._data | arctan | Element-wise arctan.
See `numpy.arctan` for more information. | def _create_method(op):
def method(self):
result = op(self._deduped_data())
return self._with_data(result, copy=True)
method.__doc__ = (f"Element-wise {name}.\n\n"
f"See `numpy.{name}` for more information.")
method.__name__ = name
return method
| (self) | [
0.02686699666082859,
-0.09872221946716309,
0.05016572028398514,
-0.018103739246726036,
-0.02989303320646286,
-0.018750924617052078,
-0.01798129826784134,
-0.0048451549373567104,
0.01626712828874588,
-0.0005717545282095671,
0.023438656702637672,
-0.014308075420558453,
0.0821402445435524,
-0... |
724,674 | scipy.sparse._data | arctanh | Element-wise arctanh.
See `numpy.arctanh` for more information. | def _create_method(op):
def method(self):
result = op(self._deduped_data())
return self._with_data(result, copy=True)
method.__doc__ = (f"Element-wise {name}.\n\n"
f"See `numpy.{name}` for more information.")
method.__name__ = name
return method
| (self) | [
0.02686699666082859,
-0.09872221946716309,
0.05016572028398514,
-0.018103739246726036,
-0.02989303320646286,
-0.018750924617052078,
-0.01798129826784134,
-0.0048451549373567104,
0.01626712828874588,
-0.0005717545282095671,
0.023438656702637672,
-0.014308075420558453,
0.0821402445435524,
-0... |
724,675 | scipy.sparse._data | argmax | Return indices of maximum elements along an axis.
Implicit zero elements are also taken into account. If there are
several maximum values, the index of the first occurrence is returned.
Parameters
----------
axis : {-2, -1, 0, 1, None}, optional
Axis along which the... | def argmax(self, axis=None, out=None):
"""Return indices of maximum elements along an axis.
Implicit zero elements are also taken into account. If there are
several maximum values, the index of the first occurrence is returned.
Parameters
----------
axis : {-2, -1, 0, 1, None}, optional
... | (self, axis=None, out=None) | [
0.026020582765340805,
0.01967409998178482,
-0.012243424542248249,
0.006148156244307756,
-0.001120000146329403,
-0.002584869973361492,
0.017232466489076614,
0.010057413950562477,
0.026320278644561768,
-0.0422041155397892,
-0.004343374632298946,
-0.006994354072958231,
-0.04833905026316643,
-... |
724,676 | scipy.sparse._data | argmin | Return indices of minimum elements along an axis.
Implicit zero elements are also taken into account. If there are
several minimum values, the index of the first occurrence is returned.
Parameters
----------
axis : {-2, -1, 0, 1, None}, optional
Axis along which the... | def argmin(self, axis=None, out=None):
"""Return indices of minimum elements along an axis.
Implicit zero elements are also taken into account. If there are
several minimum values, the index of the first occurrence is returned.
Parameters
----------
axis : {-2, -1, 0, 1, None}, optional
... | (self, axis=None, out=None) | [
0.01102400291711092,
-0.0037175484467297792,
0.01150368619710207,
0.0037895007990300655,
0.0592016838490963,
0.032409172505140305,
0.0640159621834755,
0.006798425689339638,
0.014172472059726715,
-0.02539706975221634,
0.0010869195684790611,
-0.03387438878417015,
-0.02787398174405098,
-0.045... |
724,677 | scipy.sparse._base | asformat | Return this array/matrix in the passed format.
Parameters
----------
format : {str, None}
The desired sparse format ("csr", "csc", "lil", "dok", "array", ...)
or None for no conversion.
copy : bool, optional
If True, the result is guaranteed to not sh... | def asformat(self, format, copy=False):
"""Return this array/matrix in the passed format.
Parameters
----------
format : {str, None}
The desired sparse format ("csr", "csc", "lil", "dok", "array", ...)
or None for no conversion.
copy : bool, optional
If True, the result is gu... | (self, format, copy=False) | [
0.0069890511222183704,
0.007587251719087362,
0.06465733051300049,
-0.032190948724746704,
-0.00816393457353115,
-0.016620513051748276,
0.004333727993071079,
0.0051557160913944244,
0.04430989548563957,
0.0121619813144207,
-0.0620751678943634,
-0.02446167729794979,
-0.0011791872093454003,
-0.... |
724,678 | scipy.sparse._matrix | asfptype | Upcast matrix to a floating point format (if necessary) | def asfptype(self):
"""Upcast matrix to a floating point format (if necessary)"""
return self._asfptype()
| (self) | [
0.02856433391571045,
0.01414492167532444,
0.09010203182697296,
0.029387811198830605,
0.03134356811642647,
-0.033934086561203,
-0.016726862639188766,
-0.005228216759860516,
-0.02930203266441822,
0.03763972967863083,
-0.016426637768745422,
-0.046732280403375626,
-0.03144650161266327,
0.01261... |
724,679 | scipy.sparse._data | astype | Cast the array/matrix elements to a specified type.
Parameters
----------
dtype : string or numpy dtype
Typecode or data-type to which to cast the data.
casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
Controls what kind of data casting may occu... | def astype(self, dtype, casting='unsafe', copy=True):
dtype = np.dtype(dtype)
if self.dtype != dtype:
matrix = self._with_data(
self.data.astype(dtype, casting=casting, copy=True),
copy=True
)
return matrix._with_data(matrix._deduped_data(), copy=False)
elif c... | (self, dtype, casting='unsafe', copy=True) | [
0.007184429559856653,
0.005775279365479946,
0.09304865449666977,
-0.023190587759017944,
-0.04101298376917839,
-0.01957600563764572,
0.01564827747642994,
0.03897307068109512,
0.0007414814317598939,
0.022922178730368614,
-0.07322213053703308,
0.003053158987313509,
-0.0452001728117466,
0.0489... |
724,680 | scipy.sparse._data | ceil | Element-wise ceil.
See `numpy.ceil` for more information. | def _create_method(op):
def method(self):
result = op(self._deduped_data())
return self._with_data(result, copy=True)
method.__doc__ = (f"Element-wise {name}.\n\n"
f"See `numpy.{name}` for more information.")
method.__name__ = name
return method
| (self) | [
0.02686699666082859,
-0.09872221946716309,
0.05016572028398514,
-0.018103739246726036,
-0.02989303320646286,
-0.018750924617052078,
-0.01798129826784134,
-0.0048451549373567104,
0.01626712828874588,
-0.0005717545282095671,
0.023438656702637672,
-0.014308075420558453,
0.0821402445435524,
-0... |
724,681 | scipy.sparse._compressed | check_format | Check whether the array/matrix respects the CSR or CSC format.
Parameters
----------
full_check : bool, optional
If `True`, run rigorous check, scanning arrays for valid values.
Note that activating those check might copy arrays for casting,
modifying indices... | def check_format(self, full_check=True):
"""Check whether the array/matrix respects the CSR or CSC format.
Parameters
----------
full_check : bool, optional
If `True`, run rigorous check, scanning arrays for valid values.
Note that activating those check might copy arrays for casting,
... | (self, full_check=True) | [
0.002889583120122552,
0.011293862015008926,
-0.0023728865198791027,
0.0678219422698021,
-0.002206368139013648,
-0.03880856931209564,
-0.03246128186583519,
0.008791189640760422,
0.046429235488176346,
-0.07507038861513138,
-0.04733039066195488,
-0.029150506481528282,
0.05265897884964943,
-0.... |
724,682 | scipy.sparse._base | conj | Element-wise complex conjugation.
If the array/matrix is of non-complex data type and `copy` is False,
this method does nothing and the data is not copied.
Parameters
----------
copy : bool, optional
If True, the result is guaranteed to not share data with self.
... | def conj(self, copy=True):
return self.conjugate(copy=copy)
| (self, copy=True) | [
-0.03911757469177246,
-0.03700132668018341,
0.04811164364218712,
0.015739616006612778,
-0.06676110625267029,
-0.05750250443816185,
-0.0266515351831913,
-0.0014414893230423331,
0.09496676176786423,
-0.031032836064696312,
-0.0220718365162611,
-0.04053943231701851,
-0.028503254055976868,
0.06... |
724,683 | scipy.sparse._data | conjugate | Element-wise complex conjugation.
If the array/matrix is of non-complex data type and `copy` is False,
this method does nothing and the data is not copied.
Parameters
----------
copy : bool, optional
If True, the result is guaranteed to not share data with self.
... | def conjugate(self, copy=True):
if np.issubdtype(self.dtype, np.complexfloating):
return self._with_data(self.data.conjugate(), copy=copy)
elif copy:
return self.copy()
else:
return self
| (self, copy=True) | [
-0.010950925759971142,
-0.04509512707591057,
0.07350645214319229,
0.03146536648273468,
-0.05312289670109749,
-0.02139575220644474,
0.004432725254446268,
0.001119088614359498,
0.06596732884645462,
-0.0017560747219249606,
-0.0001190258699352853,
-0.03696264699101448,
-0.050609853118658066,
0... |
724,684 | scipy.sparse._data | copy | Returns a copy of this array/matrix.
No data/indices will be shared between the returned value and current
array/matrix.
| def copy(self):
return self._with_data(self.data.copy(), copy=True)
| (self) | [
0.031151071190834045,
-0.029410025104880333,
0.015985192731022835,
0.003706124145537615,
-0.05288001149892807,
0.01877598837018013,
-0.014918375760316849,
0.016420455649495125,
0.1068524420261383,
-0.004239532630890608,
-0.021609455347061157,
-0.042024075984954834,
-0.033335912972688675,
0... |
724,685 | scipy.sparse._data | count_nonzero | Number of non-zero entries, equivalent to
np.count_nonzero(a.toarray())
Unlike the nnz property, which return the number of stored
entries (the length of the data attribute), this method counts the
actual number of non-zero entries in data.
| def count_nonzero(self):
return np.count_nonzero(self._deduped_data())
| (self) | [
-0.06220439448952675,
-0.019275764003396034,
0.03134995698928833,
0.00975350383669138,
0.06970327347517014,
0.03805600851774216,
-0.03402576968073845,
0.027501411736011505,
0.0010674346704035997,
0.015171199105679989,
-0.0481976680457592,
0.02221585437655449,
0.03044150210916996,
-0.041590... |
724,686 | scipy.sparse._data | deg2rad | Element-wise deg2rad.
See `numpy.deg2rad` for more information. | def _create_method(op):
def method(self):
result = op(self._deduped_data())
return self._with_data(result, copy=True)
method.__doc__ = (f"Element-wise {name}.\n\n"
f"See `numpy.{name}` for more information.")
method.__name__ = name
return method
| (self) | [
0.02686699666082859,
-0.09872221946716309,
0.05016572028398514,
-0.018103739246726036,
-0.02989303320646286,
-0.018750924617052078,
-0.01798129826784134,
-0.0048451549373567104,
0.01626712828874588,
-0.0005717545282095671,
0.023438656702637672,
-0.014308075420558453,
0.0821402445435524,
-0... |
724,687 | scipy.sparse._compressed | diagonal | Returns the kth diagonal of the array/matrix.
Parameters
----------
k : int, optional
Which diagonal to get, corresponding to elements a[i, i+k].
Default: 0 (the main diagonal).
.. versionadded:: 1.0
See also
--------
numpy.diagonal ... | def diagonal(self, k=0):
rows, cols = self.shape
if k <= -rows or k >= cols:
return np.empty(0, dtype=self.data.dtype)
fn = getattr(_sparsetools, self.format + "_diagonal")
y = np.empty(min(rows + min(k, 0), cols - max(k, 0)),
dtype=upcast(self.dtype))
fn(k, self.shape[0], s... | (self, k=0) | [
-0.04400721937417984,
-0.013457809574902058,
0.03487709164619446,
-0.0001438708568457514,
-0.02435918338596821,
-0.009262515231966972,
-0.011476571671664715,
0.01006140187382698,
-0.05828674137592316,
0.0536121129989624,
-0.021419281139969826,
0.029344232752919197,
0.02748168632388115,
0.0... |
724,688 | scipy.sparse._base | dot | Ordinary dot product
Examples
--------
>>> import numpy as np
>>> from scipy.sparse import csr_array
>>> A = csr_array([[1, 2, 0], [0, 0, 3], [4, 0, 5]])
>>> v = np.array([1, 0, -1])
>>> A.dot(v)
array([ 1, -3, -1], dtype=int64)
| def dot(self, other):
"""Ordinary dot product
Examples
--------
>>> import numpy as np
>>> from scipy.sparse import csr_array
>>> A = csr_array([[1, 2, 0], [0, 0, 3], [4, 0, 5]])
>>> v = np.array([1, 0, -1])
>>> A.dot(v)
array([ 1, -3, -1], dtype=int64)
"""
if np.isscalar(oth... | (self, other) | [
0.02569514513015747,
-0.04615916684269905,
0.10403310507535934,
0.06443126499652863,
0.031128887087106705,
-0.08318227529525757,
-0.06148415431380272,
-0.03527326509356499,
0.07662495225667953,
0.026192471385002136,
-0.021163959056138992,
-0.06409972161054611,
0.06476281583309174,
0.036746... |
724,689 | scipy.sparse._compressed | eliminate_zeros | Remove zero entries from the array/matrix
This is an *in place* operation.
| def eliminate_zeros(self):
"""Remove zero entries from the array/matrix
This is an *in place* operation.
"""
M, N = self._swap(self.shape)
_sparsetools.csr_eliminate_zeros(M, N, self.indptr, self.indices,
self.data)
self.prune() # nnz may have changed
| (self) | [
-0.02465658262372017,
0.033249881118535995,
0.030759884044528008,
-0.001675599254667759,
-0.018216291442513466,
-0.05590323358774185,
-0.06986968219280243,
0.02997356839478016,
0.028045225888490677,
-0.007638486102223396,
-0.06451524794101715,
0.016952570527791977,
0.03356815129518509,
-0.... |
724,690 | scipy.sparse._data | expm1 | Element-wise expm1.
See `numpy.expm1` for more information. | def _create_method(op):
def method(self):
result = op(self._deduped_data())
return self._with_data(result, copy=True)
method.__doc__ = (f"Element-wise {name}.\n\n"
f"See `numpy.{name}` for more information.")
method.__name__ = name
return method
| (self) | [
0.02686699666082859,
-0.09872221946716309,
0.05016572028398514,
-0.018103739246726036,
-0.02989303320646286,
-0.018750924617052078,
-0.01798129826784134,
-0.0048451549373567104,
0.01626712828874588,
-0.0005717545282095671,
0.023438656702637672,
-0.014308075420558453,
0.0821402445435524,
-0... |
724,691 | scipy.sparse._data | floor | Element-wise floor.
See `numpy.floor` for more information. | def _create_method(op):
def method(self):
result = op(self._deduped_data())
return self._with_data(result, copy=True)
method.__doc__ = (f"Element-wise {name}.\n\n"
f"See `numpy.{name}` for more information.")
method.__name__ = name
return method
| (self) | [
0.02686699666082859,
-0.09872221946716309,
0.05016572028398514,
-0.018103739246726036,
-0.02989303320646286,
-0.018750924617052078,
-0.01798129826784134,
-0.0048451549373567104,
0.01626712828874588,
-0.0005717545282095671,
0.023438656702637672,
-0.014308075420558453,
0.0821402445435524,
-0... |
724,692 | scipy.sparse._matrix | getH | Return the Hermitian transpose of this matrix.
See Also
--------
numpy.matrix.getH : NumPy's implementation of `getH` for matrices
| def getH(self):
"""Return the Hermitian transpose of this matrix.
See Also
--------
numpy.matrix.getH : NumPy's implementation of `getH` for matrices
"""
return self.conjugate().transpose()
| (self) | [
-0.030241983011364937,
-0.012825995683670044,
0.04728557541966438,
-0.01920868270099163,
-0.002028689719736576,
-0.02837134525179863,
0.006975921336561441,
0.03827879950404167,
-0.0013986484846100211,
-0.0035182719584554434,
0.012315034866333008,
-0.05594593659043312,
0.0027150234673172235,
... |
724,693 | scipy.sparse._matrix | get_shape | Get the shape of the matrix | def get_shape(self):
"""Get the shape of the matrix"""
return self._shape
| (self) | [
-0.001620180089958012,
-0.04010520875453949,
0.05304992198944092,
0.026658756658434868,
0.007383840158581734,
-0.004103759303689003,
0.007747597061097622,
0.03903484344482422,
0.024869242683053017,
0.01044441293925047,
-0.024618376046419144,
-0.05187921226024628,
-0.020504163578152657,
0.0... |
724,694 | scipy.sparse._matrix | getcol | Returns a copy of column j of the matrix, as an (m x 1) sparse
matrix (column vector).
| def getcol(self, j):
"""Returns a copy of column j of the matrix, as an (m x 1) sparse
matrix (column vector).
"""
return self._getcol(j)
| (self, j) | [
0.042328014969825745,
0.01051278319209814,
0.031322039663791656,
0.05592973902821541,
0.05918307602405548,
-0.021042872220277786,
0.038278646767139435,
0.06745486706495285,
0.04253567382693291,
-0.03672119602560997,
-0.030335653573274612,
-0.006645117420703173,
-0.028882034122943878,
-0.01... |
724,695 | scipy.sparse._matrix | getformat | Matrix storage format | def getformat(self):
"""Matrix storage format"""
return self.format
| (self) | [
0.05187540501356125,
-0.010504852049052715,
0.06780926883220673,
0.021863890811800957,
0.038471248000860214,
-0.008435091935098171,
-0.02597055584192276,
0.006578878965228796,
0.011679357849061489,
0.0003891066007781774,
-0.013453437946736813,
-0.032902609556913376,
-0.03843839466571808,
-... |
724,696 | scipy.sparse._matrix | getmaxprint | Maximum number of elements to display when printed. | def getmaxprint(self):
"""Maximum number of elements to display when printed."""
return self._getmaxprint()
| (self) | [
0.014732986688613892,
0.014433709904551506,
-0.009901798330247402,
0.0377260223031044,
0.00983339175581932,
0.03669992834329605,
0.01640038751065731,
-0.05516960471868515,
-0.003655456705018878,
-0.05729019641876221,
-0.03382686898112297,
-0.0528779961168766,
-0.030047426000237465,
-0.0481... |
724,697 | scipy.sparse._matrix | getnnz | Number of stored values, including explicit zeros.
Parameters
----------
axis : None, 0, or 1
Select between the number of values across the whole array, in
each column, or in each row.
| def getnnz(self, axis=None):
"""Number of stored values, including explicit zeros.
Parameters
----------
axis : None, 0, or 1
Select between the number of values across the whole array, in
each column, or in each row.
"""
return self._getnnz(axis=axis)
| (self, axis=None) | [
-0.053233250975608826,
0.012814127840101719,
0.013689788989722729,
0.036760419607162476,
0.08524256199598312,
0.08094228059053421,
-0.03946543112397194,
0.010689999908208847,
0.09099937975406647,
-0.002965109422802925,
0.0039534792304039,
-0.014383381232619286,
-0.009710299782454967,
-0.06... |
724,698 | scipy.sparse._matrix | getrow | Returns a copy of row i of the matrix, as a (1 x n) sparse
matrix (row vector).
| def getrow(self, i):
"""Returns a copy of row i of the matrix, as a (1 x n) sparse
matrix (row vector).
"""
return self._getrow(i)
| (self, i) | [
0.021010002121329308,
-0.014774552546441555,
0.026067644357681274,
0.05303596705198288,
0.018792953342199326,
-0.008902836591005325,
0.017753710970282555,
0.050611067563295364,
0.04049578309059143,
-0.02322705090045929,
-0.04434097558259964,
-0.02203192375600338,
-0.04156966507434845,
0.02... |
724,699 | scipy.sparse._data | log1p | Element-wise log1p.
See `numpy.log1p` for more information. | def _create_method(op):
def method(self):
result = op(self._deduped_data())
return self._with_data(result, copy=True)
method.__doc__ = (f"Element-wise {name}.\n\n"
f"See `numpy.{name}` for more information.")
method.__name__ = name
return method
| (self) | [
0.02686699666082859,
-0.09872221946716309,
0.05016572028398514,
-0.018103739246726036,
-0.02989303320646286,
-0.018750924617052078,
-0.01798129826784134,
-0.0048451549373567104,
0.01626712828874588,
-0.0005717545282095671,
0.023438656702637672,
-0.014308075420558453,
0.0821402445435524,
-0... |
724,700 | scipy.sparse._data | max |
Return the maximum of the array/matrix or maximum along an axis.
This takes all elements into account, not just the non-zero ones.
Parameters
----------
axis : {-2, -1, 0, 1, None} optional
Axis along which the sum is computed. The default is to
compute ... | def max(self, axis=None, out=None):
"""
Return the maximum of the array/matrix or maximum along an axis.
This takes all elements into account, not just the non-zero ones.
Parameters
----------
axis : {-2, -1, 0, 1, None} optional
Axis along which the sum is computed. The default is to
... | (self, axis=None, out=None) | [
0.012721553444862366,
0.03936009481549263,
0.01435412373393774,
0.01798502914607525,
-0.007663263939321041,
-0.02007257752120495,
-0.02844061143696308,
0.001366050448268652,
0.03782565891742706,
-0.06740817427635193,
-0.024497466161847115,
0.012775080278515816,
-0.0419650673866272,
-0.0324... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.