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

feature/mypy-types-cleanlab-internal-utils #608

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

Conversation

unna97
Copy link
Contributor

@unna97 unna97 commented Jan 24, 2023

No description provided.

Adding the types for variables within the functions. type cheatsheet:
1. np array of float type: npt.NDArray["np.floating[T]"]
2. np array of int type: npt.NDArray[np.int_]
3. np array of bool type: npt.NDArray[np.bool_]
4. np.array of either bool or int: npt.NDArray[Union[np.bool_, np.int_]]
functions added for:
1. remove_noise_from_class
2. clip_noise_rates
3. clip_values
4. value_counts
functions added for:
1. remove_noise_from_class
2. clip_noise_rates
3. clip_values
4. value_counts
…m:unna97/cleanlab into feature/mypy-types-cleanlab-internal-util
@codecov
Copy link

codecov bot commented Jan 24, 2023

Codecov Report

Merging #608 (c2eb833) into master (5eb89fc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #608   +/-   ##
=======================================
  Coverage   96.23%   96.23%           
=======================================
  Files          60       60           
  Lines        4705     4707    +2     
  Branches      817      817           
=======================================
+ Hits         4528     4530    +2     
  Misses         91       91           
  Partials       86       86           
Impacted Files Coverage Δ
cleanlab/internal/util.py 95.71% <100.00%> (+0.03%) ⬆️

@elisno
Copy link
Member

elisno commented Jan 24, 2023

Thanks for the PR!

The internal utils module is quite large, so how about we work on those in smaller segments (say 5-10 functions/methods)?

I think we can just focus on the functions you've annotated up to this point:

  • remove_noise_from_class
  • clip_noise_rates
  • clip_values
  • value_counts
  • round_preserving_row_totals
  • smart_display_dataframe

@elisno
Copy link
Member

elisno commented Jan 24, 2023

In remove_noise_from_class(link):

Note that the np.copy() function is not typed.

It's outside of our control, so we should ignore the specific warning associated with that function call.

- x = np.copy(noise_matrix)
+ x: npt.NDArray["np.floating[T]"] = np.copy(noise_matrix)  # type: ignore[no-untyped-call]

We assume that the copied variable should have the same type as the input (noise_matrix), so we'll help mypy in this line.

@unna97
Copy link
Contributor Author

unna97 commented Jan 26, 2023

Sure @elisno, do you mean with a separate PR for the above functions?

@elisno
Copy link
Member

elisno commented Jan 26, 2023

You should use this PR for those functions.

@unna97
Copy link
Contributor Author

unna97 commented Jan 26, 2023

Yes, for bigger files I am using one PR. while for other segments as you have mentioned before.

- value_counts_fill_missing_classes
- get_missing_classes
- round_preserving_sum
- estimate_pu_f1
- confusion_matrix
- print_square_matrix
- print_noise_matrix
- print_inverse_noise_matrix
- print_joint_matrix
- compress_int_array
- subset_X_y
- subset_labels
- num_unique_classes
- get_unique_classes
- format_labels
- smart_display_dataframe
@unna97
Copy link
Contributor Author

unna97 commented Feb 2, 2023

@elisno sorry for doing so much in a single commit. I did add type hints for functions other than those you mentioned. There are specific errors in outputs that I am unsure about.

@unna97
Copy link
Contributor Author

unna97 commented Feb 18, 2023

@elisno Did you have a chance to review this?

@unna97 unna97 marked this pull request as ready for review March 20, 2023 10:31
@unna97
Copy link
Contributor Author

unna97 commented Mar 23, 2023

@elisno I was waiting for suggestions before making any further changes. Will you still be reviewing this branch?

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.

None yet

2 participants