From de5d24254d26091142a20ae144d603e06dc8f939 Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Mon, 26 Mar 2018 15:14:42 -0400 Subject: [PATCH 1/4] construct paths to choropleth files intelligently --- plotly/figure_factory/_county_choropleth.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plotly/figure_factory/_county_choropleth.py b/plotly/figure_factory/_county_choropleth.py index cc70eeb9fe7..fea9930f7bd 100644 --- a/plotly/figure_factory/_county_choropleth.py +++ b/plotly/figure_factory/_county_choropleth.py @@ -23,18 +23,21 @@ def _create_us_counties_df(st_to_state_name_dict, state_to_st_dict): abs_file_path = os.path.realpath(__file__) abs_dir_path = os.path.dirname(abs_file_path) - abs_plotly_dir_path = abs_dir_path[:abs_dir_path.find('/figure_factory')] - abs_package_data_dir_path = abs_plotly_dir_path + '/package_data/' + abs_plotly_dir_path = os.path.dirname(abs_dir_path) + + abs_package_data_dir_path = os.path.join(abs_plotly_dir_path, + 'package_data') shape_pre2010 = 'gz_2010_us_050_00_500k.shp' - shape_pre2010 = abs_package_data_dir_path + shape_pre2010 + shape_pre2010 = os.path.join(abs_package_data_dir_path, shape_pre2010) + df_shape_pre2010 = gp.read_file(shape_pre2010) df_shape_pre2010['FIPS'] = (df_shape_pre2010['STATE'] + df_shape_pre2010['COUNTY']) df_shape_pre2010['FIPS'] = pd.to_numeric(df_shape_pre2010['FIPS']) states_path = 'cb_2016_us_state_500k.shp' - states_path = abs_package_data_dir_path + states_path + states_path = os.path.join(abs_package_data_dir_path, states_path) # state df df_state = gp.read_file(states_path) @@ -46,7 +49,7 @@ def _create_us_counties_df(st_to_state_name_dict, state_to_st_dict): 'cb_2016_us_county_500k.shx'] for j in range(len(filenames)): - filenames[j] = abs_package_data_dir_path + filenames[j] + filenames[j] = os.path.join(abs_package_data_dir_path, filenames[j]) dbf = io.open(filenames[0], 'rb') shp = io.open(filenames[1], 'rb') From 183a6fab1db320a3561a345cfea2198a84f360bd Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Mon, 26 Mar 2018 15:27:47 -0400 Subject: [PATCH 2/4] update the changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6468e910a43..12ca26bb522 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [2.5.1] - 2018-03-26 +### Fixed +- `plotly.figure_factory.create_choropleth` now works in Windows without raising an OSError. The module now uses intelligent path tools from `os` to manipulate and manage the shapefiles packaged with Plotly + ## [2.5.0] - 2018-03-12 ### Fixed - `import plotly.figure_factory` does not fail if `pandas` is not installed. See https://github.com/plotly/plotly.py/pull/958 From 53d57cae7456e108ea9b0e37ad16effc74d8eaa1 Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Mon, 26 Mar 2018 15:28:06 -0400 Subject: [PATCH 3/4] bump version --- plotly/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/version.py b/plotly/version.py index e59b17b4f4c..b8c54948021 100644 --- a/plotly/version.py +++ b/plotly/version.py @@ -1 +1 @@ -__version__ = '2.5.0' +__version__ = '2.5.1' From 2260054c67bebda162949cdd0ae6e86bfb776f9a Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Mon, 26 Mar 2018 15:36:27 -0400 Subject: [PATCH 4/4] changelog comments --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12ca26bb522..467969c845a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [2.5.1] - 2018-03-26 ### Fixed -- `plotly.figure_factory.create_choropleth` now works in Windows without raising an OSError. The module now uses intelligent path tools from `os` to manipulate and manage the shapefiles packaged with Plotly +- `plotly.figure_factory.create_choropleth` now works in Windows without raising an OSError. The module now uses cross-platform path tools from `os` to manipulate and manage the shapefiles contained in this package. ## [2.5.0] - 2018-03-12 ### Fixed