Author

Topic: [Solved] Programming Bitcoin , Jimmy Song. ecc.py functions aren't working (Read 230 times)

newbie
Activity: 28
Merit: 84
I see you solved your issue, however there was one thing I want to point out.
The Python error messages actually tell you a lot about what's going wrong, to the point where I could figure out some of the issues completely statically. One example is where it's telling you that the function __add__ is not defined. We can see in your code that your indents are all over the place, putting the __add__ function within the __ne__ function, so it's invisible (nonexistent) from the outside.
32. Posting multiple posts in a row (excluding bumps and reserved posts by the thread starter) is not allowed.


Thank you for the tip!!!!!!!!!!!!!!!!!!!
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
I see you solved your issue, however there was one thing I want to point out.
The Python error messages actually tell you a lot about what's going wrong, to the point where I could figure out some of the issues completely statically. One example is where it's telling you that the function __add__ is not defined. We can see in your code that your indents are all over the place, putting the __add__ function within the __ne__ function, so it's invisible (nonexistent) from the outside.
32. Posting multiple posts in a row (excluding bumps and reserved posts by the thread starter) is not allowed.
newbie
Activity: 28
Merit: 84
--snip--
I can confirm copying the answer to ecc.py (rather than trying add function to imported object) works (passed the test).

Yeah, I've been aware of ecc.py and answers.py . The functions were implemented into ecc.py from the beginning

To be safe I copied and pasted functions from answers.py into ecc.py . The problem still persists
Picture 1: https://i.stack.imgur.com/Cihsv.jpg
Picture 2: https[Suspicious link removed]rcise 1 only ask you to edit def __ne__ on ecc.py, so you don't need to modify cell Exercise 1 on Chapter1.ipynb. Just run the cell and see whether you passed the test or not.

https://i.ibb.co/8P9PTjF/111.png

LMAO, this is really a silly mistake  Cheesy Cheesy Cheesy. I thought that I was supposed to call these functions, from ecc.py to Chapter1.ipynb, and then use the functions to solve specific problems.....

but Anyway, the tests are running OK, just like in the screenshot you've provided....

Thanks!!
newbie
Activity: 28
Merit: 84
Your installation is fine; it all looks like it's running fine.
The errors appear because it's your task to implement the functions so that the tests (who output the errors you're seeing) 'pass'.
As we can see in the code, the __ne__ function is simply not implemented yet and a NotImplementedError error is raised. You are meant to remove this line and implement the function's functionality. That's the whole task here.

Spoiler: Here, in the answers.py file, you can see the solution to the exercise 1:
https://github.com/jimmysong/programmingbitcoin/blob/3fba6b992ece443e4256df057595cfbe91edda75/code-ch01/answers.py#L126

As I suspected, you're meant to simply implement the __ne__ function. So no, there are no systematic errors, it's the whole repo's purpose to give you programming problems to solve, which then result in working tests (and no error messages).

I tried to do what you've recommended, but It still doesn't work
The functions are implemented.
Please see my replies above

btw
Sorry for the delayed response
newbie
Activity: 28
Merit: 84
In the second picture, it says that test_add() is not defined. You should make sure that function actually exists by running its cell first, if the function is something you meant to write yourself and not copy from a book somewhere.

test_ne() test_add() and test_sub() are defined
Picture 1: https://i.stack.imgur.com/ROZ4n.jpg

Unfortunately, they are still not working
Picture 2: https://i.stack.imgur.com/jI4qa.jpg
Picture 3: https://i.stack.imgur.com/LUiAs.jpg


newbie
Activity: 28
Merit: 84

The errors appear because it's your task to implement the functions so that the tests (who output the errors you're seeing) 'pass'.
As we can see in the code, the __ne__ function is simply not implemented yet and a NotImplementedError error is raised. You are meant to remove this line and implement the function's functionality. That's the whole task here.

FYI, chapter 1 of the book also state you need to open ecc.py to start the exercise. I can see this confuse some people though, since i expected explicit instruction such as "To solve exercise 1, you need to open ecc.py and edit __ne__ function".

Spoiler: Here, in the answers.py file, you can see the solution to the exercise 1:
https://github.com/jimmysong/programmingbitcoin/blob/3fba6b992ece443e4256df057595cfbe91edda75/code-ch01/answers.py#L126

As I suspected, you're meant to simply implement the __ne__ function. So no, there are no systematic errors, it's the whole repo's purpose to give you programming problems to solve, which then result in working tests (and no error messages).

I can confirm copying the answer to ecc.py (rather than trying add function to imported object) works (passed the test).

Yeah, I've been aware of ecc.py and answers.py . The functions were implemented into ecc.py from the beginning

To be safe I copied and pasted functions from answers.py into ecc.py . The problem still persists
Picture 1: https://i.stack.imgur.com/Cihsv.jpg
Picture 2: https://i.stack.imgur.com/tlIig.jpg
Picture 3: https://i.stack.imgur.com/gQHf9.jpg

Importing answers.py itself into doesn't do anything
Picture 4: https://i.stack.imgur.com/kHf5w.jpg

Copying and pasting the functions themselves in the program does not help as well
Picture 5: https://i.stack.imgur.com/H89nK.jpg

Sorry for the delayed response



legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange

The errors appear because it's your task to implement the functions so that the tests (who output the errors you're seeing) 'pass'.
As we can see in the code, the __ne__ function is simply not implemented yet and a NotImplementedError error is raised. You are meant to remove this line and implement the function's functionality. That's the whole task here.

FYI, chapter 1 of the book also state you need to open ecc.py to start the exercise. I can see this confuse some people though, since i expected explicit instruction such as "To solve exercise 1, you need to open ecc.py and edit __ne__ function".

Spoiler: Here, in the answers.py file, you can see the solution to the exercise 1:
https://github.com/jimmysong/programmingbitcoin/blob/3fba6b992ece443e4256df057595cfbe91edda75/code-ch01/answers.py#L126

As I suspected, you're meant to simply implement the __ne__ function. So no, there are no systematic errors, it's the whole repo's purpose to give you programming problems to solve, which then result in working tests (and no error messages).

I can confirm copying the answer to ecc.py (rather than trying add function to imported object) works (passed the test).
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
In the second picture, it says that test_add() is not defined. You should make sure that function actually exists by running its cell first, if the function is something you meant to write yourself and not copy from a book somewhere.
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
Your installation is fine; it all looks like it's running fine.
The errors appear because it's your task to implement the functions so that the tests (who output the errors you're seeing) 'pass'.
As we can see in the code, the __ne__ function is simply not implemented yet and a NotImplementedError error is raised. You are meant to remove this line and implement the function's functionality. That's the whole task here.

Spoiler: Here, in the answers.py file, you can see the solution to the exercise 1:
https://github.com/jimmysong/programmingbitcoin/blob/3fba6b992ece443e4256df057595cfbe91edda75/code-ch01/answers.py#L126

As I suspected, you're meant to simply implement the __ne__ function. So no, there are no systematic errors, it's the whole repo's purpose to give you programming problems to solve, which then result in working tests (and no error messages).
newbie
Activity: 28
Merit: 84
Programming Bitcoin book, Jimmy Song. Chapter 1 ecc.py functions aren't recognized even though the ecc.py (the source file of the functions) is in the same folder as the file in which the Functions are being called
Picture 1: https://i.stack.imgur.com/njYMU.jpg
Picture 2: https://i.stack.imgur.com/ZTg8R.jpg
Picture 3: https://i.stack.imgur.com/nNuTL.jpg
Picture 4: https://i.stack.imgur.com/eje4Q.jpg
The functions are written:
Picture 5: https://i.stack.imgur.com/hLQPM.jpg
Picture 6: https://i.stack.imgur.com/jdEcZ.jpg
Picture 7: https://i.stack.imgur.com/sMnoC.jpg


I start the Jupyter notebook every time by typing these commands in the command prompt
Picture 8: https://i.stack.imgur.com/pSAZa.jpg

Code:
@echo on
cd C:\programmingbitcoin\programmingbitcoin

virtualenv -p C:\programmingbitcoin\programmingbitcoin\.venv\Scripts\python.exe .venv

.venv\Scripts\activate.bat

jupyter notebook
REM DO NOT CLOSE THE COMMAND PROMPT! THAT WOULD SHUTDOWN THE JUPYTER!
pause

and keep the command prompt running

Picture 9: https://i.stack.imgur.com/3VE7D.jpg

as I said, These files are in the same folder
Picture 10: https://i.stack.imgur.com/QX8Ia.jpg

The installation guide to Jupyter Notebook:
https://www.oreilly.com/library/view/programming-bitcoin/9781492031482/preface01.html#setting_up
The book's github:
https://github.com/jimmysong/programmingbitcoin

The steps to installation and starting the Jupyter Notebook I got from that guide

The question is:
What seems to be the problem here?

Why is this question being asked? There's the possibility that the problem may be systematic across the whole repository. To prevent further errors, it would be good to solve everything in advance.
The odd thing is that for the 1st time these functions were working, but after I've restarted the Jupyter notebook, they stopped doing so
The question is also posted on StackOverflow: https://stackoverflow.com/questions/70701871/programming-bitcoin-jimmy-song-ecc-py-functions-arent-working
Jump to: