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

[WIP] FIx smoothing and aggregation for unbalanced expected #466

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Phlya
Copy link
Member

@Phlya Phlya commented Oct 27, 2023

No description provided.

@Phlya Phlya requested a review from golobor October 27, 2023 15:15
@Phlya
Copy link
Member Author

Phlya commented Oct 31, 2023

I am confused about the test, if I manually run the same command that it should be running it works for me, while pytest complains about exit code 2.

Copy link
Member

@agalitsyna agalitsyna left a comment

Choose a reason for hiding this comment

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

I don't fully agree with aesthetics of the changes, maybe reconsider introduction of cols dictionary.

"n_pixels": _NUM_VALID,
"n_contacts": "count.sum",
"contact_freq": "count.avg",
"smooth_suffix": ".smoothed",
Copy link
Member

Choose a reason for hiding this comment

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

Consider renaming "suffix", "smooth suffix seems rather confusing and hard to generalize in future.

@@ -1017,25 +1019,43 @@ def expected_cis(

# additional smoothing and aggregating options would add columns only, not replace them
if smooth:
if clr_weight_name is None:
# result["count.avg"] = result["count.sum"] / result["n_valid"]
Copy link
Member

Choose a reason for hiding this comment

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

What is this commented out line?

@@ -476,6 +476,54 @@ def test_expected_smooth_cli(request, tmpdir):
assert _delta_smooth_agg < 0.02


def test_expected_smooth_nobalance_cli(request, tmpdir):
Copy link
Member

Choose a reason for hiding this comment

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

I like this test

)
# add smoothed columns to the result (only balanced for now)
result = result.merge(
result_smooth[["balanced.avg.smoothed", _DIST]],
result_smooth[[cols["contact_freq"] + cols["smooth_suffix"], _DIST]],
Copy link
Member

Choose a reason for hiding this comment

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

I find this notation very hard to read. Is it possible to retain something like this?
"count.sum" + suffix / without dictionary, having the regular notation

I endorse both readability and flexibility of the code, and here it looks like the balance is shifted towards flexibility.

cols["contact_freq"]
+ cols["smooth_suffix"]: cols["contact_freq"]
+ cols["smooth_suffix"]
+ ".agg"
Copy link
Member

Choose a reason for hiding this comment

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

".agg" is not in the cols dict anymore, although it's another type of suffix!
Consistency would be great.

@gfudenberg
Copy link
Member

@Phlya I guess this can be closed as superseded by #501 ?

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