qiskit-community / qiskit-nature

Qiskit Nature is an open-source, quantum computing, framework for solving quantum mechanical natural science problems.
https://qiskit-community.github.io/qiskit-nature/
Apache License 2.0
301 stars 204 forks source link

Formatting error message #1276

Closed julenl closed 10 months ago

julenl commented 10 months ago

An space was missing here as well.

Summary

Details and comments

coveralls commented 10 months ago

Pull Request Test Coverage Report for Build 6879272982


Totals Coverage Status
Change from base Build 6873975703: 0.0%
Covered Lines: 8768
Relevant Lines: 10104

💛 - Coveralls
mrossinek commented 10 months ago

Did you do a search if you find any more such cases besides this one?

julenl commented 10 months ago

Yesterday I didn't but today, before I sent this one, I run a recursive grep on the circuit folder and only those two (the one from yesterday and this one) came up.

mrossinek commented 10 months ago

Since you already have this search set up, why don't you run that on the entire source code rather than just the circuit module?

julenl commented 10 months ago

Sure, I did that too, short after I answered you.

cd qiskit_nature
grep -R 'The number of spatial orbitals {' -R
second_q/circuit/library/initial_states/hartree_fock.py:      f"The number of spatial orbitals {self.num_spatial_orbitals} "
second_q/circuit/library/ansatzes/ucc.py    f"The number of spatial orbitals {self.num_spatial_orbitals}"

Only those two, by that syntax.

mrossinek commented 10 months ago

Ah I see. I had assumed you would have done a search for:

That would probably require a little bit of regex magic so if that is not something you are familiar with, we can also leave it at that.

julenl commented 10 months ago

With this snippet:

for entry in os.walk('qiskit_nature'):
    for filename in entry[2]:
        file = entry[0] + os.sep + filename
        if file.endswith('.py'):
            with open(file, 'r') as fh:
                text = fh.read()
            mymatch = re.search('f".*[^\s]"\n\s+f"[^\s].*"', text)
            if mymatch:
                print(file)
                print('  ', mymatch.group()

I get:

qiskit_nature/second_q/hamiltonians/quadratic_hamiltonian.py
   f"QuadraticHamiltonian("
   f"hermitian_part={repr(self.hermitian_part)}, "
qiskit_nature/second_q/circuit/library/ansatzes/ucc.py
   f"The number of spatial orbitals {self.num_spatial_orbitals}"
   f"must be greater than number of particles of any spin kind "
qiskit_nature/second_q/operators/spin_op.py
   f"Invalid operation between operators with different spin"
   f"values. Found spin_1={spin} and spin_2={other_spin}."
qiskit_nature/second_q/operators/electronic_integrals.py
   f"The reported register_length of your beta-alpha-spin tensor, {beta_alpha_len}"
   f", does not match the alpha-spin tensor one, {alpha_len}."

But only the spin_op and ucc require changes.