Changes in / [dddf1f5:212da72]


Ignore:
Files:
37 added
17 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • README

    rdddf1f5 r212da72  
    119119CONTACT
    120120
    121 The home page of this project can be found at http://aubio.piem.org/. Feel free
     121The home page of this project can be found at http://aubio.org/. Feel free
    122122to drop me a comment (piem@altern.org) or on the mailing list, aubio@piem.org.
    123123Suggestions and feedback are most welcome.
  • configure.ac

    rdddf1f5 r212da72  
    8282AC_LIBTOOL_DLOPEN
    8383dnl AC_DISABLE_STATIC
     84dnl allow cross compiling
     85AC_LIBTOOL_WIN32_DLL
    8486AC_PROG_LIBTOOL
    8587
     
    8991AM_CONDITIONAL(MINGW, false)
    9092AM_CONDITIONAL(DARWIN, false)
    91 case "${build_os}" in
     93case "${host_os}" in
    9294*mingw* | *cygwin*)
    9395  mingw32_support="yes"
  • examples/utils.c

    rdddf1f5 r212da72  
    2222void save_data (void);
    2323void restore_data(lash_config_t * lash_config);
    24 void flush_process(aubio_process_func_t process_func, aubio_print_func_t print);
    2524pthread_t lash_thread;
    2625#endif /* LASH_SUPPORT */
     
    410409
    411410void flush_process(aubio_process_func_t process_func, aubio_print_func_t print){
    412   uint i,j;
     411  uint_t i,j;
    413412  for (i = 0; i < channels; i++) {
    414413    for (j = 0; j < obuf->length; j++) {
  • examples/utils.h

    rdddf1f5 r212da72  
    5757#endif
    5858void examples_common_process(aubio_process_func_t process_func, aubio_print_func_t print);
     59void flush_process(aubio_process_func_t process_func, aubio_print_func_t print);
    5960
    6061
  • src/Makefile.am

    rdddf1f5 r212da72  
    1 noinst_HEADERS = aubio_priv.h
     1noinst_HEADERS = \
     2        aubio_priv.h \
     3        temporal/filter_priv.h
     4
    25pkginclude_HEADERS = aubio.h \
    36        types.h \
    47        fvec.h \
     8        lvec.h \
    59        cvec.h \
    6         mathutils.h \
     10        mathutils.h
     11
     12pkgincludeutilsdir = $(pkgincludedir)/utils
     13pkgincludetemporaldir = $(pkgincludedir)/temporal
     14pkgincludespectraldir = $(pkgincludedir)/spectral
     15pkgincludepitchdir = $(pkgincludedir)/pitch
     16pkgincludeonsetdir = $(pkgincludedir)/onset
     17pkgincludetempodir = $(pkgincludedir)/tempo
     18
     19pkgincludeutils_HEADERS = \
    720        utils/hist.h \
    8         utils/scale.h \
     21        utils/scale.h
     22
     23pkgincludetemporal_HEADERS = \
    924        temporal/resample.h \
    1025        temporal/biquad.h \
    1126        temporal/filter.h \
     27        temporal/adesign.h \
     28        temporal/cdesign.h
     29
     30pkgincludespectral_HEADERS = \
    1231        spectral/filterbank.h \
    13         spectral/mfcc.c \
     32        spectral/mfcc.h \
    1433        spectral/phasevoc.h \
    1534        spectral/fft.h \
    1635        spectral/tss.h \
    17         spectral/spectral_centroid.h \
     36        spectral/spectral_centroid.h
     37
     38pkgincludepitch_HEADERS = \
    1839        pitch/pitchdetection.h \
    1940        pitch/pitchmcomb.h \
     
    2142        pitch/pitchschmitt.h \
    2243        pitch/pitchfcomb.h \
    23         pitch/pitchyinfft.h \
     44        pitch/pitchyinfft.h
     45
     46pkgincludeonset_HEADERS =       \
    2447        onset/onset.h \
    2548        onset/onsetdetection.h \
    26         onset/peakpick.h \
     49        onset/peakpick.h
     50
     51pkgincludetempo_HEADERS =       \
    2752        tempo/tempo.h \
    2853        tempo/beattracking.h
    2954
    30 nodist_pkginclude_HEADERS = config.h
    31 
    3255lib_LTLIBRARIES = libaubio.la
    33 libaubio_la_SOURCES = aubio.h \
    34         types.h \
     56libaubio_la_SOURCES = \
    3557        fvec.c \
    36         fvec.h \
     58        lvec.c \
    3759        cvec.c \
    38         cvec.h \
    3960        mathutils.c \
    40         mathutils.h \
    4161        utils/hist.c \
    42         utils/hist.h \
    4362        utils/scale.c \
    44         utils/scale.h \
    4563        temporal/resample.c \
    46         temporal/resample.h \
    4764        temporal/biquad.c \
    48         temporal/biquad.h \
    4965        temporal/filter.c \
    50         temporal/filter.h \
     66        temporal/adesign.c \
     67        temporal/cdesign.c \
    5168        spectral/filterbank.c \
    52         spectral/filterbank.h \
    53         spectral/mfcc.h \
    5469        spectral/mfcc.c \
    5570        spectral/phasevoc.c \
    56         spectral/phasevoc.h \
    5771        spectral/fft.c \
    58         spectral/fft.h \
    5972        spectral/tss.c \
    60         spectral/tss.h \
    6173        spectral/spectral_centroid.c \
    62         spectral/spectral_centroid.h \
    6374        pitch/pitchdetection.c \
    64         pitch/pitchdetection.h \
    6575        pitch/pitchmcomb.c \
    66         pitch/pitchmcomb.h \
    6776        pitch/pitchyin.c \
    68         pitch/pitchyin.h \
    6977        pitch/pitchschmitt.c \
    70         pitch/pitchschmitt.h \
    7178        pitch/pitchfcomb.c \
    72         pitch/pitchfcomb.h \
    7379        pitch/pitchyinfft.c \
    74         pitch/pitchyinfft.h \
    7580        onset/onset.c \
    76         onset/onset.h \
    7781        onset/onsetdetection.c \
    78         onset/onsetdetection.h \
    7982        onset/peakpick.c \
    80         onset/peakpick.h \
    8183        tempo/tempo.c \
    82         tempo/tempo.h \
    83         tempo/beattracking.c \
    84         tempo/beattracking.h
     84        tempo/beattracking.c
    8585
    8686AM_CFLAGS = @AUBIO_CFLAGS@ @FFTWLIB_CFLAGS@ @SAMPLERATE_CFLAGS@
  • src/aubio.h

    rdddf1f5 r212da72  
    6161#include "fvec.h"
    6262#include "cvec.h"
     63#include "lvec.h"
    6364#include "mathutils.h"
    6465#include "utils/scale.h"
     
    6869#include "temporal/biquad.h"
    6970#include "temporal/filter.h"
     71#include "temporal/adesign.h"
     72#include "temporal/cdesign.h"
    7073#include "spectral/filterbank.h"
    7174#include "spectral/mfcc.h"
  • src/aubio_priv.h

    rdddf1f5 r212da72  
    170170#define ELEM_SWAP(a,b) { register smpl_t t=(a);(a)=(b);(b)=t; }
    171171
     172#define ISDENORMAL(f) f < 1.e-37
     173
    172174#define UNUSED __attribute__((unused))
    173175
  • src/pitch/pitchdetection.c

    rdddf1f5 r212da72  
    2222#include "spectral/phasevoc.h"
    2323#include "mathutils.h"
    24 #include "temporal/filter.h"
     24#include "temporal/cdesign.h"
    2525#include "pitch/pitchmcomb.h"
    2626#include "pitch/pitchyin.h"
     
    103103      p->fftgrain = new_cvec(bufsize, channels);
    104104      p->mcomb    = new_aubio_pitchmcomb(bufsize,hopsize,channels,samplerate);
    105       p->filter   = new_aubio_cdsgn_filter(samplerate);
     105      p->filter   = new_aubio_cdsgn_filter(samplerate, channels);
    106106      p->callback = aubio_pitchdetection_mcomb;
    107107      break;
  • src/spectral/fft.c

    rdddf1f5 r212da72  
    155155    spectrum->phas[i][0] = 0.;
    156156    for (j=1; j < spectrum->length - 1; j++) {
     157      if (compspec->data[i][j] == 0.) spectrum->phas[i][j] = 0;
     158      else
    157159      spectrum->phas[i][j] = atan2f(compspec->data[i][compspec->length-j],
    158160          compspec->data[i][j]);
  • src/temporal/filter.c

    rdddf1f5 r212da72  
    2424#include "aubio_priv.h"
    2525#include "fvec.h"
     26#include "lvec.h"
    2627#include "mathutils.h"
    2728#include "temporal/filter.h"
     29#include "temporal/filter_priv.h"
    2830
    29 struct _aubio_filter_t {
    30   uint_t order;
    31   lsmp_t * a;
    32   lsmp_t * b;
    33   lsmp_t * y;
    34   lsmp_t * x;
    35 };
    36 
    37 /* bug: mono only */
    3831void aubio_filter_do(aubio_filter_t * f, fvec_t * in) {
    39   uint_t i,j,l, order = f->order;
    40   lsmp_t *x = f->x;
    41   lsmp_t *y = f->y;
    42   lsmp_t *a = f->a;
    43   lsmp_t *b = f->b;
    44   i=0;//for (i=0;i<in->channels;i++) {
    45   for (j = 0; j < in->length; j++) {
    46     /* new input */
    47     //AUBIO_DBG("befor %f\t", in->data[i][j]);
    48     x[0] = in->data[i][j];
    49     y[0] = b[0] * x[0];
    50     for (l=1;l<order; l++) {
    51       y[0] += b[l] * x[l];
    52       y[0] -= a[l] * y[l];
    53     } /* + 1e-37; for denormal ? */
    54     /* new output */
    55     in->data[i][j] = y[0];
    56     //AUBIO_DBG("after %f\n", in->data[i][j]);
    57     /* store states for next sample */
    58     for (l=order-1; l>0; l--){
    59       x[l] = x[l-1];
    60       y[l] = y[l-1];
    61     }
    62   }
    63   /* store states for next buffer */
    64   f->x = x;
    65   f->y = y;
    66   //}   
     32  aubio_filter_do_outplace(f, in, in);
    6733}
    6834
    6935void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out) {
    7036  uint_t i,j,l, order = f->order;
    71   lsmp_t *x = f->x;
    72   lsmp_t *y = f->y;
    73   lsmp_t *a = f->a;
    74   lsmp_t *b = f->b;
     37  lsmp_t *x;
     38  lsmp_t *y;
     39  lsmp_t *a = f->a->data[0];
     40  lsmp_t *b = f->b->data[0];
    7541
    76   i=0; // works in mono only !!!
    77   //for (i=0;i<in->channels;i++) {
    78   for (j = 0; j < in->length; j++) {
    79     /* new input */
    80     x[0] = in->data[i][j];
    81     y[0] = b[0] * x[0];
    82     for (l=1;l<order; l++) {
    83       y[0] += b[l] * x[l];
    84       y[0] -= a[l] * y[l];
     42  for (i = 0; i < in->channels; i++) {
     43    x = f->x->data[i];
     44    y = f->y->data[i];
     45    for (j = 0; j < in->length; j++) {
     46      /* new input */
     47      if (ISDENORMAL(in->data[i][j])) {
     48        x[0] = y[0] = 0.;
     49      } else {
     50        x[0] = in->data[i][j];
     51        y[0] = b[0] * x[0];
     52        for (l=1;l<order; l++) {
     53          y[0] += b[l] * x[l];
     54          y[0] -= a[l] * y[l];
     55        }
     56      }
     57      /* new output */
     58      out->data[i][j] = y[0];
     59      /* store for next sample */
     60      for (l=order-1; l>0; l--){
     61        x[l] = x[l-1];
     62        y[l] = y[l-1];
     63      }
    8564    }
    86     // + 1e-37;
    87     /* new output */
    88     out->data[i][j] = y[0];
    89     /* store for next sample */
    90     for (l=order-1; l>0; l--){
    91       x[l] = x[l-1];
    92       y[l] = y[l-1];
    93     }
     65    /* store for next run */
     66    f->x->data[i] = x;
     67    f->y->data[i] = y;
    9468  }
    95   /* store for next run */
    96   f->x = x;
    97   f->y = y;
    98   //}
    9969}
    10070
     
    133103}
    134104
    135 
    136 aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate) {
    137   aubio_filter_t * f = new_aubio_filter(samplerate, 7);
    138   lsmp_t * a = f->a;
    139   lsmp_t * b = f->b;
    140   /* uint_t l; */
    141   /* for now, 44100, adsgn */
    142   a[0] =  1.00000000000000000000000000000000000000000000000000000;
    143   a[1] = -4.01957618111583236952810693765059113502502441406250000;
    144   a[2] =  6.18940644292069386267485242569819092750549316406250000;
    145   a[3] = -4.45319890354411640487342083360999822616577148437500000;
    146   a[4] =  1.42084294962187751565352300531230866909027099609375000;
    147   a[5] = -0.14182547383030480458998567883099894970655441284179688;
    148   a[6] =  0.00435117723349511334451911181986361043527722358703613;
    149   b[0] =  0.25574112520425740235907596797915175557136535644531250;
    150   b[1] = -0.51148225040851391653973223583307117223739624023437500;
    151   b[2] = -0.25574112520426162120656954357400536537170410156250000;
    152   b[3] =  1.02296450081703405032840237254276871681213378906250000;
    153   b[4] = -0.25574112520426051098354491841746494174003601074218750;
    154   b[5] = -0.51148225040851369449512731080176308751106262207031250;
    155   b[6] =  0.25574112520425729133677350546349771320819854736328125;
    156   /* DBG: filter coeffs at creation time */
    157   /*
    158   for (l=0; l<f->order; l++){
    159     AUBIO_DBG("a[%d]=\t%1.16f\tb[%d]=\t%1.16f\n",l,a[l],l,b[l]);
    160   }
    161   */
    162   f->a = a;
    163   f->b = b;
    164   return f;
    165 }
    166 
    167 aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate) {
    168   aubio_filter_t * f = new_aubio_filter(samplerate, 5);
    169   lsmp_t * a = f->a;
    170   lsmp_t * b = f->b;
    171   /* uint_t l; */
    172   /* for now, 44100, cdsgn */
    173   a[0] =  1.000000000000000000000000000000000000000000000000000000000000;
    174   a[1] = -2.134674963687040794013682898366823792457580566406250000000000;
    175   a[2] =  1.279333533236063358273781886964570730924606323242187500000000;
    176   a[3] = -0.149559846089396208945743182994192466139793395996093750000000;
    177   a[4] =  0.004908700174624848651394604104325480875559151172637939453125;
    178   b[0] =  0.217008561949218803377448239189106971025466918945312500000000;
    179   b[1] = -0.000000000000000222044604925031308084726333618164062500000000;
    180   b[2] = -0.434017123898438272888711253472138196229934692382812500000000;
    181   b[3] =  0.000000000000000402455846426619245903566479682922363281250000;
    182   b[4] =  0.217008561949218969910901932962588034570217132568359375000000;
    183   /* DBG: filter coeffs at creation time */
    184   /*
    185   for (l=0; l<f->order; l++){
    186     AUBIO_DBG("a[%d]=\t%1.16f\tb[%d]=\t%1.16f\n",l,a[l],l,b[l]);
    187   }
    188   */
    189   f->a = a;
    190   f->b = b;
    191   return f;
    192 }
    193 
    194 aubio_filter_t * new_aubio_filter(uint_t samplerate UNUSED, uint_t order) {
     105aubio_filter_t * new_aubio_filter(uint_t samplerate UNUSED, uint_t order, uint_t channels) {
    195106  aubio_filter_t * f = AUBIO_NEW(aubio_filter_t);
    196   lsmp_t * x = f->x;
    197   lsmp_t * y = f->y;
    198   lsmp_t * a = f->a;
    199   lsmp_t * b = f->b;
    200   uint_t l;
     107  f->x = new_lvec(order, channels);
     108  f->y = new_lvec(order, channels);
     109  f->a = new_lvec(order, 1);
     110  f->b = new_lvec(order, 1);
     111  f->a->data[0][1] = 1.;
    201112  f->order = order;
    202   a = AUBIO_ARRAY(lsmp_t,f->order);
    203   b = AUBIO_ARRAY(lsmp_t,f->order);
    204   x = AUBIO_ARRAY(lsmp_t,f->order);
    205   y = AUBIO_ARRAY(lsmp_t,f->order);
    206   /* initial states to zeros */
    207   for (l=0; l<f->order; l++){
    208     x[l] = 0.;
    209     y[l] = 0.;
    210   }
    211   f->x = x;
    212   f->y = y;
    213   f->a = a;
    214   f->b = b;
    215113  return f;
    216114}
  • src/temporal/filter.h

    rdddf1f5 r212da72  
    6969  \param samplerate signal sampling rate
    7070  \param order order of the filter (number of coefficients)
     71  \param channels number of channels to allocate
    7172
    7273*/
    73 aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order);
    74 /** create a new A-design filter
    75 
    76   \param samplerate sampling-rate of the signal to filter
    77 
    78 */
    79 aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate);
    80 /** create a new C-design filter
    81 
    82   \param samplerate sampling-rate of the signal to filter
    83 
    84 */
    85 aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate);
     74aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order, uint_t channels);
    8675/** delete a filter object
    8776 
  • swig/aubio.i

    rdddf1f5 r212da72  
    8686
    8787/* filter */
    88 extern aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order);
    89 extern aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate);
    90 extern aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate);
     88extern aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order, uint_t channels);
    9189extern void aubio_filter_do(aubio_filter_t * b, fvec_t * in);
    9290extern void aubio_filter_do_outplace(aubio_filter_t * b, fvec_t * in, fvec_t * out);
    9391extern void aubio_filter_do_filtfilt(aubio_filter_t * b, fvec_t * in, fvec_t * tmp);
    94 /*extern int del_aubio_filter(aubio_filter_t * b);*/
     92extern void del_aubio_filter(aubio_filter_t * b);
     93
     94extern aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate, uint_t channels);
     95extern void aubio_adsgn_filter_do(aubio_filter_t * b, fvec_t * in);
     96extern void del_aubio_adsgn_filter(aubio_filter_t * b);
     97
     98extern aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate, uint_t channels);
     99extern void aubio_cdsgn_filter_do(aubio_filter_t * b, fvec_t * in);
     100extern void del_aubio_cdsgn_filter(aubio_filter_t * b);
    95101
    96102/* biquad */
     
    168174
    169175/* scale */
    170 extern aubio_scale_t * new_aubio_scale(smpl_t flow, smpl_t fhig, smpl_t ilow, smpl_t ihig       );
     176extern aubio_scale_t * new_aubio_scale(smpl_t flow, smpl_t fhig, smpl_t ilow, smpl_t ihig);
    171177extern void aubio_scale_set (aubio_scale_t *s, smpl_t ilow, smpl_t ihig, smpl_t olow, smpl_t ohig);
    172178extern void aubio_scale_do(aubio_scale_t *s, fvec_t * input);
     
    214220        aubio_pitch_schmitt,
    215221        aubio_pitch_fcomb,
    216         aubio_pitch_yinfft
     222        aubio_pitch_yinfft
    217223} aubio_pitchdetection_type;
    218224
     
    231237
    232238aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize,
    233                 uint_t hopsize,
    234                 uint_t channels,
    235                 uint_t samplerate,
    236                 aubio_pitchdetection_type type,
    237                 aubio_pitchdetection_mode mode);
     239    uint_t hopsize,
     240    uint_t channels,
     241    uint_t samplerate,
     242    aubio_pitchdetection_type type,
     243    aubio_pitchdetection_mode mode);
    238244
    239245
     
    263269aubio_pickpeak_t * new_aubio_peakpicker(smpl_t threshold);
    264270uint_t aubio_peakpick_pimrt(fvec_t * DF, aubio_pickpeak_t * p);
     271uint_t aubio_peakpick_pimrt_wt( fvec_t* DF, aubio_pickpeak_t* p, smpl_t* peakval );
    265272smpl_t aubio_peakpick_pimrt_getval(aubio_pickpeak_t* p);
    266 uint_t aubio_peakpick_pimrt_wt( fvec_t* DF, aubio_pickpeak_t* p, smpl_t* peakval );
    267273void del_aubio_peakpicker(aubio_pickpeak_t * p);
     274void aubio_peakpicker_set_threshold(aubio_pickpeak_t * p, smpl_t threshold);
     275smpl_t aubio_peakpicker_get_threshold(aubio_pickpeak_t * p);
    268276
    269277/* transient/steady state separation */
     
    475483sint_t aubio_midi_player_join(aubio_midi_player_t* player);
    476484sint_t aubio_track_send_events(aubio_track_t* track,
    477 /*  aubio_synth_t* synth, */
    478                            aubio_midi_player_t* player,
    479                            uint_t ticks);
     485    /*  aubio_synth_t* synth, */
     486    aubio_midi_player_t* player,
     487    uint_t ticks);
    480488sint_t aubio_midi_send_event(aubio_midi_player_t* player, aubio_midi_event_t* event);
    481489
  • tests/python/examples/aubioonset.py

    rdddf1f5 r212da72  
    11from template import *
    22
    3 class aubioonset_test_case(program_test_case):
     3class aubioonset_unit(program_test_case):
    44 
    55  import os.path
     
    2424    self.getOutput()
    2525    # only one onset in woodblock.aiff
    26     assert len(str(self.output)) != 0, "no output produced with command:\n" \
    27       + self.command
    28     assert len(self.output.split('\n')) == 1
     26    self.assertNotEqual(0, len(str(self.output)), \
     27      "no output produced with command:\n" + self.command)
     28    self.assertEqual(1, len(self.output.split('\n')) )
    2929    # onset should be at 0.00000
    30     assert float(self.output.strip()) == 0.
     30    self.assertEqual(0, float(self.output.strip()))
    3131
    32 for name in ["energy", "specdiff", "hfc", "complex", "phase", "kl", "mkl"]:
    33   exec("class aubioonset_test_case_"+name+"(aubioonset_test_case):\n\
     32list_of_onset_modes = ["energy", "specdiff", "hfc", "complex", "phase", \
     33                      "kl", "mkl", "specflux"]
     34
     35for name in list_of_onset_modes:
     36  exec("class aubioonset_"+name+"_unit(aubioonset_unit):\n\
    3437  options = \" -O "+name+" \"")
    3538
  • tests/python/run_all_tests

    rdddf1f5 r212da72  
    11#! /usr/bin/python
    2 
    3 # add ${src}/python and ${src}/python/aubio/.libs to python path
    4 # so the script is runnable from a compiled source tree.
    5 import sys, os
    6 
    7 cur_dir = os.path.dirname(sys.argv[0])
    8 sys.path.append(os.path.join(cur_dir,'..','..','python'))
    9 sys.path.append(os.path.join(cur_dir,'..','..','python','aubio','.libs'))
    102
    113import unittest
     
    157  return [i.split('.')[0].replace('/','.') for i in glob(path)]
    168
    17 modules_to_test  = list_of_test_files('*.py')
     9modules_to_test  = []
     10modules_to_test += list_of_test_files('src/*.py')
     11modules_to_test += list_of_test_files('src/*/*.py')
    1812modules_to_test += list_of_test_files('examples/aubio*.py')
     13modules_to_test += list_of_test_files('*.py')
    1914
    2015if __name__ == '__main__':
  • tests/python/template.py

    rdddf1f5 r212da72  
    1 
    21import unittest
    32
     
    54 
    65  def assertCloseEnough(self, first, second, places=5, msg=None):
    7         """Fail if the two objects are unequal as determined by their
    8            *relative* difference rounded to the given number of decimal places
    9            (default 7) and comparing to zero.
    10         """
    11         if round(first, places) == 0:
    12           if round(second-first, places) != 0:
    13               raise self.failureException, \
    14                     (msg or '%r != %r within %r places' % (first, second, places))
    15         else:
    16           if round((second-first)/first, places) != 0:
    17               raise self.failureException, \
    18                     (msg or '%r != %r within %r places' % (first, second, places))
     6    """Fail if the two objects are unequal as determined by their
     7       *relative* difference rounded to the given number of decimal places
     8       (default 7) and comparing to zero.
     9    """
     10    if round(first, places) == 0:
     11      if round(second-first, places) != 0:
     12        raise self.failureException, \
     13              (msg or '%r != %r within %r places' % (first, second, places))
     14    else:
     15      if round((second-first)/first, places) != 0:
     16        raise self.failureException, \
     17              (msg or '%r != %r within %r places' % (first, second, places))
Note: See TracChangeset for help on using the changeset viewer.