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

Fix Ruby/Python SWIG API when type is AlfalfaComponent #5298

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

TShapinsky
Copy link
Member

Pull request overview

Add additional function in SWIG for AlfalfaJSON::exposeFromComponent, AlfalfaPoint::setInput and AlfalfaPoint::setOutput which provides a method which takes const AlfalfaComponentBase& instead of AlfalfaComponent. This is required because it seems like SWIG cannot understand the converting constructor.

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@TShapinsky TShapinsky added the Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. label Nov 11, 2024
Comment on lines +68 to +69
AlfalfaComponent alfalfa_component(component);
$self->setInput(alfalfa_component);
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
AlfalfaComponent alfalfa_component(component);
$self->setInput(alfalfa_component);
$self->setInput(AlfalfaComponent {component});

Comment on lines +63 to +64
AlfalfaComponent alfalfa_component(component);
$self->setOutput(alfalfa_component);
Copy link
Member Author

@TShapinsky TShapinsky Nov 11, 2024

Choose a reason for hiding this comment

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

Suggested change
AlfalfaComponent alfalfa_component(component);
$self->setOutput(alfalfa_component);
$self->setOutput(AlfalfaComponent {component});

Comment on lines +75 to +76
AlfalfaComponent alfalfa_component(component);
return $self->exposeFromComponent(alfalfa_component, display_name);
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
AlfalfaComponent alfalfa_component(component);
return $self->exposeFromComponent(alfalfa_component, display_name);
return $self->exposeFromComponent(AlfalfaComponent {component}, display_name);

@@ -57,4 +57,26 @@
%template(OptionalAlfalfaPoint) boost::optional<openstudio::alfalfa::AlfalfaPoint>;
%template(OptionalAlfalfaComponent) boost::optional<openstudio::alfalfa::AlfalfaComponent>;

namespace openstudio::alfalfa {
%extend AlfalfaPoint {
Copy link
Member Author

Choose a reason for hiding this comment

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

These could be moved into the main source if desired.

@TShapinsky TShapinsky requested review from jmarrec and kbenne November 11, 2024 21:27
Copy link
Collaborator

@jmarrec jmarrec left a comment

Choose a reason for hiding this comment

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

I'm liking this AlfalfaComponent / AlfalfaComponentBase template stuff less and less. But this appears to work fine.

@@ -12,8 +12,7 @@ namespace alfalfa {
class ALFALFA_API AlfalfaComponent
{
public:
template <typename T, std::enable_if_t<std::is_base_of<AlfalfaComponentBase, T>::value, bool> = true>
AlfalfaComponent(T component) : m_component(std::make_unique<T>(std::move(component))) {}
AlfalfaComponent(const AlfalfaComponentBase& component) : m_component(component.clone()) {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious why you added this one in the main source but the others just in the Alfalfa.i

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't want the ctor exposed to the bindings so i added it here and ignored the ctors for the class in the .i .

@TShapinsky
Copy link
Member Author

I'm liking this AlfalfaComponent / AlfalfaComponentBase template stuff less and less. But this appears to work fine.

Agreed. If i get some more time before the next release it's something I want to take a look at again.

@jmarrec
Copy link
Collaborator

jmarrec commented Nov 12, 2024

@wenyikuang where do we merge this one?

@wenyikuang
Copy link
Collaborator

@wenyikuang where do we merge this one?

I haven't merged it yet, maybe in the final?

@jmarrec
Copy link
Collaborator

jmarrec commented Nov 12, 2024

@wenyikuang I'm asking because it seems that master is well ahead of develop

@wenyikuang
Copy link
Collaborator

We should merge to develop branch... I probably made a mistake some place.

@jmarrec jmarrec merged commit 4f0f8de into develop Nov 12, 2024
5 of 6 checks passed
@jmarrec jmarrec deleted the alfalfa_advanced_usage_fix branch November 12, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants