Skip to content

Commit 2fd8df9

Browse files
committed
PR feedback
1 parent 35a2546 commit 2fd8df9

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/citrine/_serialization/properties.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,17 @@ def underlying_types(self):
264264

265265
@property
266266
def serialized_types(self):
267-
return int, str
267+
return float, int, str
268268

269269
def _deserialize(self, value: SerializedInteger) -> int:
270270
if isinstance(value, bool):
271271
raise TypeError('value must be a Number, not a boolean.')
272+
elif isinstance(value, float):
273+
cast = round(value)
274+
if cast == value:
275+
return cast
276+
else:
277+
raise ValueError(f'{value} cannot be cast to an integer.')
272278
else:
273279
return int(value)
274280

src/citrine/gemd_queries/filter.py

+3
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ class AllIntegerFilter(Serializable['AllIntegerFilter'], PropertyFilterType):
5252
The lower bound on this filter range.
5353
upper: int
5454
The upper bound on this filter range.
55+
inclusive: bool
56+
Whether the lower & upper bounds are included in the range.
5557
5658
"""
5759

5860
lower = properties.Integer('lower')
5961
upper = properties.Integer('upper')
62+
inclusive = properties.Optional(properties.Boolean, 'inclusive', default=True)
6063
typ = properties.String('type', default="all_integer_filter", deserializable=False)
6164

6265

tests/_serialization/_data.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
VALID_SERIALIZATIONS = [
77
(properties.Integer, 5, 5),
8+
(properties.Integer, 5, 5.), # Accept passing a float-representation of an int to the setter
89
(properties.Float, 3.0, 3.0),
910
(properties.Raw, 1234, 1234),
1011
(properties.String, 'foo', 'foo'),

0 commit comments

Comments
 (0)