Repository navigation
Commit a624b59
authored
fix(graphics): accept unspecified dimensions in expand_dims (#270)
Fixes #261.
`expand_dims()` raises `TypeError` even though `dim=None` is its
documented default. Return `None` for an unspecified extent so callers
can choose autoscaling or obtain limits elsewhere. Update the argument
and return annotations and docstring to describe this behavior.
Validate `nd` before returning, so unsupported dimensions still raise
`ValueError`, including when `dim` is `None`; zero remains an explicit
extent. Add regressions for omitted and explicit `None` in 2D/3D,
explicit numeric extents, malformed vectors, and unsupported dimensions.
Preserve the negative-scalar and reversed-limit behavior from #262 and
its regression tests.
Validation on this branch including upstream master `824a459`
(`MPLBACKEND=Agg`):
- Python 3.12.14 full suite: **476 passed, 3 skipped**, with 71 subtests
passed and 23 warnings.
- Graphics tests on Python 3.10.12 and 3.12.14: **21 passed**, with 8
subtests passed on each version.
- Repository pre-commit hooks (Black 23.10.0, EOF, debug statements,
trailing whitespace) and `git diff --check` pass. Black also wraps
existing long lines in the touched graphics module and test file.
The existing internal callers already guard `None`. Downstream bdsim
behavior has not been tested; the `scale=None` timing change noted in
#261 remains applicable.
Signed-off-by: 李永祺 <doribelove@gmail.com>1 parent a3b6492 commit a624b59
2 files changed
Lines changed: 47 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1513 | 1513 | | |
1514 | 1514 | | |
1515 | 1515 | | |
1516 | | - | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
1517 | 1520 | | |
1518 | 1521 | | |
1519 | 1522 | | |
| |||
1736 | 1739 | | |
1737 | 1740 | | |
1738 | 1741 | | |
1739 | | - | |
| 1742 | + | |
1740 | 1743 | | |
1741 | 1744 | | |
1742 | 1745 | | |
1743 | | - | |
| 1746 | + | |
1744 | 1747 | | |
1745 | | - | |
| 1748 | + | |
1746 | 1749 | | |
1747 | 1750 | | |
1748 | | - | |
1749 | | - | |
| 1751 | + | |
| 1752 | + | |
1750 | 1753 | | |
1751 | 1754 | | |
1752 | 1755 | | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
1753 | 1760 | | |
1754 | 1761 | | |
1755 | 1762 | | |
| |||
1766 | 1773 | | |
1767 | 1774 | | |
1768 | 1775 | | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
1769 | 1781 | | |
1770 | 1782 | | |
1771 | 1783 | | |
| |||
1788 | 1800 | | |
1789 | 1801 | | |
1790 | 1802 | | |
1791 | | - | |
1792 | | - | |
1793 | 1803 | | |
1794 | 1804 | | |
1795 | 1805 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
49 | 75 | | |
50 | 76 | | |
51 | 77 | | |
| |||
56 | 82 | | |
57 | 83 | | |
58 | 84 | | |
59 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
60 | 88 | | |
61 | 89 | | |
62 | 90 | | |
| |||
0 commit comments