A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/datastax/python-driver/commit/a2d3a98 below:

Remove deprecated cqlengine.columns.Float(double_precision) parameter · datastax/python-driver@a2d3a98 · GitHub

File tree Expand file treeCollapse file tree 4 files changed

+11

-38

lines changed

Filter options

Expand file treeCollapse file tree 4 files changed

+11

-38

lines changed Original file line number Diff line number Diff line change

@@ -594,17 +594,6 @@ class Float(BaseFloat):

594 594

"""

595 595

db_type = 'float'

596 596 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 - 608 597 609 598

class Double(BaseFloat):

610 599

"""

Original file line number Diff line number Diff line change

@@ -175,15 +175,9 @@ def comparator_converter(self, val):

175 175

return val if isinstance(val, UUID) else UUID(val)

176 176 177 177 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 - 184 178

class TestFloatIO(BaseColumnIOTest):

185 179 186 -

column = FloatSingle

180 +

column = columns.Float

187 181 188 182

pkey_val = 4.75

189 183

data_val = -1.5

Original file line number Diff line number Diff line change

@@ -156,7 +156,7 @@ class AllDatatypesModel(Model):

156 156

e = columns.DateTime()

157 157

f = columns.Decimal()

158 158

g = columns.Double()

159 -

h = columns.Float(double_precision=False)

159 +

h = columns.Float()

160 160

i = columns.Inet()

161 161

j = columns.Integer()

162 162

k = columns.Text()

@@ -225,13 +225,8 @@ def test_can_insert_double_and_float(self):

225 225

"""

226 226

Test for inserting single-precision and double-precision values into a Float and Double columns

227 227 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 - 234 228

@since 2.6.0

229 +

@changed 3.0.0 removed deprecated Float(double_precision) parameter

235 230

@jira_ticket PYTHON-246

236 231

@expected_result Each floating point column type is able to hold their respective precision values.

237 232

@@ -240,24 +235,19 @@ def test_can_insert_double_and_float(self):

240 235 241 236

class FloatingPointModel(Model):

242 237

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()

246 239

d = columns.Double()

247 240 248 241

sync_table(FloatingPointModel)

249 242 250 -

FloatingPointModel.create(id=0, a=2.39)

243 +

FloatingPointModel.create(id=0, f=2.39)

251 244

output = FloatingPointModel.objects().first()

252 -

self.assertEqual(2.390000104904175, output.a)

245 +

self.assertEqual(2.390000104904175, output.f) # float loses precision

253 246 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)

255 248

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

261 251 262 252

FloatingPointModel.create(id=0, d=3.4028234663852886e+38)

263 253

output = FloatingPointModel.objects().first()

Original file line number Diff line number Diff line change

@@ -214,7 +214,7 @@ class AllDatatypes(UserType):

214 214

e = columns.DateTime()

215 215

f = columns.Decimal()

216 216

g = columns.Double()

217 -

h = columns.Float(double_precision=False)

217 +

h = columns.Float()

218 218

i = columns.Inet()

219 219

j = columns.Integer()

220 220

k = columns.Text()

@@ -261,7 +261,7 @@ class AllDatatypes(UserType):

261 261

e = columns.DateTime()

262 262

f = columns.Decimal()

263 263

g = columns.Double()

264 -

h = columns.Float(double_precision=False)

264 +

h = columns.Float()

265 265

i = columns.Inet()

266 266

j = columns.Integer()

267 267

k = columns.Text()

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4