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

Dev #20

Merged
merged 25 commits into from
Jun 7, 2024
Merged

Dev #20

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a39cc33
new SumSquareReference class
bmeyers Apr 19, 2023
1e44865
this is a test commit for educational purposes
bmeyers Apr 19, 2023
c0e4afa
undoing last commit
bmeyers Apr 19, 2023
d2fdd8e
duck typing input
bmeyers May 1, 2023
002f875
q and r should no longer be hard-coded to zero
bmeyers May 1, 2023
f222364
work on the SumSquareReference class
bmeyers May 1, 2023
dadc75c
aggregate class needs to check for q and r attributes and handles the…
bmeyers May 1, 2023
011ba4f
update default values for q and r in base class
bmeyers May 1, 2023
eed5032
Merge branch 'main' of github.com:cvxgrp/optimal-signal-decomposition…
bmeyers May 1, 2023
819acaf
fourier basis class
bmeyers May 8, 2023
94af0b3
new class for setting values at certain indices equal to a number
bmeyers May 16, 2024
e0d14cc
Merge pull request #19 from cvxgrp/dev2
bmeyers May 16, 2024
9db2b76
Merge pull request #15 from cvxgrp/feature
bmeyers May 16, 2024
bf736e3
work on Fourier basis class
bmeyers May 17, 2024
059c000
Set 'r' to be zero always. Allows weighting matrix inside sum_abs class
bmeyers Jun 1, 2024
8e661e6
update package and workflows
pluflou Jun 6, 2024
09d5ab9
fix tests dependencies
pluflou Jun 6, 2024
b824c8d
fix tests dependencies
pluflou Jun 6, 2024
3474348
fix tests dependencies, might need to clean later
pluflou Jun 6, 2024
ac101bd
rm dead link and add __version__ attr
pluflou Jun 6, 2024
4c81ce9
add _version module
pluflou Jun 7, 2024
c1f47bb
adjust triggers for test wf
pluflou Jun 7, 2024
332b588
Update build.yml
pluflou Jun 7, 2024
b89a791
Update test.yml
pluflou Jun 7, 2024
dc52dc6
Merge pull request #21 from pluflou/fix-deploy
bmeyers Jun 7, 2024
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
39 changes: 19 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"

- name: Install Twine
run: sudo $pythonLocation/bin/python3 -m pip install twine wheel
- name: Install Twine and Build
run: sudo pip install twine build

- name: Create the distribution
run: |
git fetch --prune --unshallow --tags
sudo $pythonLocation/bin/python3 setup.py sdist bdist_wheel
sudo python3 -m build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand All @@ -38,12 +38,12 @@ jobs:
shell: bash -l {0}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"

- name: Install Miniconda
uses: conda-incubator/setup-miniconda@v2
Expand All @@ -52,28 +52,27 @@ jobs:
activate-environment: ""
miniconda-version: "latest"

- name: Install the Mamba Dependencies
run: |
- name: Install the Conda Dependencies
run: |
conda config --set always_yes yes --set auto_update_conda false
conda update conda
conda install mamba -n base -c conda-forge
conda install -n base conda-libmamba-solver
mamba install python=3.9 "conda-build=3.21" colorama pip ruamel ruamel.yaml rich mamba jsonschema -c conda-forge
$pythonLocation/bin/python3 -m pip install -e .
conda install python=3.10 conda-build colorama pip ruamel ruamel.yaml rich jsonschema -c conda-forge
git fetch --prune --unshallow --tags
pip install -e .

# run install twice due to client-size to ensure all files downloaded
# echo yes before login to prevent anaconda bug breaking automation
# git tags MUST be fetched otherwise output will be blank
# bash variables cannot be used in github actions, must use actions specific syntax and methods
- name: Build the Anaconda Package
id: mambabuild
id: condabuild
run: |
mamba install anaconda-client
conda config --set anaconda_upload no
conda install anaconda-client
conda config --set anaconda_upload no --set solver libmamba
echo yes | anaconda login --username ${{ secrets.ANACONDA_CLOUD_USERNAME }} --password ${{ secrets.ANACONDA_CLOUD_PASSWORD }}
git fetch --prune --unshallow --tags
VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-) conda build . -c conda-forge -c stanfordcvxgrp --numpy 1.16.4
echo '::set-output name=gitversion::$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)'
VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-) conda build . -c anaconda -c conda-forge -c stanfordcvxgrp
echo "gitversion=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)" >> $GITHUB_OUTPUT

- name: Upload the Anaconda Package
id: condaload
Expand Down
83 changes: 43 additions & 40 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,96 +1,99 @@
name: Main Test

on:
pull_request:
push:
branches:
- master
tags:
- '*'
push:
pull_request:
branches: [main]
types: [opened, reopened]
jobs:
run-tests:
runs-on: ubuntu-latest
environment: test
strategy:
fail-fast: false
matrix:
python-version: [ "3.10", "3.11", "3.12" ]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
sudo $pythonLocation/bin/python3 -m pip install -r requirements.txt
sudo $pythonLocation/bin/python3 -m pip install pytest
sudo $pythonLocation/bin/python3 -m pip install -e .
- name: Install Python Dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install --system --break-system-packages -r requirements.txt
uv pip install --system --break-system-packages pytest pytest-cov pytest-github-report pytest-github-actions-annotate-failures

# Current unit test is not consistent. Occasionally fails despite usually passing. Needs to be fixed.
- name: Run Unit Tests
run: |
$pythonLocation/bin/python3 -m pytest --import-mode=append tests/
env:
pytest_github_report: true
pytest_verbosity: 2
run: pytest -v --cov=src --cov-report=xml --cov-report=term-missing --color=yes tests/

test-build-pypi:
needs: run-tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"

- name: Install Twine
run: sudo $pythonLocation/bin/python3 -m pip install twine wheel
- name: Install Twine and Build
run: sudo pip install twine build

- name: Create the distribution
run: |
git fetch --prune --unshallow --tags
sudo $pythonLocation/bin/python3 setup.py sdist bdist_wheel
sudo python3 -m build

test-build-conda:
needs: run-tests
runs-on: ubuntu-latest
# sets default shell to remove need for source to run the conda shell
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"

- name: Install Miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: true
activate-environment: ""
miniconda-version: "latest"

- name: Install the Mamba Dependencies
run: |
- name: Install the Conda Dependencies
run: |
conda config --set always_yes yes --set auto_update_conda false
conda update conda
conda install mamba -n base -c conda-forge
conda install -n base conda-libmamba-solver
mamba install python=3.9 "conda-build=3.21" colorama pip ruamel ruamel.yaml rich mamba jsonschema -c conda-forge
$pythonLocation/bin/python3 -m pip install -e .
conda install python=3.10 conda-build colorama pip ruamel ruamel.yaml rich jsonschema -c conda-forge
git fetch --prune --unshallow --tags
pip install -e .


# run install twice due to client-size to ensure all files downloaded
# echo yes before login to prevent anaconda bug breaking automation
# git tags MUST be fetched otherwise output will be blank
# bash variables cannot be used in github actions, must use actions specific syntax and methods
- name: Build the Anaconda Package
id: mambabuild
id: condabuild
run: |
mamba install anaconda-client
conda config --set anaconda_upload no
git fetch --prune --unshallow --tags
VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-) conda build . -c conda-forge -c stanfordcvxgrp --numpy 1.16.4
echo '::set-output name=gitversion::$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)'
conda install anaconda-client
conda clean --all
conda config --set anaconda_upload no --set solver libmamba
VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)test conda build . -c conda-forge -c stanfordcvxgrp
echo "gitversion=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)" >> $GITHUB_OUTPUT
35 changes: 20 additions & 15 deletions conda_recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package:
version: {{ environ.get('VERSION_FROM_GIT_TAG') }}

source:
git_url: https://github.com/cvxgrp/signal-decomposition
path: .. # checked out repo instead of main repo branch

build:
noarch: python
Expand All @@ -15,32 +15,37 @@ build:
requirements:
host:
- pip
- python >=3.9
- scipy
- numpy >=1.20
- scikit-learn
- cvxpy
- matplotlib
- python >=3.6

run:
- pip
- python
- scipy
- numpy >=1.20
- numpy
- scikit-learn
- cvxpy
- matplotlib
- qss
- clarabel
- pandas

test:
imports:
- gfosd
commands:
- pip check
requires:
- pip

about:
home: https://github.com/cvxgrp/signal-decomposition
license: BSD
license: BSD-3-Clause
license_file: LICENSE
license_family: BSD
license_file:
summary: Optimzation-based signal decomposition
doc_url:
dev_url:
summary: Optimization-based signal decomposition

extra:
recipe-maintainers:
- Bennet Myers
- Thistleman
- bmeyers
- thistleman
- pluflou
1 change: 1 addition & 0 deletions gfosd/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from ._version import version as __version__
from gfosd.problem import Problem
16 changes: 16 additions & 0 deletions gfosd/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# file generated by setuptools_scm
# don't change, don't track in version control
TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Tuple, Union
VERSION_TUPLE = Tuple[Union[int, str], ...]
else:
VERSION_TUPLE = object

version: str
__version__: str
__version_tuple__: VERSION_TUPLE
version_tuple: VERSION_TUPLE

__version__ = version = '0.0.2.dev30+gac101bd'
__version_tuple__ = version_tuple = (0, 0, 2, 'dev30', 'gac101bd')
5 changes: 3 additions & 2 deletions gfosd/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
SumAbs,
SumHuber,
SumQuantile,
SumCard)
SumCard,
SumSquareReference)
from gfosd.components.inequality_constraints import Inequality
from gfosd.components.basis_constraints import Basis, Periodic
from gfosd.components.basis_constraints import Basis, Periodic, Fourier
from gfosd.components.finite_set import FiniteSet, Boolean
from gfosd.components.aggregate import Aggregate
from gfosd.components.equality_constraints import (FirstValEqual,
Expand Down
8 changes: 7 additions & 1 deletion gfosd/components/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def prepare_attributes(self, T, p=1):
self._Pz = sp.block_diag([
c._Pz for c in self._gf_list
])
self._make_q()
# same logic as above but for q
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment: this is related to "close to input vector" class, which is incomplete and ready for use. q is still set to be zero for all implemented classes.

qx = self._gf_list[g_ix]._q[:self._gf_list[g_ix].x_size]
qz = np.concatenate([c._q[self._gf_list[g_ix].x_size:] for c in self._gf_list])
self._q = np.concatenate([qx, qz])
self._make_r()
self._gx = self._make_gx()
self._gz = self._make_gz()
Expand All @@ -53,6 +56,9 @@ def _make_P(self):
c._Pz for c in self._gf_list
])

def _make_r(self):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: still always set to zero

self._r = np.sum([c._r for c in self._gf_list])

def _make_gx(self):
gx = []
for ix, component in enumerate(self._gf_list):
Expand Down
4 changes: 2 additions & 2 deletions gfosd/components/base_graph_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ def _make_P(self, size):
return sp.dok_matrix(2 * (size,))

def _make_q(self):
self._q = None
self._q = np.zeros(self.x_size + self.z_size)

def _make_r(self):
self._r = None
self._r = 0

def _make_g(self, size):
return []
Expand Down
Loading