Skip to content

Commit 7a670ec

Browse files
authored
Merge pull request #241 from config-i1/Python
Merging all Python developments so far to the main branch
2 parents b297926 + 5dc42f0 commit 7a670ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+12780
-56
lines changed

.Rbuildignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ man-roxygen
99
^revdep$
1010
cran-comments.md
1111
^CRAN-SUBMISSION$
12+
python
13+
src/python_examples

.github/workflows/python_ci.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Python CI
2+
3+
on:
4+
push:
5+
branches: [Python]
6+
pull_request:
7+
branches: [Python]
8+
9+
jobs:
10+
linting:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: chartboost/ruff-action@v1
15+
with:
16+
src: "./python"

.github/workflows/ubuntu-gcc-ubsan.yaml

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
# Script generated by ChatGPT
2-
31
name: R Package UBSan Check
42

53
on:
64
pull_request:
7-
workflow_dispatch:
5+
branches:
6+
- main
87

98
jobs:
109
ubsan-check:
@@ -27,18 +26,25 @@ jobs:
2726
2827
- name: Install R package dependencies
2928
run: |
30-
Rscript -e 'install.packages(c("remotes", "devtools", "r-lib/pkgbuild", "r-lib/pkgdown"))'
29+
Rscript -e 'install.packages(c("remotes", "devtools", "pkgbuild", "pkgdown", "rcmdcheck"))'
3130
Rscript -e 'remotes::install_deps(dependencies = TRUE)'
3231
33-
- name: Install R-devel
32+
- name: Install R-devel with UBSan
3433
run: |
3534
wget https://stat.ethz.ch/R/daily/R-devel.tar.gz
3635
tar -xzf R-devel.tar.gz
3736
cd R-devel
3837
./configure --enable-strict-barrier --with-ubsan --with-gcc --with-x=no
39-
make
38+
make -j$(nproc)
4039
echo "R-devel installed."
4140
41+
- name: Verify R-devel installation
42+
run: |
43+
cd R-devel
44+
./bin/R --version
45+
./bin/Rscript -e 'sessionInfo()'
46+
4247
- name: Run UBSan checks
4348
run: |
44-
R CMD check --as-cran --use-valgrind --no-manual .
49+
export PATH=$(pwd)/R-devel/bin:$PATH
50+
R CMD check --as-cran --use-valgrind --no-manual --no-build-vignettes .

.gitignore

+143
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,146 @@ vignettes/rsconnect
2525
vignettes/Figs
2626
# Rprofile
2727
.Rprofile
28+
29+
########################
30+
### python gitignore ###
31+
########################
32+
33+
# Byte-compiled / optimized / DLL files
34+
__pycache__/
35+
*.py[cod]
36+
*$py.class
37+
38+
# C extensions
39+
*.so
40+
41+
# Distribution / packaging
42+
.Python
43+
build/
44+
develop-eggs/
45+
dist/
46+
downloads/
47+
eggs/
48+
.eggs/
49+
lib/
50+
lib64/
51+
parts/
52+
sdist/
53+
var/
54+
wheels/
55+
pip-wheel-metadata/
56+
share/python-wheels/
57+
*.egg-info/
58+
.installed.cfg
59+
*.egg
60+
MANIFEST
61+
62+
# PyInstaller
63+
# Usually these files are written by a python script from a template
64+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
65+
*.manifest
66+
*.spec
67+
68+
# Installer logs
69+
pip-log.txt
70+
pip-delete-this-directory.txt
71+
72+
# Unit test / coverage reports
73+
htmlcov/
74+
.tox/
75+
.nox/
76+
.coverage
77+
.coverage.*
78+
.cache
79+
nosetests.xml
80+
coverage.xml
81+
*.cover
82+
*.py,cover
83+
.hypothesis/
84+
.pytest_cache/
85+
86+
# Translations
87+
*.mo
88+
*.pot
89+
90+
# Django stuff:
91+
*.log
92+
local_settings.py
93+
db.sqlite3
94+
db.sqlite3-journal
95+
96+
# Flask stuff:
97+
instance/
98+
.webassets-cache
99+
100+
# Scrapy stuff:
101+
.scrapy
102+
103+
# Sphinx documentation
104+
docs/_build/
105+
106+
# PyBuilder
107+
target/
108+
109+
# Jupyter Notebook
110+
.ipynb_checkpoints
111+
112+
# IPython
113+
profile_default/
114+
ipython_config.py
115+
116+
# pyenv
117+
.python-version
118+
119+
# pipenv
120+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
121+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
122+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
123+
# install all needed dependencies.
124+
#Pipfile.lock
125+
126+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
127+
__pypackages__/
128+
129+
# Celery stuff
130+
celerybeat-schedule
131+
celerybeat.pid
132+
133+
# SageMath parsed files
134+
*.sage.py
135+
136+
# Environments
137+
.env
138+
.venv
139+
env/
140+
venv/
141+
ENV/
142+
env.bak/
143+
venv.bak/
144+
145+
# Spyder project settings
146+
.spyderproject
147+
.spyproject
148+
149+
# Rope project settings
150+
.ropeproject
151+
152+
# mkdocs documentation
153+
/site
154+
155+
# mypy
156+
.mypy_cache/
157+
.dmypy.json
158+
dmypy.json
159+
160+
# Pyre type checker
161+
.pyre/
162+
163+
#IDEs
164+
.vscode
165+
166+
# memory system file
167+
.DS_Store
168+
169+
#vim swap files
170+
*.swp

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "src/libs/carma"]
2+
path = src/libs/carma
3+
url = https://github.com/RUrlus/carma.git

CRAN-SUBMISSION

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Version: 4.1.0
2-
Date: 2024-10-01 13:06:02 UTC
3-
SHA: feb08010ab5a8340b3811ff3f1145ba32997cb43
1+
Version: 4.1.1
2+
Date: 2025-02-03 12:37:40 UTC
3+
SHA: 6b0700643ac3905c45e0ce2c29c80865b61098c8

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: smooth
22
Type: Package
33
Title: Forecasting Using State Space Models
4-
Version: 4.1.1.41005
5-
Date: 2025-01-05
4+
Version: 4.1.1
5+
Date: 2025-02-03
66
Authors@R: person("Ivan", "Svetunkov", email = "ivan@svetunkov.com", role = c("aut", "cre"),
77
comment="Senior Lecturer at Centre for Marketing Analytics and Forecasting, Lancaster University, UK")
88
URL: https://github.com/config-i1/smooth

NEWS

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
smooth v4.1.1 (Release data: 2025-01-05)
1+
smooth v4.1.1 (Release data: 2025-02-03)
22
=======
33

44
Changes:
@@ -10,6 +10,7 @@ Bugfixes:
1010
* Corrected the author details in the documentation.
1111
* reapply() would not work with bootstrap in case of negative data. Now it does.
1212
* Added a check in adam() to make sure that model is not estimated when all parameters are provided in case of ARIMA.
13+
* Tried to fix the issue with UBSAN, but not sure whether it worked, because it is not possible to reproduce it on my PC or github Actions... Just praying that it works.
1314

1415

1516
smooth v4.1.0 (Release data: 2024-10-01)

R/adamGeneral.R

+5-4
Original file line numberDiff line numberDiff line change
@@ -3049,10 +3049,11 @@ parametersChecker <- function(data, model, lags, formulaToUse, orders, constant=
30493049
# See if the estimation of the model is not needed (do we estimate anything?)
30503050
if(!any(c(etsModel & c(persistenceLevelEstimate, persistenceTrendEstimate,
30513051
persistenceSeasonalEstimate, phiEstimate,
3052-
(initialType!="complete") & c(initialLevelEstimate,
3053-
initialTrendEstimate,
3054-
initialSeasonalEstimate)),
3055-
arimaModel & c(arEstimate, maEstimate, (initialType!="complete") & initialEstimate & initialArimaEstimate),
3052+
all(initialType!=c("complete","backcasting")) & c(initialLevelEstimate,
3053+
initialTrendEstimate,
3054+
initialSeasonalEstimate)),
3055+
arimaModel & c(arEstimate, maEstimate,
3056+
all(initialType!=c("complete","backcasting")) & initialEstimate & initialArimaEstimate),
30563057
xregModel & c(persistenceXregEstimate, (initialType!="complete") & initialXregEstimate),
30573058
constantEstimate,
30583059
otherParameterEstimate))){

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
[![Downloads](https://cranlogs.r-pkg.org/badges/smooth)](https://cran.r-project.org/package=smooth)
44
[![R-CMD-check](https://github.com/config-i1/smooth/actions/workflows/test.yml/badge.svg)](https://github.com/config-i1/smooth/actions/workflows/test.yml)
55

6+
# ATTENTION: THIS IS AN EXPERIMENTAL BRANCH AIMING TO ADD A PYTHON API FOR SMOOTH!
7+
68
The package _smooth_ contains several smoothing (exponential and not) functions that are used in forecasting.
79

810
![hex-sticker of the smooth package for R](https://github.com/config-i1/smooth/blob/master/man/figures/smooth-web.png?raw=true)

cran-comments.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
---
22
title: "Cran Comments"
33
author: "Ivan Svetunkov"
4-
date: "01 October 2024"
4+
date: "03 February 2025"
55
output: html_document
66
---
77

8+
## Update
9+
I think this should fix the issue with the clang-UBSAN, gcc-UBSAN.
10+
11+
Also, the suggested package `legion` has been submitted to CRAN as well, and will become available soon.
12+
13+
814
## Version
9-
This is ``smooth`` package, v4.1.0.
15+
This is ``smooth`` package, v4.1.1.
16+
17+
This is a try to fix the UBSAN issue on CRAN.
1018

1119
## Test environments
1220
* local Ubuntu 24.04.1, R 4.4.1

python/CMakeLists.txt

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
set(CMAKE_CXX_STANDARD 17)
4+
set(CMAKE_CXX_STANDARD_REQUIRED True)
5+
set(CMAKE_CXX_EXTENSIONS OFF)
6+
7+
project(smooth VERSION 0.0.1)
8+
9+
if(SKBUILD)
10+
message(STATUS "The project is built using scikit-build")
11+
endif()
12+
13+
# Pybind11
14+
find_package(pybind11 REQUIRED)
15+
16+
# CARMA
17+
ADD_SUBDIRECTORY(../src/libs/carma carma)
18+
19+
# BLAS and LAPACK. Needed by Armadillo
20+
find_package(BLAS)
21+
find_package(LAPACK)
22+
if(LAPACK_FOUND AND BLAS_FOUND)
23+
set(lapackblas_libraries ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
24+
else()
25+
# IS: This is where they are on my system. This might change from one OS to another
26+
set(lapackblas_libraries "/usr/lib/x86_64-linux-gnu/")
27+
endif()
28+
29+
# Armadillo
30+
find_package(armadillo)
31+
IF(NOT ARMADILLO_FOUND)
32+
set(ARMADILLO_INCLUDE_DIRS "/usr/lib/")
33+
ENDIF()
34+
include_directories(${ARMADILLO_INCLUDE_DIRS})
35+
36+
# Adam General
37+
pybind11_add_module(_adam_general ../src/python_examples/adamGeneral.cpp)
38+
target_include_directories(_adam_general PRIVATE ../src/python_examples/.)
39+
target_link_libraries(_adam_general PRIVATE carma::carma ${ARMADILLO_LIBRARIES} ${lapackblas_libraries})
40+
install(TARGETS _adam_general DESTINATION smooth/adam_general)
41+
42+
43+
# Old experimental stuff by Leo
44+
# code to add the pybind11 cpp module, look at demo project
45+
# (https://github.com/ltsaprounis/python-cpp-experiments/tree/main) for details.
46+
#pybind11_add_module(_my_linalg ../src/python_examples/my_linalg.cpp)
47+
48+
# add CARMA as a subdirectory
49+
#add_subdirectory(../src/libs/carma build)
50+
#target_link_libraries(_my_linalg
51+
# PRIVATE carma::carma
52+
# ${ARMADILLO_LIBRARIES}
53+
#)
54+
55+
# install(TARGETS _my_linalg DESTINATION smooth/my_linalg)
56+

python/Makefile

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.PHONY: all lint test install environment
2+
3+
SRC_DIR = smooth
4+
5+
lint:
6+
flake8 $(SRC_DIR)
7+
pydocstyle $(SRC_DIR)
8+
9+
test:
10+
pytest $(SRC_DIR)
11+
12+
install:
13+
pip install -e ".[dev]"
14+
15+
environment:
16+
(\
17+
echo "> Creating venv"; \
18+
python -m venv .venv; \
19+
source .venv/bin/activate; \
20+
echo "> Installing local package in editable mode"; \
21+
pip install -e ".[dev]"; \
22+
echo "> Making venv available in jupyter notebooks"; \
23+
python -m ipykernel install --name=$(SRC_DIR); \
24+
jupyter kernelspec list; \
25+
echo "> Installing pre-commit"; \
26+
pre-commit install; \
27+
)
28+
29+
clean:
30+
echo "> Removing virtual environment"
31+
rm -r .venv
32+
echo "> Uninstalling from jupyter"
33+
jupyter kernelspec uninstall $(SRC_DIR)

0 commit comments

Comments
 (0)