Code Monkey home page Code Monkey logo

Comments (6)

jotterbach avatar jotterbach commented on June 3, 2024

@rasa97 Thanks for the issue report! We just refactored the Deutsch-Josza module significantly. Would you mind looking at it again and see if this is still an issue?

from grove.

rasa97 avatar rasa97 commented on June 3, 2024

The refactored one works for single qubit. However, when I run the code for 2-qubits, there are errors. For balanced, I get:

The code is print dj.is_constant(qvm, {'00':'0', '01':'1', '10':'0', '11':'1'})

line 147, in unitary_function
value = int(mappings[bitstring])
KeyError: '0'

For constant, I get the error:

line 59, in is_constant
     constant = all([bit == 0 for bit in bitstring])
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

The code is print dj.is_constant(qvm, {'00':'0', '01':'0', '10':'0', '11':'0'})

from grove.

ampolloreno avatar ampolloreno commented on June 3, 2024

@rasa97 Thank you for the followup! I'm opening up a PR to fix this!

from grove.

rasa97 avatar rasa97 commented on June 3, 2024

I'm curious to know why the inputs should be represented in a dict. Isn't list enough? Its easier that way, right?

from grove.

jotterbach avatar jotterbach commented on June 3, 2024

@rasa97 I agree that a list has less overhead, but it also makes implicit assumptions about ordering. Moreover, the structure of a dict highlights the structure of the problem and makes it more apparent. In the end you will have to provide 2**n inputs, so an additional factor of 2 will not make too much of a difference.

What's your thought on this?

from grove.

rasa97 avatar rasa97 commented on June 3, 2024

For the sake of convenience, list is better I guess. If the user has an idea about the ordering, it would be easier to just type in the bits. The pattern in which it should be typed can be highlighted in docs.

from grove.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.