Comments (9)
or use .encode()
and .decode()
, usually works with both py2 and py3.
from blimpy.
So in case of Python2 you want a non unicode string and for python3 you want a bytes? use .encode()
.
$ python2
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> s = 'bla'
>>> b = b'bla'
>>> s.encode()
'bla'
>>> s.decode()
u'bla'
>>> b.decode()
u'bla'
>>> b.encode()
'bla'
Python 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> b = b'bla'
>>> s = 'bla'
>>> b.decode()
'bla'
>>> s.encode()
b'bla'
node that you can't encode a string and decode a bytes with python3.
from blimpy.
would be great if we can use unicode for all if possible.
we could use .encode('utf-8') instead of 'ascii'
although I guess .fil files only support ascii?
from blimpy.
I'm ambivalent, but found previously it was easier to force to bytestrings, as these are more similar between Py2 and Py3. In blimpy
, we've already forced quite a few things to be bytestrings, so it's probably much more effort to change everything to UTF-8.
Having said that, it would look cleaner if keywords were header['hello']
instead of header[b'hello']
, so I won't stop anyone from embarking on a holy crusade against bytestrings should they desire.
from blimpy.
from blimpy.
it is going to be slightly to massively messy in all cases unless you drop python2 support.
Just my €0.02
from blimpy.
from blimpy.
I'm pretty serious about recompiling Julia to be zero-indexed and rebadging it as Python 4.
from blimpy.
Occurences of Python encoding, 100% ASCII and only in io/sigproc.py, for better or worse:
./io/sigproc.py: return np.int32(len(keyword)).tobytes() + keyword.encode('ascii')
./io/sigproc.py: value = value.encode('ascii')
./io/sigproc.py: return np.int32(len(keyword)).tobytes() + keyword.encode('ascii') + np.int32(len(value)).tobytes() + value
./io/sigproc.py: return np.int32(len(keyword)).tobytes() + keyword.encode('ascii') + value_dtype(value).tobytes()
@david-macmahon "I think the important thing is that blimpy stays self-consistent internally."
It is. Let's leave it at that.
from blimpy.
Related Issues (20)
- Try to remove HDF5 files that cannot be fully written due to an exception
- Inadvertently, testing is using the previous release
- Utility stax has time-axis issues
- Emit more useful write-blob messages - Filterbank and HDF5
- GuppyFile.get_data() raises StopIteration HOT 3
- Need a tool for patching the header source_name in an HDF5 file
- Support FBH5 version 2.0 reporting HOT 1
- fil2h5, h52fil, dice, and bl_scrunch can mangle the output file name
- Enhance rawhdr to focus on critical header fields for rawspec
- guppi.py assumes that numbers without periods are integers
- examine_h5 in hdf_reader.py is loading too much data
- Plotting fails plt.show() and this should work for X-terminals HOT 3
- Waterfall from existing data array + header dict combo currently broken (`setup_freqs()` missing) HOT 7
- Typo in `waterfall.py` HOT 2
- Introduce Filterbank file downsampling capability
- Need to initialise more container fields for the data_array + header case for Waterfall
- Enhance dsamp to output SIGPROC (.fil) files as well as .h5 files
- Add detailed testing to streaming Waterfall objects
- bl_scrunch never really worked correctly! )-:
- hdf5plugin.Bitshuffle's lz4 argument is deprecated, use cname='lz4' or 'none' instead
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blimpy.