You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
c = np.array(['aAaAaA', ' aA ', 'abBABba']).view(np.chararray)
c
chararray(['aAaAaA', ' aA', 'abBABba'],
dtype='|S7')
c.count('aA', end=3)
array([3, 1, 0]
Problem (as reported by Pierre GM):
"The input of the method ('aA',start,end) are checked for consistency.
However, a problem is that as soon any value is 0 or None or False,
the following values are not checked and just discarded (that's line 171 in defchararray).
When you call the count method, start defaults to None, meaning
that the end parameter is never taken into account.
"That's clearly a bug, actually 2 bugs:
start should default to 0 in that case (you need it in the count
method of strings)
when one of the parameter is not None, it should be taken into
account.
">>> if not chk or (chk.dtype is object_ and chk.item() is None):
should become
if (chk is None) of (chk.dtype is object_ and chk.item() is None):"
The text was updated successfully, but these errors were encountered:
This bug is addressed by the chararray refactoring I did in SVN r7514. It's difficult to create a simple patch for this bug, as part of its solution involved vectorizing the string operation in C.
Is there no way to mark this as "fixed" without attaching a patch?
Original ticket http://projects.scipy.org/numpy/ticket/1195 on 2009-08-17 by trac user dgoldsmith, assigned to unknown.
Example:
Problem (as reported by Pierre GM):
"The input of the method ('aA',start,end) are checked for consistency.
However, a problem is that as soon any value is 0 or None or False,
the following values are not checked and just discarded (that's line 171 in defchararray).
When you call the
count
method,start
defaults to None, meaningthat the
end
parameter is never taken into account."That's clearly a bug, actually 2 bugs:
start
should default to 0 in that case (you need it in thecount
method of strings)
account.
">>> if not chk or (chk.dtype is object_ and chk.item() is None):
should become
The text was updated successfully, but these errors were encountered: