Ask Your Question

user90664's profile - activity

2021-07-14 01:13:26 +0200 received badge  Famous Question (source)
2021-03-25 13:11:47 +0200 received badge  Notable Question (source)
2021-03-25 13:11:47 +0200 received badge  Popular Question (source)
2020-09-01 00:14:32 +0200 asked a question How do I start using SageMath in Spyder on macOS?

I installed SageMath 9.1 by downloading and running the OSX .dmg, but how do I actually start using it in my Python IDE (Spyder)? I have Python code that uses SageMath functions, which works in CoCalc, but I can't get it to work in Spyder by simply using import sage or import SageMath.

2020-08-31 22:06:30 +0200 commented answer Why doesn't the SageMath function find_local_maximum work for me in Python?

@slelievre I've now download and installed the .dmg file. The installation guide says to then "Simply use it." How do I use it in an IDE (Spyder or Jupyter notebook)?

2020-08-31 21:30:06 +0200 received badge  Supporter (source)
2020-08-28 02:38:46 +0200 received badge  Student (source)
2020-08-28 01:57:37 +0200 asked a question Why doesn't the SageMath function find_local_maximum work for me in Python?

The code below works in CoCalc, but I can't get it to run in Python in my IDE. I've imported numpy and sagemath, and referred to each as needed to define the math functions, but I can't get the find_local_maximum function to work. See below.

Code:

import numpy as np
import sagemath as sm

def mean_x(factor, values):
    return sum([np.cos(2*np.pi*v/factor) for v in values])/len(values)

def mean_y(factor, values):
    return sum([np.sin(2*np.pi*v/factor) for v in values])/len(values)

def calculatePeriodAppeal(factor, values):
    mx = mean_x(factor, values)
    my = mean_y(factor, values)
    appeal = np.sqrt(mx**2+my**2)
    return appeal

def calculateBestLinear(factor, values):
    mx = mean_x(factor, values).n()
    my = mean_y(factor, values).n()
    y0 = factor*np.atan2(my,mx)/(2*np.pi).n()
    err = 1-np.sqrt(mx**2+my**2).n()
    return [factor*x + y0, err]

def calculateGCDAppeal(factor, values):
    mx = mean_x(factor, values)
    my = mean_y(factor, values)
    appeal = 1 - np.sqrt((mx-1)**2+my**2)/2
    return appeal

testSeq = [552,827,275,809,534] 
gcd = calculateGCDAppeal(x, testSeq)
agcd = sm.find_local_maximum(gcd,20,30)
print(agcd)
np.plot(gcd,(x, 20,30))

Error:

Traceback (most recent call last):

  File "<ipython-input-163-fecb5397afab>", line 31, in <module>
    agcd = sm.find_local_maximum(gcd,20,30)

AttributeError: module 'sagemath' has no attribute 'find_local_maximum'