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

Ensure Translate/OutputSBML work on Octave and Matlab #175

Merged
merged 53 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6733096
- ensure to pass 1 into the mexCall as output parameter
fbergmann Oct 12, 2021
01e4ca3
- use nan rather than 0/0 (to avoid warnings)
fbergmann Oct 12, 2021
b521332
- need to install the correct files
fbergmann Oct 12, 2021
23ff1c3
- create basic octave ci script
fbergmann Oct 12, 2021
4845725
- ensure that common code is the same
fbergmann Oct 12, 2021
8ca1a2d
- move common code into separate file
fbergmann Oct 12, 2021
95218e1
- do not use global variables, pass them along where needed
fbergmann Oct 12, 2021
06afcae
update gitignore
skeating Oct 26, 2021
5336802
working breakdown
skeating Oct 26, 2021
da1f016
fixing tests
skeating Nov 1, 2021
9ddd01b
Merge remote-tracking branch 'origin/development' into matlab-octave-fun
skeating Nov 1, 2021
9627a6d
making headers - this does NOT build for me
skeating Nov 1, 2021
9dba082
multiple files
skeating Nov 4, 2021
afd34f7
use tmate
skeating Nov 17, 2021
e2e3cbb
take out tmate
skeating Nov 22, 2021
ec92de1
- compile additional files when using mkoctfile
fbergmann Nov 29, 2021
861b60b
- mexCallMATLABWithTrap does not exist in octave
fbergmann Nov 29, 2021
74bb5fb
- remove tmate session
fbergmann Nov 29, 2021
22c562d
Merge remote-tracking branch 'origin/matlab-octave-fun' into matlab-o…
skeating Dec 6, 2021
fec8ab8
dont create 'new' document
skeating Dec 30, 2021
e368b5f
unicode functions
skeating Dec 30, 2021
f12b923
add full set of tests to octave
skeating Dec 31, 2021
0e59921
try just one test
skeating Dec 31, 2021
cf381d9
syntax
skeating Dec 31, 2021
fd1910e
more syntax
skeating Dec 31, 2021
389c011
moved up a dir
skeating Dec 31, 2021
9924d8b
add all tests
skeating Dec 31, 2021
948871f
hopefully matches
skeating Dec 31, 2021
f4777fc
isdir deprecated
skeating Dec 31, 2021
7afaf7a
try to track actual error
skeating Dec 31, 2021
6053eb5
stupid mistake
skeating Dec 31, 2021
b70fa77
typo
skeating Jan 1, 2022
a1d2e4f
again
skeating Jan 1, 2022
5278af2
more changes to pointers
skeating Jan 1, 2022
e68547e
changing my pointers broke tests and 3 hrs did not solve things so pu…
skeating Jan 1, 2022
84d2698
add update to actions
skeating Jan 22, 2022
1ff0f26
maybe fix string adding
skeating Jan 22, 2022
23d1208
pass is octave arg
skeating Jan 22, 2022
0acbc74
return a non zero exit
skeating Jan 22, 2022
c02192b
add ;
skeating Jan 22, 2022
5bb17a0
remove debug statement
skeating Jan 30, 2022
85cd7e1
fixed greek encoding
skeating Jan 30, 2022
e9776eb
function not in octave
skeating Jan 30, 2022
d62632e
investigating octave fail
skeating Jan 31, 2022
7a9fff0
make displayLine a common function
skeating Jan 31, 2022
d8ce6f3
fix for newer octave version
skeating Apr 18, 2022
5500696
correctly identify octave
skeating Apr 18, 2022
01da9a4
octave doesnt cope with duplicate fieldnames
skeating Apr 18, 2022
2d57011
Merge remote-tracking branch 'origin/development' into matlab-octave-fun
skeating Apr 18, 2022
ea7c7b0
use generator expression to get libsbml file location
fbergmann Apr 29, 2022
8879366
allow to extract link information from import targets
fbergmann Apr 29, 2022
e340d80
fix compilation
fbergmann Apr 29, 2022
0c7155a
Merge remote-tracking branch 'origin/development' into matlab-octave-fun
skeating May 6, 2022
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
71 changes: 71 additions & 0 deletions .github/workflows/octave.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Octave

on: [push]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Checkout submodules
run: git submodule update --init --recursive

- name: update
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
sudo apt-get update

- name: add linux dependencies
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
sudo apt-get install swig liboctave-dev

- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure
# build dependencies
working-directory: ${{runner.workspace}}/build
shell: bash
run: |
cmake -DCMAKE_INSTALL_PREFIX=${{runner.workspace}}/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_BZIP2=ON -DWITH_CHECK=OFF -DWITH_EXPAT=ON -DWITH_LIBXML=OFF -DWITH_OCTAVE=ON $GITHUB_WORKSPACE

- name: Build
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE


- name: Install Strip
working-directory: ${{runner.workspace}}/build
run: cmake --install . --prefix instdir --strip

- name: Pack
working-directory: ${{runner.workspace}}/build/instdir
run: cmake -E tar cvzf ../octave_${{ matrix.os }}.tar.gz .

- name: Test
working-directory: ${{runner.workspace}}/build/instdir/lib/octave/site/oct/x86_64-pc-linux-gnu/test
shell: bash
run: LD_LIBRARY_PATH=../../../../.. octave --eval "runTests()"

- name: Upload
uses: actions/upload-artifact@v1
with:
path: ${{runner.workspace}}/build/octave_${{ matrix.os }}.tar.gz
name: octave_${{ matrix.os }}.tar.gz
5 changes: 5 additions & 0 deletions src/bindings/matlab/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
runTests.log
*.mex*
testout.xml
mytest.m
*.asv
test/Out-test1/*

9 changes: 8 additions & 1 deletion src/bindings/matlab/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,17 @@ endif()
if (EXTRA_INCLUDE_DIRS)
include_directories(${EXTRA_INCLUDE_DIRS})
endif(EXTRA_INCLUDE_DIRS)

SET(COMMON_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/ModelDetails.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/StructureFields.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/CommonFunctions.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Filenames.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/InputOutput.cpp" )

foreach(matlab_source_file "TranslateSBML" "OutputSBML")

add_library(matlab_binding_${matlab_source_file} SHARED "${CMAKE_CURRENT_SOURCE_DIR}/${matlab_source_file}.cpp")
add_library(matlab_binding_${matlab_source_file} SHARED "${CMAKE_CURRENT_SOURCE_DIR}/${matlab_source_file}.cpp" ${COMMON_FILES})
set_target_properties(matlab_binding_${matlab_source_file} PROPERTIES OUTPUT_NAME "${matlab_source_file}")
set_target_properties(matlab_binding_${matlab_source_file} PROPERTIES SUFFIX ".${MATLAB_MEX_EXT}")
set_target_properties(matlab_binding_${matlab_source_file} PROPERTIES PREFIX "")
Expand Down
114 changes: 114 additions & 0 deletions src/bindings/matlab/CommonFunctions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#include "CommonFunctions.h"


//
// report error/free memory and exit when error encountered

void
FreeMem(GV& gv)
{
/* destroy arrays created */
mxDestroyArray(gv.modelArray);
gv.modelArray = NULL;
}

void
reportError(const std::string&id, const std::string& message, GV& gv)
{
if (gv.freeMemory)
{
FreeMem(gv);
}

mexErrMsgIdAndTxt(id.c_str(), message.c_str());
}


void
displayLine(const std::string& line)
{
mxArray* mxErrors[1];
mxErrors[0] = mxCreateString(line.c_str());
mexCallMATLAB(0, NULL, 1, mxErrors, "disp");
mxDestroyArray(mxErrors[0]);
}


mxArray *
CreateIntScalar (int nValue)
{
mxArray * pArray;
int * panData;

pArray = mxCreateNumericMatrix(1,1,mxINT32_CLASS, mxREAL);
panData = (int *)mxGetData(pArray);
panData[0] = nValue;

return pArray;
}

const char* FIELDTYPE_STRINGS[] =
{
"bool"
, "char"
, "double"
, "int"
, "structure"
, "uint"
};


FieldType_t
getFieldType(const char* type)
{
if (type != NULL)
{
const FieldType_t lo = TYPE_BOOL;
const FieldType_t hi = (const FieldType_t)(TYPE_UNKNOWN - 1);

return (FieldType_t)util_bsearchStringsI(FIELDTYPE_STRINGS, type, lo, hi);
}
else
return TYPE_UNKNOWN;
}

// only used by OutputSBML
bool getRequiredStatus(const std::string& prefix, GV& gv)
{
bool required = false;

if (gv.reqdPkgPrefixes.contains(prefix))
{
required = true;
}

return required;
}

void populatePackageLists(GV& gv)
{
//reqdPkgPrefixes.append("comp");
//reqdPkgPrefixes.append("spatial");

gv.unreqdPkgPrefixes.append("fbc");
gv.unreqdPkgPrefixes.append("qual");
gv.unreqdPkgPrefixes.append("groups");
}

// only used by OutputSBML
bool
isUnknownType(std::string tc)
{
// TO DO
if (tc == "(Unknown SBML Type)")
return true;
else if (tc == "(Unknown SBML Fbc Type)")
return true;
else if (tc == "(Unknown SBML Groups Type)")
return true;
else if (tc == "(Unknown SBML Qual Type)")
return true;
else
return false;
}

24 changes: 24 additions & 0 deletions src/bindings/matlab/CommonFunctions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef COMMON_FUNTICONS_INCLUDED
#define COMMON_FUNTICONS_INCLUDED

#include <string>

#include "Variables.h"

void FreeMem(GV& gv);

void reportError(const std::string&id, const std::string& message, GV& gv);

void displayLine(const std::string& line);

mxArray * CreateIntScalar (int nValue);

FieldType_t getFieldType(const char* type);

bool getRequiredStatus(const std::string& prefix, GV& gv);

void populatePackageLists(GV& gv);

bool isUnknownType(std::string tc);

#endif // COMMON_FUNTICONS_INCLUDED
2 changes: 1 addition & 1 deletion src/bindings/matlab/ConvertFormulaToMathML.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
j = j+1;
x = SubFormula(j:length(SubFormula)-1);

if (exist('OCTAVE_VERSION', 'var'))
if (exist('OCTAVE_VERSION'))
ReplaceFormula = myRegexprep(SubFormula, n, x, 'once');
ReplaceFormula = myRegexprep(ReplaceFormula,regexptranslate('escape',x),n,2);
ReplaceFormula = myRegexprep(ReplaceFormula, 'nthroot', 'root', 'once');
Expand Down
Loading