Skip to content

Re-enable typechecking for modules  #531

@PicoCentauri

Description

@PicoCentauri

In #524 we had to disable the type checking for all modules because the means and sems of the _obs dictionary have no clear types.

We should set these types in a better way and re-enable the checker with mypy. I think the propper way is that each module has to define it's observables and we do not try to guess a complicated try-except block:

# This try/except block is used because it will fail only once and is
# therefore not a performance issue like a if statement would be.
try:
# Fail fast if the means and sems are not defined yet.
self.means # type: ignore # noqa B018
self.sems # type: ignore # noqa B018
# Take the data from the current frame and update the means and sems
for key in self._obs:
# Sanitize the data type of the observable
if isinstance(self._obs[key], list):
self._obs[key] = np.array(self._obs[key])
if key not in self._pop:
# Observable is a single sample, so _pop is 1 and _var is 0
self._pop[key] = np.ones(np.shape(self._obs[key]), dtype=int)

Originally posted by @PicoCentauri in #524 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    code cleanupImprove the quality and documentation of our codepart::coreIssues and MRs for the core part of MAICoS.priority::high

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions