HPInc / HP-Digital-Microfluidics

HP Digital Microfluidics Software Platform and Libraries
MIT License
3 stars 1 forks source link

Add DML support for samples #271

Closed EvanKirshenbaum closed 8 months ago

EvanKirshenbaum commented 8 months ago

While working on sensor support (#264), I'm realizing that it would be nice to be able to actually do something with the results in DML.

At the moment, you can say

s : take readings[([n], [interval/freq])]

and it writes to a CSV file, but you can't actually do anything with the readings. The operation just returns the number of readings taken.

What I'm thinking of doing is to say that what it returns is a Readings (subclassed by sensor, e.g., ESELogReadings) and that each of the attributes of this object is a T sample, which itself has attributes such as mean, min, max, count, variance, std dev, median, first, last. Other properties:

EvanKirshenbaum commented 8 months ago

This issue was referenced by the following commits before migration:

EvanKirshenbaum commented 8 months ago

Okay, this all seems to be working. It's a bit clunkier than I would like on the Python end, because it turns out that I can't simply create a Sample[T] because there are actually three types involved:

On the DML side, samples are referred to as, e.g., temperature sample, voltage sample, or float sample. To create them, you can say

s1 = an empty int sample;
s2 = a sample containing 3, 6, and 8.5;

(s2 will be inferred to be float sample.) For the containing expression, the and is optional, but if it's there and there are more than two elements, the Oxford comma is mandatory. (I couldn't figure out a way to get the grammar to not consider a, b and c to be a two element list where the last element is b and c, which requires to booleans.)

An int sample automatically converts to an int by taking the mean. Samples have the following attributes: count, first (first value), last (last value), min (minimum, min value, minimum value), max (maximum, max value, maximum value), range, mean (arithmetic mean), median, std dev (standard dev, std deviation, standard deviation), harmonic mean, and geometric mean.

You can add elements to a sample by

add(s, e)
s : add(e)
Migrated from internal repository. Originally created by @EvanKirshenbaum on Jun 22, 2023 at 2:58 PM PDT.