Skip to content

Commit a2d3a98

Browse files
committed
Remove deprecated cqlengine.columns.Float(double_precision) parameter
1 parent 96489cc commit a2d3a98

File tree

4 files changed

+11
-38
lines changed

4 files changed

+11
-38
lines changed

cassandra/cqlengine/columns.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -594,17 +594,6 @@ class Float(BaseFloat):
594594
"""
595595
db_type = 'float'
596596

597-
def __init__(self, double_precision=None, **kwargs):
598-
if double_precision is None or bool(double_precision):
599-
msg = "Float(double_precision=True) is deprecated. Use Double() type instead."
600-
double_precision = True
601-
warnings.warn(msg, DeprecationWarning)
602-
log.warning(msg)
603-
604-
self.db_type = 'double' if double_precision else 'float'
605-
606-
super(Float, self).__init__(**kwargs)
607-
608597

609598
class Double(BaseFloat):
610599
"""

tests/integration/cqlengine/columns/test_value_io.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,9 @@ def comparator_converter(self, val):
175175
return val if isinstance(val, UUID) else UUID(val)
176176

177177

178-
# until Floats are implicitly single:
179-
class FloatSingle(columns.Float):
180-
def __init__(self, **kwargs):
181-
super(FloatSingle, self).__init__(double_precision=False, **kwargs)
182-
183-
184178
class TestFloatIO(BaseColumnIOTest):
185179

186-
column = FloatSingle
180+
column = columns.Float
187181

188182
pkey_val = 4.75
189183
data_val = -1.5

tests/integration/cqlengine/model/test_model_io.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class AllDatatypesModel(Model):
156156
e = columns.DateTime()
157157
f = columns.Decimal()
158158
g = columns.Double()
159-
h = columns.Float(double_precision=False)
159+
h = columns.Float()
160160
i = columns.Inet()
161161
j = columns.Integer()
162162
k = columns.Text()
@@ -225,13 +225,8 @@ def test_can_insert_double_and_float(self):
225225
"""
226226
Test for inserting single-precision and double-precision values into a Float and Double columns
227227
228-
test_can_insert_double_and_float tests a Float can only hold a single-precision value, unless
229-
"double_precision" attribute is specified as True or is unspecified. This test first tests that an AttributeError
230-
is raised when attempting to input a double-precision value into a single-precision Float. It then verifies that
231-
Double, Float(double_precision=True) and Float() can hold double-precision values by default. It also verifies that
232-
columns.Float(double_precision=False) can hold a single-precision value, and a Double can hold a single-precision value.
233-
234228
@since 2.6.0
229+
@changed 3.0.0 removed deprecated Float(double_precision) parameter
235230
@jira_ticket PYTHON-246
236231
@expected_result Each floating point column type is able to hold their respective precision values.
237232
@@ -240,24 +235,19 @@ def test_can_insert_double_and_float(self):
240235

241236
class FloatingPointModel(Model):
242237
id = columns.Integer(primary_key=True)
243-
a = columns.Float(double_precision=False)
244-
b = columns.Float(double_precision=True)
245-
c = columns.Float()
238+
f = columns.Float()
246239
d = columns.Double()
247240

248241
sync_table(FloatingPointModel)
249242

250-
FloatingPointModel.create(id=0, a=2.39)
243+
FloatingPointModel.create(id=0, f=2.39)
251244
output = FloatingPointModel.objects().first()
252-
self.assertEqual(2.390000104904175, output.a)
245+
self.assertEqual(2.390000104904175, output.f) # float loses precision
253246

254-
FloatingPointModel.create(id=0, a=3.4028234663852886e+38, b=2.39, c=2.39, d=2.39)
247+
FloatingPointModel.create(id=0, f=3.4028234663852886e+38, d=2.39)
255248
output = FloatingPointModel.objects().first()
256-
257-
self.assertEqual(3.4028234663852886e+38, output.a)
258-
self.assertEqual(2.39, output.b)
259-
self.assertEqual(2.39, output.c)
260-
self.assertEqual(2.39, output.d)
249+
self.assertEqual(3.4028234663852886e+38, output.f)
250+
self.assertEqual(2.39, output.d) # double retains precision
261251

262252
FloatingPointModel.create(id=0, d=3.4028234663852886e+38)
263253
output = FloatingPointModel.objects().first()

tests/integration/cqlengine/model/test_udts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class AllDatatypes(UserType):
214214
e = columns.DateTime()
215215
f = columns.Decimal()
216216
g = columns.Double()
217-
h = columns.Float(double_precision=False)
217+
h = columns.Float()
218218
i = columns.Inet()
219219
j = columns.Integer()
220220
k = columns.Text()
@@ -261,7 +261,7 @@ class AllDatatypes(UserType):
261261
e = columns.DateTime()
262262
f = columns.Decimal()
263263
g = columns.Double()
264-
h = columns.Float(double_precision=False)
264+
h = columns.Float()
265265
i = columns.Inet()
266266
j = columns.Integer()
267267
k = columns.Text()

0 commit comments

Comments
 (0)