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

Allow homogeneous tuples as function arguments #1850

Open
wants to merge 31 commits into
base: devel
Choose a base branch
from

Conversation

EmilyBourne
Copy link
Member

@EmilyBourne EmilyBourne commented Apr 23, 2024

Allow 1D homogeneous tuples as function arguments. Fixes #738. Homogeneous tuples as arguments already worked in the low level code as homogeneous tuples are handled as arrays, however the wrapper was missing which meant that such functions couldn't be called from Python. In order to handle multi-level tuples some reorganisation of the wrapper was necessary. Namely the introduction of the _extract_X_FunctionDefArgument functions. However Python multi-level tuples may have different lengths in the elements. It proved difficult to check the size of the elements in a generic way so this was left for later work (the obvious solution is to use lists to support this).

Commit Summary

  • Update docs
  • Update BindCFunctionDefArgument to handle tuples as strideless arrays
  • Add descriptions of more tuple functions from Python.h. Group these functions together in ast.cwrapper
  • Make dtype a searchable attribute of SyntacticTypeAnnotation
  • Fix filter for used template type annotations so it also searches through indexed elements to find objects in a tuple annotation.
  • Add tests for tuples as arguments
  • Rename _get_check_function->_get_type_check_condition.
  • Allow _get_type_check_condition to return a condition which is not a function call (e.g. a Variable)
  • Add body argument to _get_type_check_condition to allow additional commands to be run before determining if the type is correct.
  • Add type checks for homogeneous tuples
  • Introduce _extract_X_FunctionDefArgument functions to describe container unpacking recursively
  • Add _extract_HomogeneousTupleType_FunctionDefArgument function to unpack 1D homogeneous tuples.
  • Ensure errors are raised for multi-D tuples.

@pyccel-bot
Copy link

pyccel-bot bot commented Apr 23, 2024

Hello again! Thank you for this new pull request 🤩.

Please begin by requesting your checklist using the command /bot checklist

@EmilyBourne
Copy link
Member Author

EmilyBourne commented Apr 23, 2024

Here is your checklist. Please tick items off when you have completed them or determined that they are not necessary for this pull request:

  • Write a clear PR description
  • Add tests to check your code works as expected
  • Update documentation if necessary
  • Update Changelog
  • Ensure any relevant issues are linked
  • Ensure new tests are passing

@EmilyBourne
Copy link
Member Author

/bot run docs

@EmilyBourne
Copy link
Member Author

/bot run pylint pyccel_lint spelling docs

@EmilyBourne
Copy link
Member Author

/bot run pylint

@EmilyBourne EmilyBourne marked this pull request as ready for review May 2, 2024 20:13
@pyccel-bot
Copy link

pyccel-bot bot commented May 2, 2024

It seems like you have forgotten to complete your checklist for this pull request. Please check the list here, fix the missing items and let me know when everything is ticked and fixed with /bot mark as ready.

@github-actions github-actions bot marked this pull request as draft May 2, 2024 20:13
@EmilyBourne EmilyBourne marked this pull request as ready for review May 2, 2024 20:17
@github-actions github-actions bot marked this pull request as draft May 2, 2024 20:18
@pyccel-bot
Copy link

pyccel-bot bot commented May 2, 2024

Unfortunately your PR is not passing the tests so it is not quite ready for review yet. Let me know when it is fixed with /bot mark as ready.

@EmilyBourne EmilyBourne marked this pull request as ready for review May 2, 2024 20:31
Copy link

@pyccel-bot pyccel-bot bot left a comment

Choose a reason for hiding this comment

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

Good job ! Your PR is using all the code it added/changed.

@pyccel-bot
Copy link

pyccel-bot bot commented May 3, 2024

Hey @pyccel/pyccel-dev ! @EmilyBourne has just created this great new pull request! Check it out and let me know what you think!

@pyccel-bot pyccel-bot bot requested a review from a team May 3, 2024 05:11
@EmilyBourne EmilyBourne added the Containers tuples/lists/sets/maps label May 6, 2024
Copy link
Contributor

@mustapha-belbiad mustapha-belbiad left a comment

Choose a reason for hiding this comment

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

Looks Good to me.

@EmilyBourne EmilyBourne marked this pull request as draft May 15, 2024 14:01
@EmilyBourne EmilyBourne marked this pull request as ready for review May 15, 2024 14:01
Copy link

@pyccel-bot pyccel-bot bot left a comment

Choose a reason for hiding this comment

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

Good job ! Your PR is using all the code it added/changed.

@pyccel-bot pyccel-bot bot added Ready_for_review Received at least one approval. Requires review from senior developer and removed needs_initial_review labels May 15, 2024
@pyccel-bot
Copy link

pyccel-bot bot commented May 15, 2024

Hey @yguclu, @EmilyBourne, this PR is looking pretty good. @EmilyBourne and @mustapha-belbiad think it is ready to merge. Could you add your expertise to confirm that this follows all the coding conventions and fits in Pyccel's future plans? Thanks 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Containers tuples/lists/sets/maps Ready_for_review Received at least one approval. Requires review from senior developer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow homogeneous tuples as read-only function arguments
2 participants