Opened 15 years ago

Closed 14 years ago

Last modified 11 years ago

#1111 closed defect (fixed)

trig functions in Calculate ignoring deg setting

Reported by: walter Owned by: garycmartin
Priority: Normal Milestone:
Component: Calculate Version: Git as of bugdate
Severity: Unspecified Keywords:
Cc: Distribution/OS:
Bug Status: New

Description

When set to degrees:

sin(45) = .850903...
should be .707106...
It is actually the sin(45) in radians.

Similarly,
cos(45) = .52532...
should be the same as sin(45) but it is actually cos(45) in radians.

So it seems that the rad/deg button is not working.

Tested on both SoaS Strawberry and the latest jhbuild

Attachments (1)

fix_angle_scaling.patch (3.3 KB) - added by garycmartin 14 years ago.
Patch from Reinier, fixes both the deg/rad issue and a bug in the sci/exp button

Download all attachments as: .zip

Change History (10)

comment:1 Changed 15 years ago by walter

The log for a simple session is included below. Note that hitting the Deg/Rad button does seem to set the Angle type properly.

I did the following:

sin(pi/4)
deg
sin(45)
rad
sin(pi/4)

sin(45) was calculated using rad instead of degrees.
-walter

1248957400.055873 DEBUG PlotLib: Using custom plotting back-end
1248957400.132679 DEBUG root: * Act 273a4004d0934f3fc3006b8408f9ca51628318b1, mesh instance None, scope private
1248957400.134366 DEBUG root: Creating a jobject.
1248957400.144148 DEBUG root: datastore.write
1248957400.161463 DEBUG root: dbus_helpers.create: 311c8396-e6a4-404f-b282-2e85bd7a958f
1248957400.164645 DEBUG root: Written object 311c8396-e6a4-404f-b282-2e85bd7a958f to the datastore.
1248957400.210186 DEBUG sugar.presence.presenceservice: Created proxy <Buddy object at 0x8c2811c (sugar+presence+buddy+Buddy at 0x8825270)>
1248957400.217080 DEBUG ShareableActivity: Setting service name org.laptop.ShareableActivity, service path /org/laptop/ShareableActivity/Calculate/273a4004d0934f3fc3006b8408f9ca51628318b1
1248957400.219923 DEBUG MathLib: Angle type set to 0.01745329251994329547
1248957400.222166 DEBUG MathLib: Format type set to 2
1248957400.223881 DEBUG MathLib: Digit limit set to 9
1248957400.779066 DEBUG root: ('Setup widget', None)
1248957400.783884 WARNING root: No gtk.AccelGroup in the top level window.
1248957400.789637 DEBUG root: ('Setup widget', None)
1248957400.792035 WARNING root: No gtk.AccelGroup in the top level window.
1248957400.803720 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c35be4 (GtkButton at 0x8c12a70)>)
1248957400.810581 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c3825c (GtkButton at 0x8c12ae8)>)
1248957400.817144 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c388c4 (GtkButton at 0x8c12b60)>)
1248957400.829047 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c38f2c (GtkButton at 0x8c16020)>)
1248957400.837407 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c3a66c (GtkButton at 0x8c16110)>)
1248957400.845926 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c3ad9c (GtkButton at 0x8c16200)>)
1248957400.854538 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c3c4dc (GtkButton at 0x8c16368)>)
1248957400.864209 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c3cc0c (GtkButton at 0x8f33c80)>)
1248957400.872512 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c3f374 (GtkButton at 0x8f33d70)>)
1248957400.880872 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c3fa7c (GtkButton at 0x8f33ed8)>)
1248957400.893513 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c421e4 (GtkButton at 0x8f34010)>)
1248957400.902160 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c428ec (GtkButton at 0x8f34100)>)
1248957400.910745 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c4402c (GtkButton at 0x8f341f0)>)
1248957400.919446 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c44734 (GtkButton at 0x8f34358)>)
1248957400.927803 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c44e3c (GtkButton at 0x8f47098)>)
1248957400.936183 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c465a4 (GtkButton at 0x8f47188)>)
1248957400.945691 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c46cd4 (GtkButton at 0x8f472f0)>)
1248957400.954332 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c4843c (GtkButton at 0x8f5b010)>)
1248957400.962909 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c48b44 (GtkButton at 0x8f5b100)>)
1248957400.975776 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c4c284 (GtkButton at 0x8f5b1f0)>)
1248957400.984376 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c4c9b4 (GtkButton at 0x8f5b2e0)>)
1248957400.991527 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c4e11c (GtkButton at 0x8f5b490)>)
1248957400.998411 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c4e784 (GtkButton at 0x8f5b508)>)
1248957401.009014 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c4ee14 (GtkButton at 0x8f5b580)>)
1248957401.016025 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c504b4 (GtkButton at 0x8f5b5f8)>)
1248957401.026810 DEBUG root: ('Setup widget', <gtk.Button object at 0x8c50b1c (GtkButton at 0x8f5b6e8)>)
1248957401.036208 DEBUG root: ('Setup widget', <gtk.ToggleButton object at 0x8c5225c (GtkToggleButton at 0x8f54b30)>)
1248957401.043619 DEBUG root: ('Setup widget', <gtk.ToggleButton object at 0x8c528c4 (GtkToggleButton at 0x8f54cb0)>)
1248957401.050870 DEBUG root: ('Setup widget', <gtk.ToggleButton object at 0x8c52f04 (GtkToggleButton at 0x8f54e30)>)
1248957401.400331 DEBUG root: Activity.canvas_map_cb
1248957401.404129 DEBUG root: Variables:
1248957401.418542 DEBUG root: Na
1248957401.419272 DEBUG root: R
1248957401.419835 DEBUG root: c
1248957401.436996 DEBUG root: c_e
1248957401.458340 DEBUG root: e
1248957401.459138 DEBUG root: e0
1248957401.459824 DEBUG root: golden_ratio
1248957401.460478 DEBUG root: h
1248957401.461176 DEBUG root: hbar
1248957401.461840 DEBUG root: kb
1248957401.462523 DEBUG root: m_e
1248957401.470524 DEBUG root: m_n
1248957401.479470 DEBUG root: m_p
1248957401.486445 DEBUG root: mu0
1248957401.495311 DEBUG root: pi
1248957401.502385 DEBUG root: Functions:
1248957401.510520 DEBUG root: And
1248957401.518259 DEBUG root: Or
1248957401.526222 DEBUG root: abs
1248957401.534264 DEBUG root: acos
1248957401.542263 DEBUG root: acosh
1248957401.550362 DEBUG root: add
1248957401.558253 DEBUG root: asin
1248957401.566720 DEBUG root: asinh
1248957401.575256 DEBUG root: atan
1248957401.583244 DEBUG root: atanh
1248957401.591288 DEBUG root: ceil
1248957401.598267 DEBUG root: cos
1248957401.606262 DEBUG root: cosh
1248957401.614283 DEBUG root: div
1248957401.622275 DEBUG root: exp
1248957401.630496 DEBUG root: fac
1248957401.638233 DEBUG root: factorial
1248957401.646276 DEBUG root: factorize
1248957401.654255 DEBUG root: floor
1248957401.662243 DEBUG root: gcd
1248957401.670288 DEBUG root: help
1248957401.678342 DEBUG root: is_int
1248957401.686256 DEBUG root: ln
1248957401.694292 DEBUG root: log10
1248957401.702276 DEBUG root: mod
1248957401.710481 DEBUG root: mul
1248957401.718248 DEBUG root: negate
1248957401.726258 DEBUG root: plot
1248957401.734257 DEBUG root: pow
1248957401.742254 DEBUG root: rand_float
1248957401.750262 DEBUG root: rand_int
1248957401.758255 DEBUG root: round
1248957401.766270 DEBUG root: shift_left
1248957401.774277 DEBUG root: shift_right
1248957401.782257 DEBUG root: sin
1248957401.790495 DEBUG root: sinc
1248957401.798231 DEBUG root: sinh
1248957401.806265 DEBUG root: sqrt
1248957401.814235 DEBUG root: sub
1248957401.822255 DEBUG root: tan
1248957401.830273 DEBUG root: tanh
1248957401.838233 DEBUG root: xor
1248957401.846263 DEBUG root: Unary ops:
1248957401.854275 DEBUG root: <class '_ast.USub'>
1248957401.862257 DEBUG root: <class '_ast.UAdd'>
1248957401.870485 DEBUG root: <class '_ast.Not'>
1248957401.878249 DEBUG root: Binary ops:
1248957401.886275 DEBUG root: <class '_ast.Sub'>
1248957401.894250 DEBUG root: <class '_ast.Div'>
1248957401.902298 DEBUG root: <class '_ast.Or'>
1248957401.910256 DEBUG root: <class '_ast.RShift'>
1248957401.918253 DEBUG root: <class '_ast.And'>
1248957401.926257 DEBUG root: <class '_ast.Mod'>
1248957401.934276 DEBUG root: <class '_ast.Mult'>
1248957401.942247 DEBUG root: <class '_ast.BitOr'>
1248957401.950260 DEBUG root: <class '_ast.Add'>
1248957401.958284 DEBUG root: <class '_ast.FloorDiv'>
1248957401.966249 DEBUG root: <class '_ast.Pow'>
1248957401.974274 DEBUG root: <class '_ast.LShift'>
1248957401.982295 DEBUG root: <class '_ast.BitAnd'>
1248957401.990261 DEBUG root: <class '_ast.BitXor'>
1248957402.000219 DEBUG root: ActivityService.set_active: 1.
(sugar-activity:13407): DEBUG: Got client ID "10744ae383287a4a0712489574027831500000125540002"
(sugar-activity:13407): DEBUG: Setting initial properties
(sugar-activity:13407): DEBUG: Received SaveYourself(SmSaveLocal, !Shutdown, SmInteractStyleNone, !Fast) in state idle
(sugar-activity:13407): DEBUG: Sending SaveYourselfDone(True) for initial SaveYourself
(sugar-activity:13407): DEBUG: Received SaveComplete message in state save-yourself-done
1248957409.992123 DEBUG root: Palette.popup immediate False
1248957410.738806 DEBUG MathLib: Angle type set to 1
1248957410.740452 DEBUG calc-activity: Angle type: 1
1248957411.284498 DEBUG root: Palette.popdown immediate False
1248957411.292067 DEBUG root: Palette.popdown immediate False
1248957411.991867 DEBUG root:
hide_cb
1248957413.321235 DEBUG Calculate: Key: s (115, 39)
1248957413.435888 DEBUG Calculate: Key: i (105, 31)
1248957413.644636 DEBUG Calculate: Key: n (110, 57)
1248957413.873368 DEBUG Calculate: Key: Shift_L (65505, 50)
1248957414.532858 DEBUG Calculate: Key: Shift_L (65505, 50)
1248957414.573088 DEBUG Calculate: Key: Shift_L (65505, 50)
1248957414.613244 DEBUG Calculate: Key: Shift_L (65505, 50)
1248957414.653299 DEBUG Calculate: Key: Shift_L (65505, 50)
1248957414.694146 DEBUG Calculate: Key: Shift_L (65505, 50)
1248957414.696729 DEBUG Calculate: Key: parenleft (40, 18)
1248957420.002293 DEBUG Calculate: Key: p (112, 33)
1248957420.316215 DEBUG Calculate: Key: i (105, 31)
1248957422.264176 DEBUG Calculate: Key: slash (47, 61)
1248957422.924172 DEBUG Calculate: Key: 4 (52, 13)
1248957423.296333 DEBUG Calculate: Key: Shift_L (65505, 50)
1248957423.702104 DEBUG Calculate: Key: parenright (41, 19)
1248957424.354060 DEBUG Calculate: Key: Return (65293, 36)
1248957424.356449 DEBUG Calculate: process(): parsing u'sin(pi/4)', label: u
1248957424.358359 DEBUG root: Parsing preprocessed equation: u'sin(pi/4)'
1248957424.361283 DEBUG Calculate: Result: 0.70710678118654746
1248957424.365247 DEBUG Calculate: font-size: 10240
1248957424.367443 DEBUG Calculate: font-size: 14336
1248957424.370595 DEBUG Calculate: font-size: 14336
1248957424.372578 DEBUG Calculate: font-size: 18432
1248957424.374778 DEBUG ShareableActivity: Not shared, not sending message add_eq({'value': ';sin(pi/4);0.707106781187;#B20008,#FF2B34;walter\n'})
1248957429.804863 DEBUG root: Palette.popup immediate False
1248957429.812137 DEBUG MathLib: Angle type set to 0.01745329251994329547
1248957429.813510 DEBUG calc-activity: Angle type: 0.01745329251994329547
1248957430.218358 DEBUG root: Palette.popdown immediate False
1248957431.139873 DEBUG Calculate: Key: s (115, 39)
1248957431.268153 DEBUG Calculate: Key: i (105, 31)
1248957431.477334 DEBUG Calculate: Key: n (110, 57)
1248957431.646958 DEBUG Calculate: Key: Shift_L (65505, 50)
1248957431.982778 DEBUG Calculate: Key: parenleft (40, 18)
1248957432.433798 DEBUG Calculate: Key: 4 (52, 13)
1248957432.642859 DEBUG Calculate: Key: 5 (53, 14)
1248957432.873653 DEBUG Calculate: Key: Shift_L (65505, 50)
1248957432.997273 DEBUG Calculate: Key: parenright (41, 19)
1248957433.878979 DEBUG Calculate: Key: Return (65293, 36)
1248957433.880680 DEBUG Calculate: process(): parsing u'sin(45)', label: u

1248957433.881685 DEBUG root: Parsing preprocessed equation: u'sin(45)'
1248957433.883043 DEBUG Calculate: Result: 0.85090352453411844
1248957433.891755 DEBUG Calculate: font-size: 10240
1248957433.893893 DEBUG Calculate: font-size: 14336
1248957433.899822 DEBUG Calculate: font-size: 14336
1248957433.907304 DEBUG Calculate: font-size: 18432
1248957433.915373 DEBUG ShareableActivity: Not shared, not sending message add_eq({'value': ';sin(45);0.850903524534;#B20008,#FF2B34;walter\n'})
1248957441.022814 DEBUG Calculate: Key: Control_L (65507, 37)
1248957441.683163 DEBUG Calculate: Key: Control_L (65507, 37)
1248957441.723415 DEBUG Calculate: Key: Control_L (65507, 37)
1248957441.764572 DEBUG Calculate: Key: Control_L (65507, 37)
1248957441.804726 DEBUG Calculate: Key: Control_L (65507, 37)
1248957441.844905 DEBUG Calculate: Key: Control_L (65507, 37)
1248957441.884993 DEBUG Calculate: Key: Control_L (65507, 37)
1248957441.925095 DEBUG Calculate: Key: Control_L (65507, 37)
1248957441.965235 DEBUG Calculate: Key: Control_L (65507, 37)
1248957442.005493 DEBUG Calculate: Key: Control_L (65507, 37)
1248957442.045685 DEBUG Calculate: Key: Control_L (65507, 37)
1248957442.086052 DEBUG Calculate: Key: Control_L (65507, 37)
1248957443.309304 DEBUG root: Palette.popup immediate False
1248957443.598059 DEBUG MathLib: Angle type set to 1
1248957443.599721 DEBUG calc-activity: Angle type: 1
1248957443.881643 DEBUG root: Palette.popdown immediate False
1248957443.978222 DEBUG root: Palette.popdown immediate False
1248957444.676684 DEBUG root: hide_cb
1248957445.113759 DEBUG Calculate: Key: s (115, 39)
1248957445.221252 DEBUG Calculate: Key: i (105, 31)
1248957445.450323 DEBUG Calculate: Key: n (110, 57)
1248957445.538239 DEBUG Calculate: Key: Shift_L (65505, 50)
1248957445.843273 DEBUG Calculate: Key: parenleft (40, 18)
1248957448.738108 DEBUG Calculate: Key: p (112, 33)
1248957449.130467 DEBUG Calculate: Key: i (105, 31)
1248957449.600598 DEBUG Calculate: Key: slash (47, 61)
1248957450.381925 DEBUG Calculate: Key: 4 (52, 13)
1248957450.630924 DEBUG Calculate: Key: Shift_L (65505, 50)
1248957450.754572 DEBUG Calculate: Key: parenright (41, 19)
1248957451.166805 DEBUG Calculate: Key: Return (65293, 36)
1248957451.168509 DEBUG Calculate: process(): parsing u'sin(pi/4)', label: u
1248957451.169539 DEBUG root: Parsing preprocessed equation: u'sin(pi/4)'
1248957451.172141 DEBUG Calculate: Result: 0.70710678118654746
1248957451.178097 DEBUG Calculate: font-size: 10240
1248957451.183101 DEBUG Calculate: font-size: 14336
1248957451.191590 DEBUG Calculate: font-size: 14336
1248957451.199231 DEBUG Calculate: font-size: 18432
1248957451.207688 DEBUG ShareableActivity: Not shared, not sending message add_eq({'value': ';sin(pi/4);0.707106781187;#B20008,#FF2B34;walter\n'})
1248957454.201603 DEBUG Calculate: Key: Control_L (65507, 37)
1248957454.446046 DEBUG Calculate: Key: q (113, 24)
1248957459.287610 DEBUG root: Palette.popdown immediate False
1248957459.689558 DEBUG root: Palette.popup immediate False
1248957459.962730 DEBUG root: Palette.popdown immediate True
1248957459.977048 DEBUG root: ('Setup widget', None)
1248957459.979463 WARNING root: No gtk.AccelGroup in the top level window.
1248957460.044679 DEBUG root: Palette.popdown immediate False
1248957462.151587 DEBUG root: Palette.popup immediate False
1248957462.723130 DEBUG sugar.presence.presenceservice: Created proxy <Buddy object at 0x8c59af4 (sugar+presence+buddy+Buddy at 0x919cba0)>
1248957462.795695 DEBUG root: Palette.popdown immediate True
1248957462.797971 DEBUG root:
hide_cb
1248957462.800289 DEBUG root: Activity.save: dbus.String(u'311c8396-e6a4-404f-b282-2e85bd7a958f')
1248957463.036840 INFO Calculate: Writing to journal (/home/walter/.sugar/default/org.laptop.Calculate/instance/1248957463)
1248957463.039787 DEBUG root: datastore.write
1248957463.041431 DEBUG root: dbus_helpers.update: 311c8396-e6a4-404f-b282-2e85bd7a958f, /home/walter/.sugar/default/org.laptop.Calculate/instance/1248957463, {'activity_id': '273a4004d0934f3fc3006b8408f9ca51628318b1', 'title_set_by_user': '1', 'uid': dbus.String(u'311c8396-e6a4-404f-b282-2e85bd7a958f'), 'title': 'Calculate Activity', 'timestamp': 1248957463, 'activity': 'org.laptop.Calculate', 'share-scope': 'private', 'keep': 0, 'icon-color': '#B20008,#FF2B34', 'mtime': '2009-07-30T12:37:43.041180', 'tags':
, 'preview': '<omitted>', 'mime_type': , 'description': }, True
1248957463.043947 DEBUG root: Written object 311c8396-e6a4-404f-b282-2e85bd7a958f to the datastore.
1248957463.104079 WARNING root: No gtk.AccelGroup in the top level window.
1248957463.116212 DEBUG root: Activity.save_cb
1248957463.123324 DEBUG Calculate: Cleaning up...
1248957463.127459 WARNING root: No gtk.AccelGroup in the top level window.
1248957463.129051 WARNING root: No gtk.AccelGroup in the top level window.
1248957463.187186 DEBUG root: Quitting the activity process.
1248957463.200540 DEBUG root: _cleanup_temp_files

comment:2 Changed 15 years ago by walter

The problem seems to be that function.py uses _angle_scaling instead of the angle_type set in MathLib.

comment:3 Changed 15 years ago by tomeu

  • Milestone changed from Unspecified by Release Team to 0.86
  • Priority changed from Unspecified by Maintainer to Normal

comment:4 Changed 14 years ago by sascha_silbe

  • Component changed from Calculate to SoaS
  • Distribution/OS changed from SoaS to Unspecified
  • Owner changed from rwh to mchua sdz

Bulk change distribution=SoaS -> component=SoaS

comment:5 Changed 14 years ago by sdz

  • Component changed from SoaS to Calculate
  • Distribution/OS changed from Unspecified to Fedora
  • Owner changed from mchua sdz to rwh

comment:6 Changed 14 years ago by quozl

  • Bug Status changed from Unconfirmed to New
  • Distribution/OS Fedora deleted

Reproduced on Calculate-30 on XO-1.5 os115, and on SoaS 2 Blueberry. Walter's observation is correct; it is an activity coding issue; angle_scaling is set but not used.

Reproduced also by niranjala on #olpc-help.

comment:7 Changed 14 years ago by garycmartin

  • Owner changed from rwh to garycmartin
  • Status changed from new to assigned

Changed 14 years ago by garycmartin

Patch from Reinier, fixes both the deg/rad issue and a bug in the sci/exp button

comment:8 Changed 14 years ago by garycmartin

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed by Reinier's above patch in commit b8e51650

comment:9 Changed 11 years ago by dnarvaez

  • Milestone 0.86 deleted

Milestone 0.86 deleted

Note: See TracTickets for help on using tickets.