How matrix-profile-foundation/tsmp works
Project Type and Purpose
• tsmp is an R package (library) with performance‐critical routines in C++ (via Rcpp).
• It implements a suite of time‐series algorithms (STAMP, STOMP, SCRIMP++, etc.) and provides plotting, data loading, and a test harness.
• It targets both interactive R users and automated CI/CD (CRAN submission, pkgdown site).
Break Down Top‐Level Components
A. R API Layer
• Directory: R/
• Exposes user‐facing functions (tsmp(), find_motif(), sdts_train(), plot(), etc.).
• Uses RcppExports.R to call into C++ routines.
B. C++ Core Library
• Directory: src/
• Contains performance functions (math.cpp, mpx.cpp, windowfunc.cpp).
• Compiled into a shared library loaded by RcppExports.
C. Data & Resources
• Directory: data/ and inst/
• Prebuilt .rda datasets (mptoy, mp_test_data, motifs_discords_small) and API versioned examples.
• Schema files, word lists, and raw resources for examples.
D. Documentation
• Directory: man/, vignettes/, README.md, pkgdown/
• Rd manuals (man/*.Rd), tutorial vignettes, and pkgdown site config.
E. Testing & Quality
• Directory: tests/ (testthat, prints, figs, spelling)
• Ensures correctness of R API and C++ bindings.
F. Build & CI/CD
• Files: DESCRIPTION, NAMESPACE, Makevars, renv.lock
• CI workflows: .github/workflows/codeql-analysis.yml, .circleci/config.yml, appveyor.yml.
• Code coverage and CRAN checks (codecov.yml, .Rbuildignore, .covrignore).
G. Deployment Targets
• CRAN (R package repository)
• GitHub (source, CI badges)
• pkgdown site (matrixprofile.org/tsmp)
Relationships & Data Flows
• R API → RcppExports.R → C++ Shared Library → core algorithms
• tsmp functions → data/ → in‐memory objects
• tests drive R API, which in turn drives C++ code paths
• CI triggers: GitHub push → CI pipelines → test suite & coverage → pkgdown build → CRAN submission checks
Architectural Patterns
• Layered architecture:
• Presentation/API Layer (R code)
• Core Engine Layer (C++ via Rcpp)
• Data/Resources Layer (inst/, data/)
• Infrastructure Layer (CI, renv, package metadata)
• Modularization: each algorithm in its own R file, each C++ feature in its own source file.
• Automated build & deployment pipeline.