diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a42a2133..5d294ed48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.3.1] - 2020-05-19 + +### Fixed +- Fix read null geoms from carto (#1637) +- Fix show_info in layout maps (#1638) + ## [1.0.3] - 2020-05-14 ### Added diff --git a/README.rst b/README.rst index a0a6c58b9..5d7e13945 100644 --- a/README.rst +++ b/README.rst @@ -4,8 +4,8 @@ CARTOframes .. image:: https://travis-ci.org/CartoDB/cartoframes.svg?branch=develop :target: https://travis-ci.org/CartoDB/cartoframes -.. image:: https://img.shields.io/badge/pypi-v1.0.3-orange - :target: https://pypi.org/project/cartoframes/1.0.3 +.. image:: https://img.shields.io/badge/pypi-v1.0.3.1-orange + :target: https://pypi.org/project/cartoframes/1.0.3.1 A Python package for integrating `CARTO `__ maps, analysis, and data services into data science workflows. @@ -14,11 +14,11 @@ Python data analysis workflows often rely on the de facto standards `pandas \ No newline at end of file diff --git a/cartoframes/assets/templates/viz/main.html.j2 b/cartoframes/assets/templates/viz/main.html.j2 index 3d26c3a53..7410bb272 100644 --- a/cartoframes/assets/templates/viz/main.html.j2 +++ b/cartoframes/assets/templates/viz/main.html.j2 @@ -51,7 +51,7 @@
{% if show_info %} - {% include 'templates/viz/info.html.j2' %} +
{% endif %} {% if has_legends or layer_selector %}
diff --git a/cartoframes/assets/templates/viz/main_layout.html.j2 b/cartoframes/assets/templates/viz/main_layout.html.j2 index 9f371c406..43c87094d 100644 --- a/cartoframes/assets/templates/viz/main_layout.html.j2 +++ b/cartoframes/assets/templates/viz/main_layout.html.j2 @@ -62,6 +62,9 @@
+ {% if maps[map_index]['show_info'] %} +
+ {% endif %}
{% if has_legends or layer_selector %} {% set layers = maps[map_index]['layers'] %} diff --git a/cartoframes/utils/columns.py b/cartoframes/utils/columns.py index 6d6df5189..37e00cce4 100644 --- a/cartoframes/utils/columns.py +++ b/cartoframes/utils/columns.py @@ -7,7 +7,6 @@ from .utils import dtypes2pg, pg2dtypes, PG_NULL BOOL_DBTYPES = ['bool', 'boolean'] -OBJECT_DBTYPES = ['text'] INT_DBTYPES = ['int2', 'int4', 'int2', 'int', 'int8', 'smallint', 'integer', 'bigint'] FLOAT_DBTYPES = ['float4', 'float8', 'real', 'double precision', 'numeric', 'decimal'] DATETIME_DBTYPES = ['date', 'timestamp', 'timestampz'] @@ -185,27 +184,21 @@ def _is_unsupported(value): def obtain_converters(columns): converters = {} - for int_column_name in type_columns_names(columns, INT_DBTYPES): - converters[int_column_name] = _convert_int - - for float_column_name in type_columns_names(columns, FLOAT_DBTYPES): - converters[float_column_name] = _convert_float - - for bool_column_name in type_columns_names(columns, BOOL_DBTYPES): - converters[bool_column_name] = _convert_bool - - for object_column_name in type_columns_names(columns, OBJECT_DBTYPES): - converters[object_column_name] = _convert_object + for column in columns: + if column.dbtype in INT_DBTYPES: + converters[column.name] = _convert_int + elif column.dbtype in FLOAT_DBTYPES: + converters[column.name] = _convert_float + elif column.dbtype in BOOL_DBTYPES: + converters[column.name] = _convert_bool + else: + converters[column.name] = _convert_generic return converters def date_columns_names(columns): - return type_columns_names(columns, DATETIME_DBTYPES) - - -def type_columns_names(columns, dbtypes): - return [x.name for x in columns if x.dbtype in dbtypes] + return [x.name for x in columns if x.dbtype in DATETIME_DBTYPES] def _convert_int(x): @@ -230,7 +223,7 @@ def _convert_bool(x): return bool(x) -def _convert_object(x): +def _convert_generic(x): if _is_none_null(x): return None return x @@ -238,10 +231,3 @@ def _convert_object(x): def _is_none_null(x): return x is None or x == PG_NULL - - -def _first_value(series): - series = series.loc[~series.isnull()] # Remove null values - if len(series) > 0: - return series.iloc[0] - return None diff --git a/cartoframes/utils/utils.py b/cartoframes/utils/utils.py index 1506c500b..772675f35 100644 --- a/cartoframes/utils/utils.py +++ b/cartoframes/utils/utils.py @@ -266,7 +266,6 @@ def get_geodataframe_data(data, encode_data=True): return data -# Dup def _first_value(series): series = series.loc[~series.isnull()] # Remove null values if len(series) > 0: diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 452caab42..d507d2264 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -5,6 +5,7 @@ We follow the git-flow model to generate the releases. The version numbers are M - M: major - m: minor - u: micro +- p: patch (only for hotfixes) ## The release branch diff --git a/tests/unit/utils/test_columns.py b/tests/unit/utils/test_columns.py index 879fa719a..157c0232e 100644 --- a/tests/unit/utils/test_columns.py +++ b/tests/unit/utils/test_columns.py @@ -6,7 +6,9 @@ from geopandas import GeoDataFrame from cartoframes.utils.geom_utils import set_geometry -from cartoframes.utils.columns import ColumnInfo, get_dataframe_columns_info, normalize_names +from cartoframes.utils.columns import ColumnInfo, get_dataframe_columns_info, normalize_names, \ + obtain_converters, _convert_int, _convert_float, \ + _convert_bool, _convert_generic class TestColumns(object): @@ -113,3 +115,21 @@ def test_column_info_geometry_troubled_names(self): ColumnInfo('the_geom', 'the_geom', 'geometry(Geometry, 4326)', True), ColumnInfo('g-e-o-m-e-t-r-y', 'g_e_o_m_e_t_r_y', 'text', False) ] + + def test_converters(self): + columns = [ + ColumnInfo('cartodb_id', 'cartodb_id', 'integer', False), + ColumnInfo('the_geom', 'the_geom', 'geometry(Geometry, 4326)', True), + ColumnInfo('name', 'name', 'text', False), + ColumnInfo('flag', 'flag', 'boolean', False), + ColumnInfo('number', 'number', 'double precision', False) + ] + + converters = obtain_converters(columns) + + assert type(converters) == dict + assert converters['cartodb_id'] == _convert_int + assert converters['the_geom'] == _convert_generic + assert converters['name'] == _convert_generic + assert converters['flag'] == _convert_bool + assert converters['number'] == _convert_float