tpattern 0.1.14__tar.gz → 0.1.15__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. {tpattern-0.1.14/tpattern.egg-info → tpattern-0.1.15}/PKG-INFO +11 -2
  2. {tpattern-0.1.14 → tpattern-0.1.15}/README.md +10 -1
  3. {tpattern-0.1.14 → tpattern-0.1.15}/pyproject.toml +1 -1
  4. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/__init__.py +1 -1
  5. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/significance.py +19 -0
  6. {tpattern-0.1.14 → tpattern-0.1.15/tpattern.egg-info}/PKG-INFO +11 -2
  7. {tpattern-0.1.14 → tpattern-0.1.15}/LICENSE +0 -0
  8. {tpattern-0.1.14 → tpattern-0.1.15}/setup.cfg +0 -0
  9. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_calibrated_pins.py +0 -0
  10. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_contrast.py +0 -0
  11. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_dedup.py +0 -0
  12. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_guided.py +0 -0
  13. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_null_compare.py +0 -0
  14. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_outputs.py +0 -0
  15. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_read_table_validation.py +0 -0
  16. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_reference.py +0 -0
  17. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_report_dendrogram.py +0 -0
  18. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_reproduction.py +0 -0
  19. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_sofcoder.py +0 -0
  20. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_starter.py +0 -0
  21. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_support_reporting.py +0 -0
  22. {tpattern-0.1.14 → tpattern-0.1.15}/tests/test_synthetic.py +0 -0
  23. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/advisor.py +0 -0
  24. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/ci.py +0 -0
  25. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/contrast.py +0 -0
  26. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/detect.py +0 -0
  27. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/diagnostics.py +0 -0
  28. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/guided.py +0 -0
  29. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/io.py +0 -0
  30. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/methods.py +0 -0
  31. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/pattern.py +0 -0
  32. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/randomise.py +0 -0
  33. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/reference.py +0 -0
  34. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/report.py +0 -0
  35. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/starter.py +0 -0
  36. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/synthetic.py +0 -0
  37. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern/viz.py +0 -0
  38. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern.egg-info/SOURCES.txt +0 -0
  39. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern.egg-info/dependency_links.txt +0 -0
  40. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern.egg-info/requires.txt +0 -0
  41. {tpattern-0.1.14 → tpattern-0.1.15}/tpattern.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tpattern
3
- Version: 0.1.14
3
+ Version: 0.1.15
4
4
  Summary: Open, auditable temporal & sequential pattern analysis (T-patterns) for sport and behaviour
5
5
  Author-email: Andrew Callaway <acallaway@bournemouth.ac.uk>
6
6
  License-Expression: MIT
@@ -49,7 +49,7 @@ auditable code — the same critical-interval method the THEME software applies
49
49
  [The method it implements](#the-method-it-implements)) — and is the analysis
50
50
  companion to the [OpenTag.Studio](https://opentag.studio) tagging tool.
51
51
 
52
- ## Two ways to use it
52
+ ## Three ways to use it
53
53
 
54
54
  ### 🚀 In your browser — Google Colab, no install, no coding
55
55
 
@@ -71,6 +71,15 @@ Three notebooks (all in [`colab/`](colab/)):
71
71
 
72
72
  `pip install tpattern` and script it — see [Getting started](#getting-started-in-a-minute), [Quickstart](#quickstart) and [`examples/`](examples/).
73
73
 
74
+ ### 📊 From R
75
+
76
+ R users (common in psychology and behavioural science) can drive the **same
77
+ engine** via [`reticulate`](https://rstudio.github.io/reticulate/) — the algorithm
78
+ stays in Python, so results match exactly. Install with
79
+ `remotes::install_github("ajcallaway/TPattern", subdir = "r")`, then run the whole
80
+ analysis in one call: `tpattern_analysis("events.csv")`. See
81
+ [Using tpattern from R](#using-tpattern-from-r).
82
+
74
83
  Bring your own data (one row per event — see [`SCHEMA.md`](SCHEMA.md)) or try the
75
84
  included [`data/`](data/) example.
76
85
 
@@ -14,7 +14,7 @@ auditable code — the same critical-interval method the THEME software applies
14
14
  [The method it implements](#the-method-it-implements)) — and is the analysis
15
15
  companion to the [OpenTag.Studio](https://opentag.studio) tagging tool.
16
16
 
17
- ## Two ways to use it
17
+ ## Three ways to use it
18
18
 
19
19
  ### 🚀 In your browser — Google Colab, no install, no coding
20
20
 
@@ -36,6 +36,15 @@ Three notebooks (all in [`colab/`](colab/)):
36
36
 
37
37
  `pip install tpattern` and script it — see [Getting started](#getting-started-in-a-minute), [Quickstart](#quickstart) and [`examples/`](examples/).
38
38
 
39
+ ### 📊 From R
40
+
41
+ R users (common in psychology and behavioural science) can drive the **same
42
+ engine** via [`reticulate`](https://rstudio.github.io/reticulate/) — the algorithm
43
+ stays in Python, so results match exactly. Install with
44
+ `remotes::install_github("ajcallaway/TPattern", subdir = "r")`, then run the whole
45
+ analysis in one call: `tpattern_analysis("events.csv")`. See
46
+ [Using tpattern from R](#using-tpattern-from-r).
47
+
39
48
  Bring your own data (one row per event — see [`SCHEMA.md`](SCHEMA.md)) or try the
40
49
  included [`data/`](data/) example.
41
50
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tpattern"
7
- version = "0.1.14"
7
+ version = "0.1.15"
8
8
  description = "Open, auditable temporal & sequential pattern analysis (T-patterns) for sport and behaviour"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -6,7 +6,7 @@ behavior: T-patterns and their detection. Behavior Research Methods,
6
6
  Instruments, & Computers, 32(1), 93-110.
7
7
  """
8
8
 
9
- __version__ = "0.1.14" # defined before submodule imports (methods.py reads it)
9
+ __version__ = "0.1.15" # defined before submodule imports (methods.py reads it)
10
10
 
11
11
  from .io import (Observation, read_observation, read_sample, read_table,
12
12
  read_sofcoder, DataFormatError, check_reference, CHECKS)
@@ -66,6 +66,7 @@ class Calibrated:
66
66
  p_emp_strength: float = 1.0 # empirical p of the analytic strength
67
67
  fwer_keep: bool = False # Holm on p_emp
68
68
  fdr_q: float = 1.0 # Benjamini-Hochberg q on p_emp
69
+ fdr_q_by: float = 1.0 # Benjamini-Yekutieli q (dependence-robust FDR)
69
70
 
70
71
 
71
72
  @dataclass
@@ -81,6 +82,8 @@ class CalibrationResult:
81
82
  def kept(self, method: str = "fdr") -> list[Calibrated]:
82
83
  if method == "fwer":
83
84
  return [c for c in self.real if c.fwer_keep]
85
+ if method in ("fdr_by", "by"):
86
+ return [c for c in self.real if c.fdr_q_by <= self.q_target]
84
87
  return [c for c in self.real if c.fdr_q <= self.q_target]
85
88
 
86
89
 
@@ -100,6 +103,20 @@ def _benjamini_hochberg(items, get_p):
100
103
  return {id(items[i]): q[i] for i in range(m)}
101
104
 
102
105
 
106
+ def _benjamini_yekutieli(items, get_p):
107
+ """Benjamini-Yekutieli q-values: the BH q scaled by the harmonic factor
108
+ c(m) = sum_{i=1..m} 1/i, which gives false-discovery-rate control under
109
+ arbitrary dependence among the p-values (Benjamini & Yekutieli, 2001).
110
+ Surrogate p-values for patterns that share events are dependent, so this is
111
+ the dependence-robust companion to the BH q; it is more conservative."""
112
+ m = len(items)
113
+ if m == 0:
114
+ return {}
115
+ cm = sum(1.0 / i for i in range(1, m + 1))
116
+ bh = _benjamini_hochberg(items, get_p)
117
+ return {k: min(1.0, v * cm) for k, v in bh.items()}
118
+
119
+
103
120
  def _holm_keep(items, get_p, alpha):
104
121
  """Holm–Bonferroni step-down; return set of ids kept at family alpha."""
105
122
  m = len(items)
@@ -217,9 +234,11 @@ def calibrate(observations, config: Config | None = None, *,
217
234
  grp = [c for c in real if c.level == lv]
218
235
  keep = _holm_keep(grp, lambda c: c.p_emp, alpha)
219
236
  qmap = _benjamini_hochberg(grp, lambda c: c.p_emp)
237
+ bymap = _benjamini_yekutieli(grp, lambda c: c.p_emp)
220
238
  for c in grp:
221
239
  c.fwer_keep = id(c) in keep
222
240
  c.fdr_q = qmap[id(c)]
241
+ c.fdr_q_by = bymap[id(c)]
223
242
 
224
243
  return CalibrationResult(real=real, surrogate_counts=surrogate_counts,
225
244
  B=B, alpha=alpha, q_target=q_target, null=null,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tpattern
3
- Version: 0.1.14
3
+ Version: 0.1.15
4
4
  Summary: Open, auditable temporal & sequential pattern analysis (T-patterns) for sport and behaviour
5
5
  Author-email: Andrew Callaway <acallaway@bournemouth.ac.uk>
6
6
  License-Expression: MIT
@@ -49,7 +49,7 @@ auditable code — the same critical-interval method the THEME software applies
49
49
  [The method it implements](#the-method-it-implements)) — and is the analysis
50
50
  companion to the [OpenTag.Studio](https://opentag.studio) tagging tool.
51
51
 
52
- ## Two ways to use it
52
+ ## Three ways to use it
53
53
 
54
54
  ### 🚀 In your browser — Google Colab, no install, no coding
55
55
 
@@ -71,6 +71,15 @@ Three notebooks (all in [`colab/`](colab/)):
71
71
 
72
72
  `pip install tpattern` and script it — see [Getting started](#getting-started-in-a-minute), [Quickstart](#quickstart) and [`examples/`](examples/).
73
73
 
74
+ ### 📊 From R
75
+
76
+ R users (common in psychology and behavioural science) can drive the **same
77
+ engine** via [`reticulate`](https://rstudio.github.io/reticulate/) — the algorithm
78
+ stays in Python, so results match exactly. Install with
79
+ `remotes::install_github("ajcallaway/TPattern", subdir = "r")`, then run the whole
80
+ analysis in one call: `tpattern_analysis("events.csv")`. See
81
+ [Using tpattern from R](#using-tpattern-from-r).
82
+
74
83
  Bring your own data (one row per event — see [`SCHEMA.md`](SCHEMA.md)) or try the
75
84
  included [`data/`](data/) example.
76
85
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes