microsoft / QuantumLibraries

Q# libraries for the Quantum Development Kit
https://docs.microsoft.com/quantum
MIT License
542 stars 179 forks source link

Chemistry classes inaccessible outside samples namespace #138

Closed christopherkang closed 5 years ago

christopherkang commented 5 years ago

Describe the bug The Broombridge class is inaccessible outside of the Microsoft.Quantum.Chemistry.Samples namespace.

To Reproduce

  1. Create a new project, e.g. named EstimateReferenceEnergy. Reference Microsoft.Quantum.Chemistry;, Microsoft.Quantum.Chemistry.OrbitalIntegrals;, and/or Microsoft.Quantum.Chemistry.Broombridge;
  2. Reference the Broombridge class in the driver, for example: var broombridge = Broombridge.Deserializers.DeserializeBroombridge($filename$); where $filename$ is the filename of a YAML file.
  3. Run the project. The error Driver.cs(29,31): error CS0103: The name 'Broombridge' does not exist in the current context should appear.
  4. Rename the namespace to Microsoft.Quantum.Chemistry.Samples. The error should disappear and allow the code to run.

Expected behavior Regardless of namespace name, the code should be able to reference the Broombridge class.

System information

Additional context Note - I've also seen this with other classes, like Paulis and QSharpFormat.

cgranade commented 5 years ago

Thanks for the report, @christopherkang! Looking at the steps you provided, I'm having trouble reproducing, in that the following C# code compiles (but obviously does not run) for 0.7.1905.3109:

using System;

using Microsoft.Quantum.Simulation.Simulators;
using Microsoft.Quantum.Chemistry.Broombridge;

namespace quantumlibraries_138
{
    class Driver
    {
        static void Main(string[] args)
        {
            var broombridge = Deserializers.DeserializeBroombridge("$filename$");
        }
    }
}

Would you be willing to share an example of this bug? Gists can be very useful for this kind of thing, if you'd be willing to share a reproduction that way. Thanks!

christopherkang commented 5 years ago

Hey @cgranade - thanks for the fast reply!

I tried replicating your code and it compiled on mine. I think the problem was that Broombridge cannot be called directly; rather, the Deserializers method needs to be called. Because I followed the example on the docs, I directly called Broombridge and the code failed to compile.

Would it be possible to update the docs to reflect this? Thank you for your help!

cgranade commented 5 years ago

@christopherkang: No worries, happy to help! I'll make a new issue on the docs and link to that from here, then.