-
Notifications
You must be signed in to change notification settings - Fork 39
Fix color parameter validation in plot_haplotype_network function (issue #738) #742
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
Fix color parameter validation in plot_haplotype_network function (issue #738) #742
Conversation
|
Thank you @mohamed-laarej . This doesn't actually solve the problem, however. The issue is slightly more complex than it appears. First, the |
|
Thank you for your feedback, @jonbrenas. I understand now that the You're right that the parameter can be either a string or a mapping, and when it's a string, it can be either a direct column name or a postfix of a column name starting with "cohorts_". I'll update my PR to handle all these cases properly while maintaining consistency with how other functions treat similar parameters. I'll submit an updated implementation soon that addresses these requirements. |
…-laarej/malariagen-data-python into fix-plot-haplotype-network-color
|
This looks great @mohamed-laarej. Have you run some tests to check that it works? Could you modify the notebook in |
|
Thanks for the feedback, @jonbrenas! Yes, I’ve run a local test script to verify that the new code handles all the cases for the |
…apping case); update tests with assertions; update notebook with examples
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
@jonbrenas Hi there! I wanted to follow up on this PR where I've implemented the requested changes to the tests and notebook examples. I'm looking forward to any additional feedback you might have when you get a chance. Thank you for your time and guidance so far! |
|
Thanks @mohamed-laarej. I'll have to create a new PR shadowing this one for the CI to work, I am pretty sure. Your code looks good but I am not sure why you needed to use a new definition of Ag3/Af1 instead of |
|
Thank you for the feedback! |
Fixes #738
Problem
The
colorparameter inplot_haplotype_networkfunction is defined inplotly_params.pyasAnnotated[Optional[Union[str, Mapping]], "Name of variable to use to color the markers."], but the function was incorrectly using it as a direct column identifier on the haplotypes dataframe without validation.Solution
This PR adds proper validation and handling for all possible color parameter formats:
When
coloris a string:When
coloris a mapping (dictionary) :When
coloris None:The implementation maintains backward compatibility with existing code while adding proper validation and error handling.
Changes Made
Testing
Tested the fix by verifying that the function correctly identifies available columns and handles the color parameter appropriately.