Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

all the trials of a block in a loop

In my experiment, I have only one block which has 5 stimuli and I wanted to add those stimuli to the block using a loop as below:

    criteria=["ê", "ù", "û", "ü" ]

    exp = expyriment.design.Experiment(name="fontic task")
    expyriment.control.initialize(exp)

    for trials in range(0, np.shape(criteria)[0]):
        block_one = expyriment.design.Block(name="activation")
        var="trial"+str(trials)
        var = expyriment.design.Trial()
        stim = expyriment.stimuli.TextLine(text=criteria[trials])
        stim.preload()
        var.add_stimulus(stim)
        block_one.add_trial(var)
        exp.add_block(block_one)

    expyriment.control.start()

    for block in exp.blocks:
        for trial in block.trials:
            trial.stimuli[0].present()
            exp.clock.wait(1000)

    expyriment.control.end()

But I could see a strange error. I don't have any idea what this error means: I even started the code with "# -- coding: utf-8 --" but still the problem is there. here is the error

     log_txt = u"{0},{1}".format(log_txt, log_comment)
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

Any comment is appreciated in advance .

Comments

  • Dear Juliette,

    does your editor with which you write the code also encode with UTF-8? If not, you need to set the encoding header to the encoding your editor uses.

    The error might, however, also be related to a bug in Expyriment (which will be fixed in version 0.9.0, probably released tomorrow).

  • Dear Florian,

    Thank you for your reply. At top of the editor I have these few lines:

        # -*- coding: utf-8 -*-
        """
        Created on Thu Feb  9 19:33:37 2017
    
        @author: Julliette
                  """
    

    up to my knowledge, these few lines is encoding the header. Am I right?

  • edited March 2017

    .

  • Yes, they are, they tell any programme that opens the file that the method to put the characters into the file was via UTF-8, so those programmes know how to read the file. But that also means that if the method is different from what you write in the file, then this will of course not work. Hence I wanted to check whether you are sure that your editor really encodes in UTF-8, but I assume you looked that up before you put the line into the file.

  • edited March 2017

    I even tried to put the data into an excel file and decode it:

        import pandas as np
        criteria = pd.read_excel(file, encoding='utf-16')
    

    but still the same error can be seen. I will wait for new version of expyriment tomorrow.

  • If you send me your script, then I can try to debug it here on my machine if you want to.

  • edited March 2017

    Hi Florian,

    That's very nice of you. here is the full script:

        # -*- coding: utf-8 -*-
        """
        Created on Thu Feb  9 19:33:37 2017
    
        @author: Julliette
        """
    
    
        import pandas as pd
        import expyriment
        import numpy as np
        from expyriment import  misc, stimuli, design
        from expyriment.misc import constants
        from expyriment.misc._timer import get_time
    
    
        criteria=["ê", "ù", "û", "ü" ]
    
        exp = expyriment.design.Experiment(name="fontic task")
        expyriment.control.initialize(exp)
    
        for trials in range(0, np.shape(criteria)[0]):
                block_one = expyriment.design.Block(name="activation")
                var="trial"+str(trials)
                var = expyriment.design.Trial()
                stim = expyriment.stimuli.TextLine(text=criteria[trials])
                stim.preload()
                var.add_stimulus(stim)
                block_one.add_trial(var)
                exp.add_block(block_one)
    
        expyriment.control.start()
    
        for block in exp.blocks:
          for trial in block.trials:
           trial.stimuli[0].present()
           exp.clock.wait(3000)
    
        expyriment.control.end()
    

    Thanks a lot in advance

  • I just checked it, and it will work with the new version. I will release it tomorrow.

  • Hi Florian,

    Thank you for the new version of the Expyriment V. 9.0.
    I installed the new expyriment-0.9.0.tar.gz on my ubuntu but still the same error is there. Do the new version only fix the decoding on windows and not Linux?

  • edited March 2017

    Hi Juliette,

    the new version fixes the problem on all OS.

    Important: Please do NOT install Expyriment from the source (expyriment-0.9.0.tar.gz)! Always install Expyriment as described in the installation instructions: http://docs.expyriment.org/Installation.html.

    If, after correct installation, the problem persists, then the characters have been put into the file with a different encoding than UTF-8. Which editor are you using to create the files?

    The code you pasted here in the forum worked for me, when copying and pasting into a new file. But I also know that my editor encodes in UTF-8 (actually, all editors on Linux should be doing this, except maybe IDLE or so).

  • Actually, if you see this exact error (from above):

    log_txt = u"{0},{1}".format(log_txt, log_comment)
        UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)
    

    Then it seems that you are not using the latest version of Expyriment (0.9.0), as the line in question has been changed to read:

    log_txt = u"{0},{1}".format(log_txt, byte2unicode(log_comment))
    

    (note the byte2unicode part)

    Hence, the new version of Expyriment cannot have created this error message.

  • Hi Florian,

    Thank you for your message. You are very right! I reinstalled expyriment using the page that you mentioned and the problem is solved :)

    Thank you very much

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games