NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
> address@hidden> wrote: > > > If you want to call java function Dounble.isNaN inside your jython > > library, you need to add import java.math at the top of your library. Such > > as: > > > > import java.math > > > > def isNaN(a) > > return Double.isNaN(a) > > > > Hello IDV support, > > Your reply is incorrect, there's a colon ':' missing. The corrected line > should read: > > def isNaN(a): > > > > Note the colon ':' at the end of the line. > > Even after correcting the colon, it still produces an error: > > Creating display: Point Cloud > > NameError: global name 'Double' is not defined > > org.python.core.PyException > > > > The error detail is: > > Traceback (most recent call last): > > File "<string>", line 1, in <module> > > File "<string>", line 8, in log10_py > > File "<string>", line 5, in isNaN > > NameError: global name 'Double' is not defined > > > > As an example of what I'm trying to do, here's what is in my local Jython > User's library: > > import java.math > > > > def isNaN(a): > > return Double.isNaN(a) > > > > def example_py(val): > > if not isNaN(val): > > val = val * 2 > > return val > > > > Then, in the Edit Formula dialog, I use 'example_py(name)' to double the > value of a variable, taking NaNs into account. > > I'd appreciate it if you would provide a tested, working example of this > simple formula, since I can't get it to work. Ok, my bad. Here is a real working example: from java.lang import Double def example_py(val): if not isNaN(val): val = val * 2 return val def isNaN(a): return Double.isNaN(a) Yuan > > Thank you. > > -- > Tod Hagan <address@hidden> > > 251 Morse Hall > Earth Systems Research Center > Institute for the Study of Earth, Oceans, and Space > University of New Hampshire > 8 College Road > Durham, NH 03824-3525 > > Ticket Details =================== Ticket ID: BWP-558582 Department: Support IDV Priority: Normal Status: Closed