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

Add round function to pyccel #983

Open
EmilyBourne opened this issue Oct 8, 2021 · 7 comments · May be fixed by #996
Open

Add round function to pyccel #983

EmilyBourne opened this issue Oct 8, 2021 · 7 comments · May be fixed by #996
Assignees

Comments

@EmilyBourne
Copy link
Member

Describe the bug
We would like to add the python builtin round to pyccel

Test Code
Provide code which does not currently work but which should do when this issue is fixed:

if __name__ == '__main__':
     print(round(4.49))
@EmilyBourne
Copy link
Member Author

For fortran this can be done with the nint function. For C it can be done with the round function

@nandiniraja348
Copy link

Hi EmilyBourne!

I would like to work on the issue. Can you assign me to the issue?

Thanks

@nandiniraja348
Copy link

Hi Emily, thanks for assigning.

Can you please describe more on the enhancement?

@EmilyBourne
Copy link
Member Author

Hi @nandiniraja348

I would recommend joining our slack:
pyccel.slack.com

That way we can have more in depth discussions if you get stuck at all.

For the issue what needs to be done is:

  1. Create a class in pyccel/ast/builtins.py to represent the function

  2. Ensure the function is recognised by adding it to the list of built-in functions (this is either in the same file or in pyccel/ast/utilities.py)

  3. Add the print functions for the 3 languages (the print function is called automatically using the name of the class so your function should be called something like _print_PythonRound). The print functions go in the files in pyccel/codegen/printing

  4. Add tests in the folder tests/epyccel

@EmilyBourne
Copy link
Member Author

If you haven't already I would recommend reading the quickstart guide which tells you what files are generated and where

@EmilyBourne
Copy link
Member Author

Thank you very much for your help :). Let me know if you need any more information

@nandiniraja348
Copy link

Thanks Emily for a detailed explanation.
I would like to join the slack channel. Can you please send an invite link to nandiniraja348@gmail.com?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants