Catalog PyPI
Back to packageRELEASE DETAILS

0.0.6

PyPI

aiida-python

AiiDA Python

Published3 Nov 2023
Direct dependencies8
Transitive dependenciesNot calculated

README

Version 0.0.6 documentation

AiiDA Python

This package is an AiiDA plugin allowing you to run python code as CalcJob on a remote computer. Usage is easy one has to inherit CalcJobPython class and instead of prepare_for_submition method one ahs to overload run_python. Parser is generated automatically one does not have to write its own.

from aiida.plugins import CalculationFactory

CalcJobPython = CalculationFactory("aiida_python.calc")

class ClassThatCannotStartWithTestExample(CalcJobPython):

    @classmethod
    def define(cls, spec):
        super().define(spec)

        spec.input('inputarray', valid_type=ArrayData)
        spec.input('repeats', valid_type=Int)
        spec.output('value', valid_type=Float)

    def run_python(self):
        import numpy as np

        a = self.inputs.inputarray
        repeats = self.inputs.repeats
        a_inv = np.linalg.inv(a)

        for ii in range(repeats):
            a_inv = np.matmul(a_inv, a_inv)
            a_inv = a_inv/sum(a_inv)

        a = np.linalg.inv(a)

        c = float(np.sum(a))
        self.outputs.value = c

Here is a test case example

def test_example(aiida_local_code_factory, clear_database):
    from aiida.plugins import CalculationFactory
    from aiida.engine import run
    import numpy as np

    executable = 'python3'
    entry_point = 'test.calc_example'

    code = aiida_local_code_factory(entry_point=entry_point, executable=executable)
    calculation = CalculationFactory(entry_point)

    np_a = np.array([[1,2,1],[3,4,3],[0,1,1]])
    a = ArrayData()
    a.set_array("only_one", np_a)

    inputs = { 'code': code,
               'inputarray': a,
               'repeats': Int(10)}

    result = run(calculation, **inputs)

For more information look at this link.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 8

Native requirements
8 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
aiida-core
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "",
  "evaluation": "NOT_EVALUATED"
}
aiida-core>=2.1.0runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"testing\"",
  "requires_python": "",
  "evaluation": "NOT_EVALUATED"
}
pytest; extra == "testing"runtime
pgtest
Environment
{
  "extras": "",
  "marker": "extra == \"testing\"",
  "requires_python": "",
  "evaluation": "NOT_EVALUATED"
}
pgtest; extra == "testing"runtime
Pillow
Environment
{
  "extras": "",
  "marker": "extra == \"testing\"",
  "requires_python": "",
  "evaluation": "NOT_EVALUATED"
}
Pillow>=8.1.2; extra == "testing"runtime
pre-commit
Environment
{
  "extras": "",
  "marker": "extra == \"pre-commit\"",
  "requires_python": "",
  "evaluation": "NOT_EVALUATED"
}
pre-commit~=2.2; extra == "pre-commit"runtime
pylint
Environment
{
  "extras": "",
  "marker": "extra == \"pre-commit\"",
  "requires_python": "",
  "evaluation": "NOT_EVALUATED"
}
pylint<2.9,>=2.5.0; extra == "pre-commit"runtime
sphinx
Environment
{
  "extras": "",
  "marker": "extra == \"docs\"",
  "requires_python": "",
  "evaluation": "NOT_EVALUATED"
}
sphinx; extra == "docs"runtime
sphinx-rtd-theme
Environment
{
  "extras": "",
  "marker": "extra == \"docs\"",
  "requires_python": "",
  "evaluation": "NOT_EVALUATED"
}
sphinx-rtd-theme; extra == "docs"runtime

Distribution files

1 collected
aiida-python-0.0.6.tar.gz

sdist · 9.8 KB · Python source

Source file

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 11:00 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:ada94abdbb9c408360fdeef49d16b0445ef01f99770b13786a00a056536e7ff5

Other collected versions

View all collected versions →