mirror of
https://github.com/fverdugo/XM_40017.git
synced 2025-11-08 20:14:23 +01:00
Merge pull request #15 from Noorts/feature/improve_session2
Improve notebooks session 2
This commit is contained in:
commit
a5f1ac6e5a
@ -25,7 +25,7 @@
|
||||
"- Tasks\n",
|
||||
"- Channels\n",
|
||||
"\n",
|
||||
"Understanding these concepts is important to learn later distributed computing."
|
||||
"Understanding these concepts is important to learn distributed computing later."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -171,7 +171,7 @@
|
||||
"id": "d483d4d0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"How is this possible? Tasks run in the brackground and this particular task is sleeping for most of the time. Thus, it is possible to use the current Julia process for other operations while the tasks is sleeping."
|
||||
"How is this possible? Tasks run in the background and this particular task is sleeping for most of the time. Thus, it is possible to use the current Julia process for other operations while the task is sleeping."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -343,7 +343,7 @@
|
||||
"source": [
|
||||
"### Useful macro: `@async`\n",
|
||||
"\n",
|
||||
"So far, we have created tasks using low-level functions, but there are more convenient ways of creating and scheduling tasks. For instance using the `@async` macro. This macro is used to run a piece of code asynchronously. Under the hood it puts the code in an anonymous function, creates a task, and schedules it. For instance, the next cell is equivalent to previous one."
|
||||
"So far, we have created tasks using low-level functions, but there are more convenient ways of creating and scheduling tasks. For instance using the `@async` macro. This macro is used to run a piece of code asynchronously. Under the hood it puts the code in an anonymous function, creates a task, and schedules it. For instance, the next cell is equivalent to the previous one."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -388,7 +388,7 @@
|
||||
"\n",
|
||||
"### Sending data between tasks\n",
|
||||
"\n",
|
||||
"Julia provides channels as a way to send data between tasks. A channel is like a FIFO queue in which tasks can put and take values from. In next example, we create a channel and a task that puts five values into the channel. Finally, the task closes the channel."
|
||||
"Julia provides channels as a way to send data between tasks. A channel is like a FIFO queue which tasks can put values into and take values from. In the next example, we create a channel and a task that puts five values into the channel. Finally, the task closes the channel."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -490,7 +490,7 @@
|
||||
"source": [
|
||||
"### Calls to `put!` and `take!` are blocking\n",
|
||||
"\n",
|
||||
"Note that `put!` and `take!` are blocking operations. Calling `put!` blocks the tasks until another task calls `take!` and viceversa. Thus, we need at least 2 tasks for this to work. If we call `put!` and `take!` from the same task, it will result in a dead lock. We have added a print statement to previous example. Run it again and note how `put!` blocks until we call `take!`. "
|
||||
"Note that `put!` and `take!` are blocking operations. Calling `put!` blocks the tasks until another task calls `take!` and viceversa. Thus, we need at least 2 tasks for this to work. If we call `put!` and `take!` from the same task, it will result in a dead lock. We have added a print statement to the previous example. Run it again and note how `put!` blocks until we call `take!`. "
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -536,7 +536,7 @@
|
||||
"source": [
|
||||
"### Buffered channels\n",
|
||||
"\n",
|
||||
"We can be a bit more flexible and use a buffered channel. In this case, `put!` will block only if the channel is full and `take!` will block if the channel is empty. We repeat previous example, but with a buffered channel of size 2. Note that we can call `put!` until the channel is full. At this point, we need to wait to until we call `take!` which removes an item from the channel, making room for a new item."
|
||||
"We can be a bit more flexible and use a buffered channel. In this case, `put!` will block only if the channel is full and `take!` will block if the channel is empty. We repeat the previous example, but with a buffered channel of size 2. Note that we can call `put!` until the channel is full. At this point, we need to wait to until we call `take!` which removes an item from the channel, making room for a new item."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@ -43,9 +43,9 @@
|
||||
"<b>Tip:</b> Did you know that Jupyter stands for Julia, Python and R?\n",
|
||||
"</div>\n",
|
||||
"\n",
|
||||
"### How to start a Jupyter nootebook in Julia\n",
|
||||
"### How to start a Jupyter notebook in Julia\n",
|
||||
"\n",
|
||||
"To run a Julia Jupyther notebook, open a Julia REPL and type\n",
|
||||
"To run a Julia Jupyter notebook, open a Julia REPL and type\n",
|
||||
"\n",
|
||||
"```julia\n",
|
||||
"julia> ]\n",
|
||||
@ -449,7 +449,7 @@
|
||||
"source": [
|
||||
"\n",
|
||||
"<div class=\"alert alert-block alert-success\">\n",
|
||||
"<b>Question:</b> Which will be the value of `x` in the last line ? (Think your answer before executing next cell to find out the result) \n",
|
||||
"<b>Question:</b> What will be the value of `x` in the last line ? (Think your answer before executing next cell to find out the result) \n",
|
||||
"</div>\n",
|
||||
"\n"
|
||||
]
|
||||
@ -478,7 +478,7 @@
|
||||
"\n",
|
||||
"### Defining functions\n",
|
||||
"\n",
|
||||
"Functions are defined as shown in next cell. The closing `end` is necessary. Do to forget it! However, the `return` is optional. The value of last line is returned by default. Indentation is recommended, but it is also optional. That's why the closing `end` is needed."
|
||||
"Functions are defined as shown in next cell. The closing `end` is necessary. Do not forget it! However, the `return` is optional. The value of last line is returned by default. Indentation is recommended, but it is also optional. That's why the closing `end` is needed."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -538,7 +538,7 @@
|
||||
"id": "e4ca76a4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Mathematical operators can also be broadcasted (like in Matlab). The following cell won't work. If we want to multiply element by element, we can use the broadcasted version below."
|
||||
"Mathematical operators can also be broadcasted (like in Matlab). Multiplying the vectors `a * b` directly won't work. If we want to multiply element by element, we can use the broadcasted version below."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -557,7 +557,7 @@
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<div class=\"alert alert-block alert-success\">\n",
|
||||
"<b>Question:</b> Which will be the value of `x` in the last line ?\n",
|
||||
"<b>Question:</b> What will be the value of `x` in the last line ?\n",
|
||||
"</div>\n"
|
||||
]
|
||||
},
|
||||
@ -1300,7 +1300,7 @@
|
||||
"source": [
|
||||
"### Arrays of any element type\n",
|
||||
"\n",
|
||||
"Arrays of fixed element type seem to be very rigid, right? Python list have not this limitation. However, we can use arrays of `Any` type, which are as flexible as Python lists, or even more since they can also contain functions. "
|
||||
"Arrays of fixed element type seem to be very rigid, right? Python list do not this limitation. However, we can use arrays of the `Any` type, which are as flexible as Python lists, or even more since they can also contain functions. "
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user