Skip to content

Commit

Permalink
Import bug fixes, readme + action updates, and addressed divion error…
Browse files Browse the repository at this point in the history
… in FS step
  • Loading branch information
JoKra1 committed Nov 28, 2023
1 parent a3dec2e commit 501e8d9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ name: Python package
on:
push:
branches:
-stable
- stable
- main
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -50,7 +51,11 @@ jobs:
path: ./wheelhouse/*.whl

release:
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
# Only create release if pull-target was 'stable' or work-flow was triggered on 'stable'
if: github.ref_name == 'stable' || github.base_ref == 'stable'
needs:
- build
runs-on: ubuntu-latest
Expand All @@ -59,6 +64,9 @@ jobs:
contents: write # Necessary for creating releases apparently.

steps:

- name: Echo Branch
run: echo "${{ github.ref_name }} ${{ github.base_ref }}"

- name: Download Artifacts
uses: actions/download-artifact@v3
Expand Down
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@
## Description
``mssm`` is a toolbox to estimate Generalized Additive Mixed Models (GAMMs) semi Markov-switching GAMMs (sMs-GAMMs) and sMs Impulse Response GAMMs (sMs-IR-GAMMs).
The ``main`` branch is updated frequently to reflect new developments. The ``stable`` branch should reflect the latest releases. if you don't need the latest functionality, you
should install from the ``stable`` branch.
should install from the ``stable`` branch (see below for instructions).

## Installation
There are two options!

Option 1 is to build directly from source. This requires ``conda`` or an installation of [eigen](https://eigen.tuxfamily.org/index.php?title=Main_Page)(``setup.py`` then expects ``eigen`` in "usr/include/eigen3"). If you have ``conda`` installed
[install eigen from conda-forge](https://anaconda.org/conda-forge/eigen). After cloning and navigating into the downloaded repository you can then install via ``pip install . ``.
The easiest option is to install from pypi via ``pip``.

1) Setup a conda environment with python > 3.10
2) Install mssm via ``pip``

Currently, mssm can only be installed from [test.pypi](https://test.pypi.org/project/mssm/#description) because sign-ups are disabled for pypi. So to install ``mssm`` run:

Option 2 (currently being worked on) is to install one of the releases from the ``stable`` branch.
```
conda create -n mssm_env python=3.10
pip install -i https://test.pypi.org/simple/ mssm
```

Once ``mssm`` can be published to pypi, you can replace the second line with ``pip install mssm``. Note: pypi will only reflect releases on the ``stable`` branch. Pushes to main will however continue to be distributed to test.pypi, so if you need the latest changes you can get them from there.

You can also build directly from source. This requires ``conda`` or an installation of [eigen](https://eigen.tuxfamily.org/index.php?title=Main_Page)(``setup.py`` then expects ``eigen`` in "usr/local/include/eigen3". This will probably not work on windows.). Once you have ``conda`` installed,
[install eigen from conda-forge](https://anaconda.org/conda-forge/eigen). After cloning and navigating into the downloaded repository you can then install via ``pip install . ``.

## To get started

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies=["numpy >= 1.24.1",
"pandas >= 1.5.3",
"scipy >= 1.10.0"]
name = "mssm"
version = "0.1.0"
version = "0.1.1"
authors = [
{ name="Joshua Krause", email="jokra001@proton.me" }
]
Expand Down
8 changes: 7 additions & 1 deletion src/mssm/src/python/gamm_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import warnings
from .exp_fam import Family,Gaussian
from .penalties import PenType,id_dist_pen,translate_sparse
from ..cpp import cpp_solvers
import cpp_solvers

def cpp_chol(A):
return cpp_solvers.chol(A)
Expand All @@ -23,6 +23,12 @@ def step_fellner_schall_sparse(gInv,emb_SJ,Bps,cCoef,cLam,scale,verbose=False):

num = max(0,(gInv @ emb_SJ).trace() - Bps)
denom = max(0,cCoef.T @ emb_SJ @ cCoef)

# Especially when using Null-penalties denom can realisitically become
# equal to zero: every coefficient of a term is penalized away. In that
# case num /denom is not defined so we return directly.
if denom <= 0: # Prevent overflow
return 1e+7
nLam = scale * (num / denom) * cLam
nLam = max(nLam,1e-7) # Prevent Lambda going to zero
nLam = min(nLam,1e+7) # Prevent overflow
Expand Down

0 comments on commit 501e8d9

Please sign in to comment.