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

Remove unnecessary functions from CodePrinter (50 lines) #1864

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

Conversation

EmilyBourne
Copy link
Member

Remove _get_comment and _get_statement from CodePrinter. _get_comment is unused and _get_statement returns the string that is passed to it. Additionally some docstrings and f-strings are added.

@pyccel-bot
Copy link

pyccel-bot bot commented May 7, 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 May 7, 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 coverage

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.

There seems to be lines in this PR which aren't tested. Please take a look at my comments and add tests which cover the new code.

If this is modified code which cannot be easily tested in this PR please open an issue to request that this code be either removed or tested. Once you have done that please leave a message on the relevant conversation beginning with the line /bot accept and referencing the issue.

Similarly if the new code cannot be tested for some reason, please leave a comment beginning with the line /bot accept on the relevant conversation explaining why the code can't be tested.

@@ -887,8 +883,8 @@ def _get_print_format_and_arg(self, var, var_code = None):

def _print_SymbolicPrint(self, expr):
# for every expression we will generate a print
code = '\n'.join("print *, 'sympy> {}'".format(a) for a in expr.expr)
return self._get_statement(code) + '\n'
code = '\n'.join(f"print *, 'sympy> {a}'" for a in expr.expr)
Copy link

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Copy link
Member Author

Choose a reason for hiding this comment

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

/bot accept
Known problem with symbolic code. See #330

@@ -2247,17 +2243,17 @@
body = ''.join(self._print(i) for i in expr.body)

# ... TODO adapt get_statement to have continuation with OpenACC
prolog = '!$acc parallel {clauses}\n'.format(clauses=clauses)
prolog = f'!$acc parallel {clauses}\n'
Copy link

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Copy link
Member Author

Choose a reason for hiding this comment

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

/bot accept
See #1514

code = ('{prolog}'
'{body}'
'{epilog}').format(prolog=prolog, body=body, epilog=epilog)
code = (f'{prolog}'
Copy link

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Copy link
Member Author

Choose a reason for hiding this comment

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

/bot accept
See #1514

@@ -2266,17 +2262,17 @@
# ...

# ... TODO adapt get_statement to have continuation with OpenACC
prolog = '!$acc loop {clauses}\n'.format(clauses=clauses)
prolog = f'!$acc loop {clauses}\n'
Copy link

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Copy link
Member Author

Choose a reason for hiding this comment

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

/bot accept
See #1514

code = ('{prolog}'
'{loop}'
'{epilog}').format(prolog=prolog, loop=loop, epilog=epilog)
code = (f'{prolog}'
Copy link

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Copy link
Member Author

Choose a reason for hiding this comment

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

/bot accept
See #1514

@@ -456,9 +463,9 @@ def _print_Assign(self, expr):
local_vars = [str(x) for x in local_vars]

if lhs_code in local_vars:
return ("local %s = %s" % (lhs_code, rhs_code))
return f"local {lhs_code} = {rhs_code}"
Copy link

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Copy link
Member Author

Choose a reason for hiding this comment

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

/bot accept
Luacode has no associated tests. Code is probably obsolete

@EmilyBourne EmilyBourne marked this pull request as ready for review May 12, 2024 16:53
@EmilyBourne EmilyBourne added the internals Pyccel's internal behavior, does not affect user experience label May 12, 2024
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 12, 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 12, 2024 17:12
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.

@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 13, 2024
@pyccel-bot
Copy link

pyccel-bot bot commented May 13, 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 😄

@EmilyBourne EmilyBourne changed the title Remove unnecessary functions from CodePrinter Remove unnecessary functions from CodePrinter (50 lines) May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internals Pyccel's internal behavior, does not affect user experience 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.

None yet

2 participants