Edit detail for FitExamples revision 1 of 1

1
Editor: simon
Time: 2006/08/14 19:04:20 GMT+0
Note: doesn't work?

changed:
-
 Here are some example of fit tests, integrated in ZWiki pages for convenient editing (cf ZWiki:ZwikiAndFit).

 Here's the original FitWiki:SimpleExample.
 First, Division.py in "ZWiki/fixtures/":zwikidir/fixtures/ looks like this::

  from fit.ColumnFixture import ColumnFixture

  class Division(ColumnFixture):
      numerator = 0.0
      denominator = 0.0
      def quotient(self):
          return self.numerator / self.denominator

A table like this has been entered on this page (using HTML):

<table border="1" cellspacing="0" cellpadding="3">
<tr><td ColSpan=3> don't process this one fixtures.Division</td></tr>
<tr><td> numerator      </td><td> denominator   </td><td> quotient()    </td></tr>
<tr><td> 1000           </td><td> 10            </td><td> 100.0000              </td></tr>
<tr><td> -1000          </td><td> 10            </td><td> -100.0000             </td></tr>
<tr><td> 1000           </td><td> 7             </td><td> 142.85715     </td></tr>
<tr><td> 1000           </td><td> .00001                </td><td> 100000000     </td></tr>
<tr><td> 1000           </td><td> 0             </td><td> INF           </td></tr>
<tr><td> 0              </td><td> 0             </td><td> NaN           </td></tr>
<tr><td> 4195835        </td><td> 3145729       </td><td> 1.3338196     </td></tr>
</table>

and here it is processed by fit (you should see cells highlighted red or green and perhaps annotated, according to the test results):

<table border="1" cellspacing="0" cellpadding="3">
<tr><td ColSpan=3> fixtures.Division</td></tr>
<tr><td> numerator      </td><td> denominator   </td><td> quotient()    </td></tr>
<tr><td> 1000           </td><td> 10            </td><td> 100.0000              </td></tr>
<tr><td> -1000          </td><td> 10            </td><td> -100.0000             </td></tr>
<tr><td> 1000           </td><td> 7             </td><td> 142.85715     </td></tr>
<tr><td> 1000           </td><td> .00001                </td><td> 100000000     </td></tr>
<tr><td> 1000           </td><td> 0             </td><td> INF           </td></tr>
<tr><td> 0              </td><td> 0             </td><td> NaN           </td></tr>
<tr><td> 4195835        </td><td> 3145729       </td><td> 1.3338196     </td></tr>
</table>

As you can see, some tests fail because of differences between java and
python's arithmetic (and also differences between the java and python fit
implementations - python fit infers types from the format of the test
data). Here's how you would need to tweak these tests to pass with python
fit:

<table border="1" cellspacing="0" cellpadding="3">
<tr><td ColSpan=3> fixtures.Division </td></tr>
<tr><td> numerator      </td><td> denominator   </td><td> quotient()    </td></tr>
<tr><td> 1000.0           </td><td> 10.0            </td><td> 100.0              </td></tr>
<tr><td> -1000.0          </td><td> 10.0            </td><td> -100.0             </td></tr>
<tr><td> 1000.0           </td><td> 7.0             </td><td> 142.85714285714286     </td></tr>
<tr><td> 1000.0           </td><td> .00001                </td><td> 99999999.999999985     </td></tr>
<tr><td> 1000.0           </td><td> 0.0             </td><td> error           </td></tr>
<tr><td> 0.0              </td><td> 0.0             </td><td> error           </td></tr>
<tr><td> 4195835.0        </td><td> 3145729       </td><td> 1.3338196011163073      </td></tr>
</table>

Here's fit's <a
href="http://fit.c2.com/Release/Documents/arithmetic.html">arithmetic.html
example</a>, again highlighting python/java arithmetic differences:

<table class="fit" border="1" cellspacing="0" cellpadding="3">
<tr>
<td COLSPAN="6">fixtures.!ArithmeticFixture</td>
</tr>

<tr>
<td>x</td>

<td>y</td>

<td>+</td>

<td>-</td>

<td>*</td>

<td>/</td>
</tr>

<tr>
<td>0</td>

<td>0</td>

<td>0</td>

<td>0</td>

<td>0</td>

<td>0</td>
</tr>


<tr>
<td>1</td>

<td>2</td>

<td>3</td>

<td>-1</td>

<td>2</td>

<td>0.5</td>
</tr>

<tr>
<td>1</td>

<td>-1</td>

<td>0</td>

<td>2</td>

<td>-1</td>

<td>-1</td>
</tr>

<tr>
<td>10000</td>

<td>10000</td>

<td>20000</td>

<td>0</td>

<td>100000000</td>

<td>1</td>
</tr>

<tr>
<td>100000</td>

<td>100000</td>

<td>200000</td>

<td>0</td>

<td>10000000000</td>

<td>1</td>
</tr>

<tr>
<td>1000000</td>

<td>1000000</td>

<td>2000000</td>

<td>0</td>

<td>1000000000000</td>

<td>1</td>
</tr>
</table>

<table BORDER="1" CELLSPACING=0 CELLPADDING=3>
    <tr>
        <td colspan=6>fixtures.!ArithmeticColumnFixture </td>
    </tr>
    <tr>
        <td>x</td>
        <td>y</td>
        <td>plus()</td>
        <td>times()</td>
        <td>divide()</td>
        <td>floating()</td>
    </tr>
    <tr>
        <td>2</td>
        <td>3</td>
        <td>5</td>
        <td>6</td>
        <td>0</td>
        <td>0.666667</td>
    </tr>
    <tr>
        <td>0</td>
        <td>0</td>
        <td>0</td>
        <td>0</td>
        <td>error</td>
        <td>error</td>
    </tr>
    <tr>
        <td>0</td>
        <td>0</td>
        <td>0</td>
        <td>0</td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td>200</td>
        <td>300</td>
        <td>500</td>
        <td>60000</td>
        <td>0</td>
        <td>0.666667</td>
    </tr>
    <tr>
        <td>2</td>
        <td>3</td>
        <td>10</td>
        <td>10</td>
        <td>10</td>
    </tr>
    <tr>
        <td>200</td>
        <td>3</td>
        <td>5</td>
        <td>6</td>
        <td>0</td>
        <td>0.666667</td>
    </tr>
    <tr>
        <td>2</td>
        <td>-3</td>
        <td>-1</td>
        <td>-6</td>
        <td>-0</td>
        <td>-0.666667</td>
    </tr>
</table>

fit.Summary generates a summary. These counts should reset on each page view, but don't:

<table BORDER="1" CELLSPACING=0 CELLPADDING=3>
<tr>
<td COLSPAN="2">fit.Summary </td>
</tr>
</table>

MusicExample has some more tests.


From BillPage Mon Aug 14 18:56:18 -0700 2006
From: Bill Page
Date: Mon, 14 Aug 2006 18:56:18 -0700
Subject: doesn't work?
Message-ID: <20060814185618-0700@fit.zwiki.org>

I guess this stuff doesn't work any more?

From simon Mon Aug 14 19:04:20 -0700 2006
From: simon
Date: Mon, 14 Aug 2006 19:04:20 -0700
Subject: doesn't work?
Message-ID: <20060814190420-0700@fit.zwiki.org>
In-Reply-To: <20060814185618-0700@fit.zwiki.org>

I think it still works, if you have fit installed in the right place (and I don't). I'll fix that if someone finds a way to use this.

Here are some example of fit tests, integrated in ZWiki? pages for convenient editing (cf ZWiki:ZwikiAndFit).

Here's the original FitWiki:SimpleExample. First, Division.py in ZWiki/fixtures/ looks like this:

  from fit.ColumnFixture import ColumnFixture

  class Division(ColumnFixture):
      numerator = 0.0
      denominator = 0.0
      def quotient(self):
          return self.numerator / self.denominator

A table like this has been entered on this page (using HTML):

don't process this one fixtures.Division
numerator denominator quotient()
1000 10 100.0000
-1000 10 -100.0000
1000 7 142.85715
1000 .00001 100000000
1000 0 INF
0 0 NaN?
4195835 3145729 1.3338196

and here it is processed by fit (you should see cells highlighted red or green and perhaps annotated, according to the test results):

fixtures.Division
numerator denominator quotient()
1000 10 100.0000
-1000 10 -100.0000
1000 7 142.85715
1000 .00001 100000000
1000 0 INF
0 0 NaN?
4195835 3145729 1.3338196

As you can see, some tests fail because of differences between java and python's arithmetic (and also differences between the java and python fit implementations - python fit infers types from the format of the test data). Here's how you would need to tweak these tests to pass with python fit:

fixtures.Division
numerator denominator quotient()
1000.0 10.0 100.0
-1000.0 10.0 -100.0
1000.0 7.0 142.85714285714286
1000.0 .00001 99999999.999999985
1000.0 0.0 error
0.0 0.0 error
4195835.0 3145729 1.3338196011163073

Here's fit's arithmetic.html example, again highlighting python/java arithmetic differences:

fixtures.ArithmeticFixture
x y + - * /
0 0 0 0 0 0
1 2 3 -1 2 0.5
1 -1 0 2 -1 -1
10000 10000 20000 0 100000000 1
100000 100000 200000 0 10000000000 1
1000000 1000000 2000000 0 1000000000000 1

fixtures.ArithmeticColumnFixture
x y plus() times() divide() floating()
2 3 5 6 0 0.666667
0 0 0 0 error error
0 0 0 0
200 300 500 60000 0 0.666667
2 3 10 10 10
200 3 5 6 0 0.666667
2 -3 -1 -6 -0 -0.666667

fit.Summary generates a summary. These counts should reset on each page view, but don't:

fit.Summary

MusicExample has some more tests.

subtopics:


comments:

doesn't work? --Bill Page, Mon, 14 Aug 2006 18:56:18 -0700 reply
I guess this stuff doesn't work any more?

doesn't work? --simon, Mon, 14 Aug 2006 19:04:20 -0700 reply
I think it still works, if you have fit installed in the right place (and I don't). I'll fix that if someone finds a way to use this.