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

redefining a function should be allowed #307

Closed
doug-q opened this issue Jul 18, 2024 · 2 comments · Fixed by #326 or #310
Closed

redefining a function should be allowed #307

doug-q opened this issue Jul 18, 2024 · 2 comments · Fixed by #326 or #310

Comments

@doug-q
Copy link
Contributor

doug-q commented Jul 18, 2024

when I use guppy in a notebook and I re-evaluate a cell containing a @guppy function definition I get an error:

guppylang.error.GuppyError: ('Module `main` already contains a definition named `rus`', None)

I suggest that instead, the existing function definition should be replaced

@mark-koch
Copy link
Collaborator

Should this behaviour be specific to notebooks or apply to all Guppy modules?

@doug-q
Copy link
Contributor Author

doug-q commented Jul 18, 2024

Should this behaviour be specific to notebooks or apply to all Guppy modules?

I don't have an opinion. It does seem natural to always overwrite, but what are the costs? Do we check types etc inside the @guppy decorator, and overwriting invalidates those checks? If so, perhaps the current behaviour should remain possible.

Passing mod = GuppyModule(allow_overwrites=True) would be fine. One could write a wrapper around this that looked for a notebook environment if one were inclined.

github-merge-queue bot pushed a commit that referenced this issue Jul 25, 2024
🤖 I have created a release *beep* *boop*
---


## [0.7.0](v0.6.2...v0.7.0)
(2024-07-25)


### ⚠ BREAKING CHANGES

* `qubit`s are now reset on allocation

### Features

* `qubit`s are now reset on allocation, and `dirty_qubit` added
([#325](#325))
([4a9e205](4a9e205))
* Allow access to struct fields and mutation of linear ones
([#295](#295))
([6698b75](6698b75)),
closes [#293](#293)
* Allow redefinition of names in guppy modules
([#326](#326))
([314409c](314409c)),
closes [#307](#307)


### Bug Fixes

* Use correct hook for error printing inside jupyter notebooks
([#324](#324))
([bfdb003](bfdb003)),
closes [#323](#323)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants