Skip to content

Conversation

@amishn2008
Copy link
Contributor

@amishn2008 amishn2008 commented Jun 22, 2025

Modified all SVG file creation functions to check for args_.redirect_exports_to_stdout in addition to their existing plot flags. When --redirect_exports_to_stdout is enabled, SVG files are no longer created regardless of other plot flag settings.

To test:

Test with redirect_exports_to_stdout flag

./cartogram sample_data/world_by_country_since_2022/world_by_country_since_2022.geojson sample_data/world_by_country_since_2022/world_population_by_country_2010.csv --redirect_exports_to_stdout --plot_polygons --add_grid --plot_density --plot_quadtree --plot_intersections

no svg files are created and only geojson output is printed to sdout

@adisidev

@github-actions
Copy link

github-actions bot commented Jun 22, 2025

🚦 Performance Comparison (α=0.05, ±3%)

🗺️ Total maps34 ❌ Failed0 🚀 Speed-ups11 🐢 Slow-downs2 ⚖️ No change21

❌ Failures

None 😎

🚀 Speed-ups (11)
map main pr Δ % p
australia_​by_​state_​and_​territory_​since_​1942/​australia_​population_​by_​state_​and_​territory_​2021.csv 0.707±0.005 0.681±0.001 -3.7 0.000
conterminous_​usa_​by_​state_​since_​1959/​conterminous_​usa_​population_​by_​state_​2020.csv 0.613±0.002 0.590±0.002 -3.8 0.000
contiguous_​usa_​by_​county_​since_​2001/​usa_​population_​by_​county_​2021.csv 43.365±0.728 39.344±0.559 -9.3 0.000
croatia_​by_​county_​since_​1992/​croatia_​covid_​cases_​by_​county_​2022.csv 0.321±0.001 0.311±0.001 -3.2 0.000
england_​by_​region_​since_​2023/​england_​population_​by_​region_​2022.csv 1.284±0.015 1.226±0.005 -4.5 0.000
indonesia_​by_​province_​since_​2022/​indonesia_​population_​by_​province_​2024.csv 0.513±0.002 0.497±0.001 -3.0 0.000
japan_​by_​prefecture_​since_​1888/​japan_​population_​by_​prefecture_​2020.csv 0.781±0.004 0.753±0.001 -3.6 0.000
usa_​by_​state_​since_​1959/​usa_​population_​by_​state_​2020.csv 0.868±0.010 0.833±0.005 -4.1 0.000
usa_​by_​state_​since_​1959/​usa_​population_​by_​state_​2020_​insetted.csv 0.702±0.002 0.681±0.002 -3.0 0.000
vietnam_​by_​province_​since_​1996/​vietnam_​population_​by_​province_​2019.csv 0.939±0.003 0.908±0.009 -3.3 0.000
world_​by_​country_​since_​2022/​world_​population_​by_​country_​2010.csv 6.608±0.982 5.256±0.778 -20.5 0.026
🐢 Slow-downs (2)
map main pr Δ % p
world_​by_​region/​world_​population_​by_​region.csv 9.482±0.086 11.533±0.709 +21.6 0.001
world_​by_​region_​wo_​antarctica/​world_​population_​by_​region_​wo_​antarctica.csv 7.192±0.951 8.228±0.068 +14.4 0.045
⚖️ No significant change (21)
map main pr Δ % p
algeria_​by_​wilaya_​since_​2019/​algeria_​population_​by_​wilaya_​2022.csv 1.009±0.002 0.992±0.005 -1.7 0.000
austria_​by_​state_​since_​1945/​austria_​population_​by_​state_​2020.csv 0.260±0.001 0.256±0.005 -1.4 0.039
bahamas_​by_​district_​since_​1999/​bahamas_​population_​by_​district_​2010.csv 3.815±0.014 3.735±0.031 -2.1 0.001
belgium_​by_​region_​simplified_​since_​1995/​belgium_​population_​by_​region_​simplified_​2022.csv 0.067±0.000 0.066±0.000 -1.5 0.000
belgium_​by_​region_​since_​1995/​belgium_​population_​by_​region_​2022.csv 0.087±0.000 0.085±0.000 -2.3 0.000
brazil_​by_​state_​since_​1988/​brazil_​population_​by_​state_​2021.csv 0.721±0.002 0.704±0.005 -2.4 0.000
china_​by_​province_​with_​chinese_​taipei_​since_​1998/​china_​population_​by_​province_​2020.csv 0.861±0.008 0.842±0.004 -2.2 0.001
croatia_​by_​county_​since_​1992/​croatia_​population_​by_​county_​2021.csv 0.244±0.001 0.237±0.001 -2.7 0.000
egypt_​by_​governorate_​since_​2009/​egypt_​population_​by_​governate_​2017.csv 1.040±0.004 1.021±0.004 -1.8 0.000
eu_​by_​country_​until_​2020/​eu_​population_​by_​country_​2021.csv 1.597±0.006 1.553±0.004 -2.7 0.000
eu_​by_​region_​until_​2020/​eu_​population_​by_​region_​2020.csv 4.445±0.094 4.325±0.309 -2.7 0.396
france_​by_​metropolitan_​region_​since_​2016/​france_​population_​by_​metropolitan_​region_​2008.csv 0.274±0.001 0.266±0.000 -3.0 0.000
germany_​by_​state_​since_​1990/​germany_​population_​by_​state_​2011.csv 0.255±0.001 0.251±0.009 -1.6 0.129
malaysia_​by_​state_​since_​2001/​malaysia_​population_​by_​state_​2020.csv 0.426±0.001 0.414±0.001 -2.9 0.000
malaysia_​by_​state_​since_​2001/​malaysia_​population_​by_​state_​2020_​insetted.csv 0.400±0.001 0.391±0.001 -2.1 0.000
metropolitan_​france_​by_​departement_​since_​2015/​metropolitan_​france_​population_​by_​departement_​2022.csv 1.292±0.003 1.312±0.018 +1.5 0.040
russia_​by_​federal_​subject_​since_​2008/​russia_​population_​by_​federal_​subject_​2010.csv 2.125±0.005 2.776±0.680 +30.7 0.066
singapore_​by_​planning_​area_​since_​1999/​singapore_​population_​by_​planning_​area_​2015.csv 2.895±0.011 2.863±0.074 -1.1 0.350
switzerland_​by_​canton_​since_​1999/​switzerland_​gdp_​in_​billion_​chf_​by_​canton_​2019.csv 0.422±0.002 0.410±0.001 -2.8 0.000
switzerland_​by_​canton_​since_​1999/​switzerland_​population_​by_​canton_​2016.csv 0.366±0.001 0.356±0.000 -2.7 0.000
tunisia_​by_​governorate_​since_​1994/​tunisia_​population_​by_​governate_​2014.csv 0.422±0.001 0.410±0.001 -2.9 0.000

@adisidev
Copy link
Collaborator

adisidev commented Jul 3, 2025

Couple of things are needed before I can merge this pull request.

  1. In your pull request comment, make sure to rephrase what the issue description was to give a more higher-level summary of what the problem was and the fix.
  2. If the fix relates to input and output, then make sure to include the command one has to run for testing, the previous output and the new output. This will act as a good sanity check as to whether the bug is actually fixed. In this case, you'll find that the bug has actually not been fixed. Hint: using only --redirect_exports_to_stdout is not enough to test the behaviour, as you'll notice the svg files outputted will not change when you use that command you don't use that command. I think it'd be a fun exercise to go based on just the hint, but I'm always there if you need more help, of course!

@amishn2008

@adisidev adisidev self-assigned this Jul 3, 2025
Copy link
Collaborator

@adisidev adisidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make changes to pull request comment and code as requested.

While we're at it, see if you can change the following line (in the same pull request) according to the issue described in #243

cart_info.reposition_insets(args.redirect_exports_to_stdout);

…l being created despite the flag's purpose being to redirect all exports to stdout and avoid file creation. This violated the principle that when --redirect_exports_to_stdout is enabled, no files should be written to disk.
Copy link
Collaborator

@nihalzp nihalzp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on the issues. Looks good to me! I think the file sample_data/australia_by_state_and_territory_since_1942/australia_population_by_state_and_territory_2021_cartogram.geojson has been added mistakenly. Once that's removed, we can merge it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this file has been mistakenly added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants