Skip to content

Conversation

@mountainMath
Copy link
Owner

Incorporate changes from #216 and resolve merge conflicts with main and bump version number to schedule for next release

dshkol and others added 25 commits November 11, 2025 21:31
Performance improvements:
- Replace repeated rbind() in loops with list accumulation + bind_rows()
- Cache full vector list once instead of repeated list_census_vectors() calls
- Affects parent_census_vectors() and child_census_vectors()

Changes:
- Add testthat and microbenchmark to Suggests in DESCRIPTION
- Optimize parent_census_vectors() and child_census_vectors() in R/census_vectors.R
- Add comprehensive unit tests in tests/testthat/test-census_vectors.R
- Add benchmark script in benchmarks/benchmark_rbind_loops.R

Expected performance gains: 10-100x for deep hierarchies

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Created three benchmark scripts:
- benchmark_rbind_loops.R: Basic benchmark comparing old vs new rbind approach
- benchmark_realistic.R: Realistic hierarchy test (87K vectors, 8 levels)
- benchmark_cache_improvement.R: Demonstrates the key optimization

Key findings:
- parent_census_vectors: 1.92x faster (cache optimization)
- child_census_vectors: 1.23x faster (cache optimization)
- Caching full vector list once eliminates repeated I/O and deserialization

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Performance improvements:
- Replace nested lapply/sapply with pre-allocated vectors
- Add early returns for edge cases (empty, single word, short text)
- Use simple for loop with vectorized paste operations

Changes:
- Optimize n-gram generation in semantic_search() (R/vector_discovery.R)
- Add 17 comprehensive unit tests (tests/testthat/test-semantic_search.R)
- Add benchmark script (benchmarks/benchmark_semantic_search.R)

Performance gains: 1.4x faster (30-40% speedup)
- 100 vectors: 1.37x speedup
- 500 vectors: 1.42x speedup
- 1000 vectors: 1.43x speedup

All tests passing (43 total)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- PERFORMANCE_SUMMARY.md: Comprehensive technical summary of all optimizations
- NEWS.md: User-facing changelog for v0.5.8 with performance improvements
- Documents 1.2-1.9x speedups in key functions
- Details testing infrastructure (43 unit tests)
- Provides benchmark reproduction instructions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Detailed performance improvement documentation
- Backward compatibility guarantees
- Trade-off analysis (memory vs speed)
- Reverse dependency impact assessment
- Testing and benchmarking details
- Migration path (no action required for users)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Complete overview document covering:
- Performance gains summary (1.2-1.9x speedups)
- Testing and quality assurance (43 tests)
- Trade-offs and risk analysis (LOW risk)
- Impact on users and maintainers
- Recommendations and next steps

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Merge branch 'main' into v0.5.11

# Conflicts:
#	DESCRIPTION
#	NEWS.md
#	README.md
#	cran-comments.md
#	docs/404.html
#	docs/LICENSE-text.html
#	docs/articles/Dwellings_by_document_type_cross_tabulation.html
#	docs/articles/Making_maps_with_cancensus.html
#	docs/articles/Taxfiler_Data.html
#	docs/articles/cancensus.html
#	docs/articles/data_discovery.html
#	docs/articles/index.html
#	docs/articles/intersecting_geometries.html
#	docs/articles/statcan_attribute_files.html
#	docs/articles/statcan_wds.html
#	docs/authors.html
#	docs/index.html
#	docs/news/index.html
#	docs/pkgdown.yml
#	docs/reference/CODES_TABLE.html
#	docs/reference/COV_SKYTRAIN_STATIONS.html
#	docs/reference/add_unique_names_to_region_list.html
#	docs/reference/as_census_region_list.html
#	docs/reference/census_vectors.html
#	docs/reference/child_census_vectors.html
#	docs/reference/dataset_attribution.html
#	docs/reference/explore_census_regions.html
#	docs/reference/explore_census_vectors.html
#	docs/reference/find_census_vectors.html
#	docs/reference/get_census.html
#	docs/reference/get_census_geometry.html
#	docs/reference/get_intersecting_geometries.html
#	docs/reference/get_recalled_database.html
#	docs/reference/get_statcan_geo_suite.html
#	docs/reference/get_statcan_geographic_attributes.html
#	docs/reference/get_statcan_geographies.html
#	docs/reference/get_statcan_geography_relationships.html
#	docs/reference/get_statcan_wds_data.html
#	docs/reference/get_statcan_wds_metadata.html
#	docs/reference/index.html
#	docs/reference/label_vectors.html
#	docs/reference/list_cancensus_cache.html
#	docs/reference/list_census_datasets.html
#	docs/reference/list_census_regions.html
#	docs/reference/list_census_vectors.html
#	docs/reference/list_recalled_cached_data.html
#	docs/reference/parent_census_vectors.html
#	docs/reference/remove_from_cancensus_cache.html
#	docs/reference/remove_recalled_cached_data.html
#	docs/reference/search_census_regions.html
#	docs/reference/search_census_vectors.html
#	docs/reference/set_cancensus_api_key.html
#	docs/reference/set_cancensus_cache_path.html
#	docs/reference/show_cancensus_api_key.html
#	docs/reference/show_cancensus_cache_path.html
- Fixed "API ket" → "API key" (appeared twice per message, in 3 locations)
- Fixed "save is permanently in our" → "save it permanently in your"
- Affected files: R/cancensus.R (lines 144, 209), R/intersect_geometry.R (line 79)
- Add retry_api_call() helper with exponential backoff for transient failures
- Add format_bytes() helper for human-readable download size display
- Add retry and max_retries parameters to get_census()
- Report download size for data and geometry downloads when quiet=FALSE
- Report number of geographic features being processed
New function that displays census vector hierarchies as an ASCII tree,
helping users understand parent-child relationships between variables.

Features:
- Displays hierarchical structure with Unicode box-drawing characters
- Supports max_depth parameter to limit tree depth
- Optional show_type parameter to display Total/Male/Female types
- Marks leaf nodes that have no children
- Works with character vector codes or tibbles from list_census_vectors()
New features:
- Add preserve_suppression_flags parameter to get_census()
  - When TRUE, creates _flag columns preserving original suppression codes
  - Codes include 'x', 'X', 'F', '...', '..', '-', 'N', '*', '**'

- New census_data_quality() function for data quality analysis
  - Reports missing value counts and percentages per vector
  - Shows detailed breakdown by suppression type when flags available
  - Warns when missing rate exceeds threshold (default 20%)
  - Suggests coarser geography for better data coverage

This helps users understand data suppression patterns from Statistics Canada
and make informed decisions about geographic aggregation levels.
Add data quality analysis and suppression flag preservation
Add visualize_vector_hierarchy() for ASCII tree display
Merge branch 'feature/progress-and-retry' into v0.5.11

# Conflicts:
#	R/cancensus.R
#	man/get_census.Rd
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