Skip to content

Commit

Permalink
Merge pull request #8 from WISDEM/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
gbarter authored Oct 9, 2023
2 parents c380260 + 816cf65 commit 6c40bd8
Show file tree
Hide file tree
Showing 15 changed files with 411 additions and 168 deletions.
128 changes: 76 additions & 52 deletions .github/workflows/CI_pyFrame3DD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,85 +5,109 @@ on: [push, pull_request]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build_conda:
name: Build (${{ matrix.os }} Python ${{ matrix.python-version }})
build_pip:
name: Pip Build (${{ matrix.os }}) - ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -l {0}

strategy:
fail-fast: False
fail-fast: false #true
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: ["3.8", "3.9", "3.10"]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: Setup C/C++ Compiler
id: install_cc
uses: rlalik/[email protected]
with:
compiler: gcc #clang

- name: checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
id: cp
with:
python-version: ${{ matrix.python-version }}
update-environment: true

# Official way to do miniconda, but it messes with the worker environment and shell
- name: Install miniconda
uses: conda-incubator/setup-miniconda@v2
- name: Pip Install pyFrame3DD
env:
MESON_ARGS: -Dpython_target=${{ steps.cp.outputs.python-path }}
CC: '${{ steps.install_cc.outputs.cc }}'
CXX: '${{ steps.install_cc.outputs.cxx }}'
run: |
'${{ steps.cp.outputs.python-path }}' -m pip install -vv .[test]
- name: Test run
run: |
'${{ steps.cp.outputs.python-path }}' -m pytest test
build_conda:
name: Conda Build (${{ matrix.os }}) - ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -el {0}

strategy:
fail-fast: false #true
matrix:
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: checkout repository
uses: actions/checkout@v3

- uses: conda-incubator/setup-miniconda@v2
# https://github.com/marketplace/actions/setup-miniconda
with:
miniconda-version: "latest"
channels: conda-forge
#mamba-version: "*"
miniforge-version: "latest"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: environment.yml
activate-environment: test
auto-activate-base: false

# This is a less official, but more lightweight way to do miniconda
#- name: Install miniconda
# uses: s-weigand/setup-conda@v1
# # https://github.com/marketplace/actions/setup-conda
# with:
# update-conda: true
# python-version: ${{ matrix.python-version }}
# conda-channels: conda-forge
# activate-conda: true
#
#- name: Update environment
# run: |
# conda env update --file environment.yml
# Install dependencies of WISDEM specific to windows
- name: Add dependencies windows specific
if: contains( matrix.os, 'windows')
run: |
conda install -y m2w64-toolchain libpython
# Install compilers
- name: Add compilers
# Install dependencies of WISDEM specific to windows
- name: Add dependencies mac specific
if: false == contains( matrix.os, 'windows')
run: |
conda install compilers
conda install -y compilers
# Install dependencies of WISDEM specific to linux/mac
#- name: Add dependencies linux specific
# if: false == contains( matrix.os, 'windows')
# run: |
# conda install ninja
# conda init bash
# Install
- name: Debug
run: |
conda list
printenv
# Install dependencies of WISDEM specific to windows
#- name: Add dependencies windows specific
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# with:
# detached: true
# if: contains( matrix.os, 'windows')
# run: |
# conda install -y m2w64-toolchain libpython


# Install
- name: Conda Install pyFrame3DD
env:
MESON_ARGS: ""
run: |
python setup.py develop
# Peek
#- name: Library name
# run: |
# ls
# echo "BREAK"
# ls pyframe3dd
# echo "BREAK"
# ls meson_build/pyframe3dd
python -m pip install .
# Run tests
- name: Conda Run pytest
- name: Test run
run: |
pytest test
python -m pytest test
71 changes: 71 additions & 0 deletions .github/workflows/Publish_pyFrame3DD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and upload to PyPI

# Build on every branch push, tag push, and pull request change:
#on: [push, pull_request]
# Alternatively, to publish when a (published) GitHub Release is created, use the following:
on:
release:
types:
- published

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Setup C/C++ Compiler
id: install_cc
uses: rlalik/[email protected]
with:
compiler: gcc #clang

- name: Checkout
uses: actions/checkout@v4

- name: Build wheels
env:
CC: '${{ steps.install_cc.outputs.cc }}'
CXX: '${{ steps.install_cc.outputs.cxx }}'
uses: pypa/[email protected]

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
#if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist

- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.pypi_password }}
# To test: repository_url: https://test.pypi.org/legacy/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ nosetests.xml
.mr.developer.cfg
.project
.pydevproject

# Emacs
*~
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ There is example code that shows usage contained in ``examples/exB.py``. This f

## Prerequisites

pyMAP requires a C compiler
pyFrame3DD requires a C compiler

## Install

For detailed installation instructions of WISDEM modules see <https://github.com/WISDEM/WISDEM> or to install pyFrame3DD by itself do:

$ python setup.py install
$ pip install WISDEM-pyFrame3DD

## Unit Tests

$ python test/test_frame.py
$ pytest test

For software issues please use <https://github.com/WISDEM/pyFrame3DD/issues>. For functionality and theory related questions and comments please use the NWTC forum for [Systems Engineering Software Questions](https://wind.nrel.gov/forum/wind/viewtopic.php?f=34&t=1002).


## License

Frame3DD uses the GNU GPL so this code must also be under the same license.
Frame3DD uses the GNU GPL so this code must also be under the same license. The larger WISDEM code has a special dispensation to use the Apache License.

2 changes: 0 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
name: test

channels:
- conda-forge
- defaults
Expand Down
8 changes: 6 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
project('pyframe3dd', 'c',
version : '1.2',
meson_version: '>= 0.60',
meson_version: '>= 1.1',
default_options: [
'buildtype=debugoptimized',
],
Expand All @@ -16,6 +15,11 @@ if m_dep.found()
add_project_link_arguments('-lm', language : 'c')
endif

is_windows = host_machine.system() == 'windows'
add_project_arguments('-DANSI=1', language : 'c')
if is_windows
add_project_arguments('-D_WIN64=1', language : 'c')
endif

# https://mesonbuild.com/Python-module.html
# Here we differentiate from the python used by meson, py3_command, and that python target, py3_target. This is useful
Expand Down
20 changes: 9 additions & 11 deletions pyframe3dd/src/HPGmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,10 @@ void ldl_mprove(
){
double sdp; /* accumulate the r.h.s. in double precision */
double *resid, /* the residual error */
rms_resid_new=0, /* the RMS error of the mprvd solution */
*dvector(); /* allocate memory for a vector of doubles */
rms_resid_new=0; /* the RMS error of the mprvd solution */
//*dvector(); /* allocate memory for a vector of doubles */
int j,i, pd;
void ldl_dcmp(),
free_dvector();
//void ldl_dcmp(), free_dvector();

resid = dvector(1,n);

Expand Down Expand Up @@ -492,11 +491,10 @@ void ldl_mprove_pm (
double sdp; // accumulate the r.h.s. in double precision
double *dx, // the residual error
*dc, // update to partial r.h.s. vector, c
rms_resid_new=0.0, // the RMS error of the mprvd solution
*dvector(); // allocate memory for a vector of doubles
rms_resid_new=0.0; // the RMS error of the mprvd solution
//*dvector(); // allocate memory for a vector of doubles
int j,i, pd;
void ldl_dcmp(),
free_dvector();
//void ldl_dcmp(), free_dvector();

dx = dvector(1,n);
dc = dvector(1,n);
Expand Down Expand Up @@ -581,10 +579,10 @@ void PSB_update (
void pseudo_inv(
double **A, double **Ai, int n, int m, double beta, int verbose
){
double *diag, *b, *x, **AtA, **AtAi, tmp, tr_AtA=0.0,
*dvector(), **dmatrix(), error;
double *diag, *b, *x, **AtA, **AtAi, tmp, tr_AtA=0.0, error;
//*dvector(), **dmatrix(), error;
int i,j,k, ok;
void ldl_dcmp(), ldl_mprove(), free_dvector(), free_dmatrix();
//void ldl_dcmp(), ldl_mprove(), free_dvector(), free_dmatrix();

diag = dvector(1,n);
b = dvector(1,n);
Expand Down
Loading

0 comments on commit 6c40bd8

Please sign in to comment.