metapensiero/metapensiero.pj

`float` is a reserve word in javascript error

robertleeplummerjr opened this issue · 19 comments

I ran: python3.6 -m metapensiero.pj basic.py on
https://github.com/OpenMined/PySyft/blob/a127e7155788be4fbff72d234060fb1432ab560d/syft/he/paillier/basic.py

and got An error occurred while compiling source file 'basic.py' UnsupportedSyntaxError: Node type 'Name': Line: 66, column: 63. Name 'float' is reserved in JavaScript.

Which references: https://github.com/OpenMined/PySyft/blob/a127e7155788be4fbff72d234060fb1432ab560d/syft/he/paillier/basic.py#L66

I believe since there is: https://docs.python.org/3/library/functions.html#float what we'd actually want to output from the parser is Number.parseFloat(tensor)

Can we have this support added?

Hi @robertleeplummerjr, and thanks for giving JavaScripthon a try and reporting this. This is filxed already in master, although I haven't made a new release

$ pj -s - 
float('1.5') 

parseFloat("1.5");

Can you try the code from this repo and install it with pip -e and report back if it works for you?

thanks

P.S. you should be aware that JavaScripthon will not convert those __mul__ methods to anything meaningful.

the same can be said for the __add__ and __sub__ methods

  1. Is there anything holding up a release?
  2. Do you have a recommendation regarding add and sub methods?

Is there a way we can get the commits that fix the float issue, and get that released, so that we benefit from the bug fixes? Thank you for the pointers!

I'll try to find the time to do a release

@robertleeplummerjr I've released version 0.7, please give a it a try and let me know

@robertleeplummerjr does it works?

I'll test it momentarily.

Now when I install, I get:

Collecting javascripthon
  Downloading javascripthon-0.7.tar.gz (530kB)
    100% |████████████████████████████████| 532kB 2.7MB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/vv/n8mynbmn21s9nbh42681klydgfn2lt/T/pip-build-VZZDT6/javascripthon/setup.py", line 14, in <module>
        with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
    TypeError: 'encoding' is an invalid keyword argument for this function

How strange! What python version are you using?

I am on osx, so I have both 2.7.13, and 3.6.2. My alias is to call from 3.6.2 though, but not sure if pip is using that, or fighting it.

most certainly it isn't

python3 -m pip install javascripthon --no-cache-dir seems to have done the trick

That uses the older version, which isn't yet released. If I install from source, the step $ pip install -r metapensiero.pj/requirements.txt gives me: You must give at least one requirement to install (see "pip help install")

Note: I actually used python3 -m pip install -r metapensiero.pj/requirements.txt

there's non need for this last step... just install python3 -m pip install javascripthon==0.7

That did it!