Skip to content

Commit 1e98326

Browse files
committed
Edited proportional flag to improve naming convention consistency
Edited proportional flag to improve naming convention consistency. Also removed duplicate code
1 parent dd41a01 commit 1e98326

6 files changed

Lines changed: 48 additions & 68 deletions

File tree

dabest/_dabest_object.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(
5454
self.__is_paired = paired
5555
self.__resamples = resamples
5656
self.__random_seed = random_seed
57-
self.__proportional = proportional
57+
self.__is_proportional = proportional
5858
self.__mini_meta = mini_meta
5959

6060
# after this call the attributes self.__experiment_label and self.__x1_level are updated
@@ -419,11 +419,11 @@ def _plot_data(self):
419419
return self.__plot_data
420420

421421
@property
422-
def proportional(self):
422+
def is_proportional(self):
423423
"""
424424
Returns the proportional parameter class.
425425
"""
426-
return self.__proportional
426+
return self.__is_proportional
427427

428428
@property
429429
def mini_meta(self):
@@ -448,7 +448,7 @@ def _check_errors(self, x, y, idx, experiment, experiment_label, x1_level):
448448
# Check if it is a valid mini_meta case
449449
if self.__mini_meta:
450450
# Only mini_meta calculation but not proportional and delta-delta function
451-
if self.__proportional:
451+
if self.__is_proportional:
452452
err0 = "`proportional` and `mini_meta` cannot be True at the same time."
453453
raise ValueError(err0)
454454
if self.__delta2:
@@ -501,7 +501,7 @@ def _check_errors(self, x, y, idx, experiment, experiment_label, x1_level):
501501
error_msg = "If `delta2` is True. `x` parameter cannot be None. String or list expected"
502502
raise ValueError(error_msg)
503503

504-
if self.__proportional:
504+
if self.__is_proportional:
505505
mes1 = "Only mean_diff is supported for proportional data when `delta2` is True"
506506
warnings.warn(message=mes1, category=UserWarning)
507507

@@ -683,7 +683,7 @@ def _compute_effectsize_dfs(self):
683683
is_paired=self.__is_paired,
684684
random_seed=self.__random_seed,
685685
resamples=self.__resamples,
686-
proportional=self.__proportional,
686+
proportional=self.__is_proportional,
687687
delta2=self.__delta2,
688688
experiment_label=self.__experiment_label,
689689
x1_level=self.__x1_level,

dabest/_effsize_objects.py

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def __init__(
106106
self.__effect_size = effect_size
107107
self.__random_seed = random_seed
108108
self.__ci = ci
109-
self.__proportional = proportional
109+
self.__is_proportional = proportional
110110
self._check_errors(control, test)
111111

112112
# Convert to numpy arrays for speed.
@@ -256,16 +256,16 @@ def _check_errors(self, control, test):
256256
err1 = "`paired` is not None; therefore Cliff's delta is not defined."
257257
raise ValueError(err1)
258258

259-
if self.__proportional and self.__effect_size not in ["mean_diff", "cohens_h"]:
260-
err1 = "`proportional` is True; therefore effect size other than mean_diff and cohens_h is not defined." + \
261-
"If you are calculating deltas' g, it's the same as delta-delta when `proportional` is True"
259+
if self.__is_proportional and self.__effect_size not in ["mean_diff", "cohens_h"]:
260+
err1 = "`is_proportional` is True; therefore effect size other than mean_diff and cohens_h is not defined." + \
261+
"If you are calculating deltas' g, it's the same as delta-delta when `is_proportional` is True"
262262
raise ValueError(err1)
263263

264-
if self.__proportional and (
264+
if self.__is_proportional and (
265265
isin(control, [0, 1]).all() == False or isin(test, [0, 1]).all() == False
266266
):
267267
err1 = (
268-
"`proportional` is True; Only accept binary data consisting of 0 and 1."
268+
"`is_proportional` is True; Only accept binary data consisting of 0 and 1."
269269
)
270270
raise ValueError(err1)
271271

@@ -333,7 +333,7 @@ def _perform_statistical_test(self):
333333
self.__permutation_count,
334334
)
335335

336-
if self.__is_paired and not self.__proportional:
336+
if self.__is_paired and not self.__is_proportional:
337337
# Wilcoxon, a non-parametric version of the paired T-test.
338338
try:
339339
wilcoxon = spstats.wilcoxon(self.__control, self.__test)
@@ -354,7 +354,7 @@ def _perform_statistical_test(self):
354354
self.__pvalue_paired_students_t = paired_t.pvalue
355355
self.__statistic_paired_students_t = paired_t.statistic
356356

357-
elif self.__is_paired and self.__proportional:
357+
elif self.__is_paired and self.__is_proportional:
358358
# for binary paired data, use McNemar's test
359359
# References:
360360
# https://en.wikipedia.org/wiki/McNemar%27s_test
@@ -368,7 +368,7 @@ def _perform_statistical_test(self):
368368
self.__pvalue_mcnemar = _mcnemar.pvalue
369369
self.__statistic_mcnemar = _mcnemar.statistic
370370

371-
elif self.__proportional:
371+
elif self.__is_proportional:
372372
# The Cohen's h calculation is for binary categorical data
373373
try:
374374
self.__proportional_difference = es.cohens_h(
@@ -544,8 +544,8 @@ def is_paired(self):
544544
return self.__is_paired
545545

546546
@property
547-
def proportional(self):
548-
return self.__proportional
547+
def is_proportional(self):
548+
return self.__is_proportional
549549

550550
@property
551551
def ci(self):
@@ -842,7 +842,7 @@ def __init__(
842842
self.__resamples = resamples
843843
self.__permutation_count = permutation_count
844844
self.__random_seed = random_seed
845-
self.__proportional = proportional
845+
self.__is_proportional = proportional
846846
self.__x1_level = x1_level
847847
self.__experiment_label = experiment_label
848848
self.__x2 = x2
@@ -885,7 +885,7 @@ def __pre_calc(self):
885885
self.__is_paired,
886886
self.__resamples,
887887
self.__random_seed,
888-
self.__proportional,
888+
self.__is_proportional,
889889
)
890890

891891
for j, current_tuple in enumerate(idx):
@@ -903,7 +903,7 @@ def __pre_calc(self):
903903
control,
904904
test,
905905
self.__effect_size,
906-
self.__proportional,
906+
self.__is_proportional,
907907
self.__is_paired,
908908
self.__ci,
909909
self.__resamples,
@@ -1300,7 +1300,7 @@ def plot(
13001300
passed to plot() : {'linewidth':1, 'alpha':0.5, 'jitter':0, 'jitter_seed':9876543210}.
13011301
sankey_kwargs: dict, default None
13021302
Whis will change the appearance of the sankey diagram used to depict
1303-
paired proportional data when `show_pairs=True` and `proportional=True`.
1303+
paired proportional data when `show_pairs=True` and `is_proportional=True`.
13041304
Pass any keyword arguments accepted by plot_tools.sankeydiag() function
13051305
here, as a dict. If None, the following keywords are passed to sankey diagram:
13061306
{"width": 0.5, "align": "center", "alpha": 0.4, "bar_width": 0.1, "rightColor": False}
@@ -1437,9 +1437,6 @@ def plot(
14371437
if self.__delta2 and not empty_circle:
14381438
color_col = self.__x2
14391439

1440-
# if self.__proportional:
1441-
# raw_marker_size = 0.01
1442-
14431440
# Modification incurred due to update of Seaborn
14441441
ci = ("ci", ci) if ci is not None else None
14451442

@@ -1450,12 +1447,12 @@ def plot(
14501447
return out
14511448

14521449
@property
1453-
def proportional(self):
1450+
def is_proportional(self):
14541451
"""
14551452
Returns the proportional parameter
14561453
class.
14571454
"""
1458-
return self.__proportional
1455+
return self.__is_proportional
14591456

14601457
@property
14611458
def results(self):
@@ -1568,13 +1565,6 @@ def dabest_obj(self):
15681565
"""
15691566
return self.__dabest_obj
15701567

1571-
@property
1572-
def proportional(self):
1573-
"""
1574-
Returns the proportional parameter
1575-
class.
1576-
"""
1577-
return self.__proportional
15781568

15791569
@property
15801570
def lqrt(self):

dabest/misc_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def get_params(
115115
delta2 = effectsize_df.delta2
116116
mini_meta = effectsize_df.mini_meta
117117
effect_size = effectsize_df.effect_size
118-
proportional = effectsize_df.proportional
118+
proportional = effectsize_df.is_proportional
119119
results = effectsize_df.results
120120
dabest_obj = effectsize_df.dabest_obj
121121
all_plot_groups = dabest_obj._all_plot_groups

nbs/API/dabest_object.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
" self.__is_paired = paired\n",
131131
" self.__resamples = resamples\n",
132132
" self.__random_seed = random_seed\n",
133-
" self.__proportional = proportional\n",
133+
" self.__is_proportional = proportional\n",
134134
" self.__mini_meta = mini_meta\n",
135135
"\n",
136136
" # after this call the attributes self.__experiment_label and self.__x1_level are updated\n",
@@ -495,11 +495,11 @@
495495
" return self.__plot_data\n",
496496
"\n",
497497
" @property\n",
498-
" def proportional(self):\n",
498+
" def is_proportional(self):\n",
499499
" \"\"\"\n",
500500
" Returns the proportional parameter class.\n",
501501
" \"\"\"\n",
502-
" return self.__proportional\n",
502+
" return self.__is_proportional\n",
503503
"\n",
504504
" @property\n",
505505
" def mini_meta(self):\n",
@@ -524,7 +524,7 @@
524524
" # Check if it is a valid mini_meta case\n",
525525
" if self.__mini_meta:\n",
526526
" # Only mini_meta calculation but not proportional and delta-delta function\n",
527-
" if self.__proportional:\n",
527+
" if self.__is_proportional:\n",
528528
" err0 = \"`proportional` and `mini_meta` cannot be True at the same time.\"\n",
529529
" raise ValueError(err0)\n",
530530
" if self.__delta2:\n",
@@ -577,7 +577,7 @@
577577
" error_msg = \"If `delta2` is True. `x` parameter cannot be None. String or list expected\"\n",
578578
" raise ValueError(error_msg)\n",
579579
" \n",
580-
" if self.__proportional:\n",
580+
" if self.__is_proportional:\n",
581581
" mes1 = \"Only mean_diff is supported for proportional data when `delta2` is True\"\n",
582582
" warnings.warn(message=mes1, category=UserWarning)\n",
583583
"\n",
@@ -759,7 +759,7 @@
759759
" is_paired=self.__is_paired,\n",
760760
" random_seed=self.__random_seed,\n",
761761
" resamples=self.__resamples,\n",
762-
" proportional=self.__proportional,\n",
762+
" proportional=self.__is_proportional,\n",
763763
" delta2=self.__delta2,\n",
764764
" experiment_label=self.__experiment_label,\n",
765765
" x1_level=self.__x1_level,\n",

nbs/API/effsize_objects.ipynb

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
" self.__effect_size = effect_size\n",
167167
" self.__random_seed = random_seed\n",
168168
" self.__ci = ci\n",
169-
" self.__proportional = proportional\n",
169+
" self.__is_proportional = proportional\n",
170170
" self._check_errors(control, test)\n",
171171
"\n",
172172
" # Convert to numpy arrays for speed.\n",
@@ -316,16 +316,16 @@
316316
" err1 = \"`paired` is not None; therefore Cliff's delta is not defined.\"\n",
317317
" raise ValueError(err1)\n",
318318
"\n",
319-
" if self.__proportional and self.__effect_size not in [\"mean_diff\", \"cohens_h\"]:\n",
320-
" err1 = \"`proportional` is True; therefore effect size other than mean_diff and cohens_h is not defined.\" + \\\n",
321-
" \"If you are calculating deltas' g, it's the same as delta-delta when `proportional` is True\"\n",
319+
" if self.__is_proportional and self.__effect_size not in [\"mean_diff\", \"cohens_h\"]:\n",
320+
" err1 = \"`is_proportional` is True; therefore effect size other than mean_diff and cohens_h is not defined.\" + \\\n",
321+
" \"If you are calculating deltas' g, it's the same as delta-delta when `is_proportional` is True\"\n",
322322
" raise ValueError(err1)\n",
323323
"\n",
324-
" if self.__proportional and (\n",
324+
" if self.__is_proportional and (\n",
325325
" isin(control, [0, 1]).all() == False or isin(test, [0, 1]).all() == False\n",
326326
" ):\n",
327327
" err1 = (\n",
328-
" \"`proportional` is True; Only accept binary data consisting of 0 and 1.\"\n",
328+
" \"`is_proportional` is True; Only accept binary data consisting of 0 and 1.\"\n",
329329
" )\n",
330330
" raise ValueError(err1)\n",
331331
"\n",
@@ -393,7 +393,7 @@
393393
" self.__permutation_count,\n",
394394
" )\n",
395395
"\n",
396-
" if self.__is_paired and not self.__proportional:\n",
396+
" if self.__is_paired and not self.__is_proportional:\n",
397397
" # Wilcoxon, a non-parametric version of the paired T-test.\n",
398398
" try:\n",
399399
" wilcoxon = spstats.wilcoxon(self.__control, self.__test)\n",
@@ -414,7 +414,7 @@
414414
" self.__pvalue_paired_students_t = paired_t.pvalue\n",
415415
" self.__statistic_paired_students_t = paired_t.statistic\n",
416416
"\n",
417-
" elif self.__is_paired and self.__proportional:\n",
417+
" elif self.__is_paired and self.__is_proportional:\n",
418418
" # for binary paired data, use McNemar's test\n",
419419
" # References:\n",
420420
" # https://en.wikipedia.org/wiki/McNemar%27s_test\n",
@@ -428,7 +428,7 @@
428428
" self.__pvalue_mcnemar = _mcnemar.pvalue\n",
429429
" self.__statistic_mcnemar = _mcnemar.statistic\n",
430430
"\n",
431-
" elif self.__proportional:\n",
431+
" elif self.__is_proportional:\n",
432432
" # The Cohen's h calculation is for binary categorical data\n",
433433
" try:\n",
434434
" self.__proportional_difference = es.cohens_h(\n",
@@ -604,8 +604,8 @@
604604
" return self.__is_paired\n",
605605
"\n",
606606
" @property\n",
607-
" def proportional(self):\n",
608-
" return self.__proportional\n",
607+
" def is_proportional(self):\n",
608+
" return self.__is_proportional\n",
609609
"\n",
610610
" @property\n",
611611
" def ci(self):\n",
@@ -1001,7 +1001,7 @@
10011001
" self.__resamples = resamples\n",
10021002
" self.__permutation_count = permutation_count\n",
10031003
" self.__random_seed = random_seed\n",
1004-
" self.__proportional = proportional\n",
1004+
" self.__is_proportional = proportional\n",
10051005
" self.__x1_level = x1_level\n",
10061006
" self.__experiment_label = experiment_label\n",
10071007
" self.__x2 = x2\n",
@@ -1044,7 +1044,7 @@
10441044
" self.__is_paired,\n",
10451045
" self.__resamples,\n",
10461046
" self.__random_seed,\n",
1047-
" self.__proportional,\n",
1047+
" self.__is_proportional,\n",
10481048
" )\n",
10491049
"\n",
10501050
" for j, current_tuple in enumerate(idx):\n",
@@ -1062,7 +1062,7 @@
10621062
" control,\n",
10631063
" test,\n",
10641064
" self.__effect_size,\n",
1065-
" self.__proportional,\n",
1065+
" self.__is_proportional,\n",
10661066
" self.__is_paired,\n",
10671067
" self.__ci,\n",
10681068
" self.__resamples,\n",
@@ -1459,7 +1459,7 @@
14591459
" passed to plot() : {'linewidth':1, 'alpha':0.5, 'jitter':0, 'jitter_seed':9876543210}.\n",
14601460
" sankey_kwargs: dict, default None\n",
14611461
" Whis will change the appearance of the sankey diagram used to depict\n",
1462-
" paired proportional data when `show_pairs=True` and `proportional=True`.\n",
1462+
" paired proportional data when `show_pairs=True` and `is_proportional=True`.\n",
14631463
" Pass any keyword arguments accepted by plot_tools.sankeydiag() function\n",
14641464
" here, as a dict. If None, the following keywords are passed to sankey diagram:\n",
14651465
" {\"width\": 0.5, \"align\": \"center\", \"alpha\": 0.4, \"bar_width\": 0.1, \"rightColor\": False}\n",
@@ -1596,9 +1596,6 @@
15961596
" if self.__delta2 and not empty_circle:\n",
15971597
" color_col = self.__x2\n",
15981598
"\n",
1599-
" # if self.__proportional:\n",
1600-
" # raw_marker_size = 0.01\n",
1601-
"\n",
16021599
" # Modification incurred due to update of Seaborn\n",
16031600
" ci = (\"ci\", ci) if ci is not None else None\n",
16041601
"\n",
@@ -1609,12 +1606,12 @@
16091606
" return out\n",
16101607
"\n",
16111608
" @property\n",
1612-
" def proportional(self):\n",
1609+
" def is_proportional(self):\n",
16131610
" \"\"\"\n",
16141611
" Returns the proportional parameter\n",
16151612
" class.\n",
16161613
" \"\"\"\n",
1617-
" return self.__proportional\n",
1614+
" return self.__is_proportional\n",
16181615
"\n",
16191616
" @property\n",
16201617
" def results(self):\n",
@@ -1727,13 +1724,6 @@
17271724
" \"\"\"\n",
17281725
" return self.__dabest_obj\n",
17291726
"\n",
1730-
" @property\n",
1731-
" def proportional(self):\n",
1732-
" \"\"\"\n",
1733-
" Returns the proportional parameter\n",
1734-
" class.\n",
1735-
" \"\"\"\n",
1736-
" return self.__proportional\n",
17371727
"\n",
17381728
" @property\n",
17391729
" def lqrt(self):\n",

0 commit comments

Comments
 (0)