CartoDB/cartoframes

Cannot render Layout with an odd number of maps and defined N_SIZE and M_SIZE values

Opened this issue · 0 comments

Problem

It is possible to render a layout with an odd number of instances of Map() with the default N_SIZE and M_SIZE values. However, the result is a single row of containing several maps, a layout which may not be ideal in all circumstances. However, when I attempt to render a Layout() instance with a defined N_SIZE and M_SIZE values and an odd number of instances of Map(), the rendering fails.

Version Info

  • Python: 3.6, 3.8
  • cartoframes: 1.0.4
  • OS: Ubuntu 18.04

Code Snippet

See this Colab Notebook for a runnable version

from cartoframes.viz import Layout, Map

# Generate list of 3 instances of Map()
maps_list = [Map() for m in range(3)]

# Add the list of 3 maps to a 2x2 layout
Layout(maps = maps_list, n_size = 2, m_size = 2)

Error message:

---------------------------------------------------------------------------
UndefinedError                            Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/IPython/core/formatters.py in __call__(self, obj)
    336             method = get_real_method(obj, self.print_method)
    337             if method is not None:
--> 338                 return method()
    339             return None
    340         else:

10 frames
/usr/local/lib/python3.6/dist-packages/jinja2/environment.py in getitem(self, obj, argument)
    450         """Get an item or attribute of an object but prefer the item."""
    451         try:
--> 452             return obj[argument]
    453         except (AttributeError, TypeError, LookupError):
    454             if isinstance(argument, string_types):

UndefinedError: list object has no element 3