Arête: How to be your best self and be happy!

In the life-long search for eudaimonia (happiness) the Stoic tell us to focus on three aspects of ourselves:

  • what we think (thought),
  • how we react (feeling) and
  • how we act (behaviour).

Arête: How to be your best self and be happy!

Monday, Mar 25, 2019, 7:00 PM

The Waterman
32 Chesterton Rd Cambridge, GB

13 Members Went

In the life-long search for eudaimonia (happiness) the Stoic tell us to focus on three aspects of ourselves: • what we think (thought), • how we react (feeling) and • how we act (behaviour) In this meeting, I want to discuss with you, how can we act. in this case, the Stoics will refer to the concept of arête! In English, this is commonly transl…

Check out this Meetup →

In this meeting, I want to discuss with you, how can we act.

in this case, the Stoics will refer to the concept of Arete! In English, this is commonly translate as virtue. However, a better translation would be “excellence of character”, implying that we have to be better version of ourselves.

In particular they would focus on four cardinal virtues:

  • Courage of facing reality
  • Justice or fairness
  • Temperance or self-control
  • Practical wisdom

In our meeting we will discuss how can be better version of ourselves and how by being virtuous we can be happy and more satisfied with our life.

Recommended books:

Videos:


The stoic fellowship:

https://stoicfellowship.com/stoicism-resources.html

As always feel free to bring notes or topic you want to discuss!

Testing in R

To test a given function in R, I use the package ‘testthat’.

A very nice intro to the package is present here: https://journal.r-project.org/archive/2011/RJ-2011-002/RJ-2011-002.pdf

However, in order to write good quality code and to do it only once, you got to carry out a paradigm shift in your writing procedure:

How to write a tests-oriented program

You might have the natural tendency to write the tests after your code.

However, this is not the best approach, indeed, after that, you might need to rewrite big part of the code, to make it more ‘testable’.

In order to avoid that, you need to write your test before the program.

Certainly, this is is a bit harder to implement, especially the first times.

Therefore, to make it easier, follow these guidelines:

Guidelines

  • Independent files:
    • One for the program, one for the tests
  • Code stile for the program:
    • Atomicity:
      • A single R file for each task/objective.
      • Single functions for each step of your algorithm. This will help later in the test
    • A main function to be invoked. This will list all the functions (steps) of the program.
  • Tests, in and out:
    • Within the program file
      • Tests that define and check the inputs
      • Tests that define and check the outputs
    • Within the test file
      • A test with correct inputs
      • Wrong inputs
      • Exceptions
Continue reading “Testing in R”

4 of the best introductory videos on Stoicism

Stoicism can have a meaning impact on your life.

In order to have a better understanding of that, I have selected four of the best introductory videos that I could found.

Hopefully, they will intrigue you and make you dig more into it!

The philosophy of Stoicism – Massimo Pigliucci

A short historic overlook on the Stoics and the impact of this philosophy in society.

The Stoics & Why Stoicism matters

These couple of videos are produce from the brilliant channel “The school of Life”.

They dig a bit more on Stoic philosophy, explaining the main concepts and figures.  

A lecture on Marcus Aurelius

In here Professor Michael Sugrue give an amazing lesson on the figure of Emperor Marcus Aurelius. This video is a must-watch even if Stoic philosophy is not your main interest.

As somebody wrote in the comment section: It’s one of those videos that you didn’t realize you needed it, until you watched it”

If you have found other valuable videos and material please let me know in the comment of this post.

Best books on Stoicism

In this post, I want to list the best books on Stoicism, that I have encounter so far.

Besides the classic three Stoic authors that have come down to us (i.e. Epictetus, Seneca and Marcus), I have also listed the most influential contemporary authors that are contributing to bringing Stoicism back to the general public.

This is of course not an exhaustive list of all books out there, but I hope that this could help you to discover, internalize and practice a philosophy and school of life that can help you live a fulfilled life.

Modern Authors

Recently (in the last 20 years or so) , many philosophers and authors have rediscovered Stoicism as a way through life.

While ancient sources are the authorities to quote, a modern beginner interested in Stoicism should probably start with one of the most recent books on the topic.

These books are wrote in plain English, and they give a 360 degree explanation of the philosophy and its history. As such they offer an accessible introduction to the philosophy, and provide a good foundation from which to develop ones understanding.

A Guide to the Good Life

A guide to the good life: the ancient art of Stoic joy, by William B Irvine

Truly one of my favourite books on Stoicism. The author, William Irvine, explains how he discovered Stoicism, in the later part of his life despite being a university professor of philosophy, and how by applying it he managed to improve his life.

Not only does he give his take of Stoicism in a very beautiful style, but he also develops it forward, exploring new techniques and redefining the old ones. Truly beautiful, strongly suggested.

Stoicism and the Art of Happiness

Stoicism and the Art of Happiness: Practical wisdom for everyday life: embrace perseverance, strength and happiness with stoic philosophy (Teach Yourself: Philosophy & Religion) by Donald Robertson

Continue reading “Best books on Stoicism”

Tutorial on Luigi, part 3 pipeline: input() and output()

In the last article we saw some small example of a Luigi pipeline, in this article I want to explore how make the different Tasks to comunicate and pass information thus LocalTarget between them.

We already saw that we can use parameters to pass info from a Task to the next, and other nice way is to use the methods: input() and output().

The use of self.input()

Let’s see an example:

 
class PassPlotNameTask(luigi.Task):
    name      = luigi.Parameter(default= "simple_plot.png")
    directory = luigi.Parameter(default="{}/{}".format(os.getcwd(), 'folder'))

    def requires(self):
        return CreatePlotTask(name=self.name,
                              directory=self.directory)

    def output(self):
        return luigi.LocalTarget(self.name)

    
class CreatePlotTask(luigi.Task):
    name      = luigi.Parameter()
    directory = luigi.Parameter()

    def run(self):
        x = range(1, 10, 1)
        y = [i ** 2 for i in x]

        fig = plt.figure()
        ax = plt.subplot(111)

        ax.plot(x, y)
        # Here we replace os.getcwd() with self.input().path
        return fig.savefig("{}/{}".format(self.input().path,
                                          self.name)) 

    def output(self):
        return luigi.LocalTarget(self.name)

    def requires(self):
        return MakeDirectory(directory=self.directory)

    
class MakeDirectory(luigi.Task):
    directory = luigi.Parameter()
    def output(self):
        return luigi.LocalTarget(self.directory)
    def run(self):
        os.mkdir(self.directory)

The value for self.input() comes from the result of the method output() inside the Task called by requires() in this case it would be the method MakeDirectory().

Continue reading “Tutorial on Luigi, part 3 pipeline: input() and output()”

Tutorial on Luigi pipeline, part 2: Examples

After the introduction of the previous post, let’s now see an example that I code to better teach myself the use of Luigi’s pipeline.

A Task in Luigi

Here follows a simple Luigi Task:

# Let's import what we need:
import os
import luigi
import matplotlib.pyplot as plt

# The Task:
class CreatePlotTask(luigi.Task):
    # A parameters is equivalent to create a constructor for each Task.
    # We can intend it as declaring a 'variable' for our script.
    # I believe to be good practice to list the parameters before their use.
    # However, in this case it is not necessary.
    name = luigi.Parameter(default= "simple_plot.png") 

    def run(self):
        x = range(1, 10, 1)
        y = [i ** 2 for i in x]

        fig = plt.figure()
        ax = plt.subplot(111)
        ax.plot(x, y)

        return fig.savefig("{}/{}".format(os.getcwd(), self.name))
    
    def output(self):
        return luigi.LocalTarget(self.name) 
Continue reading “Tutorial on Luigi pipeline, part 2: Examples”

Tutorial on Luigi pipeline, part 1: Introduction

From the documentation page of Luigi (https://luigi.readthedocs.io/en/stable/index.html) I can summarise:

Luigi is a pipeline library designed completely in Python by Spotify to solve all pipeline problem associate with long-running batch process.

Structure

The structure of a pipeline in Luigi resamble that of graph, with nodes and edges connecting the nodes.

The “nodes” are called Task and the metodo def requires() provide the connection among the nodes.

If in a pipeline, I would consider to execute the tasks one-after-the-other untill the end, e.g.:

Start -> Task A -> Task B -> Task C -> End.

Continue reading “Tutorial on Luigi pipeline, part 1: Introduction”

How to use yield in Python

Notes on the yield statement in Python

From the Python documentation we can read that:

  1. What it is: The yield statement is used when defining a generator within the body of a generator function. Thus, if you use a yield statement in a function, this creates a generator function instead of a normal function.
  2.  What it does: When a yield statement is executed, the state of the generator is frozen and the value of expression_list is returned to next()’s caller.
  3. How to use it: When a generator function is called, it returns an iterator known as a generator iterator, or simply, a generator. The body of the generator function is executed by calling the generator’s next() method repeatedly until it raises an exception.
Continue reading “How to use yield in Python”

Second Cambridge Stoics meet-up

What is the promise of Stoic philosophy?

Tuesday, Feb 19, 2019, 7:00 PM

The Waterman
32 Chesterton Rd Cambridge, GB

18 Members Went

Since antiquity, all philosophers have tried to answer the fundamental questions, providing what they consider to be the true “truth of existence”. Despite that, a question is left: What kind of advantages can the study of philosophy bring to me? especially in my daily life? Can I turn knowledge into power? The philosopher Epictetus, promises us, t…

Check out this Meetup →

Since antiquity, all philosophers have tried to answer the fundamental questions, providing what they consider to be the true “truth of existence”.

Despite that, a question is left:
What kind of advantages can the study of philosophy bring to me? especially in my daily life? Can I turn knowledge into power?

The philosopher Epictetus, promises us, that the study of Stoicism can deliver us practical and useful tools, that we can apply in our life, to reach what the Greeks called eudaimonia, in English happiness (or serenity of the spirit).

In this new meeting we are going to discuss these tools and how can we reach the ultimate goal of Stoic philosophy: Happiness!.

Come fare un grafico a barre con ggplot2

Il pacchetto ggplot2 è una delle risorse più potenti per la creazione di grafici in R.

Anche se, ggplot2 ha una curva di apprendimento piuttosto alta che potrebbe scoraggiare chi inizia a usarlo, ma credetemi ne vale sicuramente la pena.

Qui voglio mostrare un paio di esempi dei grafici a barre:

 
# Per questi grafici abbiamo le informazioni relative a un database di topi immunizzati con due diversi antigeni OVA e CFA, 
# e sono riportati i tempi  dopo la vaccinazione. 
# Il gruppo di controllo ha il tempo zero perché quelli non sono stati immunizzati.

library(ggplot2) time_days=c(0,0,0,0,0,0,0,0,0,5,5,5,5,5,5,7,7,7,7,7,14,14,14,14,14,14,60,60,60,60,60,60,60,60,60,60,60)
antigens=c('Control','Control','Control','Control','Control','Control','Control','Control','Control','OVA','OVA','OVA','CFA','CFA','CFA','OVA','OVA','OVA','CFA','CFA','OVA','OVA','OVA','CFA','CFA','CFA','OVA','OVA','OVA','CFA','CFA','CFA','OVA','OVA','OVA','CFA','CFA') 
db <- data.frame(time_days,antigens) # Il database come data.framse 
ggplot2::qplot( data = db, factor(time_days), fill = factor(time_days), geom = "bar" )+
 ggplot2::theme_classic()+
 ggplot2::scale_fill_discrete(name='Time in days') +
 ggplot2::ggtitle('Group of mice per date of sacrifice') + 
 ggplot2::xlab('Time in days') +
ggplot2::ylab('Number of mice') 


Con il seguente risultato:

Con questa trama vediamo il numero di topi e il tempo in cui sono stati sacrificati.

Ora se vogliamo vedere sia il numero di topi che gli antigeni usati potremmo fare il seguente:

 
ggplot2::qplot( data=db, geom="bar", factor(time_days), fill=factor(antigens) ) +
 ggplot2::theme_classic() +
 ggplot2::ggtitle('Group of mice per date of sacrifice and antigens')+
 ggplot2::scale_fill_discrete(name='Antigens') +
 ggplot2::xlab('Time in days') +
 ggplot2::ylab('Amount') 

Con il seguente risultato: