Translate

lunes, 10 de octubre de 2016

Update all your mercurial repos at once

The following is a bash command to update repositories located in subdirectories from the current directory.

for hg_dir in $(find -maxdepth 2 -type d -name ".hg")
do
folder="$(dirname "$hg_dir")";
cd $folder && \
echo "Updating ${folder} ..." &&\
hg pull -u && \
cd -;
done

The use of  && makes sure that updates will be run only if the directory change takes place.
The same works with git. Just change ".hg" with ".git" and hg pull -u with git pull

lunes, 19 de septiembre de 2016

Inter-, extra- and intra- polation

Interpolation: the mathematical problem of interpolation is to find a function that goes exactly through the training points. It doesn't say anything on the inputs on which this function will be later evaluated. Of course, the solution provides a way of evaluating the function in unseen inputs, but it really is not about that, it is about "going through the given points".

Extrapolation: is about the relation between the new inputs where the function will be evaluated and the inputs used for training. It doesn't say anything about the relation between the function and the training inputs, as interpolation does: you can extrapolate using an interpolating function (i.e. that goes exactly through the training inputs) or an smoothing/approximating function (i.e. that goes close to the training inputs). Extrapolation means that the new inputs are "outside the region delimited by the examples we used for training (the observation range)", for example one could say that extrapolation is evaluating a learned function outside the convex-hull of the inputs used for training (this example applies only if the input set has a notion of "inside" and "outside", which is the case in many many situations). In many dimensions it could be difficult to define what is inside the observed region, and surely there are may ways fo doing it.

Intrapolation: is a term I coined (I am sure I am not the first! do you know if anybody used it first? or maybe another clever word to express the same idea?). As in extrapolation it is about the relation the new inputs have with the inputs used for training. It doesn't say anything about the function we are using, as interpolation does. You can either intrapolate with an interpolating function or with an smoothing/approximating function. Intrapolation means that the new inputs on which the function will be evaluated are within the observation range, following the previous example, they would be inside the convex-hull of the inputs used for training.



Hence, the complement of extrapolation would be intrapolation, whether we are using an interpolant or not. I think this makes the jargon cleaner!



Summary:
interpolation ≠ smoothing/approximation
intrapolation ≠ extrapolation

miércoles, 19 de agosto de 2015

Kivy - variable Label

Lately I have been working with Kivy to produce some simple Apps. One of the things I needed was a Label which text could be changed by double clicking on it. I came up with this derived class that merges Label, TextInput and Popup.

from kivy.app import App

from kivy.uix.label import Label
from kivy.uix.popup import Popup
from kivy.uix.textinput import TextInput

class variableLabel (Label):

    def __init__(self, text):
        super(variableLabel, self).__init__()
        self.text  = text

    def on_touch_down(self, touch):
        if touch.is_double_tap and self.collide_point(*touch.pos):
          _input = TextInput(text=self.text, multiline=False, auto_dismiss=False)
          popup = Popup(title='Editing Label text', content=_input)
          _input.bind (text=self.on_text)
          _input.bind (on_text_validate=popup.dismiss)
          popup.open()

    def on_text (self, instance, value):
        self.text = value

class MyApp(App):

    def build(self):
        return variableLabel("New")

if __name__ == '__main__':
    MyApp().run()

Do you have suggestions for improvement?

viernes, 16 de enero de 2015

BIN2FRAC

Binary numbers to fractions

The mapping from binary numbers to fractions described in this article can be written in GNU Octave as the function

bin2q = @(x) arrayfun (@str2num,x) (2.^-[1:length(x)].')

Giving the results that .0100... and .001111... map to 1/4

octave> bin2q ('0100000000000000000')
ans =  0.25000
octave> bin2q ('0011111111111111111')
ans =  0.25000

Números binarios a fracciones

El mapeo de números binario a fracciones, descriptoi en este artículo se puede definir como la siguiente función en GNU Octave

bin2q = @(x) arrayfun (@str2num,x) (2.^-[1:length(x)].')

Dando el resultado que .0100... y .001111... se mapean en 1/4

octave> bin2q ('0100000000000000000')
ans =  0.25000
octave> bin2q ('0011111111111111111')
ans =  0.25000

domingo, 14 de septiembre de 2014

Salteños visitarán Bélgica

Este post es derivado de este otro.



Muchas cosas han sucedido desde la última visita de Dwengo a Salta. Si están siguiendo la página de CErrobotics ya saben de los robots fabricados en Campo Quijano y las placas Dwengo fabricadas en la escuela técnica Albert Einstein de Salta. Quizas algunos también se hayan enterado de las actividades de Fundasoft en Córdoba, que ahora comineza con sus cursos en programación y lanza su propia versión de la placa Dwengo (hace un tiempo publiqué una reseña de la historía de Dwengo).

Los que nos mantiene ocupados el día de hoy es la organización de la semana Internacional de Robótica en Gante, Belgica (del 22 al 27 de Octubre, 2014). Con el dinero que logramos juntar con nuestra campaña en IndieGoGo (dato curioso: las únicas contribuciones argentinas son de gente que vive en el exterior ¿crisis económica o poca cultura de la internet?) solventaremos los gastos de traslado de 4 jóvenes Salteños. Estos son los seleccionados:

  • Matias Fajardo (17): habitante de Orán, desde niño fascinado por los robots. Ha construído sus propios aparatos gracias a instruccions que obtuvo de revistas y de la internet.
  • Marcos Emanuel Sosa (15): nacido en J.V. Gonzales, es un hacker del radio-control desde pequeño. Un visionario que se preocupa por el mañan de la humanidad. Esperamos oir sus ideas!
  • Florencia Antonella Correa (17): viene de Moldes y confiesa no saber mucho de robótica. Sin embargo muestra un sorprendente compromiso con la divulgación de la ciencia y la tecnología en su entorno. Vamos!
  • Lourdes Guyot (18): es de Salta capital y participó en el proyecto CErrobotics, ahora busca consolidar su experiencia en robótica.

Serán acompañados por Carlos Alberto Ríos quién ha mantenido una actividad constante en su escuela, integrando cada vez mas jovenés a su clase de robótica de los días Sábados.

Este evento será el último de mi estadía en Bélgica, puesto que mi postdoctorado en la universidad de Gante llega a su final. Mi próximo destino es incierto, pero seguramente, por cuestiones personales, estaré cerca de Suiza. El plan es continuar con este tipo de actividades desde mi nuevo lugar.