Skip to content

Commit 524cd40

Browse files
mmaterarocky
andauthored
Moving private doctests to pytest for assignment and image (#901)
Just another round Co-authored-by: R. Bernstein <rocky@users.noreply.github.com>
1 parent e46b935 commit 524cd40

File tree

11 files changed

+235
-136
lines changed

11 files changed

+235
-136
lines changed

mathics/builtin/assignments/assignment.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ class Set(BinaryOperator, _SetOperator):
158158
>> B[[1;;2, 2;;-1]] = {{t, u}, {y, z}};
159159
>> B
160160
= {{1, t, u}, {4, y, z}, {7, 8, 9}}
161-
162-
#> x = Infinity;
163161
"""
164162

165163
attributes = A_HOLD_FIRST | A_PROTECTED | A_SEQUENCE_HOLD
@@ -371,12 +369,6 @@ class UpSet(BinaryOperator, _SetOperator):
371369
= custom
372370
>> UpValues[r]
373371
= {}
374-
375-
#> f[g, a + b, h] ^= 2
376-
: Tag Plus in f[g, a + b, h] is Protected.
377-
= 2
378-
#> UpValues[h]
379-
= {HoldPattern[f[g, a + b, h]] :> 2}
380372
"""
381373

382374
attributes = A_HOLD_FIRST | A_PROTECTED | A_SEQUENCE_HOLD
@@ -413,12 +405,6 @@ class UpSetDelayed(UpSet):
413405
= 2
414406
>> UpValues[b]
415407
= {HoldPattern[a[b]] :> x}
416-
417-
#> f[g, a + b, h] ^:= 2
418-
: Tag Plus in f[g, a + b, h] is Protected.
419-
#> f[a+b] ^:= 2
420-
: Tag Plus in f[a + b] is Protected.
421-
= $Failed
422408
"""
423409

424410
attributes = A_HOLD_ALL | A_PROTECTED | A_SEQUENCE_HOLD

mathics/builtin/assignments/clear.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -245,35 +245,6 @@ class Unset(PostfixOperator):
245245
>> a = b = 3;
246246
>> {a, {b}} =.
247247
= {Null, {Null}}
248-
249-
#> x = 2;
250-
#> OwnValues[x] =.
251-
#> x
252-
= x
253-
#> f[a][b] = 3;
254-
#> SubValues[f] =.
255-
#> f[a][b]
256-
= f[a][b]
257-
#> PrimeQ[p] ^= True
258-
= True
259-
#> PrimeQ[p]
260-
= True
261-
#> UpValues[p] =.
262-
#> PrimeQ[p]
263-
= False
264-
265-
#> a + b ^= 5;
266-
#> a =.
267-
#> a + b
268-
= 5
269-
#> {UpValues[a], UpValues[b]} =.
270-
= {Null, Null}
271-
#> a + b
272-
= a + b
273-
274-
#> Unset[Messages[1]]
275-
: First argument in Messages[1] is not a symbol or a string naming a symbol.
276-
= $Failed
277248
"""
278249

279250
attributes = A_HOLD_FIRST | A_LISTABLE | A_PROTECTED | A_READ_PROTECTED

mathics/builtin/image/base.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,6 @@ class ImageAtom(AtomBuiltin):
223223
<dd> produces the internal representation of an image from an array \
224224
of values for the pixels.
225225
</dl>
226-
227-
#> Image[{{{1,1,0},{0,1,1}}, {{1,0,1},{1,1,0}}}]
228-
= -Image-
229-
230-
#> Image[{{{0,0,0,0.25},{0,0,0,0.5}}, {{0,0,0,0.5},{0,0,0,0.75}}}]
231-
= -Image-
232226
"""
233227

234228
summary_text = "get internal representation of an image"

mathics/builtin/image/basic.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,6 @@ class ImagePartition(Builtin):
193193
194194
>> ImagePartition[hedy, {512, 128}]
195195
= {{-Image-}, {-Image-}, {-Image-}, {-Image-}, {-Image-}, {-Image-}}
196-
197-
#> ImagePartition[hedy, 257]
198-
= {{-Image-, -Image-}, {-Image-, -Image-}, {-Image-, -Image-}}
199-
#> ImagePartition[hedy, 646]
200-
= {{-Image-}}
201-
#> ImagePartition[hedy, 647]
202-
= {}
203-
#> ImagePartition[hedy, {256, 300}]
204-
= {{-Image-, -Image-}, {-Image-, -Image-}}
205-
206-
#> ImagePartition[hedy, {0, 300}]
207-
: {0, 300} is not a valid size specification for image partitions.
208-
= ImagePartition[-Image-, {0, 300}]
209196
"""
210197

211198
messages = {"arg2": "`1` is not a valid size specification for image partitions."}

mathics/builtin/image/composition.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ class ImageAdd(_ImageArithmetic):
7979
>> ImageAdd[i, i]
8080
= -Image-
8181
82-
#> ImageAdd[i, 0.2, i, 0.1]
83-
= -Image-
84-
85-
#> ImageAdd[i, x]
86-
: Expecting a number, image, or graphics instead of x.
87-
= ImageAdd[-Image-, x]
88-
8982
>> ein = Import["ExampleData/Einstein.jpg"];
9083
>> noise = RandomImage[{-0.1, 0.1}, ImageDimensions[ein]];
9184
>> ImageAdd[noise, ein]
@@ -117,16 +110,6 @@ class ImageMultiply(_ImageArithmetic):
117110
>> ImageMultiply[i, i]
118111
= -Image-
119112
120-
#> ImageMultiply[i, 0.2, i, 0.1]
121-
= -Image-
122-
123-
#> ImageMultiply[i, x]
124-
: Expecting a number, image, or graphics instead of x.
125-
= ImageMultiply[-Image-, x]
126-
127-
S> ein = Import["ExampleData/Einstein.jpg"];
128-
S> noise = RandomImage[{0.7, 1.3}, ImageDimensions[ein]];
129-
S> ImageMultiply[noise, ein]
130113
= -Image-
131114
"""
132115

@@ -151,13 +134,6 @@ class ImageSubtract(_ImageArithmetic):
151134
152135
>> ImageSubtract[i, i]
153136
= -Image-
154-
155-
#> ImageSubtract[i, 0.2, i, 0.1]
156-
= -Image-
157-
158-
#> ImageSubtract[i, x]
159-
: Expecting a number, image, or graphics instead of x.
160-
= ImageSubtract[-Image-, x]
161137
"""
162138

163139
summary_text = "build an image substracting pixel values of another image "

mathics/builtin/image/geometric.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,6 @@ class ImageReflect(Builtin):
156156
= -Image-
157157
>> ImageReflect[ein, Left -> Top]
158158
= -Image-
159-
160-
#> ein == ImageReflect[ein, Left -> Left] == ImageReflect[ein, Right -> Right] == ImageReflect[ein, Top -> Top] == ImageReflect[ein, Bottom -> Bottom]
161-
= True
162-
#> ImageReflect[ein, Left -> Right] == ImageReflect[ein, Right -> Left] == ImageReflect[ein, Left] == ImageReflect[ein, Right]
163-
= True
164-
#> ImageReflect[ein, Bottom -> Top] == ImageReflect[ein, Top -> Bottom] == ImageReflect[ein, Top] == ImageReflect[ein, Bottom]
165-
= True
166-
#> ImageReflect[ein, Left -> Top] == ImageReflect[ein, Right -> Bottom] (* Transpose *)
167-
= True
168-
#> ImageReflect[ein, Left -> Bottom] == ImageReflect[ein, Right -> Top] (* Anti-Transpose *)
169-
= True
170-
171-
#> ImageReflect[ein, x -> Top]
172-
: x -> Top is not a valid 2D reflection specification.
173-
= ImageReflect[-Image-, x -> Top]
174159
"""
175160

176161
summary_text = "reflect an image"
@@ -239,10 +224,6 @@ class ImageRotate(Builtin):
239224
240225
>> ImageRotate[ein, Pi / 4]
241226
= -Image-
242-
243-
#> ImageRotate[ein, ein]
244-
: Angle -Image- should be a real number, one of Top, Bottom, Left, Right, or a rule from one to another.
245-
= ImageRotate[-Image-, -Image-]
246227
"""
247228

248229
messages = {

mathics/builtin/image/misc.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,6 @@ class RandomImage(Builtin):
119119
120120
>> RandomImage[1, {100, 100}]
121121
= -Image-
122-
123-
#> RandomImage[0.5]
124-
= -Image-
125-
#> RandomImage[{0.1, 0.9}]
126-
= -Image-
127-
#> RandomImage[0.9, {400, 600}]
128-
= -Image-
129-
#> RandomImage[{0.1, 0.5}, {400, 600}]
130-
= -Image-
131-
132-
#> RandomImage[{0.1, 0.5}, {400, 600}, ColorSpace -> "RGB"]
133-
= -Image-
134122
"""
135123

136124
options = {"ColorSpace": "Automatic"}

mathics/builtin/image/pixel.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,6 @@ class PixelValue(Builtin):
2626
>> hedy = Import["ExampleData/hedy.tif"];
2727
>> PixelValue[hedy, {1, 1}]
2828
= {0.439216, 0.356863, 0.337255}
29-
#> {82 / 255, 22 / 255, 57 / 255} // N (* pixel byte values from bottom left corner *)
30-
= {0.321569, 0.0862745, 0.223529}
31-
32-
#> PixelValue[hedy, {0, 1}];
33-
: Padding not implemented for PixelValue.
34-
#> PixelValue[hedy, {512, 1}]
35-
= {0.0509804, 0.0509804, 0.0588235}
36-
#> PixelValue[hedy, {647, 1}];
37-
: Padding not implemented for PixelValue.
38-
#> PixelValue[hedy, {1, 0}];
39-
: Padding not implemented for PixelValue.
40-
#> PixelValue[hedy, {1, 512}]
41-
= {0.286275, 0.4, 0.423529}
42-
#> PixelValue[hedy, {1, 801}];
43-
: Padding not implemented for PixelValue.
4429
"""
4530

4631
messages = {"nopad": "Padding not implemented for PixelValue."}

mathics/builtin/image/properties.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ class ImageData(Builtin):
9393
9494
>> ImageData[Image[{{0, 1}, {1, 0}, {1, 1}}], "Bit"]
9595
= {{0, 1}, {1, 0}, {1, 1}}
96-
97-
#> ImageData[img, "Bytf"]
98-
: Unsupported pixel format "Bytf".
99-
= ImageData[-Image-, Bytf]
10096
"""
10197

10298
messages = {"pixelfmt": 'Unsupported pixel format "``".'}

0 commit comments

Comments
 (0)