monroews / CEE4530

MIT License
4 stars 11 forks source link

Syntax error for copied code. #92

Open bl454 opened 5 years ago

bl454 commented 5 years ago

from aguaclara.core.units import unit_registry as u u.define('equivalent = mole = eq') import aguaclara.research.environmental_processes_analysis as epa from aguaclara.research.environmental_processes_analysis import * from scipy import optimize

CayugaANC = 1.6*10(-3).8 - .210(-3.5)u.eq/u.L WolfANC = 7010(-6).8 - .210(-3.5)*u.eq/u.L

def ANC_zeroed(pHguess, ANC): return ((epa.ANC_open(pHguess) - ANC.to(u.mol/u.L)).magnitude

Now we use root finding to find the pH that results in the known ANC.

Our function will call the ANC_zeroed function. The pHguess is the first

input of the ANC_zeroed function and the range on that is set by the next

two inputs in the optimize.brentq function. The ANC is passed as an

additional argument.

def pH_open(ANC): return optimize.brentq(ANC_zeroed, 0, 14,args=(ANC))

CayugapH = pH_open(CayugaANC) WolfpH = pH_open(WolfANC)

File "", line 20 def pH_open(ANC): ^ SyntaxError: invalid syntax

monroews commented 5 years ago

Does the code work if you download the original fe I provided?

bl454 commented 5 years ago

I copied and pasted it but it’s having a syntax error on the def pH_open

monroews commented 5 years ago

I assume it is an indenting error. Thus I suggest you download the original code and see if it works on your computer.

bl454 commented 5 years ago

I did that and also tried different combinations of indenting and it is still failing

monroews commented 5 years ago

Whatever technique you used to copy and paste the code is replacing spaces with underscores. I suggest downloading the file and testing that.

bl454 commented 5 years ago

I was searching through the aguaclara folder and was not able to find the pH_open function

monroews commented 5 years ago

The code is posted on the course website.

bl454 commented 5 years ago

I'm returning an error of cannot convert equivalents/L to dimensionless even though i used the magnitude command.

monroews commented 5 years ago

Can you paste the code that you are using here or send me the code that you are using?