Skip to content

Commit 65e1f27

Browse files
authored
Use shorthand --start and --target for CLI in docs and tests (#324)
1 parent 59885b6 commit 65e1f27

File tree

7 files changed

+34
-34
lines changed

7 files changed

+34
-34
lines changed

.github/workflows/generate-morphs.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ jobs:
6565
DATASET_ARGS=$(python bin/ci.py $DATASET_ALL_CHANGED_FILES)
6666
echo "Generating morphs for the following datasets: $DATASET_ARGS"
6767
data-morph \
68-
--start-shape $DATASET_ARGS \
69-
--target-shape bullseye heart rectangle star slant_up \
68+
--start $DATASET_ARGS \
69+
--target bullseye heart rectangle star slant_up \
7070
--workers 0
7171
7272
# If shapes are added or modified in this PR
@@ -79,8 +79,8 @@ jobs:
7979
SHAPE_ARGS=$(python bin/ci.py $SHAPE_ALL_CHANGED_FILES)
8080
echo "Generating morphs for the following shapes: $SHAPE_ARGS"
8181
data-morph \
82-
--start-shape music \
83-
--target-shape $SHAPE_ARGS \
82+
--start music \
83+
--target $SHAPE_ARGS \
8484
--workers 0
8585
8686
# For core code changes, we want to do a couple morphs to see if they still look ok
@@ -89,8 +89,8 @@ jobs:
8989
if: steps.changed-files-yaml.outputs.dataset_any_changed != 'true' && steps.changed-files-yaml.outputs.shape_any_changed != 'true'
9090
run: |
9191
data-morph \
92-
--start-shape music \
93-
--target-shape bullseye heart star \
92+
--start music \
93+
--target bullseye heart star \
9494
--workers 0
9595
9696
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Once installed, Data Morph can be used on the command line or as an importable P
9898
Run `data-morph` on the command line:
9999

100100
```console
101-
$ data-morph --start-shape panda --target-shape star
101+
$ data-morph --start panda --target star
102102
```
103103

104104
This produces the animation in the newly-created `morphed_data` directory within your current working directory (shown above). More examples, including how to run multiple transformations in parallel, can be found in the [documentation](https://stefaniemolin.com/data-morph/).

docs/cli.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,41 @@ Examples
1717

1818
.. code-block:: console
1919
20-
$ data-morph --start-shape panda --target-shape star
20+
$ data-morph --start panda --target star
2121
2222
2. Morph the panda shape into all available target shapes distributing the work
2323
to as many worker processes as possible:
2424

2525
.. code-block:: console
2626
27-
$ data-morph --start-shape panda --target-shape all --workers 0
27+
$ data-morph --start panda --target all --workers 0
2828
2929
3. Morph the cat, dog, and panda shapes into the circle and slant_down shapes:
3030

3131
.. code-block:: console
3232
33-
$ data-morph --start-shape cat dog panda --target-shape circle slant_down
33+
$ data-morph --start cat dog panda --target circle slant_down
3434
3535
4. Morph the dog shape into upward-slanting lines over 50,000 iterations with seed 1:
3636

3737
.. code-block:: console
3838
39-
$ data-morph --start-shape dog --target-shape slant_up --iterations 50000 --seed 1
39+
$ data-morph --start dog --target slant_up --iterations 50000 --seed 1
4040
4141
5. Morph the cat shape into a circle, preserving summary statistics to 3 decimal places:
4242

4343
.. code-block:: console
4444
45-
$ data-morph --start-shape cat --target-shape circle --decimals 3
45+
$ data-morph --start cat --target circle --decimals 3
4646
4747
6. Morph the music shape into a bullseye, specifying the output directory:
4848

4949
.. code-block:: console
5050
51-
$ data-morph --start-shape music --target-shape bullseye --output-dir path/to/dir
51+
$ data-morph --start music --target bullseye --output-dir path/to/dir
5252
5353
7. Morph the sheep shape into vertical lines, slowly easing in and out for the animation:
5454

5555
.. code-block:: console
5656
57-
$ data-morph --start-shape sheep --target-shape v_lines --ease
57+
$ data-morph --start sheep --target v_lines --ease

docs/quickstart.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Run ``data-morph`` on the command line:
3838

3939
.. code:: console
4040
41-
$ data-morph --start-shape panda --target-shape star
41+
$ data-morph --start panda --target star
4242
4343
This produces the following animation in the newly-created ``morphed_data`` directory
4444
within your current working directory:
@@ -53,7 +53,7 @@ If you don't want the marginal plots (the histograms on the sides), you can use
5353

5454
.. code:: console
5555
56-
$ data-morph --start-shape panda --target-shape star --classic
56+
$ data-morph --start panda --target star --classic
5757
5858
Animations generated in classic mode include only the scatter plot and the summary statistics:
5959

@@ -69,7 +69,7 @@ of the initial shape:
6969

7070
.. code:: console
7171
72-
$ data-morph --start-shape panda --target-shape star --freeze 50 --ease
72+
$ data-morph --start panda --target star --freeze 50 --ease
7373
7474
Here is the resulting animation:
7575

@@ -88,7 +88,7 @@ the command below:
8888

8989
.. code:: console
9090
91-
$ data-morph --start-shape music soccer --target-shape heart diamond
91+
$ data-morph --start music soccer --target heart diamond
9292
9393
.. tip::
9494

@@ -98,7 +98,7 @@ the command below:
9898

9999
.. code:: console
100100
101-
$ data-morph --start-shape music soccer --target-shape heart diamond --workers 0
101+
$ data-morph --start music soccer --target heart diamond --workers 0
102102
103103
If you have the GNU ``parallel`` command on your machine, you can use it to run
104104
a slightly faster parallelized Data Morph (since it incurs less Python overhead),
@@ -107,7 +107,7 @@ the command below:
107107
.. code:: console
108108
109109
$ parallel --progress -j0 \
110-
> data-morph --start-shape {1} --target-shape {2} \
110+
> data-morph --start {1} --target {2} \
111111
> ::: music soccer ::: heart diamond
112112
113113
Check out the `GNU parallel documentation <https://www.gnu.org/software/parallel/sphinx.html>`_

docs/tutorials/custom-datasets.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Pass the path to the CSV file to use those points as the starting shape:
9999

100100
.. code:: console
101101
102-
$ data-morph --start-shape path/to/points.csv --target-shape wide_lines --classic
102+
$ data-morph --start path/to/points.csv --target wide_lines --classic
103103
104104
Here is an example animation generated from a custom dataset:
105105

@@ -132,4 +132,4 @@ If and only if you are given the go ahead:
132132

133133
.. code:: console
134134
135-
$ data-morph --start-shape path/to/points.csv --target-shape all
135+
$ data-morph --start path/to/points.csv --target all

docs/tutorials/shape-creation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ for the ``name`` attribute of your shape class to generate three animations:
191191

192192
.. code:: console
193193
194-
$ data-morph --start-shape panda music soccer --target-shape <your shape> --workers 3
194+
$ data-morph --start panda music soccer --target <your shape> --workers 3
195195
196196
Review the animations. Remember, some shapes will work better on certain datasets,
197197
and that's fine. However, if your shape only works well on one of the built-in datasets

tests/test_cli.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_cli_version(capsys):
3434
def test_cli_bad_shape():
3535
"""Test that invalid target shapes raise a ValueError."""
3636
with pytest.raises(ValueError, match='No valid target shapes were provided'):
37-
cli.main(['--start-shape=dino', '--target-shape=does-not-exist'])
37+
cli.main(['--start=dino', '--target=does-not-exist'])
3838

3939

4040
@pytest.mark.input_validation
@@ -50,7 +50,7 @@ def test_cli_bad_shape():
5050
def test_cli_bad_input_decimals(decimals, reason, capsys):
5151
"""Test that invalid input for decimals is handled correctly."""
5252
with pytest.raises(SystemExit):
53-
cli.main(['--start-shape=dino', f'--decimals={decimals}'])
53+
cli.main(['--start=dino', f'--decimals={decimals}'])
5454
assert f'error: argument --decimals: {reason}:' in capsys.readouterr().err
5555

5656

@@ -66,7 +66,7 @@ def test_cli_bad_input_decimals(decimals, reason, capsys):
6666
def test_cli_bad_input_floats(field, value, reason, capsys):
6767
"""Test that invalid input for floats is handled correctly."""
6868
with pytest.raises(SystemExit):
69-
cli.main([f'--{field}', value, '--start-shape=dino'])
69+
cli.main([f'--{field}', value, '--start=dino'])
7070
assert f'error: argument --{field}: {reason}' in capsys.readouterr().err
7171

7272

@@ -76,7 +76,7 @@ def test_cli_bad_input_floats(field, value, reason, capsys):
7676
def test_cli_bad_input_integers(field, value, capsys):
7777
"""Test that invalid input for integers is handled correctly."""
7878
with pytest.raises(SystemExit):
79-
cli.main(['--start-shape=dino', f'--{field}={value}'])
79+
cli.main(['--start=dino', f'--{field}={value}'])
8080
assert f'error: argument --{field}: invalid int value:' in capsys.readouterr().err
8181

8282

@@ -88,7 +88,7 @@ def test_cli_bad_input_integers(field, value, capsys):
8888
def test_cli_bad_input_boolean(field, value, capsys):
8989
"""Test that invalid input for Boolean switches are handled correctly."""
9090
with pytest.raises(SystemExit):
91-
cli.main(['--start-shape=dino', f'--{field}={value}'])
91+
cli.main(['--start=dino', f'--{field}={value}'])
9292
assert (
9393
f'error: argument --{field}: ignored explicit argument'
9494
in capsys.readouterr().err
@@ -107,8 +107,8 @@ def test_cli_dataloader(start_shape, scale, mocker):
107107
load = mocker.patch.object(cli.DataLoader, 'load_dataset', autospec=True)
108108
_ = mocker.patch.object(cli.DataMorpher, 'morph')
109109
argv = [
110-
f'--start-shape={start_shape}',
111-
'--target-shape=circle',
110+
f'--start={start_shape}',
111+
'--target=circle',
112112
*bound_args,
113113
]
114114
cli.main([arg for arg in argv if arg])
@@ -145,8 +145,8 @@ def test_cli_one_shape(start_shape, flag, mocker, tmp_path):
145145
morph_mock = mocker.patch.object(cli.DataMorpher, 'morph', autospec=True)
146146

147147
argv = [
148-
f'--start-shape={morph_args["start_shape_name"]}',
149-
f'--target-shape={morph_args["target_shape"]}',
148+
f'--start={morph_args["start_shape_name"]}',
149+
f'--target={morph_args["target_shape"]}',
150150
f'--iterations={morph_args["iterations"]}',
151151
f'--decimals={init_args["decimals"]}' if init_args['decimals'] else '',
152152
f'--seed={init_args["seed"]}',
@@ -220,9 +220,9 @@ def test_cli_multiple_shapes(
220220
workers = 2
221221
cli.main(
222222
[
223-
'--start-shape',
223+
'--start',
224224
*start_shape,
225-
'--target-shape',
225+
'--target',
226226
*target_shape,
227227
f'--iterations={iterations}',
228228
f'--output-dir={tmp_path}',

0 commit comments

Comments
 (0)