Skip to content

Commit

Permalink
added doctests to code example in computation_process.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nh916 committed Oct 3, 2023
1 parent cba421b commit 2d8862d
Showing 1 changed file with 69 additions and 106 deletions.
175 changes: 69 additions & 106 deletions src/cript/nodes/primary_nodes/computation_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,42 +143,30 @@ def __init__(
Examples
--------
```python
# create file node for input data node
data_files = cript.File(
source="https://criptapp.org",
type="calibration",
extension=".csv",
data_dictionary="my file's data dictionary"
)
# create input data node
input_data = cript.Data(name="my data name", type="afm_amp", files=[data_files])
# Material node for Quantity node
my_material = cript.Material(
name="my material",
identifier=[{"alternative_names": "my material alternative name"}]
)
# create quantity node
my_quantity = cript.Quantity(key="mass", value=1.23, unit="gram")
# create ingredient node
ingredient = cript.Ingredient(
material=my_material,
quantities=[my_quantity],
)
# create computational process node
my_computational_process = cript.ComputationalProcess(
name="my computational process name",
type="cross_linking",
input_data=[input_data],
ingredient=[ingredient],
)
```
>>> import cript
>>> data_files = cript.File(
... name="my file node name",
... source="https://criptapp.org",
... type="calibration",
... extension=".csv",
... data_dictionary="my file's data dictionary"
... )
>>> input_data = cript.Data(name="my data name", type="afm_amp", file=[data_files])
>>> my_material = cript.Material(
... name="my material",
... identifier=[{"alternative_names": "my material alternative name"}]
... )
>>> my_quantity = cript.Quantity(key="mass", value=1.23, unit="kg")
>>> ingredient = cript.Ingredient(
... material=my_material,
... quantity=[my_quantity],
... )
>>> my_computation_process = cript.ComputationProcess(
... name="my computational process name",
... type="cross_linking",
... input_data=[input_data],
... ingredient=[ingredient],
... )
Parameters
Expand Down Expand Up @@ -257,9 +245,8 @@ def type(self) -> str:
Examples
--------
```python
my_computational_process.type = "DPD"
```
>>> import cript
>>> my_computation_process.type = "DPD" # doctest: +SKIP
Returns
-------
Expand Down Expand Up @@ -298,21 +285,16 @@ def input_data(self) -> List[Any]:
Examples
--------
```python
# create file node for the data node
my_file = cript.File(
source="https://criptapp.org",
type="calibration",
extension=".csv",
data_dictionary="my file's data dictionary"
)
# create input data node
my_input_data = cript.Data(name="my input data name", type="afm_amp", files=[my_file])
# set computational process data node
my_computation.input_data = my_input_data
```
>>> import cript
>>> my_file = cript.File(
... name="my file node name",
... source="https://criptapp.org",
... type="calibration",
... data_dictionary="my file's data dictionary",
... extension=".csv",
... )
>>> my_input_data = cript.Data(name="my input data name", type="afm_amp", file=[my_file])
>>> my_computation_process.input_data = [my_input_data] # doctest: +SKIP
Returns
-------
Expand Down Expand Up @@ -346,21 +328,16 @@ def output_data(self) -> List[Any]:
Examples
--------
```python
# create file node for the data node
my_file = cript.File(
source="https://criptapp.org",
type="calibration",
extension=".csv",
data_dictionary="my file's data dictionary"
)
# create input data node
my_output_data = cript.Data(name="my output data name", type="afm_amp", files=[my_file])
# set computational process data node
my_computation.output_data = my_input_data
```
>>> import cript
>>> my_file = cript.File(
... name="my file node name",
... source="https://criptapp.org",
... type="calibration",
... extension=".csv",
... data_dictionary="my file's data dictionary"
... )
>>> my_output_data = cript.Data(name="my output data name", type="afm_amp", file=[my_file])
>>> my_computation_process.output_data = [my_output_data] # doctest: +SKIP
Returns
-------
Expand Down Expand Up @@ -394,15 +371,15 @@ def ingredient(self) -> List[Any]:
Examples
--------
```python
# create ingredient node
my_ingredient = cript.Ingredient(
material=simple_material_node,
quantities=[simple_quantity_node],
)
my_computational_process.ingredient = my_ingredient
```
>>> import cript
>>> my_material = cript.Material(name="my material", identifier=[{"bigsmiles": "123456"}])
>>> my_quantity = cript.Quantity(
... key="mass", value=11.2, unit="kg", uncertainty=0.2, uncertainty_type="stdev"
... )
>>> my_ingredient = cript.Ingredient(
... material=my_material, quantity=[my_quantity], keyword=["catalyst"]
... )
>>> my_computation_process.ingredient = [my_ingredient] # doctest: +SKIP
Returns
-------
Expand Down Expand Up @@ -436,12 +413,10 @@ def software_configuration(self) -> List[Any]:
Examples
--------
```python
# create software configuration node
my_software_configuration = cript.SoftwareConfiguration(software=simple_software_node)
my_computational_process.software_configuration = my_software_configuration
```
>>> import cript
>>> my_software = cript.Software(name="LAMMPS", version="23Jun22", source="lammps.org")
>>> my_software_configuration = cript.SoftwareConfiguration(software=my_software)
>>> my_computation_process.software_configuration = [my_software_configuration] # doctest: +SKIP
Returns
-------
Expand Down Expand Up @@ -475,13 +450,9 @@ def condition(self) -> List[Any]:
Examples
--------
```python
# create condition node
my_condition = cript.Condition(key="atm", type="min", value=1)
my_computational_process.condition = [my_condition]
```
>>> import cript
>>> my_condition = cript.Condition(key="atm", type="min", value=1)
>>> my_computation_process.condition = [my_condition] # doctest: +SKIP
Returns
-------
Expand Down Expand Up @@ -515,15 +486,10 @@ def citation(self) -> List[Any]:
Examples
--------
```python
# create a reference node for the citation
my_reference = cript.Reference(type="journal_article", title="'Living' Polymers")
# create a reference
my_citation = cript.Citation(type="derived_from", reference=my_reference)
my_computational_process.citation = [my_citation]
```
>>> import cript
>>> my_reference = cript.Reference(type="journal_article", title="'Living' Polymers")
>>> my_citation = cript.Citation(type="derived_from", reference=my_reference)
>>> my_computation_process.citation = [my_citation] # doctest: +SKIP
Returns
-------
Expand Down Expand Up @@ -557,12 +523,9 @@ def property(self) -> List[Any]:
Examples
--------
```python
# create a property node
my_property = cript.Property(key="modulus_shear", type="min", value=1.23, unit="gram")
my_computational_process.property = [my_property]
```
>>> import cript
>>> my_property = cript.Property(key="modulus_shear", type="min", value=1.23, unit="gram")
>>> my_computation_process.property = [my_property] # doctest: +SKIP
Returns
-------
Expand Down

0 comments on commit 2d8862d

Please sign in to comment.