pennylane icon indicating copy to clipboard operation
pennylane copied to clipboard

Group "utility" operations into same file.

Open albi3ro opened this issue 2 years ago • 1 comments

Right now, Barrier and WireCut are located in pennylane/ops/qubit/non_parametric_ops.py, even though they are not unique to qubit ops. Snapshot is located in its own file in pennylane/ops/snapshot.py.

I propose grouping all three ops:

  • Barrier
  • WireCut
  • Snapshot

into a new file pennylane/ops/utility_ops.py. The tests should then be moved as well.

I am open to a different name than "utility". Whatever term bests describes "things we mostly treat as operations but aren't really."

Update: Let's place these in pennylane/ops/meta.py.

albi3ro avatar Aug 16 '22 17:08 albi3ro

Maybe a module name that indicates that these are 'meta' operations? That is, they use the Operation abstraction but aren't actually operations in the theoretical sense

josh146 avatar Aug 16 '22 20:08 josh146

Hi! Can I work on this issue?

tgag17 avatar Oct 16 '22 19:10 tgag17

Hi @tgag17 , Go ahead! I've tagged you on the issue.

albi3ro avatar Oct 17 '22 18:10 albi3ro

Thanks @albi3ro!

tgag17 avatar Oct 17 '22 18:10 tgag17

Heyy, is this issue still available? Please let me know!! As the related/attached PR is closed due to inactivity

AnuravModak avatar Nov 01 '23 07:11 AnuravModak

This issue is still good to go. Feel free to take this on @AnuravModak !

albi3ro avatar Nov 01 '23 13:11 albi3ro

Hello @albi3ro, I've begun working on this issue, and I have a few questions. But before that, let me update you on my progress. I've relocated the Barrier and WireCut operations from pennylane/ops/qubit/non_parametric_ops.py, moved the Snapshot operation from pennylane/ops/snapshot.py, and deleted the snapshot.py file. Additionally, I've updated the import statements in pennylane/ops/qubit/__init__.py.

Now, I'd like to know your plan regarding the movement of the corresponding test code. Should I transfer the test code from tests/ops/qubit/test_non_parametric_ops.py to meta.py , or do you have a different directory or file in mind where I should relocate these test codes?

Also kindly provide the command to reformat the files according to black formatting style or any other mandatory formatting styles so that there is no issue with formatting.

AnuravModak avatar Nov 03 '23 17:11 AnuravModak

Thanks for reaching out @AnuravModak :)

Moving tests from tests/ops/qubit/test_non_parametric_opy.py and tests/ops/test_snapshot.py to a new file tests/ops/test_meta.py would be recommended.

Formatting with black can be done with:

black -l 100 pennylane
black -l 100 tests

and pylint can be run with

pylint relevant_file.py

These commands can also be found in our page on Submitting a pull request

albi3ro avatar Nov 03 '23 18:11 albi3ro

Closed by #4789

albi3ro avatar Nov 07 '23 18:11 albi3ro