Skip to content

Commit

Permalink
Merge pull request #1639 from CartoDB/release/1.0.3.1
Browse files Browse the repository at this point in the history
Release 1.0.3.1
  • Loading branch information
Jesus89 committed May 19, 2020
2 parents ce9fe3b + 7528523 commit 53ef04a
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 43 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Expand Up @@ -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 <https://carto.com/>`__ maps, analysis, and data services into data science workflows.

Expand All @@ -14,11 +14,11 @@ Python data analysis workflows often rely on the de facto standards `pandas <htt
Try it Out
==========

* Stable (1.0.3): |stable|
* Stable (1.0.3.1): |stable|
* Latest (develop branch): |develop|

.. |stable| image:: https://mybinder.org/badge_logo.svg
:target: https://mybinder.org/v2/gh/cartodb/cartoframes/v1.0.3?filepath=examples
:target: https://mybinder.org/v2/gh/cartodb/cartoframes/v1.0.3.1?filepath=examples

.. |develop| image:: https://mybinder.org/badge_logo.svg
:target: https://mybinder.org/v2/gh/cartodb/cartoframes/develop?filepath=examples
Expand Down
2 changes: 1 addition & 1 deletion binder/requirements.txt
@@ -1,4 +1,4 @@
cartoframes==1.0.3
cartoframes==1.0.3.1
# Additional dependencies from examples
matplotlib
dask
Expand Down
2 changes: 1 addition & 1 deletion cartoframes/_version.py
@@ -1 +1 @@
__version__ = '1.0.3'
__version__ = '1.0.3.1'
2 changes: 0 additions & 2 deletions cartoframes/assets/init_layout.js.j2
@@ -1,9 +1,7 @@
const maps = {{ maps|tojson }};
const show_info = '{{show_info}}' === 'True';
const is_static = '{{is_static}}' === 'True';

init({
show_info,
is_static,
maps
});
7 changes: 4 additions & 3 deletions cartoframes/assets/src/bundle.js
Expand Up @@ -478,9 +478,9 @@ var init = (function () {
return value.toLocaleString();
}

function updateViewport(map) {
function updateViewport(id, map) {
function updateMapInfo() {
const mapInfo$ = document.getElementById('map-info');
const mapInfo$ = document.getElementById(id);
const center = map.getCenter();
const lat = center.lat.toFixed(6);
const lng = center.lng.toFixed(6);
Expand Down Expand Up @@ -870,7 +870,8 @@ var init = (function () {
const map = createMap(container, basemapStyle, settings.bounds, settings.mapboxtoken);

if (settings.show_info) {
updateViewport(map);
const id = mapIndex !== undefined ? `map-info-${mapIndex}` : 'map-info';
updateViewport(id, map);
}

if (settings.camera) {
Expand Down
3 changes: 2 additions & 1 deletion cartoframes/assets/src/map.js
Expand Up @@ -25,7 +25,8 @@ export function initMap(settings, mapIndex) {
const map = createMap(container, basemapStyle, settings.bounds, settings.mapboxtoken);

if (settings.show_info) {
updateViewport(map);
const id = mapIndex !== undefined ? `map-info-${mapIndex}` : 'map-info';
updateViewport(id, map);
}

if (settings.camera) {
Expand Down
4 changes: 2 additions & 2 deletions cartoframes/assets/src/utils.js
Expand Up @@ -33,9 +33,9 @@ export function formatNumber(value) {
return value.toLocaleString();
}

export function updateViewport(map) {
export function updateViewport(id, map) {
function updateMapInfo() {
const mapInfo$ = document.getElementById('map-info');
const mapInfo$ = document.getElementById(id);
const center = map.getCenter();
const lat = center.lat.toFixed(6);
const lng = center.lng.toFixed(6);
Expand Down
1 change: 0 additions & 1 deletion cartoframes/assets/templates/viz/info.html.j2

This file was deleted.

2 changes: 1 addition & 1 deletion cartoframes/assets/templates/viz/main.html.j2
Expand Up @@ -51,7 +51,7 @@
<div class="as-map-area">
<div id="map" class="map"></div>
{% if show_info %}
{% include 'templates/viz/info.html.j2' %}
<div id="map-info" class="map-info"></div>
{% endif %}
{% if has_legends or layer_selector %}
<div class="as-map-panels" data-name="Legends">
Expand Down
3 changes: 3 additions & 0 deletions cartoframes/assets/templates/viz/main_layout.html.j2
Expand Up @@ -62,6 +62,9 @@
<as-responsive-content id="main-container-{{map_index}}" class="layout-map">
<div class="as-map-area">
<div id="map-{{ map_index }}" class="map"></div>
{% if maps[map_index]['show_info'] %}
<div id="map-info-{{ map_index }}" class="map-info"></div>
{% endif %}
</div>
{% if has_legends or layer_selector %}
{% set layers = maps[map_index]['layers'] %}
Expand Down
36 changes: 11 additions & 25 deletions cartoframes/utils/columns.py
Expand Up @@ -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']
Expand Down Expand Up @@ -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):
Expand All @@ -230,18 +223,11 @@ def _convert_bool(x):
return bool(x)


def _convert_object(x):
def _convert_generic(x):
if _is_none_null(x):
return None
return 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
1 change: 0 additions & 1 deletion cartoframes/utils/utils.py
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions docs/RELEASING.md
Expand Up @@ -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

Expand Down
22 changes: 21 additions & 1 deletion tests/unit/utils/test_columns.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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

0 comments on commit 53ef04a

Please sign in to comment.