Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
EBB2675 committed Feb 14, 2025
1 parent 4897e70 commit 021be15
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ maintainers = [
license = { file = "LICENSE" }
dependencies = [
"nomad-lab>=1.3.0",
"python-magic-bin; sys_platform == 'win32'",
"nomad-simulations>=0.0.6",
]

[project.urls]
Repository = "https://github.com/EBB2675/nomad-parser-qutip"
Repository = "https://github.com/FAIRmat-NFDI/nomad-parser-qutip"

[project.optional-dependencies]
dev = ["ruff", "pytest", "structlog"]
Expand Down Expand Up @@ -77,7 +77,7 @@ select = [
"UP",
# isort
"I",
# pylint
# pylint
"PL",
]

Expand Down
6 changes: 4 additions & 2 deletions src/nomad_parser_qutip/parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def load(self):

parser_entry_point = QutipEntryPoint(
name='QuTiP Parser',
description='Parser for QuTiP outputs in text format.',
description='Parser for QuTiP outputs.',
# The following is a regular expression for the name of a potential mainfile.
# If this expression is given:
# the parser is only considered for a file, if the expression matches.
mainfile_name_re='.*\.out.*',
mainfile_contents_re=r'EBB2675 Version [\d\.]*', # to be fixed
)
3 changes: 3 additions & 0 deletions src/nomad_parser_qutip/parsers/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from nomad.config import config
from nomad.parsing.parser import MatchingParser
from nomad.datamodel.metainfo.workflow import Workflow
from nomad_simulations.schema_packages.general import Program, Simulation

configuration = config.get_plugin_entry_point(
Expand All @@ -28,5 +29,7 @@ def parse(
child_archives: dict[str, 'EntryArchive'] = None,
) -> None:
simulation = Simulation()
# here we are populating the archive with the program name
simulation.program = Program(name='QuTiP')
# put the simulation section into archive data
archive.data = simulation
25 changes: 12 additions & 13 deletions src/nomad_parser_qutip/schema_packages/schema_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@ class Qobj(ArchiveSection):
A section to semantically represent a QuTiP Qobj.
The main quantities are:
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).
dims : Hilbert space dimensions.
shape : Shape of the underlying data.
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 : Boolean flag indicating whether an operator is Hermitian.
data : Numerical data stored as a 2D array.
data : Matrix representing state or operator.
"""

dims = Quantity(
type=list,
type=np.int32,
shape=['*', '*'],
description=(
"""Hilbert space dimensions of the quantum object. For example, a ket
state in a 2-dimensional space may have dims=[[2], [1]]."""
"""List of dimensions keeping track of the tensor structure.
Example for a ket: [[2], [1]]."""
),
)

shape = Quantity(
type=list,
type=np.int32,
shape=['*'],
description=(
"""Shape of the underlying data matrix. For example, a state vector (ket)
might have shape=[2, 1]."""
"""Shape of the underlying data array.
Example for a ket : [2, 1]."""
),
)

Expand Down Expand Up @@ -74,11 +74,10 @@ class Qobj(ArchiveSection):
)

data = Quantity(
type=np.ndarray,
type=np.float64,
shape=['*', '*'],
description=(
"""The numerical matrix data of the quantum object.
It is stored as a 2D array."""
"""Sparse matrix characterizing the quantum object."""
),
)

Expand All @@ -88,7 +87,7 @@ def normalize(self, archive, logger) -> None:
"""
super().normalize(archive, logger)
# this is just a placeholder, will take care of it later.
# a simple example for the normalization function
if self.data is not None:
data_shape = list(self.data.shape)
if self.shape != data_shape:
Expand Down
4 changes: 2 additions & 2 deletions tests/parsers/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from nomad.datamodel import EntryArchive

from nomad_parser_qutip.parsers.parser import NewParser
from nomad_parser_qutip.parsers.parser import QutipParser


def test_parse_file():
parser = NewParser()
parser = QutipParser()
archive = EntryArchive()
parser.parse('tests/data/example.out', archive, logging.getLogger())

Expand Down

0 comments on commit 021be15

Please sign in to comment.