Skip to content

Commit

Permalink
Update hello demo program for current conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Aug 19, 2024
1 parent 5496dc5 commit bfc5d8a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/autoblack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: 3.11
- name: Install click
run: pip install 'click==8.0.4'
- name: Install Black
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
strategy:
matrix:
os: [macOS]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.8, 3.9, 3.10, 3.11]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.9, 3.11]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
strategy:
matrix:
os: [windows]
python-version: [ 3.8, 3.9]
python-version: [ 3.9, 3.11]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions pymathics/hello/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"""

from pymathics.hello.version import __version__
from pymathics.hello.__main__ import Hello # noqa
from pymathics.hello.__main__ import Hello

__all__ = ("__version__", "Hello", "pymathics_version_data")

# To be recognized as an external mathics module, the following variable
# is required:
#
pymathics_version_data = {
"author": "The Mathics Team",
"author": "The Mathics3 Team",
"version": __version__,
"requires": [],
}
27 changes: 21 additions & 6 deletions pymathics/hello/__main__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
# -*- coding: utf-8 -*-
from mathics.core.atoms import String
from mathics.core.builtin import Builtin
from mathics.core.evaluation import Evaluation


class Hello(Builtin):
"""
<dl>
<dt>'Hello'[$person$]
<dd>An example function in a Python-importable Mathics module.
<dd>An example function in a Python-importable Mathics3 module.
</dl>
>> Hello["World"]
See also the <url>
:developer guide section:
https://mathics-development-guide.readthedocs.io/en/latest/extending/developing-code/extending/tutorial/1-builtin.html</url> for an \
explanation of everything.
>> Hello[]
= Hello, World!
>> Hello["rocky"]
= Hello, rocky!
"""

summary_text = """classic "hello" demo"""

# The function below should start with "apply"
def eval_with_name(self, person, evaluation):
"%(name)s[person_String]"
# %(name)s is just a more flexible way of writing "Hello".
# If the class name changes, so will the above pattern.
def eval(self, evaluation: Evaluation):
"Hello[]"
return String("Hello, World!")

# The function below should start with "eval"
def eval_with_name(self, person: String, evaluation: Evaluation) -> String:
"Hello[person_String]"
# The above pattern matches Hello with a single string argument.
# See https://reference.wolfram.com/language/tutorial/Patterns.html#7301
# and https://reference.wolfram.com/language/ref/Cases.html
Expand Down

0 comments on commit bfc5d8a

Please sign in to comment.