nmr 0.9.1__tar.gz → 0.11.0__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 (72) hide show
  1. nmr-0.11.0/.gitignore +130 -0
  2. nmr-0.11.0/.python-version +1 -0
  3. nmr-0.11.0/.travis.yml +24 -0
  4. nmr-0.11.0/CHANGELIST +0 -0
  5. nmr-0.11.0/FUNDING.yml +1 -0
  6. nmr-0.11.0/PKG-INFO +148 -0
  7. nmr-0.11.0/README.md +127 -0
  8. nmr-0.11.0/TAGS +30280 -0
  9. nmr-0.11.0/google-10000-english.txt +9669 -0
  10. nmr-0.9.1/README.rst → nmr-0.11.0/nmr/__init__.py +8 -0
  11. nmr-0.11.0/nmr/__main__.py +90 -0
  12. nmr-0.11.0/nmr/_main.py +94 -0
  13. nmr-0.11.0/nmr/category.py +104 -0
  14. {nmr-0.9.1 → nmr-0.11.0}/nmr/count_words.py +4 -3
  15. nmr-0.11.0/nmr/nmr.py +27 -0
  16. nmr-0.11.0/nmr/pack_numbers.py +206 -0
  17. nmr-0.11.0/nmr/radixes.py +19 -0
  18. nmr-0.11.0/nmr/type_namer.py +69 -0
  19. nmr-0.11.0/nmr/types/__init__.py +37 -0
  20. nmr-0.11.0/nmr/types/chess.py +89 -0
  21. nmr-0.11.0/nmr/types/fraction.py +40 -0
  22. nmr-0.11.0/nmr/types/integer.py +17 -0
  23. nmr-0.11.0/nmr/types/ip_address.py +14 -0
  24. nmr-0.11.0/nmr/types/lat_long.py +50 -0
  25. nmr-0.11.0/nmr/types/phone_number.py +48 -0
  26. nmr-0.11.0/nmr/types/sem_ver.py +29 -0
  27. nmr-0.11.0/nmr/types/time/__init__.py +0 -0
  28. nmr-0.11.0/nmr/types/time/constants.py +87 -0
  29. nmr-0.11.0/nmr/types/time/formats.py +60 -0
  30. nmr-0.11.0/nmr/types/time/time.py +123 -0
  31. nmr-0.11.0/nmr/types/uuid.py +23 -0
  32. nmr-0.11.0/nmr/words.py +138 -0
  33. nmr-0.11.0/poetry.lock +7 -0
  34. nmr-0.11.0/pyproject.toml +57 -0
  35. nmr-0.11.0/reflog.txt +1000 -0
  36. nmr-0.11.0/scripts/homophones.txt +441 -0
  37. nmr-0.11.0/scripts/nmbr +7 -0
  38. nmr-0.11.0/scripts/remove_homophones.py +34 -0
  39. nmr-0.11.0/test/__init__.py +0 -0
  40. nmr-0.11.0/test/test_category.py +45 -0
  41. nmr-0.11.0/test/test_chess.py +57 -0
  42. nmr-0.11.0/test/test_huge.py +84 -0
  43. nmr-0.11.0/test/test_main.py +51 -0
  44. nmr-0.11.0/test/test_nmr.py +57 -0
  45. nmr-0.11.0/test/test_pack_numbers.py +24 -0
  46. nmr-0.11.0/test/test_radixes.py +13 -0
  47. nmr-0.11.0/test/test_sign.py +22 -0
  48. nmr-0.11.0/test/test_time_format.py +9 -0
  49. nmr-0.11.0/test/test_types.py +60 -0
  50. nmr-0.11.0/test/test_words.py +53 -0
  51. nmr-0.11.0/tox.ini +10 -0
  52. nmr-0.11.0/uv.lock +300 -0
  53. nmr-0.11.0/words.txt +2345 -0
  54. nmr-0.9.1/PKG-INFO +0 -50
  55. nmr-0.9.1/nmr/__init__.py +0 -38
  56. nmr-0.9.1/nmr/__main__.py +0 -63
  57. nmr-0.9.1/nmr/_main.py +0 -92
  58. nmr-0.9.1/nmr/nmr.py +0 -125
  59. nmr-0.9.1/nmr/types/__init__.py +0 -32
  60. nmr-0.9.1/nmr/types/_type.py +0 -29
  61. nmr-0.9.1/nmr/types/fraction.py +0 -75
  62. nmr-0.9.1/nmr/types/hex.py +0 -13
  63. nmr-0.9.1/nmr/types/integer.py +0 -11
  64. nmr-0.9.1/nmr/types/ip_address.py +0 -14
  65. nmr-0.9.1/nmr/types/lat_long.py +0 -48
  66. nmr-0.9.1/nmr/types/sem_ver.py +0 -30
  67. nmr-0.9.1/nmr/types/times.py +0 -109
  68. nmr-0.9.1/nmr/types/type_groups.py +0 -50
  69. nmr-0.9.1/nmr/types/uuid.py +0 -20
  70. nmr-0.9.1/pyproject.toml +0 -34
  71. nmr-0.9.1/setup.py +0 -35
  72. {nmr-0.9.1 → nmr-0.11.0}/LICENSE +0 -0
nmr-0.11.0/.gitignore ADDED
@@ -0,0 +1,130 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pipenv
85
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
86
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
87
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
88
+ # install all needed dependencies.
89
+ #Pipfile.lock
90
+
91
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
92
+ __pypackages__/
93
+
94
+ # Celery stuff
95
+ celerybeat-schedule
96
+ celerybeat.pid
97
+
98
+ # SageMath parsed files
99
+ *.sage.py
100
+
101
+ # Environments
102
+ .env
103
+ .venv
104
+ env/
105
+ venv/
106
+ ENV/
107
+ env.bak/
108
+ venv.bak/
109
+
110
+ # Spyder project settings
111
+ .spyderproject
112
+ .spyproject
113
+
114
+ # Rope project settings
115
+ .ropeproject
116
+
117
+ # mkdocs documentation
118
+ site/
119
+
120
+ # mypy
121
+ .mypy_cache/
122
+ .dmypy.json
123
+ dmypy.json
124
+
125
+ # Pyre type checker
126
+ .pyre/
127
+
128
+ # direnv
129
+ .direnv/
130
+ .envrc
@@ -0,0 +1 @@
1
+ 3.10
nmr-0.11.0/.travis.yml ADDED
@@ -0,0 +1,24 @@
1
+ language: python
2
+
3
+ python:
4
+ - '3.7'
5
+
6
+ matrix:
7
+ include:
8
+ - python: 3.10.2
9
+ dist: xenial
10
+
11
+ install:
12
+ - pip install -r requirements.txt
13
+ - pip install -r test_requirements.txt
14
+
15
+ script:
16
+ - flake8
17
+ - coverage run -m pytest
18
+
19
+ # Don't compile "experimental" branches starting with x-, y-, or z-.
20
+ branches:
21
+ except:
22
+ - /^x-.*$/
23
+ - /^y-.*$/
24
+ - /^z-.*$/
nmr-0.11.0/CHANGELIST ADDED
File without changes
nmr-0.11.0/FUNDING.yml ADDED
@@ -0,0 +1 @@
1
+ github: rec
nmr-0.11.0/PKG-INFO ADDED
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: nmr
3
+ Version: 0.11.0
4
+ Summary: 🌐 Name all canonical things 🌐
5
+ Author-email: Tom Ritchford <tom@swirly.com>
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Requires-Python: >=3.10
15
+ Requires-Dist: chess<2,>=1.9.3
16
+ Requires-Dist: dtyper<3,>=2.0.0
17
+ Requires-Dist: lat-lon-parser<2,>=1.3.0
18
+ Requires-Dist: semver<4,>=3.0.2
19
+ Requires-Dist: typer<0.8,>=0.7.0
20
+ Description-Content-Type: text/markdown
21
+
22
+ 🔢 `nmr`: name all canonical things 🔢
23
+
24
+ Give each canonical thing a unique English name using non-repeating words from a
25
+ short list of common, short English words... or use a word list of your choice.
26
+
27
+ The word list is here: https://github.com/rec/nmr/blob/main/words.txt
28
+
29
+
30
+ Canonical things include but are not limited to:
31
+
32
+ * numbers
33
+ * fractions
34
+ * times, dates, time intervals
35
+ * lat/long positions on the earth
36
+ * IP addresses
37
+ * UUIDs
38
+
39
+ Other unimplemented possibilities:
40
+
41
+ * Phone numbers
42
+ * Periodic table
43
+ * Chemical compounds(?) (probably not worth the huge effort)
44
+ * Pieces of music! (my original motivating example)
45
+
46
+
47
+ Shorter or simpler things should generally be represented by shorter names.
48
+
49
+ Extending this to your own domain is easy and you can either add it to this
50
+ codebase or write your own code and easily plug in in.
51
+
52
+ Installs both a module named `nmr` and an executable called `nmr.py`
53
+
54
+ # EXAMPLE
55
+
56
+ ``` python
57
+ import nmr
58
+
59
+ assert nmr(0) == ['the']
60
+ assert nmr(2718281828) == ['the', 'race', 'tie', 'hook']
61
+
62
+ for i in range(-2, 3):
63
+ print(i, ':', *nmr(i))
64
+
65
+ # Prints
66
+ # -2 : to
67
+ # -1 : of
68
+ # 0 : the
69
+ # 1 : and
70
+ # 2 : a
71
+ ```
72
+
73
+ # HOW IT WORKS
74
+
75
+ All of this involves the same trick over and over again - counting using positional notation:
76
+ https://en.wikipedia.org/wiki/Positional_notation
77
+
78
+ By default `nmr` has 1628 different words, which you can think of as 1628 different
79
+ digits.
80
+
81
+ There's a wrinkle that makes things harder: the author decided that repeating
82
+ words was unaesthetic, so counting is a little trickier, but you don't have to
83
+ understand how it's done.
84
+
85
+ With repeating words eliminated, 1628 is the minimum total number of words
86
+ needed to be able to represent all 64-bit integers with at most six words.
87
+
88
+
89
+ Conversion runs as follows.
90
+
91
+ First you take your type, whatever it is, and figure out a way to represent it as a
92
+ number in positional notation, where perhaps the digits have different values.
93
+
94
+ Suppose you're wanting to represent the time of the day, down to milliseconds.
95
+
96
+ You represent it as a four digit number: hours, minutes, seconds, milliseconds
97
+
98
+ Next, you take the positional number, and evaluate it into a "type-relative number",
99
+ a number that makes sense only within this type.
100
+
101
+ For example, to represent the time 15:11:55.823, we'd evaluate the number
102
+ `((((15 * 60) + 11) * 60 + 55) * 1000 + 823)` to get the type relative number,
103
+ but this number might mean something completely different for say, lat-long.
104
+
105
+ Now, each type also gets its own fixed "type identifier number" and that gets combined
106
+ with the type-relative number to give a new number, the `nmr` number which is unique
107
+ over all types.
108
+
109
+ Then that `nmr` number is encoded into a non-repeating sequence of words from the
110
+ word list, which is the `nmr` name.
111
+
112
+ ----
113
+
114
+ In the reverse direction, a `nmr` name is given, and it's converted back into an `nmr`
115
+ number, then split into the type identifier number and type-relative number.
116
+
117
+ The type identifier number is used to look up which type is being decoded, and then
118
+ the type-relative number is decoded into the positional number, and finally
119
+ back into the original type.
120
+
121
+ ----
122
+
123
+ You are guaranteed that for each original canonical thing, T, there is a unique
124
+ canonical name, and that decoding that name will always reproduce exactly the
125
+ same thing.
126
+
127
+ It's mathematically
128
+ an [injection](https://en.wikipedia.org/wiki/Bijection,_injection_and_surjection).
129
+
130
+ On the other hand, if you start with a random name and try to decode, a data type
131
+ isn't required to give any guarantees at all.
132
+
133
+ You aren't even guaranteed that the decoding will return anything - some names just
134
+ won't correspond even to a known type. If a name can be decoded to a known type,
135
+ that type decoder might still not be able to come up with a type. Or, if it comes
136
+ up with a type, that type might have a different canonical name.
137
+
138
+ This is all good because it makes it really easy to whip up an encoder/decoder, but for
139
+ the basic encoders included with the program, we can offer a better guarantee: that we
140
+ can always decode any any type-relative number and return an instance of the type, even
141
+ if we weren't given a canonical name.
142
+
143
+ Separately, we add a "type wrapping" feature to the main program so that unknown type
144
+ identifier numbers just wrap repeated over known type identifiers - again, this will
145
+ never be a canonical name.
146
+
147
+ With those features, it means you can type random names into the program, and see what
148
+ sort of thing you get.
nmr-0.11.0/README.md ADDED
@@ -0,0 +1,127 @@
1
+ 🔢 `nmr`: name all canonical things 🔢
2
+
3
+ Give each canonical thing a unique English name using non-repeating words from a
4
+ short list of common, short English words... or use a word list of your choice.
5
+
6
+ The word list is here: https://github.com/rec/nmr/blob/main/words.txt
7
+
8
+
9
+ Canonical things include but are not limited to:
10
+
11
+ * numbers
12
+ * fractions
13
+ * times, dates, time intervals
14
+ * lat/long positions on the earth
15
+ * IP addresses
16
+ * UUIDs
17
+
18
+ Other unimplemented possibilities:
19
+
20
+ * Phone numbers
21
+ * Periodic table
22
+ * Chemical compounds(?) (probably not worth the huge effort)
23
+ * Pieces of music! (my original motivating example)
24
+
25
+
26
+ Shorter or simpler things should generally be represented by shorter names.
27
+
28
+ Extending this to your own domain is easy and you can either add it to this
29
+ codebase or write your own code and easily plug in in.
30
+
31
+ Installs both a module named `nmr` and an executable called `nmr.py`
32
+
33
+ # EXAMPLE
34
+
35
+ ``` python
36
+ import nmr
37
+
38
+ assert nmr(0) == ['the']
39
+ assert nmr(2718281828) == ['the', 'race', 'tie', 'hook']
40
+
41
+ for i in range(-2, 3):
42
+ print(i, ':', *nmr(i))
43
+
44
+ # Prints
45
+ # -2 : to
46
+ # -1 : of
47
+ # 0 : the
48
+ # 1 : and
49
+ # 2 : a
50
+ ```
51
+
52
+ # HOW IT WORKS
53
+
54
+ All of this involves the same trick over and over again - counting using positional notation:
55
+ https://en.wikipedia.org/wiki/Positional_notation
56
+
57
+ By default `nmr` has 1628 different words, which you can think of as 1628 different
58
+ digits.
59
+
60
+ There's a wrinkle that makes things harder: the author decided that repeating
61
+ words was unaesthetic, so counting is a little trickier, but you don't have to
62
+ understand how it's done.
63
+
64
+ With repeating words eliminated, 1628 is the minimum total number of words
65
+ needed to be able to represent all 64-bit integers with at most six words.
66
+
67
+
68
+ Conversion runs as follows.
69
+
70
+ First you take your type, whatever it is, and figure out a way to represent it as a
71
+ number in positional notation, where perhaps the digits have different values.
72
+
73
+ Suppose you're wanting to represent the time of the day, down to milliseconds.
74
+
75
+ You represent it as a four digit number: hours, minutes, seconds, milliseconds
76
+
77
+ Next, you take the positional number, and evaluate it into a "type-relative number",
78
+ a number that makes sense only within this type.
79
+
80
+ For example, to represent the time 15:11:55.823, we'd evaluate the number
81
+ `((((15 * 60) + 11) * 60 + 55) * 1000 + 823)` to get the type relative number,
82
+ but this number might mean something completely different for say, lat-long.
83
+
84
+ Now, each type also gets its own fixed "type identifier number" and that gets combined
85
+ with the type-relative number to give a new number, the `nmr` number which is unique
86
+ over all types.
87
+
88
+ Then that `nmr` number is encoded into a non-repeating sequence of words from the
89
+ word list, which is the `nmr` name.
90
+
91
+ ----
92
+
93
+ In the reverse direction, a `nmr` name is given, and it's converted back into an `nmr`
94
+ number, then split into the type identifier number and type-relative number.
95
+
96
+ The type identifier number is used to look up which type is being decoded, and then
97
+ the type-relative number is decoded into the positional number, and finally
98
+ back into the original type.
99
+
100
+ ----
101
+
102
+ You are guaranteed that for each original canonical thing, T, there is a unique
103
+ canonical name, and that decoding that name will always reproduce exactly the
104
+ same thing.
105
+
106
+ It's mathematically
107
+ an [injection](https://en.wikipedia.org/wiki/Bijection,_injection_and_surjection).
108
+
109
+ On the other hand, if you start with a random name and try to decode, a data type
110
+ isn't required to give any guarantees at all.
111
+
112
+ You aren't even guaranteed that the decoding will return anything - some names just
113
+ won't correspond even to a known type. If a name can be decoded to a known type,
114
+ that type decoder might still not be able to come up with a type. Or, if it comes
115
+ up with a type, that type might have a different canonical name.
116
+
117
+ This is all good because it makes it really easy to whip up an encoder/decoder, but for
118
+ the basic encoders included with the program, we can offer a better guarantee: that we
119
+ can always decode any any type-relative number and return an instance of the type, even
120
+ if we weren't given a canonical name.
121
+
122
+ Separately, we add a "type wrapping" feature to the main program so that unknown type
123
+ identifier numbers just wrap repeated over known type identifiers - again, this will
124
+ never be a canonical name.
125
+
126
+ With those features, it means you can type random names into the program, and see what
127
+ sort of thing you get.