• Drizzel

    I assume you’re in the console right now. First of all, there’s a small arrow in the top left corner, or you can alternatively swipe left and/ or right to switch between console and code. Oh, and as long as you’re asking something related to pythonista, there’s no stupid questions, just stupid answers.

    posted in Pythonista read more
  • Drizzel

    import numpy as np
    import sys
    import motion
    import matplotlib.pyplot as plt
    from time import sleep
    import console
    g=0;
    ag=0;
    data=0;
    data_ag=0;
    
    del g
    del ag
    del data
    del data_ag
    fs=100;
    duration=5;
    def main():
        console.alert('Motion Plot', 'When you tap Continue, accelerometer (motion) data will be recorded for 5 seconds.', 'Continue')
        motion.start_updates()
        sleep(0.2)
        print('Capturing motion data...')
        num_samples = fs*duration;
        data = []
        data_ag = []
        for i in range(num_samples):
            sleep(1/fs)
            ag=motion.get_user_acceleration();
            g = motion.get_gravity();
            #a=motion.get_gravity()
            #motion.get_attitude()
            #motion.get_magnetic_field()
            data.append(g);
            data_ag.append(ag);
        
        motion.stop_updates()
        print('Capture finished, plotting...')
        
        x_values = [x/fs for x in range(num_samples)]
        for i, color, label in zip(range(3), 'rgb', 'XYZ'):
            plt.plot(x_values, [g[i] for g in data], color, label=label, lw=2)
            szg=sys.getsizeof(g)
        print(szg)
        print(g)
        print(ag)
        print(type(data[1]))
        plt.grid(True)
        plt.xlabel('t')
        plt.ylabel('G')
        plt.gca().set_ylim([-1.0, 1.0])
        plt.legend()
        plt.show()
    
    
    main()
    

    posted in Pythonista read more
  • Drizzel

    your dataset (the variable data) is an array

    data = []
    

    that contains tuples, which is the variable g.

    data = [()]
    

    This tuple then contains 3 variables.

    data = [(5.67, 1.87, 3.93)]
    

    Running this code:

    for g in data:
        print(g)
    

    will print every tuple in the data array, which is (5.67, 1.87, 3.93).
    If you want to print a single float (the name for a number with decimal places), just use this:

    print(g[0])
    

    Replace the 0 with a 1 to print the second float in g, and 2 for the third float in g

    posted in Pythonista read more
  • Drizzel

    Whenever I try to run this basic script, I get the Error [Errno 1] Operation not permitted. It’s some example code of the pylatex module, so it should theoretically work. Or is it IOS that blocks some functions?

    #!/usr/bin/python
    """
    This example shows basic document generation functionality.
    
    ..  :copyright: (c) 2014 by Jelte Fennema.
        :license: MIT, see License for more details.
    """
    
    # begin-doc-include
    from pylatex import Document, Section, Subsection, Command
    from pylatex.utils import italic, NoEscape
    
    
    def fill_document(doc):
        """Add a section, a subsection and some text to the document.
    
        :param doc: the document
        :type doc: :class:`pylatex.document.Document` instance
        """
        with doc.create(Section('A section')):
            doc.append('Some regular text and some ')
            doc.append(italic('italic text. '))
    
            with doc.create(Subsection('A subsection')):
                doc.append('Also some crazy characters: $&#{}')
    
    
    if __name__ == '__main__':
        # Basic document
        doc = Document('basic')
        fill_document(doc)
    
        doc.generate_pdf(clean_tex=False)
        doc.generate_tex()
    
        # Document with `\maketitle` command activated
        doc = Document()
    
        doc.preamble.append(Command('title', 'Awesome Title'))
        doc.preamble.append(Command('author', 'Anonymous author'))
        doc.preamble.append(Command('date', NoEscape(r'\today')))
        doc.append(NoEscape(r'\maketitle'))
    
        fill_document(doc)
    
        doc.generate_pdf('basic_maketitle', clean_tex=False)
    
        # Add stuff to the document
        with doc.create(Section('A second section')):
            doc.append('Some text.')
    
        doc.generate_pdf('basic_maketitle2', clean_tex=False)
        tex = doc.dumps()  # The document as string in LaTeX syntax
    

    posted in Pythonista read more
  • Drizzel

    @BrianAz look at this. This module allows you to create shortcuts for the shortcuts app in pythonista, which is compatible with siri

    posted in General Discussion read more
  • Drizzel

    Sorry for the late reply, your answer was exactly what I needed. I tried things like self.close() and self.hide(), but I just didn’t get to the self.view.close()

    posted in Pythonista read more
  • Drizzel

    @donaldcassey yes it should work with soundcloud. I didn’t test it, but the module contains a file for extracting data from soundcloud. If you want to use this, just copy the code into a new directory and create a file called ‘songs.txt’ . Then paste every link into a new line in the text file. The code does not work if the file contains empty lines, but you can fix that with by replacing

    dl.download([song_url]) 
    

    with

    if not “\n” in song_url: dl.download([song_url])
    

    posted in Pythonista read more
  • Drizzel

    I don’t want to bore you with a ton of details, so long story short: how do I close a game that has been coded with the scene module? I don’t want to tap the little close button in the top right corner.

    posted in Pythonista read more
  • Drizzel

    @cvp wow, that’s interesting. How do you add another Button to the toolbar?

    posted in Pythonista read more
  • Drizzel

    @JonB Great, i will definitely look into them. For others who might want to know, one interesting module I found is NEAT

    posted in General Discussion read more

Internal error.

Oops! Looks like something went wrong!