Commit Graph

322 Commits

Author SHA1 Message Date
Joachim Le Fournis
bd5cdb0f65 [py] Support round on int 2020-11-23 12:12:46 +01:00
Gabriel Ozouf
7dcf1662b0 [python/helpers] Change interrupt check delay
Keyboard interruption used to be checked once every 20000 calls to
micropython_port_vm_hook_loop. However, if costly functions were
executed in between calls to this method, the delay for activating
interruptions would increase.
Now, keyboard interruption is checked after a fixed amount of time has
passed. This way, if the process waits a long time between two calls
to micropython_port_vm_hook_loop, it is still interrupted in a timely
manner.

Change-Id: I37ca3bd4a996fa086078f504340dd857526e356a
2020-08-31 15:32:02 +02:00
Gabriel Ozouf
34ebf1e6e0 [python/kandinsky] Remove additional interrupt
Additional checks for interruptions were making the kandinsky module
slower.
/!\ Some scripts are now very difficult to interrupt

Change-Id: I4c18273d8895deaac68084411a52556c8459d52b
2020-08-31 15:32:02 +02:00
Hugo Saint-Vignes
7eb694822d [python] Add magenta color
Change-Id: I7a5e12f6f3d79da802149a6aeef88387941ccdd8
2020-08-11 17:08:23 +02:00
Arthur Camouseigt
d7fb5c256c [turtle] Fixed remanent images bug
We now erase the turtle before writing text. This way we can redraw it
on top of it, preventing overlapping and remanent images.

Those scripts are causing issues :
goto(-30,50)
write('coucou')
left(270)
goto(30,50)
write('oui')
-----------
up()
goto(-30,50)
write('coucou')
goto(30,50)
write('oui')

Change-Id: I01a6e5f8308937b5051165548c2046883da587d2
2020-06-10 10:35:13 +02:00
Léa Saviot
1ccb55a16e [apps/code] Fix script importation status
Scenario: Execute the script parabola.py, open the variable box, select
any leaf, enter, open the variable box again -> no variables are loaded
anymore
2020-06-09 15:12:13 +02:00
Émilie Feral
fc238f639a [python] Fix test on matplotlib 2020-06-04 14:50:10 +02:00
Émilie Feral
420dd04766 [apps/shared][python/port] CurveView::drawArrow uses pixel computation
instead of float computation to avoid precision errors, by default the
arrow size is decided in pixels.
2020-06-04 14:50:10 +02:00
Arthur Camouseigt
4b20c69174 [python/modturtle.cpp] Added support for float parameter in colormode()
The function can now accept the value 1.0 in addition to 1

Change-Id: I9a7021076844784ca997fc618253524089cbe855
(cherry picked from commit c69e1542ecc9a7e474a3f1e92cc97f644bf4b701)
2020-06-04 14:50:10 +02:00
Émilie Feral
1b2750c247 [python] matplotlib: add assertions to ensure authorized access to
args[i]
2020-06-04 14:50:10 +02:00
Arthur Camouseigt
aec25eb8d4 [matplotlib/modpyplot.cpp] Modified the error messages due to too many arguments
Change-Id: I48a8283a0c6311a52df152cbce3b0c824b46454b
(cherry picked from commit 94b90533c751c10dadb8e6144e613ed4839f09c4)
2020-06-04 14:50:10 +02:00
Arthur Camouseigt
e1a356fe88 [matplotlib/modpyplot.cpp] Added support for third parameter color in plot function
It is now possible to specify the color of the plot through a third positional argument in the plot function. However, is a keyword (color or c) is then used, it will override the previous color command.

Change-Id: I5a73ddb322e650db486de568e4a56b4752751cfb
(cherry picked from commit e6cc196cca405e5a4f8058a6af917aa0e7962b8a)
2020-06-04 14:50:10 +02:00
Arthur Camouseigt
4b88521e14 [matplotlib/modpyplot.cpp] Removing c keyword from some functions to match pyplot spec
Change-Id: I53fa8c9edc8bcfdfb9c36797b41a1c36494e2c74
(cherry picked from commit 42b245ed97d6fa3394316888489660f4f76f0a78)
2020-06-04 14:50:10 +02:00
Arthur Camouseigt
06dc97152c [matplotlib/modpyplot.cpp] Added support for keyword argument c, a shortcut for color
Change-Id: I89227a73fca6fd50ae190107fc23c3c7acadc6db
(cherry picked from commit bc642c2d8d105ed609cf8b4d86800879645afd7e)
2020-06-04 14:50:10 +02:00
Arthur Camouseigt
d6e32594b8 [test/matplotlib.cpp][modpyplot.cpp] Changed matplotlib tests
Modified the tests for pyplot module and added error raisers to module functions

Change-Id: I164feafaf562f16d646841c1f9dfbbe32e6a763b
2020-06-04 14:50:10 +02:00
Arthur Camouseigt
68e3208799 [matplotlib/modpyplot.cpp] Removed function previously used for setting colors
Change-Id: I76bb489d5a5b78162873f68c5e3cca8cebb77aba
2020-06-04 14:50:10 +02:00
Arthur Camouseigt
c39b432dd6 [matplotlib/modpyplot.cpp] Adding keyword arguments support for plot function
plot function can now take into account the following keywords arguments :
- color

Change-Id: I29b82ba25fa68ec4d8e1797112f133440dee22a0
2020-06-04 14:50:10 +02:00
Arthur Camouseigt
b26d448573 [matplotlib/modpyplot.cpp] Adding keyword arguments support for scatter function
scatter function can now take into account the following keywords arguments :
- color

Change-Id: Iaea5a7a46d25e3efe2214368334ce859900d6ae6
2020-06-04 14:50:10 +02:00
Arthur Camouseigt
5daaa2c050 [matplotlib/modpyplot.cpp] Adding keyword arguments support for hist function
hist function can now take into account the following keyword arguments :
- color

Change-Id: I69eca6555d892db958d2bd002f438a40908b2d9d
2020-06-04 14:50:10 +02:00
Arthur Camouseigt
0e3684e137 [matplotlib/modpyplot.cpp] Adding keyword arguments support for bar function
bar function can now take into account the following keywords arguments :
- color

Change-Id: Iefa68cff59986d89c37cfecd7e3750f03c33ca59
2020-06-04 14:50:09 +02:00
Arthur Camouseigt
41da4f2bd5 [matplotlib/modpyplot] Adding keyword argument support for arrow function
Arrow function can now take into account the following keywords arguements :
- head_width
- color

Change-Id: I205dcd5776d53a4efcbf1e6da4edf29d8e399cab
2020-06-04 14:50:09 +02:00
Arthur Camouseigt
985c31920d [matplotlib/plot_store.cpp] Removed useless function
checkFloatType function used to check for an obj type before cast. This is already done by mp_obj_get_float

Change-Id: I745bb3066328678ab0b2a2149c8f38a84f26fbd2
2020-06-04 14:50:09 +02:00
Arthur Camouseigt
68ff71f72a [matplotlib/modpyplot.cpp] Modified the way to add mp_float
To prevent crashes caused by failed casts from char to float, removed optimization.

Change-Id: Ia91aafa007538b6c05f7aace5e5962989d313c98
2020-06-04 14:50:09 +02:00
Arthur
59bf8bbcf4 [matplotlib] Added cyan color to the color palette
Change-Id: I29476d8148ad98285505adc460b90628573518fa
2020-06-04 14:50:09 +02:00
Arthur
fe7c4b1a8a [python/turtle] Added write method
Allows user to print strings with the turtle

Change-Id: I06a3832f6fa36d29506be10c48a1b2fb34cb69fb
2020-06-04 14:50:09 +02:00
Arthur
7cd0b7e0e0 [matplotlib] Removed useless initializers in PlotStore constructor
Change-Id: Idea0ce07cbc800139539f9d3fb27811920645184
2020-06-04 14:50:09 +02:00
Arthur
13d0bcf676 [matplotlib] Modified isEmpty method for showing axis
Added a condition for being considered empty.
Allows axis("on") or axis((0,1,2,3)) to display something with show()
This behavior is the same as the python module

Change-Id: If5f3b07c280ee9ead2bc23d23cbbb4f01da7eae5
2020-06-04 14:50:09 +02:00
Émilie Feral
d8666a52d3 [python] matplotlib: fix tests about arrow function 2020-06-04 14:50:09 +02:00
Émilie Feral
0c9fb57b33 [python] matplotlib: check float type of the head_width arg of arrow function 2020-06-04 14:50:09 +02:00
Émilie Feral
9b7c47a7f0 [python] matplotlib: arrow can have up to 6 args 2020-06-04 14:50:09 +02:00
Émilie Feral
083f959b7b [python] matplotlib: Enable to change the arrow shape via the head_width
arg
2020-06-04 14:50:09 +02:00
Émilie Feral
0f8f82b94b [python] matplotlib: Add a parameter to to arrow to set the arrow width 2020-06-04 14:50:09 +02:00
Émilie Feral
e2c06cbb44 [python] matplotlib: add color argument to plot, scatter, hist, bar and
arrow
2020-06-04 14:50:08 +02:00
Émilie Feral
a22990943b [python] matplotlib: missing static keyword 2020-06-04 14:50:08 +02:00
Émilie Feral
273d10dc26 [python] Change names: ColorParse::ParseColor --> Color::Parse 2020-06-04 14:50:08 +02:00
Émilie Feral
ab69c0069c [python] Fix alignement issues in MicroPython::collectRootsAtAddress 2020-06-04 14:50:08 +02:00
Léa Saviot
d1c8bbdaf7 [apps/code] The console marks imported script for the var box
After lauching the console, if we fetch a script we mark it as fetched.
When the variable box displays variables from imported scripts, it scans
all the variables from the scripts marked as fetched.
2020-06-04 14:50:06 +02:00
Émilie Feral
7f3f67aba0 [python] Clean type confusion 2020-05-18 14:39:46 +02:00
Émilie Feral
4e1f7c1cb8 [python] Fix comment 2020-05-18 14:39:46 +02:00
Émilie Feral
3f6647f3ae [ion][python] Implement an architecture-dependant collect_registers.
setjmp is not guaranteed to collect all registers without modification
on all platforms.

This fixes the following bug: when the pointer of a newly allocated
object on the Python heap is stored in rpb registers on x86_64 arch, it
was not collected by the garbarge collector.
2020-05-18 14:39:46 +02:00
Émilie Feral
5a32006dcd [python] Revert: collectRoots does not need to look for unaligned
pointers as they should not exist
2020-05-18 14:39:46 +02:00
Émilie Feral
3f5487ca90 [python] Forbid inlining on gc_collect to avoid missing some roots 2020-05-18 14:39:46 +02:00
Émilie Feral
9b419acf40 [python] kandinsky port: rename TupleForRGB to TupleForKDColor 2020-04-30 14:12:32 +02:00
Émilie Feral
4bca330f0d [python] Coding style 2020-04-30 14:12:32 +02:00
Émilie Feral
0811221943 [python] Clean port ColorParser 2020-04-30 14:12:32 +02:00
Émilie Feral
7c24f2fc28 [python] Coding style 2020-04-30 14:12:32 +02:00
Émilie Feral
ba15415847 [python] modturtle: avoid unexpected cast 2020-04-30 14:12:32 +02:00
Émilie Feral
686a1493e5 [python] Coding style 2020-04-30 14:12:32 +02:00
Émilie Feral
e7df25d558 [python] Kandinsky module: color accepts "#FF0000", "red" kinds of
arguments
2020-04-30 14:12:32 +02:00
Émilie Feral
af0cdbcc1b Coding style 2020-04-30 14:12:32 +02:00