FAIRChemistry / software-driven-rdm

🚀 - Generate powerful Python code from verbose markdown documents
5 stars 4 forks source link

`DataModel.get()` does not get element if value is `float(0)` or `int(0)` #52

Closed haeussma closed 7 months ago

haeussma commented 8 months ago

Tried out the following data model:

Version: 0.2.2

# Data structure of a calibration experiment
This data model describes the structure of a calibration experiment for an analyte. The calibration experiment consists of a list of samples that were measured. Each sample contains the initial concentration and the measured signal. The calibration experiment also contains information on the measurement conditions such as the temperature and pH at which the calibration experiment was performed.

## Objects

### Calibration
A `Calibration` contains information on the measurement conditions and the actual measurements of the calibration experiment for an analyte.

- analyte_name
    - type: string
    - description: Name of the analyte that was calibrated
- __inchi__
    - type: string
    - description: InChI of the analyte that was calibrated
- __date_measured__
    - type: datetime
    - description: Timestamp of when the calibration experiment was performed
- __temperature__
    - type: float
    - description: Temperature at which the calibration experiment was performed
- __ph__
    - type: float
    - description: pH at which the calibration experiment was performed
- __samples__
    - type: Sample
    - multiple: True
    - description: List of samples that were used for the calibration experiment

### Sample
A `Sample` contains describes individual measurements of a `Calibration`. 

- __init_conc__
    - type: float
    - description: Initial concentration of the sample
- __conc_unit__
    - type: string
    - description: Unit of concentration
- __measured_signal__
    - type: float
    - description: Signal that was measured for the sample
- signal_unit
    - type: string
    - description: Unit of the signal

When adding different Samples to Calibration and trying the get all init_conc values from samples/init_conc via the DataModel.get(), the returned list does not contain values of 0.0, yet these values are in the instance.

JR-1991 commented 7 months ago

@haeussma thanks for submitting. I have created a PR that fixes it and added tests for validation. Can you try it with the PR again?