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

dropped ensemble requirement to single model #69

Merged
merged 2 commits into from
Aug 8, 2023

Conversation

Ashwani132003
Copy link
Contributor

Close #11

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for your contributions. If you haven't already, please send a signed Contributor License Agreement (CLA) to Christopher Teubert ([email protected]). CLAs can be found here: https://github.com/nasa/prog_models/tree/master/forms. Also, make sure you're familiar with the developer notes and contributing sections of our developers guide, https://nasa.github.io/progpy/dev_guide.html#notes-for-developers

Copy link
Contributor

@teubert teubert left a comment

Choose a reason for hiding this comment

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

Thank you @Ashwani132003 for your PR. A few suggestions before I can approve it. Let me know if you would like help with any of this.

if len(models) < 2:
raise ValueError('EnsembleModel requires at least two models')
if len(models) < 1:
raise ValueError('EnsembleModel requires at least one models')
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
raise ValueError('EnsembleModel requires at least one models')
raise ValueError('EnsembleModel requires at least one model')

Comment on lines 30 to 33
try:
EnsembleModel([m])
except ValueError:
self.fail("Error EnsembleModel raised ValueError Unexpectedly")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
try:
EnsembleModel([m])
except ValueError:
self.fail("Error EnsembleModel raised ValueError Unexpectedly")
EnsembleModel([m])

Try-except not necessary - test would fail if value error is raised

tests/test_ensemble.py Show resolved Hide resolved
@teubert
Copy link
Contributor

teubert commented Jul 19, 2023

Follow-up note: ignore the failing tests. Tests are not working properly for some reason on this branch. For this PR I will run the tests manually

@Ashwani132003
Copy link
Contributor Author

Please check the below code for test_single_model:
def test_single_model(self):
"""
This tests that the ensemble model works with a single model, ensuring that inputs, states, outputs, and events are correctly handled.
"""
m = OneInputOneOutputOneEventLM()
em = EnsembleModel([m])

    # inputs, states, outputs, and events should be the same as the single model
    self.assertSetEqual(set(em.inputs), {'u1'})
    self.assertSetEqual(set(em.states), {'x1'})
    self.assertSetEqual(set(em.outputs), {'z1'})
    self.assertSetEqual(set(em.events), {'x1 == 10'})

    # Initialize
    x_t0 = em.initialize()
    self.assertEqual(x_t0['x1'], 0)

    # State transition
    u = em.InputContainer({'u1': 1})
    x_t1 = em.next_state(x_t0, u, 1)
    self.assertEqual(x_t1['x1'], 1)

    # Output
    z = em.output(x_t1)
    self.assertEqual(z['z1'], 1)

    # Event state
    es = em.event_state(x_t1)
    self.assertEqual(es['x1 == 10'], 0.9)

    # Threshold met
    self.assertFalse(em.threshold_met(x_t1)['x1 == 10'])

    # Transition again
    x_t2 = em.next_state(x_t1, u, 2)

    # Threshold met
    # x1 == 3
    self.assertFalse(em.threshold_met(x_t2)['x1 == 10'])

Is this implementation right, or i have to make changes.

One more thing while trying to do the changes and pushing the commit, I'm getting extra/previous commits alongside my commit, can you suggest some best way to do the changes without having to add them.
image
or i can try to make a new pr with all the changes in it.

@Ashwani132003 Ashwani132003 force-pushed the new_enhancement branch 3 times, most recently from e4598c3 to e57af59 Compare July 26, 2023 03:17
@kjjarvis
Copy link
Contributor

kjjarvis commented Aug 1, 2023

Hi @Ashwani132003, I'd be happy to help with your PR. Can you update me on the current status? Are you still having trouble with the extra/previous commits alongside yours?

@Ashwani132003
Copy link
Contributor Author

Hi @Ashwani132003, I'd be happy to help with your PR. Can you update me on the current status? Are you still having trouble with the extra/previous commits alongside yours?

hey, thanks for asking, but I somehow managed to resolve that, you can tell me if there are any other issues related to my pr.

@kjjarvis
Copy link
Contributor

kjjarvis commented Aug 1, 2023

Hi @Ashwani132003, I'm glad you got the previous issues resolved. I'm reviewing your code and it looks good so far. I'm having trouble pulling your code, and I think it's because it's forked off of dev. Will you please branch off of the ProgPy dev branch, add the changes to that new branch, and then request a review from me and @teubert? Then we should be able to review and merge. Thank you!

Copy link
Contributor

@teubert teubert left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. I was on leave last week, but now I'm back.

Everything looks great. Thank you for your help with this.

@teubert teubert merged commit 6bb2941 into nasa:dev Aug 8, 2023
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants