-
Notifications
You must be signed in to change notification settings - Fork 0
Hsaito/python wrapped matlab #2
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @taiseiKMC, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a Python-wrapped MATLAB Simulink model into the FalCAuN framework, enabling the verification of Simulink models using adaptive STL learning. It includes a Kotlin example demonstrating the integration, a Python implementation of the SUL, and enhancements to the Java code to support batch processing of input signals for improved performance. Additionally, new tests have been added to ensure the functionality of the new features.
Highlights
- Kotlin Example: Added a new Kotlin script
ATS1-python.ktsthat demonstrates the usage of FalCAuN-core and FalCAuN-python with a Python-wrapped Simulink model. This script sets up an automatic transmission model, defines STL properties, and runs verification using GA-based equivalence testing. - Python SUL Implementation: Created a Python script
autotrans_matlab.pythat wraps a Simulink model for automatic transmission control. It includes classes for signal handling and Simulink interaction, providing a System Under Learning (SUL) interface compatible with FalCAuN. - PythonModel Enhancement: Modified
PythonModel.javato include an optionalexecmethod for batch processing of input signals. This allows for more efficient execution when the Python model provides anexecfunction. - NumericSUL Update: Updated
PythonNumericSUL.javato utilize theexecmethod in the Python model if available, improving performance by processing input signals in batches instead of one at a time. - Testing Improvements: Added a new test case
numericExecuteTest2inPythonNumericSULTest.javato verify the functionality of theexecmethod in the Python model. Also, a new python scripttest_numeric_sul_with_exec.pywas added to support this test.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a Python-wrapped MATLAB SUL and integrates it into the existing framework. A key addition is the exec method for batch processing of inputs, which is a good performance optimization. The changes also include a new Kotlin example script demonstrating the usage with an automatic transmission model.
| """ | ||
|
|
||
| (t, y) = self.simulinkModel.step(inputSignal) | ||
| y = np.array(y[0], dtype=np.float64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The simulinkModel.step() method can return an empty list for y. In such cases, accessing y[0] will raise an IndexError. You should add a check to handle an empty y before accessing its elements. This same vulnerability exists in the exec method on line 312.
| y = np.array(y[0], dtype=np.float64) | |
| (t, y) = self.simulinkModel.step(inputSignal) | |
| if not y: | |
| return [] | |
| y = np.array(y[0], dtype=np.float64) |
| signalStep = 1.0 | ||
| simulinkSimulationStep = 0.0025 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
690a5a7 to
672c52d
Compare
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a Python-wrapped MATLAB SUL (System Under Learning) and integrates it into the FalCAuN framework. The key change is adding an exec method for batch processing of signals, which is a significant performance optimization. The changes span across Java, Kotlin, and Python, including new example scripts and tests. I focused on improving code clarity, maintainability, and idiomatic usage of language features in Kotlin and Python.
| var updaterLogger = LoggerFactory.getLogger(AbstractAdaptiveSTLUpdater::class.java) as Logger | ||
| updaterLogger.level = Level.INFO | ||
| var updateListLogger = LoggerFactory.getLogger(AdaptiveSTLList::class.java) as Logger | ||
| updateListLogger.level = Level.INFO | ||
| var LTSminVersionLogger = LoggerFactory.getLogger(LTSminVersion::class.java) as Logger | ||
| LTSminVersionLogger.level = Level.INFO | ||
| var AbstractLTSminLogger = LoggerFactory.getLogger(AbstractLTSmin::class.java) as Logger | ||
| AbstractLTSminLogger.level = Level.INFO | ||
| var EQSearchProblemLogger = LoggerFactory.getLogger(EQSearchProblem::class.java) as Logger | ||
| EQSearchProblemLogger.level = Level.INFO | ||
| var SimulinkSteadyStateGeneticAlgorithmLogger = LoggerFactory.getLogger(EQSteadyStateGeneticAlgorithm::class.java) as Logger | ||
| SimulinkSteadyStateGeneticAlgorithmLogger.level = Level.INFO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logger level setting is repetitive. Consider using a loop for conciseness and maintainability.
listOf(
AbstractAdaptiveSTLUpdater::class.java,
AdaptiveSTLList::class.java,
LTSminVersion::class.java,
AbstractLTSmin::class.java,
EQSearchProblem::class.java,
EQSteadyStateGeneticAlgorithm::class.java
).forEach { (LoggerFactory.getLogger(it) as Logger).level = Level.INFO }
| val verifier = NumericSULVerifier(autoTransSUL, signalStep, properties, mapper) | ||
| // Timeout must be set before adding equivalence testing | ||
| verifier.setTimeout(60 * 40) // 40 minutes | ||
| verifier.addCornerCaseEQOracle(signalLength, signalLength / 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for (i in 0 until verifier.cexProperty.size) { | ||
| println("${verifier.cexProperty[i]} is falsified by the following counterexample") | ||
| println("cex concrete input: ${verifier.cexConcreteInput[i]}") | ||
| println("cex abstract input: ${verifier.cexAbstractInput[i]}") | ||
| println("cex output: ${verifier.cexOutput[i]}") | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using forEachIndexed for more idiomatic Kotlin.
verifier.cexProperty.forEachIndexed { i, property ->
println("$property is falsified by the following counterexample")
println("cex concrete input: ${verifier.cexConcreteInput[i]}")
println("cex abstract input: ${verifier.cexAbstractInput[i]}")
println("cex output: ${verifier.cexOutput[i]}")
}
| simulinkModel : SimulinkModel | ||
| MDL = "Autotrans_shift" | ||
|
|
||
| def initScript(eng : matlab.engine.MatlabEngine) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bumps [org.apache.maven.plugins:maven-dependency-plugin](https://github.com/apache/maven-dependency-plugin) from 3.8.0 to 3.8.1. - [Release notes](https://github.com/apache/maven-dependency-plugin/releases) - [Commits](apache/maven-dependency-plugin@maven-dependency-plugin-3.8.0...maven-dependency-plugin-3.8.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-dependency-plugin dependency-version: 3.8.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [org.hibernate.validator:hibernate-validator](https://github.com/hibernate/hibernate-validator) from 8.0.2.Final to 9.0.1.Final. - [Changelog](https://github.com/hibernate/hibernate-validator/blob/9.0.1.Final/changelog.txt) - [Commits](hibernate/hibernate-validator@8.0.2.Final...9.0.1.Final) --- updated-dependencies: - dependency-name: org.hibernate.validator:hibernate-validator dependency-version: 9.0.1.Final dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [org.jacoco:jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.12 to 0.8.13. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](jacoco/jacoco@v0.8.12...v0.8.13) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-version: 0.8.13 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.5.2 to 3.5.3. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](apache/maven-surefire@surefire-3.5.2...surefire-3.5.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-version: 3.5.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.1.2 to 5.4.3. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](codecov/codecov-action@v5.1.2...v5.4.3) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-version: 5.4.3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [commons-cli:commons-cli](https://github.com/apache/commons-cli) from 1.9.0 to 1.10.0. - [Changelog](https://github.com/apache/commons-cli/blob/master/RELEASE-NOTES.txt) - [Commits](apache/commons-cli@rel/commons-cli-1.9.0...rel/commons-cli-1.10.0) --- updated-dependencies: - dependency-name: commons-cli:commons-cli dependency-version: 1.10.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps `junit.jupiter.version` from 5.12.0 to 5.13.4. Updates `org.junit.jupiter:junit-jupiter-api` from 5.12.0 to 5.13.4 - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](junit-team/junit-framework@r5.12.0...r5.13.4) Updates `org.junit.jupiter:junit-jupiter-engine` from 5.12.0 to 5.13.4 - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](junit-team/junit-framework@r5.12.0...r5.13.4) Updates `org.junit.vintage:junit-vintage-engine` from 5.12.0 to 5.13.4 - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](junit-team/junit-framework@r5.12.0...r5.13.4) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-api dependency-version: 5.13.4 dependency-type: direct:development update-type: version-update:semver-minor - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-version: 5.13.4 dependency-type: direct:development update-type: version-update:semver-minor - dependency-name: org.junit.vintage:junit-vintage-engine dependency-version: 5.13.4 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [black.ninia:jep](https://github.com/ninia/jep) from 4.2.1 to 4.2.2. - [Release notes](https://github.com/ninia/jep/releases) - [Commits](ninia/jep@v4.2.1...v4.2.2) --- updated-dependencies: - dependency-name: black.ninia:jep dependency-version: 4.2.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Fixed a bug in TemporalRelease * Update core/src/main/java/net/maswag/falcaun/TemporalRelease.java Co-authored-by: Copilot <[email protected]> * Update core/src/test/java/net/maswag/falcaun/STLReleaseTest.java Co-authored-by: Copilot <[email protected]> * Fixed a compilation error * Not fix the version of Python in CI --------- Co-authored-by: Copilot <[email protected]>
Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.18.0 to 5.19.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](mockito/mockito@v5.18.0...v5.19.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-version: 5.19.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.27.3 to 3.27.4. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](assertj/assertj@assertj-build-3.27.3...assertj-build-3.27.4) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-version: 3.27.4 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [net.bytebuddy:byte-buddy](https://github.com/raphw/byte-buddy) from 1.17.6 to 1.17.7. - [Release notes](https://github.com/raphw/byte-buddy/releases) - [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md) - [Commits](raphw/byte-buddy@byte-buddy-1.17.6...byte-buddy-1.17.7) --- updated-dependencies: - dependency-name: net.bytebuddy:byte-buddy dependency-version: 1.17.7 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.11.2 to 3.11.3. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](apache/maven-javadoc-plugin@maven-javadoc-plugin-3.11.2...maven-javadoc-plugin-3.11.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-version: 3.11.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
And also add its test
Remove an unused variable
Reflect Gemini's reviews
df3d0fa to
c61e88a
Compare
| FalCAuN Examples with Scala | ||
| ============================ | ||
|
|
||
| This directory contains examples to directly execute FalCAuN via Scala. Our examples depends on [scala-cli](https://scala-cli.virtuslab.org/). We tested these examples using Scala 3.7.2 and Scala CLI 1.8.5. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[LanguageTool] reported by reviewdog 🐶
You should probably use “depend”. (AGREEMENT_SENT_START[1])
Suggestions: depend
URL: https://languagetool.org/insights/post/grammar-subject-verb-agreement/#4-collective-nouns-can-be-singular-or-plural
Rule: https://community.languagetool.org/rule/show/AGREEMENT_SENT_START?lang=en-US&subId=1
Category: GRAMMAR
Link to the corresponding issue (if exists)
Summary of the changes
Check list
Other Notes (if exists)