Closed
Description
It seems that whitespace in a character array is treated as if it is zero. An example of this is shown below with details about the environment. This seems to match up with how character arrays work. Still this seems a bit surprising from a Python perspective. Am trying to understand if this is intentional and also if there is an builtin element-wise operator that we can use to reproduce this behavior.
Code snippet:
In [1]: import numpy as np
In [2]: s = np.array(list("hello world"))
In [3]: s
Out[3]:
array(['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'],
dtype='|S1')
In [4]: s.nonzero()
Out[4]: (array([ 0, 1, 2, 3, 4, 6, 7, 8, 9, 10]),)
Environment:
name: np2
channels:
- conda-forge
- defaults
dependencies:
- appnope=0.1.0=py27_0
- backports.shutil_get_terminal_size=1.0.0=py27_1
- blas=1.1=openblas
- ca-certificates=2017.4.17=0
- certifi=2017.4.17=py27_0
- decorator=4.1.1=py27_0
- enum34=1.1.6=py27_1
- ipython=5.4.1=py27_0
- ipython_genutils=0.2.0=py27_0
- libgfortran=3.0.0=0
- ncurses=5.9=10
- numpy=1.13.1=py27_blas_openblas_200
- openblas=0.2.19=2
- openssl=1.0.2l=0
- pathlib2=2.3.0=py27_0
- pexpect=4.2.1=py27_0
- pickleshare=0.7.3=py27_0
- pip=9.0.1=py27_0
- prompt_toolkit=1.0.14=py27_0
- ptyprocess=0.5.2=py27_0
- pygments=2.2.0=py27_0
- python=2.7.13=1
- readline=6.2=0
- scandir=1.5=py27_1
- setuptools=36.2.2=py27_0
- simplegeneric=0.8.1=py27_0
- six=1.10.0=py27_1
- sqlite=3.13.0=1
- tk=8.5.19=1
- traitlets=4.3.2=py27_0
- wcwidth=0.1.7=py27_0
- wheel=0.29.0=py27_0
- zlib=1.2.11=0
- pip:
- backports.shutil-get-terminal-size==1.0.0
- ipython-genutils==0.2.0
- prompt-toolkit==1.0.14
Metadata
Metadata
Assignees
Labels
No labels