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,106 @@
1
+ """Tests for :mod:`polyphys.simulate.core`.
2
+
3
+ Every expected value follows by hand from the box formulas of the LAMMPS
4
+ ``Howto_triclinic`` page and ``Domain::lamda2x`` and ``Domain::unmap``: edge
5
+ vectors A = (lx, 0, 0), B = (xy, ly, 0), C = (xz, yz, lz); scaled
6
+ coordinates s map to o + s_a A + s_b B + s_c C; image flags i unwrap r to
7
+ r + i_x A + i_y B + i_z C.
8
+ """
9
+
10
+ import numpy as np
11
+ import pytest
12
+
13
+ from polyphys.simulate.core import Box, LammpsFormatError
14
+ from polyphys.simulate.data import BrokenDataError
15
+ from polyphys.simulate.dump import BrokenDumpError
16
+ from polyphys.simulate.log import BrokenLogError
17
+
18
+
19
+ @pytest.fixture
20
+ def make_box():
21
+ """Return a factory of boxes; keyword arguments replace the defaults.
22
+
23
+ The default is the triclinic box with lo (1, 2, 3), hi (5, 7, 9), and
24
+ tilt factors (0.5, -1.0, 2.0), so lengths (4, 5, 6).
25
+ """
26
+ def _make(**overrides):
27
+ fields = {"lo": np.array([1.0, 2.0, 3.0]),
28
+ "hi": np.array([5.0, 7.0, 9.0]),
29
+ "tilt": np.array([0.5, -1.0, 2.0]), "triclinic": True}
30
+ fields.update(overrides)
31
+ return Box(**fields)
32
+ return _make
33
+
34
+
35
+ def test_box_edges_follow_the_tilt_factors(make_box):
36
+ """The edges are A = (lx, 0, 0), B = (xy, ly, 0), C = (xz, yz, lz)."""
37
+ box = make_box()
38
+
39
+ edges = box.edges()
40
+
41
+ np.testing.assert_array_equal(
42
+ edges, [[4.0, 0.0, 0.0], [0.5, 5.0, 0.0], [-1.0, 2.0, 6.0]])
43
+
44
+
45
+ def test_box_to_cartesian_adds_the_scaled_edges_to_the_origin(make_box):
46
+ """Scaled (0.5, 0.2, 0.5) maps to o + 0.5 A + 0.2 B + 0.5 C."""
47
+ box = make_box()
48
+
49
+ cartesian = box.to_cartesian([[0.5, 0.2, 0.5]])
50
+
51
+ # x = 1 + 2 + 0.1 - 0.5, y = 2 + 1 + 1, z = 3 + 3, by hand; the products
52
+ # of these binary fractions are exact in float64.
53
+ np.testing.assert_allclose(cartesian, [[2.6, 4.0, 6.0]], rtol=0,
54
+ atol=1e-15)
55
+
56
+
57
+ def test_box_unwrap_adds_whole_edges_per_image_flag(make_box):
58
+ """Image flags (1, -1, 2) move r by A - B + 2 C."""
59
+ box = make_box()
60
+
61
+ unwrapped = box.unwrap([[0.0, 0.0, 0.0]], [[1, -1, 2]])
62
+
63
+ # A - B + 2C = (4 - 0.5 - 2, -5 + 4, 12), by hand.
64
+ np.testing.assert_array_equal(unwrapped, [[1.5, -1.0, 12.0]])
65
+
66
+
67
+ def test_box_tilt_defaults_to_zero():
68
+ """An orthogonal box made from its bounds alone has zero tilt."""
69
+ box = Box(lo=np.zeros(3), hi=np.ones(3))
70
+
71
+ np.testing.assert_array_equal(box.tilt, [0.0, 0.0, 0.0])
72
+ assert not box.triclinic
73
+ assert box.boundary is None
74
+
75
+
76
+ @pytest.mark.parametrize(
77
+ ("overrides", "match"),
78
+ [
79
+ pytest.param({"hi": np.ones(2)}, r"'hi' must have shape \(3,\)",
80
+ id="hi-shape"),
81
+ pytest.param({"hi": np.array([5.0, 2.0, 9.0])}, "must be below",
82
+ id="hi-not-above-lo"),
83
+ pytest.param({"triclinic": False}, "zero tilt factors",
84
+ id="orthogonal-with-tilt"),
85
+ ],
86
+ )
87
+ def test_box_rejects_an_invalid_box(make_box, overrides, match):
88
+ """Misshapen or misordered bounds, or tilt without triclinic, raise."""
89
+ with pytest.raises(ValueError, match=match):
90
+ make_box(**overrides)
91
+
92
+
93
+ def test_box_arrays_are_read_only(make_box):
94
+ """A box's bounds cannot be changed in place."""
95
+ box = make_box()
96
+
97
+ with pytest.raises(ValueError, match="read-only"):
98
+ box.lo[0] = 0.0
99
+
100
+
101
+ @pytest.mark.parametrize(
102
+ "error", [BrokenLogError, BrokenDumpError, BrokenDataError])
103
+ def test_broken_file_errors_share_one_base(error):
104
+ """Each broken-file error is a LammpsFormatError and a ValueError."""
105
+ assert issubclass(error, LammpsFormatError)
106
+ assert issubclass(error, ValueError)