sonolus.py 0.1.3__tar.gz → 0.1.5__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.
Potentially problematic release.
This version of sonolus.py might be problematic. Click here for more details.
- sonolus_py-0.1.5/.github/workflows/publish.yaml +52 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/.gitignore +5 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/LICENSE +21 -21
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/PKG-INFO +1 -1
- sonolus_py-0.1.5/doc_stubs/builtins.pyi +252 -0
- sonolus_py-0.1.5/doc_stubs/math.pyi +156 -0
- sonolus_py-0.1.5/doc_stubs/num.pyi +5 -0
- sonolus_py-0.1.5/doc_stubs/random.pyi +97 -0
- sonolus_py-0.1.5/docs/CNAME +1 -0
- sonolus_py-0.1.5/docs/concepts/builtins.md +49 -0
- sonolus_py-0.1.5/docs/concepts/cli.md +16 -0
- sonolus_py-0.1.5/docs/concepts/constructs.md +487 -0
- sonolus_py-0.1.5/docs/concepts/index.md +2 -0
- sonolus_py-0.1.5/docs/concepts/project.md +178 -0
- sonolus_py-0.1.5/docs/concepts/resources.md +239 -0
- sonolus_py-0.1.5/docs/concepts/types.md +582 -0
- sonolus_py-0.1.5/docs/index.md +22 -0
- sonolus_py-0.1.5/docs/reference/builtins.md +4 -0
- sonolus_py-0.1.5/docs/reference/index.md +2 -0
- sonolus_py-0.1.5/docs/reference/math.md +4 -0
- sonolus_py-0.1.5/docs/reference/random.md +4 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.archetype.md +5 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.array.md +6 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.array_like.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.bucket.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.containers.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.debug.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.easing.md +5 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.effect.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.engine.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.globals.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.instruction.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.interval.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.iterator.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.level.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.num.md +4 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.options.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.particle.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.print.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.project.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.quad.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.record.md +13 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.runtime.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.sprite.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.text.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.timing.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.transform.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.ui.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.values.md +3 -0
- sonolus_py-0.1.5/docs/reference/sonolus.script.vec.md +3 -0
- sonolus_py-0.1.5/mkdocs.yml +113 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/pyproject.toml +9 -1
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/scripts/generate.py +91 -91
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/backend/blocks.py +756 -756
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/backend/excepthook.py +37 -37
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/backend/finalize.py +77 -69
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/backend/interpret.py +7 -7
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/backend/ir.py +29 -3
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/backend/mode.py +24 -24
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/backend/node.py +40 -40
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/backend/ops.py +197 -197
- sonolus_py-0.1.5/sonolus/backend/optimize/allocate.py +126 -0
- sonolus_py-0.1.5/sonolus/backend/optimize/constant_evaluation.py +374 -0
- sonolus_py-0.1.5/sonolus/backend/optimize/copy_coalesce.py +85 -0
- sonolus_py-0.1.5/sonolus/backend/optimize/dead_code.py +185 -0
- sonolus_py-0.1.5/sonolus/backend/optimize/dominance.py +96 -0
- {sonolus_py-0.1.3/sonolus/backend → sonolus_py-0.1.5/sonolus/backend/optimize}/flow.py +122 -92
- sonolus_py-0.1.5/sonolus/backend/optimize/inlining.py +137 -0
- sonolus_py-0.1.5/sonolus/backend/optimize/liveness.py +177 -0
- sonolus_py-0.1.5/sonolus/backend/optimize/optimize.py +44 -0
- sonolus_py-0.1.5/sonolus/backend/optimize/passes.py +52 -0
- sonolus_py-0.1.5/sonolus/backend/optimize/simplify.py +191 -0
- sonolus_py-0.1.5/sonolus/backend/optimize/ssa.py +200 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/backend/place.py +17 -25
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/backend/utils.py +58 -48
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/backend/visitor.py +1151 -882
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/build/cli.py +7 -1
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/build/compile.py +88 -90
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/build/engine.py +10 -5
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/build/level.py +24 -23
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/build/node.py +43 -43
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/archetype.py +438 -139
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/array.py +27 -10
- sonolus_py-0.1.5/sonolus/script/array_like.py +297 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/bucket.py +253 -191
- sonolus_py-0.1.5/sonolus/script/containers.py +453 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/debug.py +26 -10
- sonolus_py-0.1.5/sonolus/script/easing.py +365 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/effect.py +191 -131
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/engine.py +71 -4
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/globals.py +303 -269
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/instruction.py +205 -151
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/internal/__init__.py +5 -5
- sonolus_py-0.1.5/sonolus/script/internal/builtin_impls.py +255 -0
- {sonolus_py-0.1.3/sonolus/script → sonolus_py-0.1.5/sonolus/script/internal}/callbacks.py +127 -127
- sonolus_py-0.1.5/sonolus/script/internal/constant.py +139 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/internal/context.py +26 -9
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/internal/descriptor.py +17 -17
- sonolus_py-0.1.5/sonolus/script/internal/dict_impl.py +65 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/internal/generic.py +6 -9
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/internal/impl.py +38 -13
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/internal/introspection.py +17 -14
- sonolus_py-0.1.5/sonolus/script/internal/math_impls.py +121 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/internal/native.py +40 -38
- sonolus_py-0.1.5/sonolus/script/internal/random.py +67 -0
- sonolus_py-0.1.5/sonolus/script/internal/range.py +81 -0
- sonolus_py-0.1.5/sonolus/script/internal/transient.py +51 -0
- sonolus_py-0.1.5/sonolus/script/internal/tuple_impl.py +113 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/internal/value.py +3 -3
- sonolus_py-0.1.5/sonolus/script/interval.py +338 -0
- sonolus_py-0.1.5/sonolus/script/iterator.py +167 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/level.py +24 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/num.py +80 -48
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/options.py +257 -191
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/particle.py +190 -157
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/pointer.py +30 -30
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/print.py +102 -81
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/project.py +8 -0
- sonolus_py-0.1.5/sonolus/script/quad.py +263 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/record.py +47 -16
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/runtime.py +52 -1
- sonolus_py-0.1.5/sonolus/script/sprite.py +418 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/text.py +409 -407
- sonolus_py-0.1.5/sonolus/script/timing.py +114 -0
- sonolus_py-0.1.5/sonolus/script/transform.py +398 -0
- sonolus_py-0.1.5/sonolus/script/ui.py +216 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/values.py +6 -13
- sonolus_py-0.1.5/sonolus/script/vec.py +196 -0
- sonolus_py-0.1.5/tests/__init__.py +0 -0
- sonolus_py-0.1.5/tests/script/__init__.py +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/tests/script/conftest.py +33 -3
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/tests/script/test_array.py +91 -10
- sonolus_py-0.1.5/tests/script/test_array_map.py +253 -0
- sonolus_py-0.1.5/tests/script/test_dict.py +44 -0
- sonolus_py-0.1.5/tests/script/test_flow.py +868 -0
- sonolus_py-0.1.5/tests/script/test_functions.py +1208 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/tests/script/test_interval.py +2 -2
- sonolus_py-0.1.5/tests/script/test_match.py +533 -0
- sonolus_py-0.1.5/tests/script/test_operator.py +264 -0
- sonolus_py-0.1.5/tests/script/test_random.py +302 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/tests/script/test_range.py +44 -7
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/tests/script/test_record.py +81 -1
- sonolus_py-0.1.5/tests/script/test_transform.py +301 -0
- sonolus_py-0.1.5/tests/script/test_tuple.py +70 -0
- sonolus_py-0.1.5/tests/script/test_var_array.py +627 -0
- sonolus_py-0.1.5/tests/script/test_vec.py +131 -0
- sonolus_py-0.1.5/uv.lock +717 -0
- sonolus_py-0.1.3/sonolus/backend/allocate.py +0 -51
- sonolus_py-0.1.3/sonolus/backend/optimize.py +0 -9
- sonolus_py-0.1.3/sonolus/backend/passes.py +0 -6
- sonolus_py-0.1.3/sonolus/backend/simplify.py +0 -30
- sonolus_py-0.1.3/sonolus/script/comptime.py +0 -160
- sonolus_py-0.1.3/sonolus/script/containers.py +0 -247
- sonolus_py-0.1.3/sonolus/script/graphics.py +0 -150
- sonolus_py-0.1.3/sonolus/script/internal/builtin_impls.py +0 -144
- sonolus_py-0.1.3/sonolus/script/interval.py +0 -112
- sonolus_py-0.1.3/sonolus/script/iterator.py +0 -214
- sonolus_py-0.1.3/sonolus/script/math.py +0 -92
- sonolus_py-0.1.3/sonolus/script/range.py +0 -58
- sonolus_py-0.1.3/sonolus/script/sprite.py +0 -333
- sonolus_py-0.1.3/sonolus/script/timing.py +0 -42
- sonolus_py-0.1.3/sonolus/script/transform.py +0 -114
- sonolus_py-0.1.3/sonolus/script/ui.py +0 -160
- sonolus_py-0.1.3/sonolus/script/vec.py +0 -78
- sonolus_py-0.1.3/tests/script/test_array_map.py +0 -59
- sonolus_py-0.1.3/tests/script/test_var_array.py +0 -296
- sonolus_py-0.1.3/uv.lock +0 -257
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/.python-version +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/README.md +0 -0
- {sonolus_py-0.1.3/sonolus → sonolus_py-0.1.5/doc_stubs}/__init__.py +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/scripts/runtimes/Engine/Tutorial/Blocks.json +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/scripts/runtimes/Functions.json +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/scripts/runtimes/Level/Play/Blocks.json +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/scripts/runtimes/Level/Preview/Blocks.json +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/scripts/runtimes/Level/Watch/Blocks.json +0 -0
- {sonolus_py-0.1.3/sonolus/backend → sonolus_py-0.1.5/sonolus}/__init__.py +0 -0
- {sonolus_py-0.1.3/sonolus/build → sonolus_py-0.1.5/sonolus/backend}/__init__.py +0 -0
- {sonolus_py-0.1.3/sonolus/script → sonolus_py-0.1.5/sonolus/backend/optimize}/__init__.py +0 -0
- {sonolus_py-0.1.3/tests → sonolus_py-0.1.5/sonolus/build}/__init__.py +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/build/collection.py +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/build/project.py +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/py.typed +0 -0
- {sonolus_py-0.1.3/tests → sonolus_py-0.1.5/sonolus}/script/__init__.py +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/sonolus/script/internal/error.py +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/tests/script/test_assert.py +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/tests/script/test_helpers.py +0 -0
- {sonolus_py-0.1.3 → sonolus_py-0.1.5}/tests/script/test_num.py +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on: push
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
name: Build
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
|
|
10
|
+
steps:
|
|
11
|
+
- name: Checkout
|
|
12
|
+
uses: actions/checkout@v4
|
|
13
|
+
- name: Install uv
|
|
14
|
+
uses: astral-sh/setup-uv@v3
|
|
15
|
+
with:
|
|
16
|
+
version: 0.5.2
|
|
17
|
+
- name: Install Python
|
|
18
|
+
run: |
|
|
19
|
+
uv python install
|
|
20
|
+
- name: Install project
|
|
21
|
+
run: |
|
|
22
|
+
uv sync --all-extras --dev
|
|
23
|
+
- name: Run tests
|
|
24
|
+
run: |
|
|
25
|
+
uv run pytest tests -n auto
|
|
26
|
+
- name: Build
|
|
27
|
+
run: |
|
|
28
|
+
uv build
|
|
29
|
+
- name: Store distribution packages
|
|
30
|
+
uses: actions/upload-artifact@v4
|
|
31
|
+
with:
|
|
32
|
+
name: python-package-distributions
|
|
33
|
+
path: dist/
|
|
34
|
+
publish:
|
|
35
|
+
name: Publish
|
|
36
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
37
|
+
needs:
|
|
38
|
+
- build
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
environment:
|
|
41
|
+
name: pypi
|
|
42
|
+
url: https://pypi.org/project/sonolus.py
|
|
43
|
+
permissions:
|
|
44
|
+
id-token: write
|
|
45
|
+
steps:
|
|
46
|
+
- name: Download distribution packages
|
|
47
|
+
uses: actions/download-artifact@v4
|
|
48
|
+
with:
|
|
49
|
+
name: python-package-distributions
|
|
50
|
+
path: dist/
|
|
51
|
+
- name: Publish to PyPI
|
|
52
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Kyle Chang
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Kyle Chang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# ruff: noqa
|
|
2
|
+
import builtins
|
|
3
|
+
from typing import (
|
|
4
|
+
Any,
|
|
5
|
+
Callable,
|
|
6
|
+
Iterable,
|
|
7
|
+
Iterator,
|
|
8
|
+
Sequence,
|
|
9
|
+
overload,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
def abs(x: builtins.int | builtins.float) -> builtins.int | builtins.float:
|
|
13
|
+
"""Return the absolute value of a number.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
x: A number.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
The absolute value of x.
|
|
20
|
+
"""
|
|
21
|
+
...
|
|
22
|
+
|
|
23
|
+
def bool(x: builtins.int | builtins.float | builtins.bool) -> builtins.bool:
|
|
24
|
+
"""Convert a value to a Boolean.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
x: The value to convert.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
The Boolean value of x.
|
|
31
|
+
"""
|
|
32
|
+
...
|
|
33
|
+
|
|
34
|
+
def callable(obj: object) -> bool:
|
|
35
|
+
"""Check if the object appears callable.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
obj: The object to check.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
True if the object appears callable, False otherwise.
|
|
42
|
+
"""
|
|
43
|
+
...
|
|
44
|
+
|
|
45
|
+
def enumerate[T](iterable: Iterable[T], start: int = 0) -> Iterator[tuple[int, T]]:
|
|
46
|
+
"""Return an enumerate object.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
iterable: The iterable to enumerate.
|
|
50
|
+
start: The starting index.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
An enumerate object.
|
|
54
|
+
"""
|
|
55
|
+
...
|
|
56
|
+
|
|
57
|
+
def filter[T](function: Callable[[T], builtins.bool] | None, iterable: Iterable[T]) -> Iterator[T]:
|
|
58
|
+
"""Construct an iterator from those elements of iterable for which function returns true.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
function: A function that tests if each element should be included. If None, returns the elements that are true.
|
|
62
|
+
iterable: The iterable to filter.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
An iterator yielding the filtered elements.
|
|
66
|
+
"""
|
|
67
|
+
...
|
|
68
|
+
|
|
69
|
+
def float(x: builtins.int | builtins.float) -> builtins.float:
|
|
70
|
+
"""Convert a number to a floating point number.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
x: The number to convert.
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
The floating point representation of x.
|
|
77
|
+
"""
|
|
78
|
+
...
|
|
79
|
+
|
|
80
|
+
def int(x: builtins.int | builtins.float) -> builtins.int:
|
|
81
|
+
"""Convert a number to an integer.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
x: The number to convert.
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
The integer representation of x.
|
|
88
|
+
"""
|
|
89
|
+
...
|
|
90
|
+
|
|
91
|
+
def isinstance(obj: object, classinfo: type | tuple[type, ...]) -> builtins.bool:
|
|
92
|
+
"""Check if an object is an instance of a class or of a subclass thereof.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
obj: The object to check.
|
|
96
|
+
classinfo: A type or a tuple of types.
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
True if the object is an instance of classinfo, False otherwise.
|
|
100
|
+
"""
|
|
101
|
+
...
|
|
102
|
+
|
|
103
|
+
def issubclass(cls: type, classinfo: type | tuple[type, ...]) -> builtins.bool:
|
|
104
|
+
"""Check if a class is a subclass of another class or a tuple of classes.
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
cls: The class to check.
|
|
108
|
+
classinfo: A class or a tuple of classes.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
True if cls is a subclass of classinfo, False otherwise.
|
|
112
|
+
"""
|
|
113
|
+
...
|
|
114
|
+
|
|
115
|
+
def len(s: object) -> builtins.int:
|
|
116
|
+
"""Return the number of items in a container.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
s: The container object.
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
The number of items in s.
|
|
123
|
+
"""
|
|
124
|
+
...
|
|
125
|
+
|
|
126
|
+
def map[T, S](function: Callable[[T], S], iterable: Iterable[T]) -> Iterator[S]:
|
|
127
|
+
"""Apply a function to every item of an iterable and return an iterator.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
function: The function to apply.
|
|
131
|
+
iterable: The iterable to process.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
An iterator with the results.
|
|
135
|
+
"""
|
|
136
|
+
...
|
|
137
|
+
|
|
138
|
+
@overload
|
|
139
|
+
def max[T](iterable: Iterable[T], *, key: Callable[[T], Any] | None = ...) -> T:
|
|
140
|
+
"""Return the largest item in an iterable or the largest of two or more arguments.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
iterable: The iterable to evaluate.
|
|
144
|
+
key: A function of one argument that is used to extract a comparison key from each element.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
The largest item.
|
|
148
|
+
"""
|
|
149
|
+
...
|
|
150
|
+
|
|
151
|
+
@overload
|
|
152
|
+
def max[T](arg1: T, arg2: T, *args: T, key: Callable[[T], Any] | None = ...) -> T:
|
|
153
|
+
"""Return the largest item in an iterable or the largest of two or more arguments.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
arg1: First argument.
|
|
157
|
+
arg2: Second argument.
|
|
158
|
+
*args: Additional arguments.
|
|
159
|
+
key: A function of one argument that is used to extract a comparison key from each element.
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
The largest item.
|
|
163
|
+
"""
|
|
164
|
+
...
|
|
165
|
+
|
|
166
|
+
@overload
|
|
167
|
+
def min[T](iterable: Iterable[T], *, key: Callable[[T], Any] | None = ...) -> T:
|
|
168
|
+
"""Return the smallest item in an iterable or the smallest of two or more arguments.
|
|
169
|
+
|
|
170
|
+
Args:
|
|
171
|
+
iterable: The iterable to evaluate.
|
|
172
|
+
key: A function of one argument that is used to extract a comparison key from each element.
|
|
173
|
+
|
|
174
|
+
Returns:
|
|
175
|
+
The smallest item.
|
|
176
|
+
"""
|
|
177
|
+
...
|
|
178
|
+
|
|
179
|
+
@overload
|
|
180
|
+
def min[T](arg1: T, arg2: T, *args: T, key: Callable[[T], Any] | None = ...) -> T:
|
|
181
|
+
"""Return the smallest item in an iterable or the smallest of two or more arguments.
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
arg1: First argument.
|
|
185
|
+
arg2: Second argument.
|
|
186
|
+
*args: Additional arguments.
|
|
187
|
+
key: A function of one argument that is used to extract a comparison key from each element.
|
|
188
|
+
|
|
189
|
+
Returns:
|
|
190
|
+
The smallest item.
|
|
191
|
+
"""
|
|
192
|
+
...
|
|
193
|
+
|
|
194
|
+
@overload
|
|
195
|
+
def range(stop: builtins.int) -> builtins.range:
|
|
196
|
+
"""Return an immutable sequence of numbers from 0 to stop.
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
stop: Stop value.
|
|
200
|
+
|
|
201
|
+
Returns:
|
|
202
|
+
The range object.
|
|
203
|
+
"""
|
|
204
|
+
...
|
|
205
|
+
|
|
206
|
+
@overload
|
|
207
|
+
def range(start: builtins.int, stop: builtins.int, step: builtins.int = ...) -> builtins.range:
|
|
208
|
+
"""Return an immutable sequence of numbers from start to stop by step.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
start: Start value.
|
|
212
|
+
stop: Stop value.
|
|
213
|
+
step: Step value.
|
|
214
|
+
|
|
215
|
+
Returns:
|
|
216
|
+
The range object.
|
|
217
|
+
"""
|
|
218
|
+
...
|
|
219
|
+
|
|
220
|
+
def reversed[T](seq: Sequence[T]) -> Iterator[T]:
|
|
221
|
+
"""Return a reverse iterator.
|
|
222
|
+
|
|
223
|
+
Args:
|
|
224
|
+
seq: The sequence to reverse.
|
|
225
|
+
|
|
226
|
+
Returns:
|
|
227
|
+
An iterator over the reversed sequence.
|
|
228
|
+
"""
|
|
229
|
+
...
|
|
230
|
+
|
|
231
|
+
def round(number: builtins.int | builtins.float, ndigits: builtins.int = ...) -> builtins.float:
|
|
232
|
+
"""Round a number to a given precision in decimal digits.
|
|
233
|
+
|
|
234
|
+
Args:
|
|
235
|
+
number: The number to round.
|
|
236
|
+
ndigits: The number of decimal digits to round to.
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
The rounded number.
|
|
240
|
+
"""
|
|
241
|
+
...
|
|
242
|
+
|
|
243
|
+
def zip[T](*iterables: Iterable[T]) -> Iterator[tuple[T, ...]]:
|
|
244
|
+
"""Return an iterator of tuples, where the i-th tuple contains the i-th element from each of the argument sequences.
|
|
245
|
+
|
|
246
|
+
Args:
|
|
247
|
+
*iterables: Iterables to aggregate.
|
|
248
|
+
|
|
249
|
+
Returns:
|
|
250
|
+
An iterator of aggregated tuples.
|
|
251
|
+
"""
|
|
252
|
+
...
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# ruff: noqa
|
|
2
|
+
def sin(x: float) -> float:
|
|
3
|
+
"""Compute the sine of x.
|
|
4
|
+
|
|
5
|
+
Args:
|
|
6
|
+
x: The angle in radians.
|
|
7
|
+
|
|
8
|
+
Returns:
|
|
9
|
+
The sine of x.
|
|
10
|
+
"""
|
|
11
|
+
...
|
|
12
|
+
|
|
13
|
+
def cos(x: float) -> float:
|
|
14
|
+
"""Compute the cosine of x.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
x: The angle in radians.
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
The cosine of x.
|
|
21
|
+
"""
|
|
22
|
+
...
|
|
23
|
+
|
|
24
|
+
def tan(x: float) -> float:
|
|
25
|
+
"""Compute the tangent of x.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
x: The angle in radians.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
The tangent of x.
|
|
32
|
+
"""
|
|
33
|
+
...
|
|
34
|
+
|
|
35
|
+
def asin(x: float) -> float:
|
|
36
|
+
"""Compute the arcsine of x.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
x: A value between -1 and 1.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
The arcsine of x in radians.
|
|
43
|
+
"""
|
|
44
|
+
...
|
|
45
|
+
|
|
46
|
+
def acos(x: float) -> float:
|
|
47
|
+
"""Compute the arccosine of x.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
x: A value between -1 and 1.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
The arccosine of x in radians.
|
|
54
|
+
"""
|
|
55
|
+
...
|
|
56
|
+
|
|
57
|
+
def atan(x: float) -> float:
|
|
58
|
+
"""Compute the arctangent of x.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
x: A numeric value.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
The arctangent of x in radians.
|
|
65
|
+
"""
|
|
66
|
+
...
|
|
67
|
+
|
|
68
|
+
def atan2(y: float, x: float) -> float:
|
|
69
|
+
"""Compute the arctangent of y / x considering the quadrant.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
y: The y-coordinate.
|
|
73
|
+
x: The x-coordinate.
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
The arctangent of y / x in radians.
|
|
77
|
+
"""
|
|
78
|
+
...
|
|
79
|
+
|
|
80
|
+
def sinh(x: float) -> float:
|
|
81
|
+
"""Compute the hyperbolic sine of x.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
x: A numeric value.
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
The hyperbolic sine of x.
|
|
88
|
+
"""
|
|
89
|
+
...
|
|
90
|
+
|
|
91
|
+
def cosh(x: float) -> float:
|
|
92
|
+
"""Compute the hyperbolic cosine of x.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
x: A numeric value.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
The hyperbolic cosine of x.
|
|
99
|
+
"""
|
|
100
|
+
...
|
|
101
|
+
|
|
102
|
+
def tanh(x: float) -> float:
|
|
103
|
+
"""Compute the hyperbolic tangent of x.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
x: A numeric value.
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
The hyperbolic tangent of x.
|
|
110
|
+
"""
|
|
111
|
+
...
|
|
112
|
+
|
|
113
|
+
def floor(x: float) -> int:
|
|
114
|
+
"""Return the largest integer less than or equal to x.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
x: A numeric value.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
The floor of x.
|
|
121
|
+
"""
|
|
122
|
+
...
|
|
123
|
+
|
|
124
|
+
def ceil(x: float) -> int:
|
|
125
|
+
"""Return the smallest integer greater than or equal to x.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
x: A numeric value.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
The ceiling of x.
|
|
132
|
+
"""
|
|
133
|
+
...
|
|
134
|
+
|
|
135
|
+
def trunc(x: float) -> int:
|
|
136
|
+
"""Truncate x to the nearest integer towards zero.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
x: A numeric value.
|
|
140
|
+
|
|
141
|
+
Returns:
|
|
142
|
+
The truncated integer value of x.
|
|
143
|
+
"""
|
|
144
|
+
...
|
|
145
|
+
|
|
146
|
+
def log(x: float, base: float = ...) -> float:
|
|
147
|
+
"""Compute the logarithm of x to the given base.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
x: The number for which to compute the logarithm.
|
|
151
|
+
base: The base of the logarithm. If omitted, returns the natural logarithm of x.
|
|
152
|
+
|
|
153
|
+
Returns:
|
|
154
|
+
The logarithm of x to the specified base.
|
|
155
|
+
"""
|
|
156
|
+
...
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# ruff: noqa
|
|
2
|
+
from typing import (
|
|
3
|
+
Any,
|
|
4
|
+
Sequence,
|
|
5
|
+
overload,
|
|
6
|
+
MutableSequence,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
@overload
|
|
10
|
+
def randrange(stop: int) -> int:
|
|
11
|
+
"""Return a randomly selected element from range(stop).
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
stop: The end of the range.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
A randomly selected integer from the range.
|
|
18
|
+
"""
|
|
19
|
+
...
|
|
20
|
+
|
|
21
|
+
@overload
|
|
22
|
+
def randrange(start: int, stop: int, step: int = ...) -> int:
|
|
23
|
+
"""Return a randomly selected element from range(start, stop, step).
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
start: The start of the range.
|
|
27
|
+
stop: The end of the range.
|
|
28
|
+
step: The step size.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
A randomly selected integer from the range.
|
|
32
|
+
"""
|
|
33
|
+
...
|
|
34
|
+
|
|
35
|
+
def randrange(start: int, stop: int = ..., step: int = ...) -> int:
|
|
36
|
+
"""Return a randomly selected element from range(start, stop, step).
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
start: The start of the range.
|
|
40
|
+
stop: The end of the range.
|
|
41
|
+
step: The step size.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
A randomly selected integer from the range.
|
|
45
|
+
"""
|
|
46
|
+
...
|
|
47
|
+
|
|
48
|
+
def randint(a: int, b: int) -> int:
|
|
49
|
+
"""Return a random integer N such that a <= N <= b.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
a: The lower bound.
|
|
53
|
+
b: The upper bound.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
A randomly selected integer between a and b, inclusive.
|
|
57
|
+
"""
|
|
58
|
+
...
|
|
59
|
+
|
|
60
|
+
def choice[T](seq: Sequence[T]) -> T:
|
|
61
|
+
"""Return a randomly selected element from a non-empty sequence.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
seq: The sequence to choose from.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
A randomly selected element from the sequence.
|
|
68
|
+
"""
|
|
69
|
+
...
|
|
70
|
+
|
|
71
|
+
def shuffle(seq: MutableSequence[Any]) -> None:
|
|
72
|
+
"""Shuffle the sequence in place.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
seq: The mutable sequence to shuffle.
|
|
76
|
+
"""
|
|
77
|
+
...
|
|
78
|
+
|
|
79
|
+
def random() -> float:
|
|
80
|
+
"""Return a random floating point number in the range [0.0, 1.0).
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
A random float between 0.0 (inclusive) and 1.0 (exclusive).
|
|
84
|
+
"""
|
|
85
|
+
...
|
|
86
|
+
|
|
87
|
+
def uniform(a: float, b: float) -> float:
|
|
88
|
+
"""Return a random floating point number N such that a <= N <= b.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
a: The lower bound.
|
|
92
|
+
b: The upper bound.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
A random float between a and b.
|
|
96
|
+
"""
|
|
97
|
+
...
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sonolus.py.qwewqa.xyz
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Builtins
|
|
2
|
+
Sonolus.py comes with support for a number of built-in functions.
|
|
3
|
+
|
|
4
|
+
- `abs(x)`
|
|
5
|
+
- `bool(object)` (for a num argument)
|
|
6
|
+
- `callable(object)`
|
|
7
|
+
- `enumerate(iterable, start=0)`
|
|
8
|
+
- `filter(function, iterable)`
|
|
9
|
+
- `float(x)` (for a num argument)
|
|
10
|
+
- `int(x)` (for a num argument)
|
|
11
|
+
- `isinstance(object, classinfo)`
|
|
12
|
+
- `issubclass(class, classinfo)`
|
|
13
|
+
- `len(s)`
|
|
14
|
+
- `map(function, iterable)`
|
|
15
|
+
- `max(iterable, *, key=None)`, `max(arg1, arg2, *args, key=None)`
|
|
16
|
+
- `min(iterable, *, key=None)`, `min(arg1, arg2, *args, key=None)`
|
|
17
|
+
- `range(stop)`, `range(start, stop[, step])`
|
|
18
|
+
- `reversed(seq)`
|
|
19
|
+
- `round(number[, ndigits])`
|
|
20
|
+
- `zip(*iterables)`
|
|
21
|
+
|
|
22
|
+
## Standard library modules
|
|
23
|
+
Sonolus.py also comes with support for some standard library modules.
|
|
24
|
+
|
|
25
|
+
### math
|
|
26
|
+
- `sin(x)`
|
|
27
|
+
- `cos(x)`
|
|
28
|
+
- `tan(x)`
|
|
29
|
+
- `asin(x)`
|
|
30
|
+
- `acos(x)`
|
|
31
|
+
- `atan(x)`
|
|
32
|
+
- `atan2(y, x)`
|
|
33
|
+
- `sinh(x)`
|
|
34
|
+
- `cosh(x)`
|
|
35
|
+
- `tanh(x)`
|
|
36
|
+
- `floor(x)`
|
|
37
|
+
- `ceil(x)`
|
|
38
|
+
- `trunc(x)`
|
|
39
|
+
- `log(x[, base])`
|
|
40
|
+
|
|
41
|
+
### random
|
|
42
|
+
- `randrange(stop)`, `random.randrange(start, stop[, step])`
|
|
43
|
+
- `randint(a, b)`
|
|
44
|
+
- `choice(seq)`
|
|
45
|
+
- `shuffle(seq)`
|
|
46
|
+
- `random()` (does not include 1)
|
|
47
|
+
- `uniform(a, b)` (may include `b` where Python normally doesn't)
|
|
48
|
+
|
|
49
|
+
Creating `Random` instances is not supported.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Command Line
|
|
2
|
+
The Sonolus.py CLI provides commands to run and build Sonolus scripts.
|
|
3
|
+
|
|
4
|
+
## Starting a development server
|
|
5
|
+
To start a development server, run the following command in the root directory of your project:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
sonolus-py dev
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Building the project
|
|
12
|
+
To build the project, run the following command in the root directory of your project:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
sonolus-py build
|
|
16
|
+
```
|