epymorph 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 (104) hide show
  1. epymorph/__init__.py +7 -0
  2. epymorph/__main__.py +16 -0
  3. epymorph/adrio/__init__.py +0 -0
  4. epymorph/adrio/acs5.py +1378 -0
  5. epymorph/adrio/adrio.py +953 -0
  6. epymorph/adrio/cdc.py +1826 -0
  7. epymorph/adrio/commuting_flows.py +283 -0
  8. epymorph/adrio/csv.py +499 -0
  9. epymorph/adrio/humidity.py +206 -0
  10. epymorph/adrio/lodes.py +509 -0
  11. epymorph/adrio/numpy.py +160 -0
  12. epymorph/adrio/prism.py +345 -0
  13. epymorph/adrio/processing.py +1221 -0
  14. epymorph/adrio/soda.py +602 -0
  15. epymorph/adrio/us_tiger.py +289 -0
  16. epymorph/adrio/validation.py +382 -0
  17. epymorph/attribute.py +614 -0
  18. epymorph/cache.py +680 -0
  19. epymorph/cli/__init__.py +0 -0
  20. epymorph/cli/cache.py +78 -0
  21. epymorph/cli/main.py +29 -0
  22. epymorph/compartment_model.py +1873 -0
  23. epymorph/data/__init__.py +1 -0
  24. epymorph/data/ipm/__init__.py +22 -0
  25. epymorph/data/ipm/no.py +14 -0
  26. epymorph/data/ipm/pei.py +40 -0
  27. epymorph/data/ipm/seirs.py +50 -0
  28. epymorph/data/ipm/sirh.py +55 -0
  29. epymorph/data/ipm/sirs.py +48 -0
  30. epymorph/data/ipm/sparsemod.py +96 -0
  31. epymorph/data/mm/__init__.py +22 -0
  32. epymorph/data/mm/centroids.py +76 -0
  33. epymorph/data/mm/flat.py +61 -0
  34. epymorph/data/mm/icecube.py +50 -0
  35. epymorph/data/mm/no.py +29 -0
  36. epymorph/data/mm/pei.py +105 -0
  37. epymorph/data/mm/sparsemod.py +73 -0
  38. epymorph/data/pei.py +424 -0
  39. epymorph/data_shape.py +593 -0
  40. epymorph/data_type.py +185 -0
  41. epymorph/data_usage.py +258 -0
  42. epymorph/database.py +1301 -0
  43. epymorph/error.py +195 -0
  44. epymorph/event.py +196 -0
  45. epymorph/geography/__init__.py +0 -0
  46. epymorph/geography/custom.py +93 -0
  47. epymorph/geography/scope.py +457 -0
  48. epymorph/geography/us_census.py +1056 -0
  49. epymorph/geography/us_geography.py +502 -0
  50. epymorph/geography/us_tiger.py +1083 -0
  51. epymorph/initializer.py +786 -0
  52. epymorph/kit.py +107 -0
  53. epymorph/log/__init__.py +0 -0
  54. epymorph/log/file.py +128 -0
  55. epymorph/log/messaging.py +139 -0
  56. epymorph/log/movement.py +228 -0
  57. epymorph/movement_model.py +347 -0
  58. epymorph/parameter_fitting/__init__.py +0 -0
  59. epymorph/parameter_fitting/distribution.py +68 -0
  60. epymorph/parameter_fitting/dynamics.py +19 -0
  61. epymorph/parameter_fitting/filter/__init__.py +0 -0
  62. epymorph/parameter_fitting/filter/base_filter.py +50 -0
  63. epymorph/parameter_fitting/filter/particle.py +32 -0
  64. epymorph/parameter_fitting/filter/particle_filter.py +296 -0
  65. epymorph/parameter_fitting/likelihood.py +54 -0
  66. epymorph/parameter_fitting/output.py +73 -0
  67. epymorph/parameter_fitting/particlefilter_simulation.py +175 -0
  68. epymorph/parameter_fitting/perturbation.py +19 -0
  69. epymorph/parameter_fitting/utils/__init__.py +0 -0
  70. epymorph/parameter_fitting/utils/data_loader.py +97 -0
  71. epymorph/parameter_fitting/utils/epymorph_simulation.py +119 -0
  72. epymorph/parameter_fitting/utils/observations.py +63 -0
  73. epymorph/parameter_fitting/utils/parameter_estimation.py +49 -0
  74. epymorph/parameter_fitting/utils/params_perturb.py +43 -0
  75. epymorph/parameter_fitting/utils/particle_initializer.py +95 -0
  76. epymorph/parameter_fitting/utils/resampler.py +258 -0
  77. epymorph/parameter_fitting/utils/utils.py +101 -0
  78. epymorph/params.py +438 -0
  79. epymorph/py.typed +0 -0
  80. epymorph/rume.py +871 -0
  81. epymorph/simulation.py +991 -0
  82. epymorph/simulator/__init__.py +0 -0
  83. epymorph/simulator/basic/__init__.py +0 -0
  84. epymorph/simulator/basic/basic_simulator.py +171 -0
  85. epymorph/simulator/basic/ipm_exec.py +437 -0
  86. epymorph/simulator/basic/mm_exec.py +244 -0
  87. epymorph/simulator/basic/output.py +213 -0
  88. epymorph/simulator/world.py +149 -0
  89. epymorph/simulator/world_list.py +274 -0
  90. epymorph/strata.py +24 -0
  91. epymorph/sympy_shim.py +57 -0
  92. epymorph/time.py +1197 -0
  93. epymorph/tools/__init__.py +0 -0
  94. epymorph/tools/data.py +297 -0
  95. epymorph/tools/ipm_diagram.py +208 -0
  96. epymorph/tools/out_map.py +551 -0
  97. epymorph/tools/out_plot.py +423 -0
  98. epymorph/tools/out_table.py +582 -0
  99. epymorph/util.py +1036 -0
  100. epymorph-1.0.0.dist-info/METADATA +57 -0
  101. epymorph-1.0.0.dist-info/RECORD +104 -0
  102. epymorph-1.0.0.dist-info/WHEEL +5 -0
  103. epymorph-1.0.0.dist-info/entry_points.txt +2 -0
  104. epymorph-1.0.0.dist-info/top_level.txt +1 -0
epymorph/cli/cache.py ADDED
@@ -0,0 +1,78 @@
1
+ """Implements the `cache` CLI subcommands."""
2
+ # ruff: noqa: T201
3
+
4
+ from argparse import _SubParsersAction
5
+
6
+ from epymorph.cache import (
7
+ CACHE_PATH,
8
+ Directory,
9
+ FileError,
10
+ cache_inventory,
11
+ cache_remove_confirmation,
12
+ format_file_size,
13
+ )
14
+
15
+
16
+ def define_argparser(command_parser: _SubParsersAction):
17
+ """Define `cache` subcommand."""
18
+ p = command_parser.add_parser("cache", help="manage epymorph's file cache")
19
+ cmd = p.add_subparsers(title="cache_commands", dest="cache_commands", required=True)
20
+
21
+ list_cmd = cmd.add_parser("list", help="list the contents of the cache")
22
+ list_cmd.set_defaults(handler=lambda args: handle_list())
23
+
24
+ remove_cmd = cmd.add_parser("remove", help="remove a file or folder from the cache")
25
+ remove_cmd.add_argument(
26
+ "path",
27
+ type=str,
28
+ help=(
29
+ "the relative path to a file or folder in the cache, "
30
+ "or omit to purge the cache entirely"
31
+ ),
32
+ nargs="?",
33
+ default=".",
34
+ )
35
+ remove_cmd.set_defaults(handler=lambda args: handle_remove(path=args.path))
36
+
37
+ dir_cmd = cmd.add_parser("dir", help="output the absolute path of the cache folder")
38
+ dir_cmd.set_defaults(handler=lambda args: handle_dir())
39
+
40
+
41
+ def handle_list() -> int:
42
+ """CLI command handler: cache list."""
43
+
44
+ def print_folders_in(directory: Directory, indent: str = " "):
45
+ child_dirs = (d for d in directory.children if isinstance(d, Directory))
46
+ for x in sorted(child_dirs, key=lambda x: x.name):
47
+ print(f"{indent}- {x.name} ({format_file_size(x.size)})")
48
+ print_folders_in(x, indent + " ")
49
+
50
+ cache = cache_inventory()
51
+ print(f"epymorph cache is using {format_file_size(cache.size)} ({CACHE_PATH})")
52
+ print_folders_in(cache)
53
+ return 0 # exit code: success
54
+
55
+
56
+ def handle_remove(path: str) -> int:
57
+ """CLI command handler: remove a file or folder from the cache."""
58
+ try:
59
+ to_remove, confirm_remove = cache_remove_confirmation(path)
60
+ if path == ".":
61
+ print("This will delete all cache entries")
62
+ elif to_remove.is_dir():
63
+ print(f"This will delete all cache entries at {to_remove}")
64
+ else:
65
+ print(f"This will delete the cached file {to_remove}")
66
+ response = input("Are you sure? [y/N]: ")
67
+ if response.lower() in ("y", "yes"):
68
+ confirm_remove()
69
+ return 0 # exit code: success
70
+ except FileError as e:
71
+ print(f"Error: {e}")
72
+ return 1 # exit code: failed
73
+
74
+
75
+ def handle_dir() -> int:
76
+ """CLI command handler: print the path to the cache directory."""
77
+ print(CACHE_PATH)
78
+ return 0
epymorph/cli/main.py ADDED
@@ -0,0 +1,29 @@
1
+ """Implements the main CLI parser."""
2
+
3
+ from argparse import ArgumentParser
4
+ from importlib.metadata import version
5
+
6
+ from epymorph.cli.cache import define_argparser as def_cache
7
+
8
+
9
+ def define_argparser() -> ArgumentParser:
10
+ """Build a parser for all supported CLI commands."""
11
+ # Using argparse to configure available commands and arguments.
12
+ cli_parser = ArgumentParser(
13
+ prog="epymorph", description="EpiMoRPH spatial meta-population modeling."
14
+ )
15
+
16
+ cli_parser.add_argument(
17
+ "-V", "--version", action="version", version=version("epymorph")
18
+ )
19
+
20
+ # Define a set of subcommands for the main program.
21
+ # The only requirement is that they all define a 'handler' function
22
+ # in their defaults.
23
+ command_parser = cli_parser.add_subparsers(
24
+ title="commands", dest="command", required=True
25
+ )
26
+
27
+ def_cache(command_parser)
28
+
29
+ return cli_parser