-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Results arrays (#144) #145
Conversation
…ys for shear, moment, torque, axial, deflection, and relative deflection. Passes current tests. Addresses #114.
… caused an error when calling Member3D.rel_deflection
Let me know your thoughts on this and if you would like any other additions to the code base to support this proposed change. |
I like this. It seems like |
Glad you like it! Agreed, the "array" functions and the "plot" methods are similar and the implementation code is repetitive. I hear what you are saying on adding a boolean flag to the plot methods. My only misgiving with such an approach is that it would make the return type of the plot functions inconsistent which I think is unexpected. If (I mean "when") I was cruising the API to see what method to use to get a result array, the plot methods would not be my first guess. However, I think that reducing the amount of repetition would be good because it reduces the quantity of code requiring maintenance. Let me know what you think of this counter proposal: Add a method like this: def _results_array(self, action: str, n_points: int, direction: Optional[str] = None, combo_name="Combo 1") -> np.ndarray:
"""
Returns the results array according to the parameters.
action: {"shear", "moment", "torque", "axial", "deflection", "rel_deflection"}
n_points: the number of points
direction: the direction of action to retrieve
combo_name: the load combination to retrieve
"""
action_function = getattr(self, action)
L = self.L()
x_arr = linspace(0, L, n_points)
if direction is None:
y_arr = array(
[self.action_function(x, combo_name) for x in x_arr]
)
else:
y_arr = array(
[self.action_function(direction, x, combo_name) for x in x_arr]
)
return array([x_arr, y_arr]) Then, the implementation of each array function simply becomes: def shear_array(direction: str, n_points: int, combo_name="Combo1") -> array:
"""
...doc string
"""
return self._results_array("shear", direction, n_points, combo_name) The plot functions could then call the Since these methods would be "private" methods, and only called internally by other methods, you could also do away with a lot of error checking (like checking if the Let me know your thoughts on this and I can put it together. |
I see what you're getting at, and I'll probably move it that direction. I've merged your PR for now. |
Addresses #144 with the following changes:
Member3D
for the following:shear_array
moment_array
torque_array
axial_array
deflection_array
rel_deflection_array
n_points
argument to the "plot" methods to allow for varying the resolution of the plot (added the argument as the final keyword argument to not break any existing code).Member3D.rel_deflection
where the actualLoadCombo
object was being passed toMember3D.d
instead of the combo name.