polyphys 1.0.0__py3-none-any.whl

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 (69) hide show
  1. polyphys/__init__.py +7 -0
  2. polyphys/__version__.py +22 -0
  3. polyphys/analyze/__init__.py +51 -0
  4. polyphys/analyze/clusters.py +1738 -0
  5. polyphys/analyze/correlations.py +995 -0
  6. polyphys/analyze/density.py +1138 -0
  7. polyphys/analyze/measurer.py +1338 -0
  8. polyphys/analyze/pipeline.py +1868 -0
  9. polyphys/analyze/stats.py +810 -0
  10. polyphys/analyze/sumrule.py +1159 -0
  11. polyphys/manage/__init__.py +11 -0
  12. polyphys/manage/organizer.py +2188 -0
  13. polyphys/manage/parser.py +1264 -0
  14. polyphys/manage/types.py +171 -0
  15. polyphys/manage/utils.py +777 -0
  16. polyphys/probe/__init__.py +25 -0
  17. polyphys/probe/binders.py +711 -0
  18. polyphys/probe/chain_size.py +583 -0
  19. polyphys/probe/core.py +437 -0
  20. polyphys/probe/histograms.py +863 -0
  21. polyphys/probe/pairs.py +555 -0
  22. polyphys/simulate/__init__.py +48 -0
  23. polyphys/simulate/build.py +1231 -0
  24. polyphys/simulate/core.py +237 -0
  25. polyphys/simulate/data.py +977 -0
  26. polyphys/simulate/dump.py +752 -0
  27. polyphys/simulate/log.py +788 -0
  28. polyphys/spec.py +1359 -0
  29. polyphys/tests/analyze/test_clusters.py +1058 -0
  30. polyphys/tests/analyze/test_correlations.py +708 -0
  31. polyphys/tests/analyze/test_density.py +813 -0
  32. polyphys/tests/analyze/test_measurer.py +785 -0
  33. polyphys/tests/analyze/test_pipeline.py +1881 -0
  34. polyphys/tests/analyze/test_stats.py +732 -0
  35. polyphys/tests/analyze/test_sumrule.py +917 -0
  36. polyphys/tests/conftest.py +753 -0
  37. polyphys/tests/data/lammps_build/make_starts.py +70 -0
  38. polyphys/tests/manage/test_organizer.py +1495 -0
  39. polyphys/tests/manage/test_parser.py +1222 -0
  40. polyphys/tests/manage/test_utils.py +498 -0
  41. polyphys/tests/probe/conftest.py +407 -0
  42. polyphys/tests/probe/test_binders.py +686 -0
  43. polyphys/tests/probe/test_chain_size.py +557 -0
  44. polyphys/tests/probe/test_core.py +391 -0
  45. polyphys/tests/probe/test_histograms.py +779 -0
  46. polyphys/tests/probe/test_pairs.py +475 -0
  47. polyphys/tests/simulate/test_build.py +1042 -0
  48. polyphys/tests/simulate/test_core.py +106 -0
  49. polyphys/tests/simulate/test_data.py +858 -0
  50. polyphys/tests/simulate/test_dump.py +487 -0
  51. polyphys/tests/simulate/test_log.py +667 -0
  52. polyphys/tests/strategies.py +120 -0
  53. polyphys/tests/synthetic.py +410 -0
  54. polyphys/tests/test_conftest.py +414 -0
  55. polyphys/tests/test_docs.py +82 -0
  56. polyphys/tests/test_packaging.py +97 -0
  57. polyphys/tests/test_spec.py +772 -0
  58. polyphys/tests/viz/conftest.py +32 -0
  59. polyphys/tests/viz/test_colors.py +113 -0
  60. polyphys/tests/viz/test_helpers.py +292 -0
  61. polyphys/viz/__init__.py +15 -0
  62. polyphys/viz/colors.py +204 -0
  63. polyphys/viz/helpers.py +549 -0
  64. polyphys-1.0.0.dist-info/METADATA +339 -0
  65. polyphys-1.0.0.dist-info/RECORD +69 -0
  66. polyphys-1.0.0.dist-info/WHEEL +5 -0
  67. polyphys-1.0.0.dist-info/licenses/AUTHORS.rst +13 -0
  68. polyphys-1.0.0.dist-info/licenses/LICENSE +22 -0
  69. polyphys-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,171 @@
1
+ """\
2
+ ==========================================================
3
+ :mod:`polyphys.manage.types`
4
+ ==========================================================
5
+
6
+ This :mod:`~polyphys.manage.types` module provides type definitions and type
7
+ aliases to support clarity, type safety, and documentation for the data
8
+ structures and classes used within the PolyPhys package.
9
+
10
+ Custom types here represent domain-specific concepts such as `PropertyT`,
11
+ `EntityT`, and `DirectionT`, which clarify the usage of fundamental
12
+ types like `str`, `int`, and `bool`. `PhaseT` and `StageT` are the phase and
13
+ stage vocabularies that :func:`~polyphys.manage.organizer.make_database`
14
+ checks its arguments against, and `NormalizerT` the ways a density profile
15
+ may be normalized.
16
+
17
+ Composite types such as tuples and dictionaries (`TimeSeriesT`,
18
+ `NonScalarHistT`, etc.) group related information for structured
19
+ data handling.
20
+
21
+ This module also defines type aliases for input sources and simulation
22
+ metadata.
23
+ """
24
+ from typing import (
25
+ TextIO, IO, Any, Callable, Literal, TYPE_CHECKING, TypeVar, TypeAlias,
26
+ Iterable, Sequence
27
+ )
28
+ from gzip import GzipFile
29
+ from os import PathLike
30
+ import numpy as np
31
+ import pandas as pd
32
+
33
+ if TYPE_CHECKING:
34
+ from .parser import ParserBase
35
+
36
+ __all__ = [
37
+ 'AnyPathIter',
38
+ 'AxisT',
39
+ 'BinT',
40
+ 'DirectionT',
41
+ 'EdgeDataT',
42
+ 'EdgeT',
43
+ 'EnsembleName',
44
+ 'EnsembleT',
45
+ 'EntityT',
46
+ 'FreqDataT',
47
+ 'GeometryT',
48
+ 'GroupT',
49
+ 'HasEdgeT',
50
+ 'HistogramT',
51
+ 'HnsStatdictT',
52
+ 'InputType',
53
+ 'LineageT',
54
+ 'NonScalarHistT',
55
+ 'NonScalarMatT',
56
+ 'NormalizerT',
57
+ 'ParserClassT',
58
+ 'ParserInstanceT',
59
+ 'PathGroup',
60
+ 'PathGroupIter',
61
+ 'PathIter',
62
+ 'Pathish',
63
+ 'PhaseT',
64
+ 'PlaneT',
65
+ 'PrimitiveLineageT',
66
+ 'PropertyT',
67
+ 'StageT',
68
+ 'TimeSeriesT',
69
+ 'TopologyT',
70
+ 'WholeName',
71
+ 'WholeRelationT',
72
+ 'WholeT',
73
+ ]
74
+
75
+ #: A parser instance, an instance of a
76
+ #: :class:`~polyphys.manage.parser.ParserBase` subclass.
77
+ ParserInstanceT = TypeVar("ParserInstanceT", bound="ParserBase")
78
+ # A concrete alias, not type[ParserInstanceT]: an alias over a TypeVar is
79
+ # generic, and every bare use of it fails mypy --strict with [type-arg].
80
+ #: A parser class, a subclass of :class:`~polyphys.manage.parser.ParserBase`.
81
+ ParserClassT: TypeAlias = type["ParserBase"]
82
+
83
+
84
+ #: A file-system path, a ``str`` or an :class:`os.PathLike` of ``str``.
85
+ Pathish = str | PathLike[str]
86
+ #: An iterable of paths.
87
+ PathIter = Iterable[Pathish]
88
+ #: The paths of one group, such as the files that share a basename, e.g.
89
+ #: ``tuple[Path, ...]``.
90
+ PathGroup = Sequence[Pathish]
91
+ #: An iterable of path groups, e.g. ``list[tuple[Path, ...]]``.
92
+ PathGroupIter = Iterable[PathGroup]
93
+ #: An iterable of paths or of path groups, for user-facing functions.
94
+ AnyPathIter = PathIter | PathGroupIter
95
+
96
+ # --- Basic Type Aliases ---
97
+ #: A Cartesian axis, 0, 1, or 2 for x, y, or z.
98
+ AxisT = Literal[0, 1, 2]
99
+ #: How :func:`~polyphys.analyze.measurer.fixedsize_bins` fits a range to
100
+ #: whole bins, ``'ordinary'``, ``'nonnegative'``, or ``'periodic'``.
101
+ BinT = Literal['ordinary', 'nonnegative', 'periodic']
102
+ #: A direction of a histogram or profile, ``'x'``, ``'y'``, ``'z'``, the
103
+ #: radial ``'r'``, or the azimuthal ``'theta'``.
104
+ DirectionT = Literal['x', 'y', 'z', 'r', 'theta']
105
+ #: The name of an artifact at the ``ensemble`` level.
106
+ EnsembleName = str
107
+ #: A species label, such as ``'Mon'`` or ``'Crd'``.
108
+ EntityT = str
109
+ #: The geometry of a simulation box, a periodic ``'cubic'`` box or a
110
+ #: ``'cylindrical'`` one, periodic along its axis.
111
+ GeometryT = Literal['cubic', 'cylindrical']
112
+ #: A particle group, such as ``'bug'`` or ``'all'``.
113
+ GroupT = str
114
+ #: Whether a quantity has bin edges.
115
+ HasEdgeT = bool
116
+ #: A level of the artifact lineage.
117
+ LineageT = Literal['segment', 'whole', 'ensemble_long', 'ensemble', 'space']
118
+ #: How the segments of a whole combine;
119
+ #: :func:`~polyphys.manage.organizer.whole_from_segments` sums
120
+ #: ``'histogram'`` segments, joins ``'tseries'`` segments, and checks that
121
+ #: ``'bin_edge'`` segments agree.
122
+ WholeRelationT = Literal['histogram', 'tseries', 'bin_edge']
123
+ #: A phase directory of a project, in the order the data flows through them;
124
+ #: :func:`~polyphys.manage.organizer.make_database` accepts exactly these.
125
+ PhaseT = Literal['simsAll', 'simsCont', 'logs', 'trjs', 'probes', 'analysis',
126
+ 'viz', 'galaxy', 'allInOne']
127
+ #: How a density profile is normalized, by the value of its first bin
128
+ #: (``r = 0``, the cylinder axis or the chain's center of mass), its last bin
129
+ #: (the far field along z or in a periodic cube), or its maximum; by a
130
+ #: number; or by a function of the scaled profile that returns the value.
131
+ NormalizerT = (Literal['first', 'last', 'max'] | float
132
+ | Callable[[pd.DataFrame], float])
133
+ #: A Cartesian plane, ``'xy'``, ``'yz'``, or ``'zx'``.
134
+ PlaneT = Literal['xy', 'yz', 'zx']
135
+ #: A lineage level that the probe writes, ``'segment'`` or ``'whole'``.
136
+ PrimitiveLineageT = Literal['segment', 'whole']
137
+ #: The name of a physical property, such as ``'gyrT'``.
138
+ PropertyT = str
139
+ #: A stage of a phase directory;
140
+ #: :func:`~polyphys.manage.organizer.make_database` accepts exactly these.
141
+ StageT = Literal['segment', 'wholeSim', 'ens', 'ensAvg', 'space', 'galaxy']
142
+ #: The topology of a chain, such as ``'linear'`` or ``'ring'``.
143
+ TopologyT = str
144
+ #: The name of an artifact at the ``whole`` level.
145
+ WholeName = str
146
+
147
+ # --- Composite Data Structures ---
148
+ #: Bin edges keyed by name.
149
+ EdgeDataT = dict[str, np.ndarray]
150
+ #: A direction and a particle group.
151
+ EdgeT = tuple[DirectionT, GroupT]
152
+ #: An ensemble's name and its data.
153
+ EnsembleT = tuple[EnsembleName, np.ndarray | pd.DataFrame]
154
+ #: Frequencies keyed by name.
155
+ FreqDataT = dict[str, np.ndarray]
156
+ #: A direction, a species, and a particle group.
157
+ HistogramT = tuple[DirectionT, EntityT, GroupT]
158
+ #: Binding statistics of H-NS proteins keyed by name.
159
+ HnsStatdictT = dict[str, list[int] | np.ndarray]
160
+ #: A property, a species, a particle group, and an axis.
161
+ NonScalarHistT = tuple[PropertyT, EntityT, GroupT, AxisT]
162
+ #: A property, a species, and a particle group.
163
+ NonScalarMatT = tuple[PropertyT, EntityT, GroupT]
164
+ #: A property, a species, and a particle group.
165
+ TimeSeriesT = tuple[PropertyT, EntityT, GroupT]
166
+ #: The data of wholes keyed by whole name.
167
+ WholeT = dict[WholeName, np.ndarray | pd.DataFrame]
168
+
169
+ # --- IO Types ---
170
+ #: An open file, a :class:`gzip.GzipFile`, a text file, or any file object.
171
+ InputType = GzipFile | TextIO | IO[Any]