Skip to content

Commit

Permalink
linting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
EBB2675 committed Feb 10, 2025
1 parent fd8e2a1 commit 4897e70
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 33 deletions.
7 changes: 5 additions & 2 deletions src/nomad_parser_qutip/parsers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from nomad.config.models.plugins import ParserEntryPoint
from pydantic import Field

# from pydantic import Field


class QutipEntryPoint(ParserEntryPoint):
def load(self):
from nomad_parser_qutip.parsers.parser import QutipParser

return QutipParser(**self.dict())


parser_entry_point = QutipEntryPoint(
name='QuTiP Parser',
description='Parser for QuTiP outputs in text format.',
mainfile_name_re='.*\.out.*',
mainfile_contents_re=r'EBB2675 Version [\d\.]*', # to be fixed later on with real vals
mainfile_contents_re=r'EBB2675 Version [\d\.]*', # to be fixed
)
3 changes: 0 additions & 3 deletions src/nomad_parser_qutip/parsers/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
)

from nomad.config import config
from nomad.units import ureg
from nomad.parsing.parser import MatchingParser

from nomad_simulations.schema_packages.general import Program, Simulation

configuration = config.get_plugin_entry_point(
Expand All @@ -32,4 +30,3 @@ def parse(
simulation = Simulation()
simulation.program = Program(name='QuTiP')
archive.data = simulation

44 changes: 16 additions & 28 deletions src/nomad_parser_qutip/schema_packages/schema_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,12 @@
)

if TYPE_CHECKING:
from nomad.datamodel.datamodel import (
EntryArchive,
)
from structlog.stdlib import (
BoundLogger,
)
pass

import numpy as np
from nomad.config import config
from nomad.datamodel.data import Schema
from nomad.datamodel.metainfo.annotations import ELNAnnotation, ELNComponentEnum
from nomad.metainfo import (Quantity,
SchemaPackage,
SubSection,
MEnum,
Section)
from nomad.datamodel.data import ArchiveSection

from nomad.metainfo import MEnum, Quantity, SchemaPackage

configuration = config.get_plugin_entry_point(
'nomad_parser_qutip.schema_packages:schema_package_entry_point'
Expand All @@ -33,14 +22,13 @@ class Qobj(ArchiveSection):
A section to semantically represent a QuTiP Qobj.
The main quantities are:
dims : The Hilbert space dimensions as a nested list (e.g. [[2], [1]] for a ket).
shape : The shape of the underlying data matrix (e.g. [2, 1] for a column vector).
type : A string (enumerated) to label the Qobj (e.g. 'ket', 'bra', 'oper', 'super').
dims : Hilbert space dimensions as a nested list (e.g. [[2], [1]] for a ket).
shape : SWape of the underlying data matrix (e.g. [2, 1] for a column vector).
type : MEnum to label the Qobj (e.g. 'ket', 'bra', 'oper', 'super').
dtype : The data type indicator (for example, 'Dense' or 'csr') showing the
numerical storage format.
isherm : A Boolean flag indicating whether an operator is Hermitian.
(For state vectors, this property is typically not meaningful.)
data : The numerical data stored as a 2D array (matrix) containing the Qobj values.
isherm : Boolean flag indicating whether an operator is Hermitian.
data : Numerical data stored as a 2D array.
"""

dims = Quantity(
Expand All @@ -64,8 +52,11 @@ class Qobj(ArchiveSection):
type = Quantity(
type=MEnum('ket', 'bra', 'oper', 'super'),
description=(
"""Type of the quantum object. Examples include 'ket' for state vectors,
'bra' for dual vectors, 'oper' for operators, and 'super' for superoperators."""
"""Type of the quantum object.
'ket' for state vectors,
'bra' for dual vectors,
'oper' for operators,
'super' for superoperators."""
),
)

Expand All @@ -79,9 +70,7 @@ class Qobj(ArchiveSection):

isherm = Quantity(
type=bool,
description=(
"""Flag indicating whether the operator is Hermitian."""
),
description=("""Flag indicating whether the operator is Hermitian."""),
)

data = Quantity(
Expand All @@ -97,16 +86,15 @@ def normalize(self, archive, logger) -> None:
"""
Normalization method to check consistency of the Qobj.
For instance, one could verify that the provided `shape` matches the shape of `data`
or that the product of the dimensions implied by `dims` is consistent with `data.shape`.
"""
super().normalize(archive, logger)
# this is just a placeholder, will take care of it later.
if self.data is not None:
data_shape = list(self.data.shape)
if self.shape != data_shape:
logger.warning(
f"Inconsistent shape: quantity 'shape' is {self.shape} but data.shape is {data_shape}."
"Inconsistent shape!"
)


m_package.__init_metainfo__()

0 comments on commit 4897e70

Please sign in to comment.