It will have something to do with how IO is handled in Python 3. A print statement before this error will show this. We may need to detect the type that self.data is - in Python 2 and 3 it will probably be a string and byte-array respectively - and then convert to the correct type. It might be a relax problem. Though that depends on what self.data is. If it was created by nmrglue, then the problem might be with nmrglue. In any case, in data_store/nmrglue.py we can test for the type and convert to the correct format for b64encode() to work around the issue. An example already in relax is in the version.py file:
# Decode Python 3 byte arrays. if hasattr(line, 'decode'): line = line.decode() And in the ./pipe_control/dasha.py file: # Encode to a Python 3 byte array. if hasattr(line, 'encode'): line = line.encode() One of these conversions will be relevant here. See the files for more details. Cheers, Edward On 15 January 2015 at 09:26, Troels Emtekær Linnet <tlin...@nmr-relax.com> wrote: > So this has nothing to do with nmrglue, I guess? > > But to the base64 module of python. > > Best > Troels > > 2015-01-14 19:13 GMT+01:00 Edward d Auvergne > <no-reply.invalid-addr...@gna.org>: >> >> Follow-up Comment #94, task #7873 (project relax): >> >> When I run the Nmrglue system tests in Python 2, they pass. However in >> Python >> 3 I see: >> >> $ python3 ./relax -s --time Nmrglue >> Echoing of user function calls has been enabled. >> >> >> ============================= >> = System / functional tests = >> ============================= >> >> . 0.00 s for Nmrglue.test_nmrglue_read >> . 0.00 s for Nmrglue.test_nmrglue_read_several >> . 0.16 s for Nmrglue.test_plot_contour >> . 0.10 s for Nmrglue.test_plot_contour_cpmg >> . 0.12 s for Nmrglue.test_plot_correlation >> . 2.90 s for Nmrglue.test_plot_hist_cpmg >> . 3.44 s for Nmrglue.test_plot_hist_cpmg_several >> E 0.00 s for Nmrglue.test_save_state >> . 0.00 s for Nmrglue.test_version >> >> ====================================================================== >> ERROR: test_save_state (test_suite.system_tests.nmrglue.Nmrglue) >> Test saving a state with numpy arrays, reset relax, and read the state >> again. >> ---------------------------------------------------------------------- >> >> relax> pipe.create(pipe_name='mf', pipe_type='mf', bundle=None) >> >> relax> spectrum.nmrglue_read(file='128_0_FT.ft2', >> >> dir='/data/relax/branches/nmrglue/test_suite/shared_data/dispersion/repeated_analysis/SOD1/cpmg_disp_sod1d90a_060518/cpmg_disp_sod1d90a_060518_normal.fid/ft2_data', >> nmrglue_id='test') >> Filesize of .ft2 file is: 527360 >> Type of encoding is: <class 'numpy.ndarray'> >> Storing numpy array to: /tmp/tmpl4p2zk/data.npy >> Filesize of .npy file is: 525392 >> Shape of data is 256x513 >> dtype of data is float32 >> Type of data[0][0]: <class 'numpy.float32'> >> >> relax> state.save(state='state', dir='/tmp/tmpl4p2zk', compress_type=1, >> force=True) >> Opening the file '/tmp/tmpl4p2zk/state.bz2' for writing. >> Traceback (most recent call last): >> File "/data/relax/branches/nmrglue/test_suite/system_tests/nmrglue.py", >> line >> 569, in test_save_state >> self.interpreter.state.save('state', dir=dirpath, compress_type=1, >> force=True) >> File "/data/relax/branches/nmrglue/prompt/uf_objects.py", line 225, in >> __call__ >> self._backend(*new_args, **uf_kargs) >> File "/data/relax/branches/nmrglue/pipe_control/state.py", line 128, in >> save_state >> ds.to_xml(file) >> File "/data/relax/branches/nmrglue/data_store/__init__.py", line 643, in >> to_xml >> self[pipe].to_xml(xmldoc, pipe_element, >> pipe_type=self[pipe].pipe_type) >> File "/data/relax/branches/nmrglue/data_store/pipe_container.py", line >> 335, >> in to_xml >> self.nmrglue.to_xml(doc, element) >> File "/data/relax/branches/nmrglue/data_store/data_classes.py", line >> 244, in >> to_xml >> self[key].to_xml(doc, dict_item_element) >> File "/data/relax/branches/nmrglue/data_store/nmrglue.py", line 138, in >> to_xml >> string = b64encode(self.data) >> File "/usr/lib64/python3.3/base64.py", line 58, in b64encode >> raise TypeError("expected bytes, not %s" % s.__class__.__name__) >> TypeError: expected bytes, not ndarray >> >> ---------------------------------------------------------------------- >> Ran 9 tests in 6.725s >> >> FAILED (errors=1) >> >> _______________________________________________________ >> >> Reply to this item at: >> >> <http://gna.org/task/?7873> >> >> _______________________________________________ >> Message sent via/by Gna! >> http://gna.org/ >> > _______________________________________________ relax (http://www.nmr-relax.com) This is the relax-devel mailing list relax-devel@gna.org To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-devel