Commit 108dda08 authored by Mario's avatar Mario
Browse files

Merge branch 'mario_wrk'

parents 9cc6bbad bc172815
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
Collects the config from 3 different locations:

* Local script directory (DMT_config.yaml).
* User's home directory (%LOCALAPPDATA%\DMT\DMT_config.yaml or $XDG_CONFIG_HOME/DMT/DMT_config.yaml with $XDG_CONFIG_HOME defaulting to ~/.config) and
* User's home directory (%LOCALAPPDATA%\\DMT\\DMT_config.yaml or $XDG_CONFIG_HOME/DMT/DMT_config.yaml with $XDG_CONFIG_HOME defaulting to ~/.config) and
* DMT package installation directory (DMT/config/DMT_config.yaml)

They are all read and finally taken in the order given here. This means that anything given in the local directory overwrites all others.
@@ -72,7 +72,7 @@ except FileNotFoundError:
        warnings.warn(
            (
                "The DMT user configuration file has been moved. The new paths are:\n"
                + "Windows: %LOCALAPPDATA%\DMT\DMT_config.yaml\n"
                + "Windows: %LOCALAPPDATA%\\DMT\\DMT_config.yaml\n"
                + "Linux and MacOS: $XDG_CONFIG_HOME/DMT/DMT_config.yaml\n"
                + "Defaulting to ~/.config/DMT/DMT_config.yaml"
            ),
+5 −10
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
# along with this program.  If not, see <http://www.gnu.org/licenses/>
import numpy as np
from skrf import network as rf_network
from DMT.core import specifiers, set_col_name, sub_specifiers
from DMT.core import specifiers, sub_specifiers


def is_iterable(arg):
@@ -494,25 +494,20 @@ class DataProcessor(object):
        col_vb, col_ib, col_vc, col_ic, col_ve = None, None, None, None, None
        try:
            col_vb = df.get_col_name(specifiers.VOLTAGE, "B")
            col_vb_force = set_col_name(
                specifiers.VOLTAGE, "B", sub_specifiers=sub_specifiers.FORCED
            )
            col_vb_force = specifiers.VOLTAGE + "B" + sub_specifiers.FORCED

            df[col_vb_force] = df[col_vb].to_numpy()
        except KeyError:
            pass
        try:
            col_vc = df.get_col_name(specifiers.VOLTAGE, "C")
            col_vc_force = set_col_name(
                specifiers.VOLTAGE, "C", sub_specifiers=sub_specifiers.FORCED
            )
            col_vc_force = specifiers.VOLTAGE + "C" + sub_specifiers.FORCED
            df[col_vc_force] = df[col_vc].to_numpy()
        except KeyError:
            pass
        try:
            col_ve = df.get_col_name(specifiers.VOLTAGE, "E")
            col_ve_force = set_col_name(
                specifiers.VOLTAGE, "E", sub_specifiers=sub_specifiers.FORCED
            )
            col_ve_force = specifiers.VOLTAGE + "E" + sub_specifiers.FORCED
            df[col_ve_force] = df[col_ve].to_numpy()
        except KeyError:
            pass
+2 −2
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ Author: Mario Krattenmacher | Mario.Krattenmacher@semimod.de
# along with this program.  If not, see <http://www.gnu.org/licenses/>
import copy
from collections import OrderedDict
from typing import List, Dict, Type
from typing import List, Dict, Type, Union
from DMT.core import (
    create_md5_hash,
    DutView,
@@ -235,7 +235,7 @@ class DutCircuit(DutView):
        else:
            raise OSError("The modelcard has to be a instance of MCard or its children!")

    def get_hash(self):
    def get_hash(self) -> Union[bool, str]:
        """Returns a md5 hash generated from self.inp_header, if it is not set, this will return False!

        Is overwritten here, to include the imported and appended files!
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import os
from typing import Union


def create_md5_hash(*contents: Union[str, os.PathLike]):
def create_md5_hash(*contents: Union[str, os.PathLike]) -> str:
    """Construct the hash MD5 string with all parameters

    Parameters
+24 −5
Original line number Diff line number Diff line
@@ -48,11 +48,15 @@ from pathlib import Path

import _pickle as cpickle  # type: ignore
import numpy as np
from typing import Dict, OrderedDict, Type, Union, List, Optional
from typing import Dict, OrderedDict, Type, Union, List, Optional, TYPE_CHECKING
from pint.formatting import siunitx_format_unit
from pint.errors import UndefinedUnitError

from DMT.core import unit_registry

if TYPE_CHECKING:
    from DMT.core.circuit import Circuit

from DMT.exceptions import (
    ValueExcludedError,
    ValueTooLargeError,
@@ -822,7 +826,8 @@ class McParameterCollection(object):
        return collection

    def get(
        self, parameters: Union[str, McParameter, list[str], tuple[str], McParameterCollection]
        self,
        parameters: Union[str, McParameter, list[str], tuple[str], McParameterCollection],
    ) -> Union[McParameter, McParameterCollection]:
        """Returns a McParameterCollection with copies of all given parameter names.

@@ -1243,7 +1248,8 @@ class McParameterCollection(object):
                data_table.end_table_header()
                data_table.add_hline()
                data_table.add_row(
                    (MultiColumn(2, align="r", data="continued on next Page"),), strict=False
                    (MultiColumn(2, align="r", data="continued on next Page"),),
                    strict=False,
                )
                data_table.add_hline()
                data_table.end_table_footer()
@@ -1267,7 +1273,8 @@ class McParameterCollection(object):
                            # )
                            group_desc = self.possible_groups[group]
                            data_table.add_row(
                                (MultiColumn(2, align="l", data=group_desc),), strict=False
                                (MultiColumn(2, align="l", data=group_desc),),
                                strict=False,
                            )
                        except KeyError:
                            pass
@@ -1283,7 +1290,7 @@ class McParameterCollection(object):
                    else:
                        data_table.add_row(
                            [
                                NoEscape(f"{para:<12s}/\si{{{para:u}}}"),
                                NoEscape(f"{para:<12s}/\\si{{{para:u}}}"),
                                NoEscape(f"{para:g}"),
                            ],
                            strict=False,
@@ -1388,3 +1395,15 @@ class McParameterCollection(object):
            return self.eq_paras(other)

        return NotImplemented

    def get_circuit(self, use_build_in=False, topology=None, **kwargs) -> Circuit:
        """Here the modelcard defines it's default simulation circuit.

        Parameters
        ----------
        use_build_in : {False, True}, optional
            Creates a circtui the modelcard using the build-in model
        topology : optional
            If a model has multiple standard circuits, use the topology to differentiate between them..
        """
        raise NotImplementedError("The superclass McParameterCollection has no circuit :(.")
Loading