can't open tempfile when using memmap array

Bug #1918036 reported by Shiki TAKEUCHI
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
swan
Fix Committed
Undecided
Unassigned

Bug Description

When I try to input a big array, I get this err.

```
Using memory-mapped arrays...
Traceback (most recent call last):
.......
  File "/ENVPATH/lib/python3.8/site-packages/swan/pycwt.py", line 234, in cwt_f
    return cwt_a(signal, scales, dt, wavelet, ppd, verbose=verbose)
  File "/ENVPATH/lib/python3.8/site-packages/swan/pycwt.py", line 219, in cwt_a
    W = memsafe_arr((len(scales), siglen), 'complex')
  File "/ENVPATH/lib/python3.8/site-packages/swan/pycwt.py", line 34, in memsafe_arr
    return np.memmap(_tmpfile, dtype=dtype, shape=shape)
  File "/ENVPATH/lib/python3.8/site-packages/numpy/core/memmap.py", line 251, in __new__
    fid.write(b'\0')
TypeError: write() argument must be str, not bytes
```
(I am using Python 3.8.6)

This error is caused by line 33 in 'swan/pycwt.py' and to fix this,

- _tmpfile = tmpf.TemporaryFile('w+')
+ _tmpfile = tmpf.TemporaryFile('wb+')

Please consider merge it.

Revision history for this message
A Brazhe (brazhe) wrote :

Thank you for pointing this out, merged.

Changed in swan:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.