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

Update comp_function() to take in separate inputs #222

Merged
merged 7 commits into from
Jun 20, 2023

Conversation

MayaSimone
Copy link
Contributor

Found two methods of declaring multiple inputs in the functions of comp_function(), and have adjusted the test suite to only support one method. Going forward, each input must be declared as its own individual variable (not a single list to be iterated through). Updated docstrings still needed.

Ex.

gr.Model()
            >> gr.cp_function(
                fun=lambda a, b: a+b,
                var=["a", "b"],
                out=["c"],
            )

@zdelrosario
Copy link
Owner

Great! Like we expected, the laminate plate code is still failing. I think this should be an easy fix though; take a look at Line 412 of plane_laminate.py:

                Function(
                    lambda X: uniaxial_stress_limit(X),
                    make_names(Theta_nom),
                    list(itertools.chain.from_iterable([
                        ["g_11_tension_{}".format(i),
                         "g_22_tension_{}".format(i),
                         "g_11_compression_{}".format(i),
                         "g_22_compression_{}".format(i),
                         "g_12_shear_{}".format(i)] for i in range(k)
                    ])),
                    "limit states",
                    0
                )

We should be able to fix this by using a splat in the lambda function

                Function(
                    lambda *X: uniaxial_stress_limit(X),
                    make_names(Theta_nom),
                    list(itertools.chain.from_iterable([
                        ["g_11_tension_{}".format(i),
                         "g_22_tension_{}".format(i),
                         "g_11_compression_{}".format(i),
                         "g_22_compression_{}".format(i),
                         "g_12_shear_{}".format(i)] for i in range(k)
                    ])),
                    "limit states",
                    0
                )

This also suggests we can preserve old functionality if users define a lambda function using the * operator (which is something we can note in the docstring).

Can you give this edit a try and re-push?

@codecov
Copy link

codecov bot commented Jun 16, 2023

Codecov Report

Patch coverage: 52.94% and project coverage change: -0.01 ⚠️

Comparison is base (8a65efb) 76.83% compared to head (c99bc1c) 76.83%.

❗ Current head c99bc1c differs from pull request most recent head af43395. Consider uploading reports for the commit af43395 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #222      +/-   ##
==========================================
- Coverage   76.83%   76.83%   -0.01%     
==========================================
  Files          87       87              
  Lines        6740     6739       -1     
==========================================
- Hits         5179     5178       -1     
  Misses       1561     1561              
Impacted Files Coverage Δ
grama/eval_defaults.py 97.43% <ø> (ø)
grama/fit/fit_scikitlearn.py 77.41% <ø> (ø)
grama/models/circuit_RLC.py 100.00% <ø> (ø)
grama/models/plane_laminate.py 84.13% <ø> (ø)
grama/models/pipe_flow.py 52.17% <38.46%> (ø)
grama/core.py 84.61% <100.00%> (ø)
grama/models/ishigami.py 100.00% <100.00%> (ø)
grama/models/linear_normal.py 100.00% <100.00%> (ø)
grama/models/test.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Owner

@zdelrosario zdelrosario left a comment

Choose a reason for hiding this comment

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

Great contribution! Some small changes necessary, and let's talk about updating the docstring for cp_function().

grama/core.py Outdated Show resolved Hide resolved
grama/models/circuit_RLC.py Show resolved Hide resolved
tests/test_fit.py Outdated Show resolved Hide resolved
@zdelrosario zdelrosario merged commit 1639664 into zdelrosario:master Jun 20, 2023
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