Menu

#1687 Jython shortcomings 2016

nextrelease
open
nobody
None
5
2025-12-06
2016-10-06
No

I keep forgetting about this task, which would probably only take half an hour, so I'm starting this ticket to keep track of shortcomings in the Jython editor.

  1. completions for imports works well, but the documentation popup would also be nice. "from org.das2.util.filesystem import FileSystemU<c>" This is particularly useful, because I know the completion can be done without executing any code, and provides a nice way to get at the javadocs.</c>

Discussion

1 2 > >> (Page 1 of 2)
  • Jeremy Faden

    Jeremy Faden - 2016-10-06

    Item 1 is done.

     
  • Jeremy Faden

    Jeremy Faden - 2016-10-07

    "2". the completion for FileSystemUtil is the no-argument constructor FileSystemUtil(), when I intend to use FileSystemUtil.<c>. I should put in a private no-arg constructor to indicate that this is a helper class of static methods, and in this case make sure the constructor is not a completion.</c>

     

    Last edit: Jeremy Faden 2016-10-07
  • Jeremy Faden

    Jeremy Faden - 2017-04-11

    "3". In this code, you should be able to do completions within the paint method, because it knows "g" is a Graphics object.

    reset()
    
    from org.das2.graph import Painter
    class MyPainter(Painter):
      def paint(self,g):
        from java.awt.geom import GeneralPath
    
        from java.awt.geom import Arc2D
        p2 = GeneralPath()
        arc = Arc2D.Double(100,100,200,200,0,60,Arc2D.OPEN)
        p2.append(arc.getPathIterator(None),True)
        arc = Arc2D.Double(150,150,100,100,60,-60,Arc2D.OPEN)
        p2.append(arc.getPathIterator(None),True)
        p2.closePath()
    
        g.setColor(Color.RED)
        g.fill(p2) 
    
    dom.canvases[0].controller.dasCanvas.addTopDecorator(MyPainter()) 
    
     

    Last edit: Jeremy Faden 2017-04-11
  • Jeremy Faden

    Jeremy Faden - 2017-05-18

    (item4) Package completions:

    from org.autoplot.pngwalk import <c> and
    from org.autoplot.p<c> </c></c>

    should work so you can peek around package.

     

    Last edit: Jeremy Faden 2018-02-22
  • Jeremy Faden

    Jeremy Faden - 2017-12-22

    I use the package completions all the time to get documentation, when completions within the code don't work.

    I reworked how some of the completions were done (old code was still parsing jython by hand), and this has broken some of the completions. This would be another nice January study...

    Also, with the new custom Renderers in Jython, it would be all the more helpful to get completions on "g" "xaxis" and "yaxis" of "def render( self, g, xaxis, yaxis, monitor )"

     

    Last edit: Jeremy Faden 2017-12-22
  • Jeremy Faden

    Jeremy Faden - 2017-12-22

    Also I need to study why /home/jbf/ct/autoplot/script/2017/20171221/snowFlake.jy shows where "from math import cos" is needed because the default cos always returns dataset.

    (2019-02-18: this is not needed.)

     

    Last edit: Jeremy Faden 2019-02-18
  • Jeremy Faden

    Jeremy Faden - 2018-01-25
    from org.autoplot.datasource import DataSourceUtil
    Da<C>
    

    shows DataSourceUtil() when it is a bunch of static methods. This should not have the parentheses.

    Also, Netbeans Jython completions look very nice, and these should be reviewed as well.

    Also, Masafumi and I were working on a script and it was clear that completions were loading data in the background.

     
  • Jeremy Faden

    Jeremy Faden - 2018-02-22

    (item5). I find now that often I can't get completions down in the code so I pop up to the top to get compltions. This should never happen, and I'm pretty sure the old completions model would refactor to a code which would always work, while the new syntax-based refactoring leaves things in that shouldn't be.
    (item6). "ds= plot( ripples(10),<c> " gives completions on ripples, not plot.
    (item7). "ds= plot( ds,⎵<c>" gives different completions than "ds= plot( ds,<c>" (⎵ is space)</c></c></c>

     

    Last edit: Jeremy Faden 2018-02-22
  • Jeremy Faden

    Jeremy Faden - 2018-02-22

    For the posting from 2018-01-25, DataSourceUtil had a public constructor. If classes do not have a public constructor, then no parenthesis are shown.

    It would be nice if the completion for this would add the dot automatically and show all static methods.

    (Whoops, see 2016-10-07 above, where I realized this.)

     

    Last edit: Jeremy Faden 2018-02-22
  • Jeremy Faden

    Jeremy Faden - 2018-02-22

    This demos item 5, I think:

    size= getParam( 'size', 2, 'radius of the semicircle', [1,2,4,8] )
    tr= getParam( 'timerange', '2000-01-01', 'timerange to load' )
    tr= DatumRangeUtil.parseTimeRange(tr)
    hr= dataset( '3600 s' )
    nt= int( ( dataset(tr.width()) / hr ).value() ) * 60
    # <C> here shows it is trying to eval line 5.
    
     
  • Jeremy Faden

    Jeremy Faden - 2018-02-22

    Here's a second demo of item 5:

    DtoR= PI/180.0
    
    ds= ripples(160,360)
    ds0= ds
    ds= transpose(ds)
    nn=size(ds)
    tot= nn[0]*nn[1]
    f= dindgen(tot)
    ii= floor(f/nn[1])
    jj= (f-ii) % nn[1]
    lon= ii + 90.0
    lat= 90.0 - (jj - 90.0)
    x = 2.0*lat*cos(lon*DtoR) + 180.0 
    y = 2.0*lat*sin(lon*DtoR) + 180.0 
    
    rr= sqrt( x**2 + y**2 )
    aa= atan2( y, x )
    interpol<C>
    
     
  • Jeremy Faden

    Jeremy Faden - 2018-02-23

    I think item 5 is working now. The problem was the simplify script wasn't removing lines like "tot=nn[0]+nn[1]" where it didn't have nn resolved.

     
  • Jeremy Faden

    Jeremy Faden - 2018-02-23

    DatumRangeUtil wasn't accepted automatically:

    tr= '2016-001T00:00Z'
    tr= DatumRangeUtil.parseTimeRange(tr)
    

    Also, I forgot the keyboard shortcut ctrl-shift-F12.

    The problem is that parseTimeRange was throwing an exception, because tr was not a time range. I've improved the error feedback.

     

    Last edit: Jeremy Faden 2018-02-24
  • Jeremy Faden

    Jeremy Faden - 2018-02-23

    I should note too that by now I'm sure that this all needs to be rewritten. What should happen is a the jython initialization code should also be parsed (or run) to form all the symbols there, and then a table of fast functions (e.g. fltarr can always be run within a few millisecond, as opposed to fftPower which needs many seconds to run--look for progress bars in the APIs) is used to see which lines can be left in the code.

     
  • Jeremy Faden

    Jeremy Faden - 2018-02-24

    (item8) you can't get documentation on the second line after continuation:

    annotation( 0, text='VAN ALLEN PROBES '+scAB, fontSize='1.4em', 
                anchorOffset='+7em,60%+2em', anchorPosition='NW', 
                columnId='', rowId='',<C> )
    
     
  • Ivar Christopher

    (item9) When optional argument anchorType "canvas" misspelled the error message was confusing. Optional arguments to the plot command (and annotation) need to be updated.

     

    Last edit: Jeremy Faden 2018-02-28
  • Jeremy Faden

    Jeremy Faden - 2018-02-28

    Regarding (item9) , I made it so that for the plot documentation, the "see also" link is detected and added to the completion popup.

     
  • Jeremy Faden

    Jeremy Faden - 2018-02-28

    Regarding (item9),

    d= annotation( blah='s' )

    gives a fine error.

    a= annotation( anchorType='canvaz' )

    could be improved to show the enumerated values.

    Ivar, is it one of these two cases you observed?

     
  • Jeremy Faden

    Jeremy Faden - 2018-07-06

    (item10) This shows where in one place it gets the documentation (C1) and in another (C2) it doesn't:

    from java.net import HttpURLConnec<C1>tion
    urlc= HttpURLConnec<C2>tion(
    
     
  • Jeremy Faden

    Jeremy Faden - 2019-02-11

    (Item 11) This should work but doesn't:

    # simplify should work here
    iData=0
    sPJ= ['PJ4 North', 'PJ4 South', 'PJ5 North', 'PJ5 South', 'PJ6 North', 'PJ6 South']
    
    sFdir= PWD
    
    sFname=['s1', 's2', 's3', 's4', 's5', 's6']
    
    sFile= sFdir+sFname[iData]+".hdf5"
    
    print(sFile)  # completions don't see sFile
    
    dslon= 360.0-getDataSet(sFile+'?longitude_map') 
    
    print(sFile) # completions fail
    

    What string concentation would allow for completions, this should be done.

     

    Last edit: Jeremy Faden 2019-02-11
  • Jeremy Faden

    Jeremy Faden - 2019-02-13

    (Item 12) Multiline with indents is not treated properly. When I try to run the following script, it fails at line 12 with a syntax error.

    # demo JGit library
    
    import sys
    addToSearchPath(sys.path,
        'https://repo.eclipse.org/content/groups/releases//org/eclipse/jgit/org.eclipse.jgit/5.2.1.201812262042-r/org.eclipse.jgit-5.2.1.201812262042-r.jar',
        monitor )
    
    from org.eclipse.jgit.api import Git
    from java.io import File
    
    git= Git.cloneRepository()\
       .setURI("https://github.com/autoplot/dev.git")\    # line 12
       .setDirectory(File("/tmp/ap/dev.g"))\
       .call()
    
    head = repository.resolve("HEAD")
    

    This may be the same as (item 8).

     

    Last edit: Jeremy Faden 2019-12-19
  • Jeremy Faden

    Jeremy Faden - 2019-02-13

    Regarding (item 12), Actions->Developer->"Show Simplified Script" shows how the addToSearchPath looses its third line.

     
  • Jeremy Faden

    Jeremy Faden - 2019-12-18

    item12 is only inclusive now when the last line is a continuation (starting with whitespace).

     
  • Jeremy Faden

    Jeremy Faden - 2019-12-19

    Item 8 remains (completion on third line).

     
1 2 > >> (Page 1 of 2)
MongoDB Logo MongoDB