Skip to content

[BUG] Map.fly_to raises if you pass a numpy.int64 for zoom #1046

@shawnboltz

Description

@shawnboltz

Context

I called Map.fly_to and passed a value for zoom that was a numpy.int64.

Resulting behaviour, error message or logs

A type error got raised because of the numpy.int64. The type checking in the fly_to is overly restrictive and explicitly checks for a normal int or float:

if not isinstance(zoom, (int, float)):
    raise TypeError(f"Expected zoom to be an int or float, got {type(zoom)}")

I recommend instead trying to cast the value for zoom (and latitude and longitude) to floats and only raising if that fails.

Environment

  • OS: Windows 11
  • Browser: Firefox
  • Lonboard Version: 0.12.1 (though I see it's still present in 0.13.0)

Steps to reproduce the bug

import geopandas as gpd
import numpy as np
from shapely.geometry import Point

import lonboard

d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
gdf = gpd.GeoDataFrame(d, crs="EPSG:4326")
layer = lonboard.ScatterplotLayer.from_geopandas(gdf)
map_ = lonboard.Map(layers=[layer])

map_.fly_to(longitude=0, latitude=0, zoom=np.int64(2))

Thank you for all of your efforts on lonboard. This library has been extremely helpful for a project that I'm currently working on that involves plotting large shapefiles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions