Skip to content

MethodSCRIPT

pypalmsens.MethodScript


              flowchart TD
              pypalmsens.MethodScript[MethodScript]
              pypalmsens._methods.base.BaseTechnique[BaseTechnique]
              pypalmsens._methods.base_model.BaseModel[BaseModel]

                              pypalmsens._methods.base.BaseTechnique --> pypalmsens.MethodScript
                                pypalmsens._methods.base_model.BaseModel --> pypalmsens._methods.base.BaseTechnique
                



              click pypalmsens.MethodScript href "" "pypalmsens.MethodScript"
              click pypalmsens._methods.base.BaseTechnique href "" "pypalmsens._methods.base.BaseTechnique"
              click pypalmsens._methods.base_model.BaseModel href "" "pypalmsens._methods.base_model.BaseModel"
            

Create a method script sandbox object.

The MethodSCRIPT Sandbox allows you to write your own MethodSCRIPT and run them on your instrument.

The MethodSCRIPT language allows for programming a human-readable script directly into the potentiostat. The simple script language makes it easy to combine different measurements and other tasks.

For more information see: https://www.palmsens.com/methodscript/

Methods:

  • from_dict

    Structure technique instance from dict.

  • from_file

    Load methodscript from file.

  • from_method_id

    Create new instance of appropriate technique from method ID.

  • to_dict

    Return the technique instance as a new key/value dictionary mapping.

  • to_file

    Save script to file.

Attributes:

script class-attribute instance-attribute

script: str = 'e\nwait 100m\nif 1 < 2\n    send_string "Hello world"\nendif\n\n'

Script to run.

For more info on MethodSCRIPT, see: https://www.palmsens.com/methodscript/ for more information.

from_dict classmethod

from_dict(obj: dict[str, Any]) -> BaseTechnique

Structure technique instance from dict.

Opposite of .to_dict()

Source code in src/pypalmsens/_methods/base.py
35
36
37
38
39
40
@classmethod
def from_dict(cls, obj: dict[str, Any]) -> BaseTechnique:
    """Structure technique instance from dict.

    Opposite of `.to_dict()`"""
    return cls.model_validate(obj)

from_file classmethod

from_file(path: str | Path = 'methodscript.mscr') -> MethodScript

Load methodscript from file.

Parameters:

  • path

    (str | Path, default: 'methodscript.mscr' ) –

    Path to methodscript file.

Returns:

Source code in src/pypalmsens/_methods/techniques.py
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
@classmethod
def from_file(cls, path: str | Path = 'methodscript.mscr') -> MethodScript:
    """Load methodscript from file.

    Parameters
    ----------
    path: str | Path
        Path to methodscript file.

    Returns
    -------
    method: MethodScript
    """
    with Path(path).open('r') as f:
        script = f.read()

    return cls(script=script)

from_method_id classmethod

from_method_id(id: str) -> BaseTechnique

Create new instance of appropriate technique from method ID.

Source code in src/pypalmsens/_methods/base.py
42
43
44
45
46
@classmethod
def from_method_id(cls, id: str) -> BaseTechnique:
    """Create new instance of appropriate technique from method ID."""
    new = cls._registry[id]
    return new()

to_dict

to_dict() -> dict[str, Any]

Return the technique instance as a new key/value dictionary mapping.

Source code in src/pypalmsens/_methods/base.py
31
32
33
def to_dict(self) -> dict[str, Any]:
    """Return the technique instance as a new key/value dictionary mapping."""
    return self.model_dump()

to_file

to_file(path: str | Path = 'methodscript.mscr') -> None

Save script to file.

Parameters:

  • path

    (str | Path, default: 'methodscript.mscr' ) –

    Path to methodscript file.

Source code in src/pypalmsens/_methods/techniques.py
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
def to_file(self, path: str | Path = 'methodscript.mscr') -> None:
    """Save script to file.

    Parameters
    ----------
    path: str | Path
        Path to methodscript file.
    """
    with Path(path).open('w') as f:
        _ = f.write(self.script)