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

Changed beam to generic element #263

Merged
merged 17 commits into from
Sep 16, 2024
Merged

Conversation

obucklin
Copy link
Contributor

@obucklin obucklin commented Jul 1, 2024

This is to make the process of adding elements to a Model simpler by eliminating the need for multiple functions e.g. add_beam and add_plate. I left the TimberModel.plates attribute commented out, but if the Plates element PR gets accepted, then I can uncomment those lines. I tested this with invoke test and with GH. It may still break some things...

What type of change is this?

  • Bug fix in a backwards-compatible manner.
  • New feature in a backwards-compatible manner.
  • Breaking change: bug fix or new feature that involve incompatible API changes.
  • Other (e.g. doc update, configuration, etc)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I added a line to the CHANGELOG.md file in the Unreleased section under the most fitting heading (e.g. Added, Changed, Removed).
  • I ran all tests on my computer and it's all green (i.e. invoke test).
  • I ran lint on my computer and there are no errors (i.e. invoke lint).
  • I added new functions/classes and made them available on a second-level import, e.g. compas_timber.datastructures.Beam.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

Copy link
Contributor

@chenkasirer chenkasirer left a comment

Choose a reason for hiding this comment

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

I generally like this change. commented on some issues

src/compas_timber/model/model.py Show resolved Hide resolved
src/compas_timber/model/model.py Outdated Show resolved Hide resolved
An instance of a Joint class.

beams : tuple(:class:`~compas_timber.elements.Beam`)
The two beams that should be joined.
beams : tuple(:class:`~compas_timber.elements.Element`)
Copy link
Contributor

Choose a reason for hiding this comment

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

beams -> elements

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a change that would probably have larger consequences. I would do that in another PR :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

I was referring to the name of the argument. you changes the type to Element (btw Element is a compas_model thing) but argument is still called beams. But maybe it should only be called using Beam in which case I'd just revert the change to the type.

src/compas_timber/model/model.py Outdated Show resolved Hide resolved

def remove_joint(self, joint):
def remove_interaction(self, joint):
Copy link
Contributor

Choose a reason for hiding this comment

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

this should still be called remove_joint as it is not quite the same as the parent implementation, right?

Copy link
Contributor Author

@obucklin obucklin Jul 2, 2024

Choose a reason for hiding this comment

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

Good question. I was thinking about this in terms of Joint being a specific type of the generic type Interaction. However, without any other types of interaction we could leave it as remove_joint

What about add_interaction? should I change that to match the input parameters of the compas_model method?

Copy link
Contributor

Choose a reason for hiding this comment

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

keep in mind that since TimberModel inherits from Model, the Model interface is fully available on TimberModel objects. We could totally have remove_joint/add_joint live alongside remove_interaction/add_interaction.

Any specific operation to interactions of type Joint can be handled in add_joint whereas other kinds of interactions that are not timber model specific can still be added using add_interaction.

src/compas_timber/model/model.py Outdated Show resolved Hide resolved
src/compas_timber/model/model.py Outdated Show resolved Hide resolved
src/compas_timber/model/model.py Outdated Show resolved Hide resolved
src/compas_timber/model/model.py Outdated Show resolved Hide resolved
src/compas_timber/model/model.py Outdated Show resolved Hide resolved
@obucklin obucklin requested a review from chenkasirer July 8, 2024 12:26
Copy link
Contributor

@chenkasirer chenkasirer left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor Author

@obucklin obucklin left a comment

Choose a reason for hiding this comment

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

looks good

CHANGELOG.md Outdated
* Changed `TimberModel.beams` to return generator of `Beam` elements.
* Changed `TimberModel.walls` to return generator of `Wall` elements.
* Changed `TimberModel.plates` to return generator of `Plate` elements.
* Changed `TimberModel.joints` to return generator of `Plate` elements.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

repeated line

@chenkasirer chenkasirer merged commit 75769e4 into main Sep 16, 2024
14 checks passed
@chenkasirer chenkasirer deleted the make_model_elements_generic branch September 16, 2024 08:10
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.

2 participants