<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [1]: import numpy as np

In [2]: np.append([], (unichr(0)))
Out[2]:
array([u''],
      dtype='&lt;U32')

In [3]: np.append([], (unichr(1)))
Out[3]:
array([u'\x01'],
      dtype='&lt;U32')

In [4]: np.unique(unichr(0))
Out[4]:
array([u''],
      dtype='&lt;U1')

In [5]: np.unique(unichr(1))
Out[5]:
array([u'\x01'],
      dtype='&lt;U1')

In [6]: np.array([unichr(0)])
Out[6]:
array([u''],
      dtype='&lt;U1')

In [7]: np.array([unichr(1)])
Out[7]:
array([u'\x01'],
      dtype='&lt;U1')

In [8]: np.array([unichr(0), unichr(1)])
Out[8]:
array([u'', u'\x01'],
      dtype='&lt;U1')

In [9]: [unichr(0)]
Out[9]: [u'\x00']"><pre class="notranslate"><code class="notranslate">In [1]: import numpy as np

In [2]: np.append([], (unichr(0)))
Out[2]:
array([u''],
      dtype='&lt;U32')

In [3]: np.append([], (unichr(1)))
Out[3]:
array([u'\x01'],
      dtype='&lt;U32')

In [4]: np.unique(unichr(0))
Out[4]:
array([u''],
      dtype='&lt;U1')

In [5]: np.unique(unichr(1))
Out[5]:
array([u'\x01'],
      dtype='&lt;U1')

In [6]: np.array([unichr(0)])
Out[6]:
array([u''],
      dtype='&lt;U1')

In [7]: np.array([unichr(1)])
Out[7]:
array([u'\x01'],
      dtype='&lt;U1')

In [8]: np.array([unichr(0), unichr(1)])
Out[8]:
array([u'', u'\x01'],
      dtype='&lt;U1')

In [9]: [unichr(0)]
Out[9]: [u'\x00']
</code></pre></div>
<h3 dir="auto">Describe the issue:</h3>
<p dir="auto">On osx-arm64, running the following</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np

Sigma = np.full((5, 5), 0.7)
np.fill_diagonal(Sigma, 1)

rng = np.random.default_rng(12)

X = rng.multivariate_normal(np.zeros(5), Sigma, 1)
print(X)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-v">Sigma</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">full</span>((<span class="pl-c1">5</span>, <span class="pl-c1">5</span>), <span class="pl-c1">0.7</span>)
<span class="pl-s1">np</span>.<span class="pl-en">fill_diagonal</span>(<span class="pl-v">Sigma</span>, <span class="pl-c1">1</span>)

<span class="pl-s1">rng</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">default_rng</span>(<span class="pl-c1">12</span>)

<span class="pl-v">X</span> <span class="pl-c1">=</span> <span class="pl-s1">rng</span>.<span class="pl-en">multivariate_normal</span>(<span class="pl-s1">np</span>.<span class="pl-en">zeros</span>(<span class="pl-c1">5</span>), <span class="pl-v">Sigma</span>, <span class="pl-c1">1</span>)
<span class="pl-en">print</span>(<span class="pl-v">X</span>)</pre></div>
<p dir="auto">prints</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[[ 0.7989866   0.26512508 -0.43169361 -0.72572551  0.12306469]]"><pre class="notranslate"><code class="notranslate">[[ 0.7989866   0.26512508 -0.43169361 -0.72572551  0.12306469]]
</code></pre></div>
<p dir="auto">Running the same code on linux64 prints</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[[ 0.36925409  0.06273453 -0.92231155 -0.1340844   0.65416457]]"><pre class="notranslate"><code class="notranslate">[[ 0.36925409  0.06273453 -0.92231155 -0.1340844   0.65416457]]
</code></pre></div>
<p dir="auto">This is equally an issue for scipy:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from scipy.stats import multivariate_normal

X = multivariate_normal(mean=np.zeros(5), cov=Sigma, seed=12).rvs(1)

print(X)"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">scipy</span>.<span class="pl-s1">stats</span> <span class="pl-k">import</span> <span class="pl-s1">multivariate_normal</span>

<span class="pl-v">X</span> <span class="pl-c1">=</span> <span class="pl-en">multivariate_normal</span>(<span class="pl-s1">mean</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">zeros</span>(<span class="pl-c1">5</span>), <span class="pl-s1">cov</span><span class="pl-c1">=</span><span class="pl-v">Sigma</span>, <span class="pl-s1">seed</span><span class="pl-c1">=</span><span class="pl-c1">12</span>).<span class="pl-en">rvs</span>(<span class="pl-c1">1</span>)

<span class="pl-en">print</span>(<span class="pl-v">X</span>)</pre></div>
<p dir="auto">prints</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[-0.04337636 -1.19324783  0.23303855 -0.47834447 -0.57976733]"><pre class="notranslate"><code class="notranslate">[-0.04337636 -1.19324783  0.23303855 -0.47834447 -0.57976733]
</code></pre></div>
<p dir="auto">on osx-arm64 and</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[-0.29356888 -0.19370035 -0.7717682   0.30701745 -1.10967747]"><pre class="notranslate"><code class="notranslate">[-0.29356888 -0.19370035 -0.7717682   0.30701745 -1.10967747]
</code></pre></div>
<p dir="auto">on linux-64.</p>
<details>
<p dir="auto">Output of <code class="notranslate">conda list</code> on osx-arm64:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# packages in environment at /Users/mlondschien/mambaforge/envs/numpy:
#
# Name                    Version                   Build  Channel
bzip2                     1.0.8                h3422bc3_4    conda-forge
ca-certificates           2022.12.7            h4653dfc_0    conda-forge
libblas                   3.9.0           16_osxarm64_openblas    conda-forge
libcblas                  3.9.0           16_osxarm64_openblas    conda-forge
libcxx                    14.0.6               h2692d47_0    conda-forge
libffi                    3.4.2                h3422bc3_5    conda-forge
libgfortran               5.0.0           11_3_0_hd922786_27    conda-forge
libgfortran5              11.3.0              hdaf2cc0_27    conda-forge
liblapack                 3.9.0           16_osxarm64_openblas    conda-forge
libopenblas               0.3.21          openmp_hc731615_3    conda-forge
libsqlite                 3.40.0               h76d750c_0    conda-forge
libzlib                   1.2.13               h03a7124_4    conda-forge
llvm-openmp               15.0.6               h7cfbb63_0    conda-forge
ncurses                   6.3                  h07bb92c_1    conda-forge
numpy                     1.24.0          py311ha92fb03_0    conda-forge
openssl                   3.0.7                h03a7124_1    conda-forge
pip                       22.3.1             pyhd8ed1ab_0    conda-forge
python                    3.11.0          h93c2e33_0_cpython    conda-forge
python_abi                3.11                    3_cp311    conda-forge
readline                  8.1.2                h46ed386_0    conda-forge
scipy                     1.9.3           py311h0bcca16_2    conda-forge
setuptools                65.6.3             pyhd8ed1ab_0    conda-forge
tk                        8.6.12               he1e0b03_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h57fd34a_0    conda-forge"><pre class="notranslate"><code class="notranslate"># packages in environment at /Users/mlondschien/mambaforge/envs/numpy:
#
# Name                    Version                   Build  Channel
bzip2                     1.0.8                h3422bc3_4    conda-forge
ca-certificates           2022.12.7            h4653dfc_0    conda-forge
libblas                   3.9.0           16_osxarm64_openblas    conda-forge
libcblas                  3.9.0           16_osxarm64_openblas    conda-forge
libcxx                    14.0.6               h2692d47_0    conda-forge
libffi                    3.4.2                h3422bc3_5    conda-forge
libgfortran               5.0.0           11_3_0_hd922786_27    conda-forge
libgfortran5              11.3.0              hdaf2cc0_27    conda-forge
liblapack                 3.9.0           16_osxarm64_openblas    conda-forge
libopenblas               0.3.21          openmp_hc731615_3    conda-forge
libsqlite                 3.40.0               h76d750c_0    conda-forge
libzlib                   1.2.13               h03a7124_4    conda-forge
llvm-openmp               15.0.6               h7cfbb63_0    conda-forge
ncurses                   6.3                  h07bb92c_1    conda-forge
numpy                     1.24.0          py311ha92fb03_0    conda-forge
openssl                   3.0.7                h03a7124_1    conda-forge
pip                       22.3.1             pyhd8ed1ab_0    conda-forge
python                    3.11.0          h93c2e33_0_cpython    conda-forge
python_abi                3.11                    3_cp311    conda-forge
readline                  8.1.2                h46ed386_0    conda-forge
scipy                     1.9.3           py311h0bcca16_2    conda-forge
setuptools                65.6.3             pyhd8ed1ab_0    conda-forge
tk                        8.6.12               he1e0b03_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h57fd34a_0    conda-forge
</code></pre></div>
<p dir="auto">Output of <code class="notranslate">conda list</code> on linux-64:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# packages in environment at /home/mlondschien/miniforge3/envs/numpy:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2022.12.7            ha878542_0    conda-forge
ld_impl_linux-64          2.39                 hcc3a1bd_1    conda-forge
libblas                   3.9.0           16_linux64_openblas    conda-forge
libcblas                  3.9.0           16_linux64_openblas    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 12.2.0              h65d4601_19    conda-forge
libgfortran-ng            12.2.0              h69a702a_19    conda-forge
libgfortran5              12.2.0              h337968e_19    conda-forge
libgomp                   12.2.0              h65d4601_19    conda-forge
liblapack                 3.9.0           16_linux64_openblas    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libopenblas               0.3.21          pthreads_h78a6416_3    conda-forge
libsqlite                 3.40.0               h753d276_0    conda-forge
libstdcxx-ng              12.2.0              h46fd767_19    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libzlib                   1.2.13               h166bdaf_4    conda-forge
ncurses                   6.3                  h27087fc_1    conda-forge
numpy                     1.24.0                   pypi_0    pypi
openssl                   3.0.7                h0b41bf4_1    conda-forge
pip                       22.3.1             pyhd8ed1ab_0    conda-forge
python                    3.11.0          ha86cf86_0_cpython    conda-forge
python_abi                3.11                    3_cp311    conda-forge
readline                  8.1.2                h0f457ee_0    conda-forge
scipy                     1.9.3                    pypi_0    pypi
setuptools                65.6.3             pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge"><pre class="notranslate"><code class="notranslate"># packages in environment at /home/mlondschien/miniforge3/envs/numpy:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2022.12.7            ha878542_0    conda-forge
ld_impl_linux-64          2.39                 hcc3a1bd_1    conda-forge
libblas                   3.9.0           16_linux64_openblas    conda-forge
libcblas                  3.9.0           16_linux64_openblas    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 12.2.0              h65d4601_19    conda-forge
libgfortran-ng            12.2.0              h69a702a_19    conda-forge
libgfortran5              12.2.0              h337968e_19    conda-forge
libgomp                   12.2.0              h65d4601_19    conda-forge
liblapack                 3.9.0           16_linux64_openblas    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libopenblas               0.3.21          pthreads_h78a6416_3    conda-forge
libsqlite                 3.40.0               h753d276_0    conda-forge
libstdcxx-ng              12.2.0              h46fd767_19    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libzlib                   1.2.13               h166bdaf_4    conda-forge
ncurses                   6.3                  h27087fc_1    conda-forge
numpy                     1.24.0                   pypi_0    pypi
openssl                   3.0.7                h0b41bf4_1    conda-forge
pip                       22.3.1             pyhd8ed1ab_0    conda-forge
python                    3.11.0          ha86cf86_0_cpython    conda-forge
python_abi                3.11                    3_cp311    conda-forge
readline                  8.1.2                h0f457ee_0    conda-forge
scipy                     1.9.3                    pypi_0    pypi
setuptools                65.6.3             pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
</code></pre></div>
</details>
<h3 dir="auto">Reproduce the code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np

Sigma = np.full((5, 5), 0.7)
np.fill_diagonal(Sigma, 1)

rng = np.random.default_rng(12)

X = rng.multivariate_normal(np.zeros(5), Sigma, 1)
print(X)

from scipy.stats import multivariate_normal

X = multivariate_normal(mean=np.zeros(5), cov=Sigma, seed=12).rvs(1)

print(X)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-v">Sigma</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">full</span>((<span class="pl-c1">5</span>, <span class="pl-c1">5</span>), <span class="pl-c1">0.7</span>)
<span class="pl-s1">np</span>.<span class="pl-en">fill_diagonal</span>(<span class="pl-v">Sigma</span>, <span class="pl-c1">1</span>)

<span class="pl-s1">rng</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">default_rng</span>(<span class="pl-c1">12</span>)

<span class="pl-v">X</span> <span class="pl-c1">=</span> <span class="pl-s1">rng</span>.<span class="pl-en">multivariate_normal</span>(<span class="pl-s1">np</span>.<span class="pl-en">zeros</span>(<span class="pl-c1">5</span>), <span class="pl-v">Sigma</span>, <span class="pl-c1">1</span>)
<span class="pl-en">print</span>(<span class="pl-v">X</span>)

<span class="pl-k">from</span> <span class="pl-s1">scipy</span>.<span class="pl-s1">stats</span> <span class="pl-k">import</span> <span class="pl-s1">multivariate_normal</span>

<span class="pl-v">X</span> <span class="pl-c1">=</span> <span class="pl-en">multivariate_normal</span>(<span class="pl-s1">mean</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">zeros</span>(<span class="pl-c1">5</span>), <span class="pl-s1">cov</span><span class="pl-c1">=</span><span class="pl-v">Sigma</span>, <span class="pl-s1">seed</span><span class="pl-c1">=</span><span class="pl-c1">12</span>).<span class="pl-en">rvs</span>(<span class="pl-c1">1</span>)

<span class="pl-en">print</span>(<span class="pl-v">X</span>)</pre></div>
<h3 dir="auto">Error message:</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Runtime information:</h3>
<p dir="auto">On osx-arm64:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Python 3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:21:25) [Clang 14.0.4 ] on darwin
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import sys, numpy; print(numpy.__version__); print(sys.version)
1.24.0
3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:21:25) [Clang 14.0.4 ]
&gt;&gt;&gt; print(numpy.show_runtime())
[{'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
                      'found': ['ASIMDHP', 'ASIMDDP'],
                      'not_found': ['ASIMDFHM']}},
 {'architecture': 'VORTEX',
  'filepath': '/Users/mlondschien/mambaforge/envs/numpy/lib/libopenblas.0.dylib',
  'internal_api': 'openblas',
  'num_threads': 10,
  'prefix': 'libopenblas',
  'threading_layer': 'openmp',
  'user_api': 'blas',
  'version': '0.3.21'},
 {'filepath': '/Users/mlondschien/mambaforge/envs/numpy/lib/libomp.dylib',
  'internal_api': 'openmp',
  'num_threads': 10,
  'prefix': 'libomp',
  'user_api': 'openmp',
  'version': None}]
None"><pre class="notranslate"><code class="notranslate">Python 3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:21:25) [Clang 14.0.4 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import sys, numpy; print(numpy.__version__); print(sys.version)
1.24.0
3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:21:25) [Clang 14.0.4 ]
&gt;&gt;&gt; print(numpy.show_runtime())
[{'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
                      'found': ['ASIMDHP', 'ASIMDDP'],
                      'not_found': ['ASIMDFHM']}},
 {'architecture': 'VORTEX',
  'filepath': '/Users/mlondschien/mambaforge/envs/numpy/lib/libopenblas.0.dylib',
  'internal_api': 'openblas',
  'num_threads': 10,
  'prefix': 'libopenblas',
  'threading_layer': 'openmp',
  'user_api': 'blas',
  'version': '0.3.21'},
 {'filepath': '/Users/mlondschien/mambaforge/envs/numpy/lib/libomp.dylib',
  'internal_api': 'openmp',
  'num_threads': 10,
  'prefix': 'libomp',
  'user_api': 'openmp',
  'version': None}]
None
</code></pre></div>
<p dir="auto">(I needed to install <code class="notranslate">threadpoolctl</code> for the second result. This did not change the original issue.)</p>
<p dir="auto">On linux-64:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Python 3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:24:40) [GCC 10.4.0] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import sys, numpy
&gt;&gt;&gt; print(numpy.__version__); print(sys.version)
1.24.0
3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:24:40) [GCC 10.4.0]
&gt;&gt; print(numpy.show_runtime())
[{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
                      'found': ['SSSE3',
                                'SSE41',
                                'POPCNT',
                                'SSE42',
                                'AVX',
                                'F16C',
                                'FMA3',
                                'AVX2'],
                      'not_found': ['AVX512F',
                                    'AVX512CD',
                                    'AVX512_KNL',
                                    'AVX512_KNM',
                                    'AVX512_SKX',
                                    'AVX512_CLX',
                                    'AVX512_CNL',
                                    'AVX512_ICL']}},
 {'architecture': 'Haswell',
  'filepath': '/home/mlondschien/miniforge3/envs/numpy/lib/libopenblasp-r0.3.21.so',
  'internal_api': 'openblas',
  'num_threads': 8,
  'prefix': 'libopenblas',
  'threading_layer': 'pthreads',
  'user_api': 'blas',
  'version': '0.3.21'}]
None"><pre class="notranslate"><code class="notranslate">Python 3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:24:40) [GCC 10.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import sys, numpy
&gt;&gt;&gt; print(numpy.__version__); print(sys.version)
1.24.0
3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:24:40) [GCC 10.4.0]
&gt;&gt; print(numpy.show_runtime())
[{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
                      'found': ['SSSE3',
                                'SSE41',
                                'POPCNT',
                                'SSE42',
                                'AVX',
                                'F16C',
                                'FMA3',
                                'AVX2'],
                      'not_found': ['AVX512F',
                                    'AVX512CD',
                                    'AVX512_KNL',
                                    'AVX512_KNM',
                                    'AVX512_SKX',
                                    'AVX512_CLX',
                                    'AVX512_CNL',
                                    'AVX512_ICL']}},
 {'architecture': 'Haswell',
  'filepath': '/home/mlondschien/miniforge3/envs/numpy/lib/libopenblasp-r0.3.21.so',
  'internal_api': 'openblas',
  'num_threads': 8,
  'prefix': 'libopenblas',
  'threading_layer': 'pthreads',
  'user_api': 'blas',
  'version': '0.3.21'}]
None
</code></pre></div>
<p dir="auto">(Also after installing <code class="notranslate">threadpoolctl</code>)</p>
<h3 dir="auto">Context for the issue:</h3>
<p dir="auto">Reproducibility is extremely important for scientific research.</p>