Skip to content

Commit

Permalink
fix missing import of pandas
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelaye committed Feb 3, 2016
1 parent 09d4906 commit 8515554
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 6 deletions.
13 changes: 7 additions & 6 deletions notebooks/tests/test_markings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"collapsed": false
},
Expand All @@ -12,6 +12,7 @@
"from planet4 import markings\n",
"import numpy as np\n",
"from numpy.testing import assert_allclose\n",
"import pandas as pd\n",
"\n",
"blotchdata = dict(\n",
" x = 100,\n",
Expand All @@ -35,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"collapsed": true
},
Expand All @@ -53,7 +54,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"collapsed": false
},
Expand Down Expand Up @@ -81,7 +82,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"collapsed": false
},
Expand All @@ -96,7 +97,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"collapsed": true
},
Expand Down Expand Up @@ -125,4 +126,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
78 changes: 78 additions & 0 deletions notebooks/tests/test_markings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

# coding: utf-8

# In[ ]:

# setup
from planet4 import markings
import numpy as np
from numpy.testing import assert_allclose
import pandas as pd

blotchdata = dict(
x = 100,
y = 200,
radius_1 = 30,
radius_2 = 40,
angle = 25,
image_id='blotch_id',
)
blotchdata = pd.Series(blotchdata)

fandata = dict(x = 300,
y = 400,
angle = 55,
spread = 17,
distance = 23,
image_id = 'fan_id'
)
fandata = pd.Series(fandata)


# In[ ]:

# test_blotch
blotch = markings.Blotch(blotchdata)
assert blotch.angle == 25
assert blotch.center == (100, 200)
assert blotch.height == 80
assert blotch.width == 60
assert blotch.x == 100
assert blotch.y == 200


# In[ ]:

# test_fan
fan = markings.Fan(fandata)
assert_allclose(fan.base, np.array([300, 400]))
assert_allclose(fan.coords, np.array([[ 313.92663903, 414.67561542],
[ 300. , 400. ],
[ 309.02737644, 418.10611602]]))
assert_allclose(fan.inside_half, 8.5)
assert_allclose(fan.armlength, 20.231781009871817)
assert_allclose(fan.v1, np.array([13.92663903, 14.67561542]))
assert_allclose(fan.v2, np.array([ 9.02737644, 18.10611602]))
assert_allclose(fan.center, np.array([ 311.47700774, 416.39086572]))
assert_allclose(fan.circle_base, np.array([ 4.89926259, -3.4305006 ]))
assert_allclose(fan.radius, 2.990447637172394)
assert_allclose(fan.center, np.array([ 311.47700774, 416.39086572]))
assert_allclose(fan.midpoint, np.array([ 306.65986158, 409.51126803]))
assert_allclose(fan.base_to_midpoint_vec,
np.array([[ 300. , 400. ],
[ 306.65986158, 409.51126803]]))


# In[ ]:

fnotch = markings.Fnotch(0.4, markings.Fan(fandata),
markings.Blotch(blotchdata))
assert_allclose(fnotch.value, 0.4)
assert isinstance(fnotch.get_marking(0.8), markings.Blotch)
assert isinstance(fnotch.get_marking(0.3), markings.Fan)


# In[ ]:



0 comments on commit 8515554

Please sign in to comment.