Skip to content

Commit

Permalink
Moving private doctests to pytest for assignment and image (#901)
Browse files Browse the repository at this point in the history
Just another round

Co-authored-by: R. Bernstein <[email protected]>
  • Loading branch information
mmatera and rocky committed Aug 12, 2023
1 parent e46b935 commit 524cd40
Show file tree
Hide file tree
Showing 11 changed files with 235 additions and 136 deletions.
14 changes: 0 additions & 14 deletions mathics/builtin/assignments/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ class Set(BinaryOperator, _SetOperator):
>> B[[1;;2, 2;;-1]] = {{t, u}, {y, z}};
>> B
= {{1, t, u}, {4, y, z}, {7, 8, 9}}
#> x = Infinity;
"""

attributes = A_HOLD_FIRST | A_PROTECTED | A_SEQUENCE_HOLD
Expand Down Expand Up @@ -371,12 +369,6 @@ class UpSet(BinaryOperator, _SetOperator):
= custom
>> UpValues[r]
= {}
#> f[g, a + b, h] ^= 2
: Tag Plus in f[g, a + b, h] is Protected.
= 2
#> UpValues[h]
= {HoldPattern[f[g, a + b, h]] :> 2}
"""

attributes = A_HOLD_FIRST | A_PROTECTED | A_SEQUENCE_HOLD
Expand Down Expand Up @@ -413,12 +405,6 @@ class UpSetDelayed(UpSet):
= 2
>> UpValues[b]
= {HoldPattern[a[b]] :> x}
#> f[g, a + b, h] ^:= 2
: Tag Plus in f[g, a + b, h] is Protected.
#> f[a+b] ^:= 2
: Tag Plus in f[a + b] is Protected.
= $Failed
"""

attributes = A_HOLD_ALL | A_PROTECTED | A_SEQUENCE_HOLD
Expand Down
29 changes: 0 additions & 29 deletions mathics/builtin/assignments/clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,35 +245,6 @@ class Unset(PostfixOperator):
>> a = b = 3;
>> {a, {b}} =.
= {Null, {Null}}
#> x = 2;
#> OwnValues[x] =.
#> x
= x
#> f[a][b] = 3;
#> SubValues[f] =.
#> f[a][b]
= f[a][b]
#> PrimeQ[p] ^= True
= True
#> PrimeQ[p]
= True
#> UpValues[p] =.
#> PrimeQ[p]
= False
#> a + b ^= 5;
#> a =.
#> a + b
= 5
#> {UpValues[a], UpValues[b]} =.
= {Null, Null}
#> a + b
= a + b
#> Unset[Messages[1]]
: First argument in Messages[1] is not a symbol or a string naming a symbol.
= $Failed
"""

attributes = A_HOLD_FIRST | A_LISTABLE | A_PROTECTED | A_READ_PROTECTED
Expand Down
6 changes: 0 additions & 6 deletions mathics/builtin/image/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,6 @@ class ImageAtom(AtomBuiltin):
<dd> produces the internal representation of an image from an array \
of values for the pixels.
</dl>
#> Image[{{{1,1,0},{0,1,1}}, {{1,0,1},{1,1,0}}}]
= -Image-
#> Image[{{{0,0,0,0.25},{0,0,0,0.5}}, {{0,0,0,0.5},{0,0,0,0.75}}}]
= -Image-
"""

summary_text = "get internal representation of an image"
Expand Down
13 changes: 0 additions & 13 deletions mathics/builtin/image/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,6 @@ class ImagePartition(Builtin):
>> ImagePartition[hedy, {512, 128}]
= {{-Image-}, {-Image-}, {-Image-}, {-Image-}, {-Image-}, {-Image-}}
#> ImagePartition[hedy, 257]
= {{-Image-, -Image-}, {-Image-, -Image-}, {-Image-, -Image-}}
#> ImagePartition[hedy, 646]
= {{-Image-}}
#> ImagePartition[hedy, 647]
= {}
#> ImagePartition[hedy, {256, 300}]
= {{-Image-, -Image-}, {-Image-, -Image-}}
#> ImagePartition[hedy, {0, 300}]
: {0, 300} is not a valid size specification for image partitions.
= ImagePartition[-Image-, {0, 300}]
"""

messages = {"arg2": "`1` is not a valid size specification for image partitions."}
Expand Down
24 changes: 0 additions & 24 deletions mathics/builtin/image/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ class ImageAdd(_ImageArithmetic):
>> ImageAdd[i, i]
= -Image-
#> ImageAdd[i, 0.2, i, 0.1]
= -Image-
#> ImageAdd[i, x]
: Expecting a number, image, or graphics instead of x.
= ImageAdd[-Image-, x]
>> ein = Import["ExampleData/Einstein.jpg"];
>> noise = RandomImage[{-0.1, 0.1}, ImageDimensions[ein]];
>> ImageAdd[noise, ein]
Expand Down Expand Up @@ -117,16 +110,6 @@ class ImageMultiply(_ImageArithmetic):
>> ImageMultiply[i, i]
= -Image-
#> ImageMultiply[i, 0.2, i, 0.1]
= -Image-
#> ImageMultiply[i, x]
: Expecting a number, image, or graphics instead of x.
= ImageMultiply[-Image-, x]
S> ein = Import["ExampleData/Einstein.jpg"];
S> noise = RandomImage[{0.7, 1.3}, ImageDimensions[ein]];
S> ImageMultiply[noise, ein]
= -Image-
"""

Expand All @@ -151,13 +134,6 @@ class ImageSubtract(_ImageArithmetic):
>> ImageSubtract[i, i]
= -Image-
#> ImageSubtract[i, 0.2, i, 0.1]
= -Image-
#> ImageSubtract[i, x]
: Expecting a number, image, or graphics instead of x.
= ImageSubtract[-Image-, x]
"""

summary_text = "build an image substracting pixel values of another image "
Expand Down
19 changes: 0 additions & 19 deletions mathics/builtin/image/geometric.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,6 @@ class ImageReflect(Builtin):
= -Image-
>> ImageReflect[ein, Left -> Top]
= -Image-
#> ein == ImageReflect[ein, Left -> Left] == ImageReflect[ein, Right -> Right] == ImageReflect[ein, Top -> Top] == ImageReflect[ein, Bottom -> Bottom]
= True
#> ImageReflect[ein, Left -> Right] == ImageReflect[ein, Right -> Left] == ImageReflect[ein, Left] == ImageReflect[ein, Right]
= True
#> ImageReflect[ein, Bottom -> Top] == ImageReflect[ein, Top -> Bottom] == ImageReflect[ein, Top] == ImageReflect[ein, Bottom]
= True
#> ImageReflect[ein, Left -> Top] == ImageReflect[ein, Right -> Bottom] (* Transpose *)
= True
#> ImageReflect[ein, Left -> Bottom] == ImageReflect[ein, Right -> Top] (* Anti-Transpose *)
= True
#> ImageReflect[ein, x -> Top]
: x -> Top is not a valid 2D reflection specification.
= ImageReflect[-Image-, x -> Top]
"""

summary_text = "reflect an image"
Expand Down Expand Up @@ -239,10 +224,6 @@ class ImageRotate(Builtin):
>> ImageRotate[ein, Pi / 4]
= -Image-
#> ImageRotate[ein, ein]
: Angle -Image- should be a real number, one of Top, Bottom, Left, Right, or a rule from one to another.
= ImageRotate[-Image-, -Image-]
"""

messages = {
Expand Down
12 changes: 0 additions & 12 deletions mathics/builtin/image/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,6 @@ class RandomImage(Builtin):
>> RandomImage[1, {100, 100}]
= -Image-
#> RandomImage[0.5]
= -Image-
#> RandomImage[{0.1, 0.9}]
= -Image-
#> RandomImage[0.9, {400, 600}]
= -Image-
#> RandomImage[{0.1, 0.5}, {400, 600}]
= -Image-
#> RandomImage[{0.1, 0.5}, {400, 600}, ColorSpace -> "RGB"]
= -Image-
"""

options = {"ColorSpace": "Automatic"}
Expand Down
15 changes: 0 additions & 15 deletions mathics/builtin/image/pixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@ class PixelValue(Builtin):
>> hedy = Import["ExampleData/hedy.tif"];
>> PixelValue[hedy, {1, 1}]
= {0.439216, 0.356863, 0.337255}
#> {82 / 255, 22 / 255, 57 / 255} // N (* pixel byte values from bottom left corner *)
= {0.321569, 0.0862745, 0.223529}
#> PixelValue[hedy, {0, 1}];
: Padding not implemented for PixelValue.
#> PixelValue[hedy, {512, 1}]
= {0.0509804, 0.0509804, 0.0588235}
#> PixelValue[hedy, {647, 1}];
: Padding not implemented for PixelValue.
#> PixelValue[hedy, {1, 0}];
: Padding not implemented for PixelValue.
#> PixelValue[hedy, {1, 512}]
= {0.286275, 0.4, 0.423529}
#> PixelValue[hedy, {1, 801}];
: Padding not implemented for PixelValue.
"""

messages = {"nopad": "Padding not implemented for PixelValue."}
Expand Down
4 changes: 0 additions & 4 deletions mathics/builtin/image/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ class ImageData(Builtin):
>> ImageData[Image[{{0, 1}, {1, 0}, {1, 1}}], "Bit"]
= {{0, 1}, {1, 0}, {1, 1}}
#> ImageData[img, "Bytf"]
: Unsupported pixel format "Bytf".
= ImageData[-Image-, Bytf]
"""

messages = {"pixelfmt": 'Unsupported pixel format "``".'}
Expand Down
Loading

0 comments on commit 524cd40

Please sign in to comment.