#29232 closed defect (duplicate)

Let `std` work on a list of floats

Reported by: slelievre Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: statistics Keywords: float, std, sqrt
Cc: chapoton, slelievre Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by slelievre)

Initial report by Ingo Dahn at:

Minimal example:

sage: version()
'SageMath version 9.0, Release Date: 2020-01-01'
sage: sage: std([float(3.2), float(3.4)])
Traceback (most recent call last)
...
AttributeError: 'float' object has no attribute 'sqrt'

Fix this by changing the function std(v, bias) at line 219 of src/sage/stats/basic_stats.py:

-    return variance(v, bias=bias).sqrt()
+    try:
+        return variance(v, bias=bias).sqrt()
+     except AttributeError:
+        from sage.functions.other import sqrt
+        return sqrt(variance(v, bias=bias))

It turns out this was already fixed at #29184, merged in Sage 9.1.beta5.

Change History (5)

comment:1 Changed 14 months ago by slelievre

  • Description modified (diff)

comment:2 Changed 14 months ago by chapoton

what about #29184 ?

comment:3 Changed 14 months ago by slelievre

  • Component changed from PLEASE CHANGE to statistics
  • Milestone changed from sage-9.1 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review
  • Type changed from PLEASE CHANGE to defect

Sorry, missed that. Please close as duplicate.

comment:4 Changed 14 months ago by slelievre

  • Description modified (diff)

comment:5 Changed 14 months ago by chapoton

  • Resolution set to duplicate
  • Status changed from needs_review to closed
Note: See TracTickets for help on using tickets.