Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging all Python developments so far to the main branch #241

Merged
merged 54 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
af62959
update readme with disclaimer
ltsaprounis Mar 22, 2023
fc78a6e
Merge pull request #203 from ltsaprounis/start-smooth-for-python
Mar 22, 2023
4e00b3b
Merge remote-tracking branch 'upstream/master' into start-smooth-for-…
ltsaprounis Sep 21, 2023
91d88ec
update gitignore with python stuff
ltsaprounis Sep 21, 2023
f4d60ee
add template code from python-cpp-experimnets
ltsaprounis Sep 21, 2023
faff3fc
added carma (armadillo-numpy support) as submodule on release tag v0.6.7
ltsaprounis Sep 21, 2023
712202f
add example code for pybind11 and carma 'my_linalg'
ltsaprounis Sep 22, 2023
1c3d94e
move python example files in separate dir
ltsaprounis Sep 23, 2023
94649e4
move python example files in separate dir
ltsaprounis Sep 23, 2023
0c2c295
Merge pull request #206 from ltsaprounis/start-smooth-for-python
Sep 27, 2023
a349f66
modified adamGeneral.cpp/h and created first pybind11 wrapper till it…
ltsaprounis Oct 25, 2023
6ccc35d
fixed python import
ltsaprounis Oct 25, 2023
72aa827
Merge pull request #207 from ltsaprounis/start-smooth-for-python
Oct 25, 2023
dddd1ca
1/2-way there for the sma forecasts
ltsaprounis Nov 1, 2023
de3b4cd
Merge pull request #208 from config-i1/master
Nov 1, 2023
11b5614
Merge pull request #209 from ltsaprounis/start-smooth-for-python
Nov 2, 2023
218949c
Redefined lags_model_all and related objects. Just trying to see how …
Nov 2, 2023
fd356af
Merge pull request #210 from config-i1/master
Nov 10, 2023
a737453
Renamed the "profilesObserved" into "indexLookupTable".
Nov 10, 2023
4ea303f
Merge pull request #211 from config-i1/master
Nov 10, 2023
8c82fd5
Merge pull request #212 from config-i1/master
Nov 16, 2023
93049b1
functional adam_profile code & test script for debugging
ltsaprounis Nov 22, 2023
675b804
Merge pull request #214 from ltsaprounis/start-smooth-for-python
Nov 22, 2023
3b9a533
Had to amend find_package() to include the path to armadillo manually…
Nov 23, 2023
5a42f6f
Tuning CMakeLists.txt to remove redundant stuff
Nov 29, 2023
3bc5fa0
This now works on the PC of @config-i1. Had to do a bit of a manual t…
Nov 30, 2023
7537c7e
ruff for linting and formatting and CI with linting step
ltsaprounis Dec 20, 2023
18873e9
remove dummy my_linalg module
ltsaprounis Dec 20, 2023
d96603b
pass all ruff checks (not full scope of rules)
ltsaprounis Dec 20, 2023
88e9b10
added N rules in ruff rule scope.
ltsaprounis Dec 20, 2023
d1641dc
small comment in pyproject.toml
ltsaprounis Jan 8, 2024
c0b48b2
transfer adam_forecaster
ltsaprounis Feb 13, 2024
9e86476
Merge pull request #216 from ltsaprounis/adam_forecaster
Feb 13, 2024
cb87118
Merge pull request #219 from config-i1/master
Apr 29, 2024
c22149d
Merge pull request #233 from config-i1/master
config-i1 Nov 29, 2024
8fb29e5
trying to commit again
FilTheo Dec 13, 2024
db4828a
Merge pull request #235 from FilTheo/Python
config-i1 Dec 13, 2024
0457a4c
full adam example (beta)
FilTheo Jan 24, 2025
8cdc65e
step-by-step functions example
FilTheo Jan 24, 2025
f50e8ff
updated core functions
FilTheo Jan 24, 2025
1ba964d
Merge pull request #236 from FilTheo/Python
config-i1 Jan 24, 2025
15d23f6
Ignore python folder
config-i1 Jan 24, 2025
999ef4b
Merge pull request #237 from config-i1/master
config-i1 Jan 24, 2025
62057d8
Trying to fix the bloody CRAN issue with UBSAN
config-i1 Feb 2, 2025
b5e4936
Submitted to CRAN
config-i1 Feb 2, 2025
c5dafb8
Trying to fix this fucking shit!
config-i1 Feb 3, 2025
f58045b
Don't check on pushes
config-i1 Feb 3, 2025
4fad396
Hoping to fix the issue with the nloptr on UBSAN
config-i1 Feb 3, 2025
ad7eb35
Name all chunks in the vignette
config-i1 Feb 3, 2025
6b07006
Second try, submitting to CRAN
config-i1 Feb 3, 2025
99e7fcb
Submitted to CRAN
config-i1 Feb 3, 2025
a1f997a
Ignore yet another python folder
config-i1 Feb 11, 2025
fa55ade
Merge pull request #239 from config-i1/master
config-i1 Feb 11, 2025
5dc42f0
Merge pull request #240 from config-i1/master
config-i1 Feb 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ man-roxygen
^revdep$
cran-comments.md
^CRAN-SUBMISSION$
python
src/python_examples
16 changes: 16 additions & 0 deletions .github/workflows/python_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Python CI

on:
push:
branches: [Python]
pull_request:
branches: [Python]

jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
with:
src: "./python"
20 changes: 13 additions & 7 deletions .github/workflows/ubuntu-gcc-ubsan.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Script generated by ChatGPT

name: R Package UBSan Check

on:
pull_request:
workflow_dispatch:
branches:
- main

jobs:
ubsan-check:
Expand All @@ -27,18 +26,25 @@ jobs:

- name: Install R package dependencies
run: |
Rscript -e 'install.packages(c("remotes", "devtools", "r-lib/pkgbuild", "r-lib/pkgdown"))'
Rscript -e 'install.packages(c("remotes", "devtools", "pkgbuild", "pkgdown", "rcmdcheck"))'
Rscript -e 'remotes::install_deps(dependencies = TRUE)'

- name: Install R-devel
- name: Install R-devel with UBSan
run: |
wget https://stat.ethz.ch/R/daily/R-devel.tar.gz
tar -xzf R-devel.tar.gz
cd R-devel
./configure --enable-strict-barrier --with-ubsan --with-gcc --with-x=no
make
make -j$(nproc)
echo "R-devel installed."

- name: Verify R-devel installation
run: |
cd R-devel
./bin/R --version
./bin/Rscript -e 'sessionInfo()'

- name: Run UBSan checks
run: |
R CMD check --as-cran --use-valgrind --no-manual .
export PATH=$(pwd)/R-devel/bin:$PATH
R CMD check --as-cran --use-valgrind --no-manual --no-build-vignettes .
143 changes: 143 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,146 @@ vignettes/rsconnect
vignettes/Figs
# Rprofile
.Rprofile

########################
### python gitignore ###
########################

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

#IDEs
.vscode

# memory system file
.DS_Store

#vim swap files
*.swp
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/libs/carma"]
path = src/libs/carma
url = https://github.com/RUrlus/carma.git
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 4.1.0
Date: 2024-10-01 13:06:02 UTC
SHA: feb08010ab5a8340b3811ff3f1145ba32997cb43
Version: 4.1.1
Date: 2025-02-03 12:37:40 UTC
SHA: 6b0700643ac3905c45e0ce2c29c80865b61098c8
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: smooth
Type: Package
Title: Forecasting Using State Space Models
Version: 4.1.1.41005
Date: 2025-01-05
Version: 4.1.1
Date: 2025-02-03
Authors@R: person("Ivan", "Svetunkov", email = "ivan@svetunkov.com", role = c("aut", "cre"),
comment="Senior Lecturer at Centre for Marketing Analytics and Forecasting, Lancaster University, UK")
URL: https://github.com/config-i1/smooth
Expand Down
3 changes: 2 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
smooth v4.1.1 (Release data: 2025-01-05)
smooth v4.1.1 (Release data: 2025-02-03)
=======

Changes:
Expand All @@ -10,6 +10,7 @@ Bugfixes:
* Corrected the author details in the documentation.
* reapply() would not work with bootstrap in case of negative data. Now it does.
* Added a check in adam() to make sure that model is not estimated when all parameters are provided in case of ARIMA.
* 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.


smooth v4.1.0 (Release data: 2024-10-01)
Expand Down
9 changes: 5 additions & 4 deletions R/adamGeneral.R
Original file line number Diff line number Diff line change
Expand Up @@ -3049,10 +3049,11 @@ parametersChecker <- function(data, model, lags, formulaToUse, orders, constant=
# See if the estimation of the model is not needed (do we estimate anything?)
if(!any(c(etsModel & c(persistenceLevelEstimate, persistenceTrendEstimate,
persistenceSeasonalEstimate, phiEstimate,
(initialType!="complete") & c(initialLevelEstimate,
initialTrendEstimate,
initialSeasonalEstimate)),
arimaModel & c(arEstimate, maEstimate, (initialType!="complete") & initialEstimate & initialArimaEstimate),
all(initialType!=c("complete","backcasting")) & c(initialLevelEstimate,
initialTrendEstimate,
initialSeasonalEstimate)),
arimaModel & c(arEstimate, maEstimate,
all(initialType!=c("complete","backcasting")) & initialEstimate & initialArimaEstimate),
xregModel & c(persistenceXregEstimate, (initialType!="complete") & initialXregEstimate),
constantEstimate,
otherParameterEstimate))){
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[![Downloads](https://cranlogs.r-pkg.org/badges/smooth)](https://cran.r-project.org/package=smooth)
[![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)

# ATTENTION: THIS IS AN EXPERIMENTAL BRANCH AIMING TO ADD A PYTHON API FOR SMOOTH!

The package _smooth_ contains several smoothing (exponential and not) functions that are used in forecasting.

![hex-sticker of the smooth package for R](https://github.com/config-i1/smooth/blob/master/man/figures/smooth-web.png?raw=true)
Expand Down
12 changes: 10 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
---
title: "Cran Comments"
author: "Ivan Svetunkov"
date: "01 October 2024"
date: "03 February 2025"
output: html_document
---

## Update
I think this should fix the issue with the clang-UBSAN, gcc-UBSAN.

Also, the suggested package `legion` has been submitted to CRAN as well, and will become available soon.


## Version
This is ``smooth`` package, v4.1.0.
This is ``smooth`` package, v4.1.1.

This is a try to fix the UBSAN issue on CRAN.

## Test environments
* local Ubuntu 24.04.1, R 4.4.1
Expand Down
56 changes: 56 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
cmake_minimum_required(VERSION 3.16)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)

project(smooth VERSION 0.0.1)

if(SKBUILD)
message(STATUS "The project is built using scikit-build")
endif()

# Pybind11
find_package(pybind11 REQUIRED)

# CARMA
ADD_SUBDIRECTORY(../src/libs/carma carma)

# BLAS and LAPACK. Needed by Armadillo
find_package(BLAS)
find_package(LAPACK)
if(LAPACK_FOUND AND BLAS_FOUND)
set(lapackblas_libraries ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
else()
# IS: This is where they are on my system. This might change from one OS to another
set(lapackblas_libraries "/usr/lib/x86_64-linux-gnu/")
endif()

# Armadillo
find_package(armadillo)
IF(NOT ARMADILLO_FOUND)
set(ARMADILLO_INCLUDE_DIRS "/usr/lib/")
ENDIF()
include_directories(${ARMADILLO_INCLUDE_DIRS})

# Adam General
pybind11_add_module(_adam_general ../src/python_examples/adamGeneral.cpp)
target_include_directories(_adam_general PRIVATE ../src/python_examples/.)
target_link_libraries(_adam_general PRIVATE carma::carma ${ARMADILLO_LIBRARIES} ${lapackblas_libraries})
install(TARGETS _adam_general DESTINATION smooth/adam_general)


# Old experimental stuff by Leo
# code to add the pybind11 cpp module, look at demo project
# (https://github.com/ltsaprounis/python-cpp-experiments/tree/main) for details.
#pybind11_add_module(_my_linalg ../src/python_examples/my_linalg.cpp)

# add CARMA as a subdirectory
#add_subdirectory(../src/libs/carma build)
#target_link_libraries(_my_linalg
# PRIVATE carma::carma
# ${ARMADILLO_LIBRARIES}
#)

# install(TARGETS _my_linalg DESTINATION smooth/my_linalg)

33 changes: 33 additions & 0 deletions python/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.PHONY: all lint test install environment

SRC_DIR = smooth

lint:
flake8 $(SRC_DIR)
pydocstyle $(SRC_DIR)

test:
pytest $(SRC_DIR)

install:
pip install -e ".[dev]"

environment:
(\
echo "> Creating venv"; \
python -m venv .venv; \
source .venv/bin/activate; \
echo "> Installing local package in editable mode"; \
pip install -e ".[dev]"; \
echo "> Making venv available in jupyter notebooks"; \
python -m ipykernel install --name=$(SRC_DIR); \
jupyter kernelspec list; \
echo "> Installing pre-commit"; \
pre-commit install; \
)

clean:
echo "> Removing virtual environment"
rm -r .venv
echo "> Uninstalling from jupyter"
jupyter kernelspec uninstall $(SRC_DIR)
Loading
Loading