Skip to content

Commit

Permalink
test nans
Browse files Browse the repository at this point in the history
  • Loading branch information
knaaptime committed Sep 10, 2024
1 parent dc1ec1a commit e86d913
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions mapclassify/tests/test_rgba.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,29 @@

world = geopandas.read_file(
"https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip"
)
).reset_index(drop=True)


def test_rgba():
colors = get_color_array(world.area, cmap="viridis")[0]
assert_array_equal(colors, np.array([68, 1, 84, 255]))


def test_rgba():
def test_rgba_hex():
colors = get_color_array(world.area, cmap="viridis", as_hex=True)[0]
assert_array_equal(colors,'#440154')

def test_rgba_nan():
worldnan = world.copy()
worldnan['area'] = worldnan.area
worldnan.loc[0, 'area'] = np.nan
colors = get_color_array(worldnan['area'], cmap="viridis", nan_color=[0,0,0,0])[0]
assert_array_equal(colors, np.array([0, 0, 0, 0]))

def test_rgba_nan_hex():
worldnan = world.copy()
worldnan['area'] = worldnan.area
worldnan.loc[0, 'area'] = np.nan
colors = get_color_array(worldnan['area'], cmap="viridis",nan_color=[0,0,0,0], as_hex=True)[0]
assert_array_equal(colors, np.array(['#000000']))

0 comments on commit e86d913

Please sign in to comment.