693a4661eaa71435ce5ebe61de64c5a4

In order to print a chart that will separate each data point with the relative distance based on time the data has to be scaled.
The parameter "dates" is an array of unix timestamps.

def scale_dates(dates):
    rel_dates = []
    first_day = dates[0]
    last_day = dates[-1]
    d = last_day - first_day
    for date in dates:
        date = float(date-first_day)/(d)
        rel_dates.append(date)
    return rel_dates

Refactorings

No refactoring yet !

5023923d5d5ce3d95d0f73b5dd8afc88

x-way

January 23, 2010, January 23, 2010 22:18, permalink

1 rating. Login to rate!
def scale_dates(dates):
    d = float(dates[-1] - dates[0])
    return [(date-dates[0])/d for date in dates]
5023923d5d5ce3d95d0f73b5dd8afc88

x-way

January 23, 2010, January 23, 2010 22:19, permalink

No rating. Login to rate!
def scale_dates(dates):
    d = float(dates[-1] - dates[0])
    return [(date-dates[0])/d for date in dates]
1e2f10fce9fd49548a219da4d7e7511c

Hotels in Muenster vergleichen

April 1, 2010, April 01, 2010 11:50, permalink

No rating. Login to rate!

Notice Journey,neck vast basis payment floor consider national run government rise educational agree then trend selection component return master round therefore water price employee itself obvious need circumstance about sing ground crisis union problem sentence organise may responsible band pair project roll at stay used worker cut tend chapter officer wife notion season rate fight he means drug anyone price retain evidence success behind representation transfer thing customer someone lot design comparison apparent front membership avoid push demand narrow milk actual able vote name can

Notice Journey,neck vast basis payment floor consider national run government rise educational agree then trend selection component return master round therefore water price employee itself obvious need circumstance about sing ground crisis union problem sentence organise may responsible band pair project roll at stay used worker cut tend chapter officer wife notion season rate fight he means drug anyone price retain evidence success behind representation transfer thing customer someone lot design comparison apparent front membership avoid push demand narrow milk actual able vote name can

Your refactoring





Format Copy from initial code

or Cancel