From 292ee6cb20ea9339bef2d6d3611b425ea140c5ca Mon Sep 17 00:00:00 2001 From: Younes Strittmatter Date: Thu, 25 Jul 2024 16:26:57 -0400 Subject: [PATCH 1/2] docs: fix tutorial --- docs/Basic Usage.ipynb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/Basic Usage.ipynb b/docs/Basic Usage.ipynb index d2ff7b1..829a899 100644 --- a/docs/Basic Usage.ipynb +++ b/docs/Basic Usage.ipynb @@ -111,7 +111,7 @@ }, "outputs": [], "source": [ - "X_sampled = summed_inequality_sample(condition_pool = X_prime, reference_conditions = X, n = n)\n", + "X_sampled = summed_inequality_sample(conditions=X_prime, reference_conditions=X, num_samples=n)\n", "print(X_sampled)" ] }, @@ -160,9 +160,18 @@ }, "outputs": [], "source": [ - "X_sampled = summed_inequality_sample(condition_pool = X_prime, reference_conditions = X, n = n)\n", + "X_sampled = summed_inequality_sample(conditions=X_prime, reference_conditions=X, num_samples=n)\n", "print(X_sampled)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [], + "metadata": { + "collapsed": false + } } ], "metadata": { From d00cfdb6424b0b6f7dee1871ced4d5c273600c18 Mon Sep 17 00:00:00 2001 From: Younes Strittmatter Date: Thu, 25 Jul 2024 16:34:51 -0400 Subject: [PATCH 2/2] feat: fix return value to be pd dataframe --- .../experimentalist/inequality/__init__.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/autora/experimentalist/inequality/__init__.py b/src/autora/experimentalist/inequality/__init__.py index b37eccc..99fcf61 100644 --- a/src/autora/experimentalist/inequality/__init__.py +++ b/src/autora/experimentalist/inequality/__init__.py @@ -60,28 +60,33 @@ def sample( Examples: The value 1 is not in the reference. Therefore it is choosen. >>> summed_inequality_sample([1, 2, 3], [2, 3, 4]) - array([[1]]) + 0 + 0 1 The equality distance is set to 0.4. 1 and 1.3 are considered equal, so are 3 and 3.1. Therefore 2 is choosen. >>> summed_inequality_sample([1, 2, 3], [1.3, 2.7, 3.1], 1, .4) - array([[2]]) + 0 + 0 2 The value 3 appears least often in the reference. >>> summed_inequality_sample([1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3]) - array([[3]]) + 0 + 0 3 The experimentalist "fills up" the reference array so the values are contributed evenly >>> summed_inequality_sample([1, 1, 1, 2, 2, 2, 3, 3, 3], [1, 1, 2, 2, 2, 2, 3, 3, 3], 3) - array([[1], - [3], - [1]]) + 0 + 0 1 + 1 3 + 2 1 The experimentalist samples without replacemnt! >>> summed_inequality_sample([1, 2, 3], [1, 1, 1], 3) - array([[3], - [2], - [1]]) + 0 + 0 3 + 1 2 + 2 1 """ @@ -150,6 +155,8 @@ def sample( new_conditions = np.array(condition_pool_res[:num_samples]) if isinstance(conditions, pd.DataFrame): new_conditions = pd.DataFrame(new_conditions, columns=conditions.columns) + else: + new_conditions = pd.DataFrame(new_conditions) return new_conditions