Skip to content

Comments

tag_to_var_map arguments and tests#109

Merged
fletchapin merged 19 commits intomainfrom
feature/debug-calculate-values
Sep 29, 2025
Merged

tag_to_var_map arguments and tests#109
fletchapin merged 19 commits intomainfrom
feature/debug-calculate-values

Conversation

@dalyw
Copy link
Contributor

@dalyw dalyw commented Aug 28, 2025

Resolves #107

  • Adding tag_to_var_map argument when calculate_values is called in 4 instances in tag.py (in process_custom_ops, process_binary_ops, process unary_ops)
  • Adding test for use of tag_to_var_map in test_tag.py
  • Adding helper function generate_tag_to_var_map to generate the expectation file for use in test_tag.py

@dalyw dalyw requested a review from fletchapin August 28, 2025 16:57
@codecov
Copy link

codecov bot commented Aug 28, 2025

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.25%. Comparing base (0177ecb) to head (bc8a997).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pype_schema/tag.py 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #109      +/-   ##
==========================================
+ Coverage   87.20%   87.25%   +0.04%     
==========================================
  Files          11       11              
  Lines        3361     3373      +12     
==========================================
+ Hits         2931     2943      +12     
  Misses        430      430              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dalyw dalyw marked this pull request as draft August 31, 2025 00:21
@dalyw
Copy link
Contributor Author

dalyw commented Aug 31, 2025

Converted to draft. I added a couple of more tests to increase the CodeCov, but they're on the server that's down. Can recreate them depending on how long that takes to fix.

@dalyw dalyw marked this pull request as ready for review September 25, 2025 16:00
)
else:
relevant_data = processed_relevant_data

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 change was added because when using tag_to_var_map, relevant_data wouldn't already be a np array. Can think about if there are better ways to handle this

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a reasonable solution to me!

tag.calculate_values(data)
elif data_type == "InvalidUnary":
data = "invalid_data_type" # pass a string
tag.calculate_values(data)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively could pass in a string for the "Invalid" test too and make them all use the same invalid data type?

else:
raise TypeError("Data must be either a list, array, or Series")
if result is None:
raise TypeError("Data must be either a list, array, or Series")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this TypeError to the end to simplify when this is raised and help with codecov... alternatively can just add separate tests for each operation type

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work? I would think that there would be an UnboundLocalError because the variable result may be referenced without being defined.

Besides that bug, I'm all for streamlining the logic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!! That did raise an UnboundLocalError.

The test in test_calculate_values was passing because a TypeError was being raised earlier, from process_unary_ops in tag.py. So unary_helper was never even called

I removed that type checking entirely instead, since unary_helper shouldn't ever be called outside process_unary_ops... is that ok or do you prefer to keep it as it was originally just in case?

Copy link
Contributor

@fletchapin fletchapin left a comment

Choose a reason for hiding this comment

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

I believe there is a potential UnboundLocalError, but if that is addressed then we're good to go!

else:
raise TypeError("Data must be either a list, array, or Series")
if result is None:
raise TypeError("Data must be either a list, array, or Series")
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work? I would think that there would be an UnboundLocalError because the variable result may be referenced without being defined.

Besides that bug, I'm all for streamlining the logic

)
else:
relevant_data = processed_relevant_data

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a reasonable solution to me!

Adding tests for:
- TypeError from unary_helper
- tag_to_var_map with List data
- invalid mode in VirtualTag class
@fletchapin fletchapin merged commit d639824 into main Sep 29, 2025
4 checks passed
@dalyw dalyw deleted the feature/debug-calculate-values branch September 29, 2025 22:39
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.

BUG: tag_to_var_map argument missing from calls to calculate_values

2 participants