@@ -137,71 +137,21 @@ end
137
137
==(::Number, ::Interval)
138
138
139
139
Test whether an interval is the singleton of a given number. In other words, the
140
- result is true if and only if the interval contains only that number. This
141
- function errors whenever the input interval is not a singleton.
140
+ result is true if and only if the interval contains only that number.
142
141
143
142
!!! note
144
143
Comparison between intervals is purposely disallowed. Indeed, equality
145
144
between non-singleton intervals has distinct properties, notably ``x = y``
146
145
does not imply ``x - y = 0``. See instead [`isequal_interval`](@ref).
147
146
"""
148
- function Base.:(== )(x:: BareInterval , y:: Number )
149
- isthin (x) || return throw (ArgumentError (" `==` is only supported between thin intervals and numbers" ))
150
- return inf (x) == y
151
- end
152
- Base.:(== )(x:: Number , y:: BareInterval ) = y == x
153
- function Base.:(== )(x:: Interval , y:: Number )
154
- isnai (x) && return false
155
- return bareinterval (x) == y
156
- end
157
- Base.:(== )(x:: Number , y:: Interval ) = y == x
158
- Base.:(== )(x:: BareInterval , y:: Interval ) = throw (MethodError (== , (x, y)))
159
- Base.:(== )(x:: Interval , y:: BareInterval ) = throw (MethodError (== , (x, y)))
147
+ Base.:(== )(x:: Union{BareInterval,Interval} , y:: Number ) = isthin (x, y)
148
+ Base.:(== )(x:: Number , y:: Union{BareInterval,Interval} ) = y == x
160
149
161
- """
162
- iszero(::BareInterval)
163
- iszero(::Interval)
150
+ # follows docstring of `Base.iszero`
151
+ Base. iszero (x:: Union{BareInterval,Interval} ) = isthinzero (x)
164
152
165
- Test whether an interval is the singleton of zero. This function errors whenever
166
- the input interval is not a singleton.
167
- """
168
- function Base. iszero (x:: BareInterval )
169
- isthin (x) || return throw (ArgumentError (" `iszero` is only supported for thin intervals" ))
170
- return iszero (inf (x))
171
- end
172
- function Base. iszero (x:: Interval )
173
- isnai (x) && return false
174
- return iszero (bareinterval (x))
175
- end
176
-
177
- """
178
- isone(::BareInterval)
179
- isone(::Interval)
153
+ # follows docstring of `Base.isone`
154
+ Base. isone (x:: Union{BareInterval,Interval} ) = isthinone (x)
180
155
181
- Test whether an interval is the singleton of one. This function errors whenever
182
- the input interval is not a singleton.
183
- """
184
- function Base. isone (x:: BareInterval )
185
- isthin (x) || return throw (ArgumentError (" `isone` is only supported for thin intervals" ))
186
- return isone (inf (x))
187
- end
188
- function Base. isone (x:: Interval )
189
- isnai (x) && return false
190
- return isone (bareinterval (x))
191
- end
192
-
193
- """
194
- isinteger(::BareInterval)
195
- isinteger(::Interval)
196
-
197
- Test whether an interval is the singleton of an integer. This function errors
198
- whenever the input interval is not a singleton.
199
- """
200
- function Base. isinteger (x:: BareInterval )
201
- isthin (x) || return throw (ArgumentError (" `isinteger` is only supported for thin intervals" ))
202
- return isinteger (inf (x))
203
- end
204
- function Base. isinteger (x:: Interval )
205
- isnai (x) && return false
206
- return isinteger (bareinterval (x))
207
- end
156
+ # follows docstring of `Base.isinteger`
157
+ Base. isinteger (x:: Union{BareInterval,Interval} ) = isthininteger (x)
0 commit comments