Is it not OK to ask my supervisor about a piece of code?

Watch
AliceSwann
Badges: 12
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#1
Report Thread starter 1 month ago
#1
I'm doing an MSc physics and my project is on astrophysics. Because I'm new to this area, I had a hard time learning to use the different python environments etc. Sometimes I run into trouble with coding and I feel really stuck because I'm really not good with coding... But I dare not tell my supervisor about it because the project is on physics and coding really seems like the most basic part that I should sort out myself. However I really need some help with it and I don't know whom I can turn to? Any suggestions?
1
reply
Composure
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#2
Report 1 month ago
#2
What coding problems are you running into?
0
reply
the bear
Badges: 20
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#3
Report 1 month ago
#3
could you discuss it with other students on your course ?
0
reply
PhoenixFortune
Badges: 21
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#4
Report 1 month ago
#4
(Original post by AliceSwann)
I'm doing an MSc physics and my project is on astrophysics. Because I'm new to this area, I had a hard time learning to use the different python environments etc. Sometimes I run into trouble with coding and I feel really stuck because I'm really not good with coding... But I dare not tell my supervisor about it because the project is on physics and coding really seems like the most basic part that I should sort out myself. However I really need some help with it and I don't know whom I can turn to? Any suggestions?
Does your university have a department for study skills which includes coding and stats help?
0
reply
Mr Wednesday
Badges: 19
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#5
Report 1 month ago
#5
(Original post by AliceSwann)
I'm doing an MSc physics and my project is on astrophysics. Because I'm new to this area, I had a hard time learning to use the different python environments etc. Sometimes I run into trouble with coding and I feel really stuck because I'm really not good with coding... But I dare not tell my supervisor about it because the project is on physics and coding really seems like the most basic part that I should sort out myself. However I really need some help with it and I don't know whom I can turn to? Any suggestions?
Yes, you should talk to your supervisor, but they may not have the time or inclination to help you debug code, and at the MSc level that’s really not their role. I certainly would not expect to do that if supervising an MSc project.

What they should be doing is suggesting (or you could ask for help with) things like what specific test problems to run your code against. That’s a key element in physics based coding and comes under the general heading of “benchmarking”. It tests whether your code bares any relation to reality / known data / results in journals / theoretical scaling laws etc. If you have some kind of working code, then that’s something you should be discussing at project meetings - and it helps provide targets to point your code development at, and can identify bugs as a result.
Last edited by Mr Wednesday; 1 month ago
2
reply
AliceSwann
Badges: 12
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#6
Report Thread starter 1 month ago
#6
(Original post by PhoenixFortune)
Does your university have a department for study skills which includes coding and stats help?
I'm not sure, but I'll look it up, thanks!
0
reply
AliceSwann
Badges: 12
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#7
Report Thread starter 1 month ago
#7
(Original post by Composure)
What coding problems are you running into?
Well I was running the same piece of code but it suddenly says couldn't find module... but it was running before and I couldn't figure out what's wrong
0
reply
AliceSwann
Badges: 12
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#8
Report Thread starter 1 month ago
#8
(Original post by the bear)
could you discuss it with other students on your course ?
Yeah, though they don't necessarily know what's going on
0
reply
AliceSwann
Badges: 12
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#9
Report Thread starter 1 month ago
#9
(Original post by Mr Wednesday)
Yes, you should talk to your supervisor, but they may not have the time or inclination to help you debug code, and at the MSc level that’s really not their role. I certainly would not expect to do that if supervising an MSc project.

What they should be doing is suggesting (or you could ask for help with) things like what specific test problems to run your code against. That’s a key element in physics based coding and comes under the general heading of “benchmarking”. It tests whether your code bares any relation to reality / known data / results in journals / theoretical scaling laws etc. If you have some kind of working code, then that’s something you should be discussing at project meetings - and it helps provide targets to point your code development at, and can identify bugs as a result.
That makes sense, well apparently I'm a bit lost...! I kinda regret applying to such a hard project, and every day I tell myself I can always drop out and take my BSc hahaha
0
reply
Steam0204
Badges: 4
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#10
Report 1 month ago
#10
(Original post by AliceSwann)
Well I was running the same piece of code but it suddenly says couldn't find module... but it was running before and I couldn't figure out what's wrong
So I don't work with python myself, I use R, but from your post it seems the problem is that python is looking for a coding object (i.e. a module) which it could find before and now can't find. When a problem like that occurs in R it's usually because R/python has "forgotten" the line of code that created that coding object. This is generally either one of two reasons. Reason 1 - You originally created that module manually so when you run your code again it isn't recreated, hence python can't find it because it 'doesn't exist' for it, or reason 2 - You aren't re-running the section of code where that module is created when you re-run it. If it should be created as part of the code you should just try re-running the entirety of your code for this thing, in the correct order. If it's manual, you'll need to a) recreate it manually and b) it's good practice to code it in so it runs automatically. At least, I think that's likely to be the problem. Tbh it's hard to help with coding problems without being able to see the code in person, but I think I recognise this one!

To answer your original question, I'd say that, if this is the solution, then really you'd probably benefit from finding an intro to coding course, either at your uni or online (there are plenty of free courses online!) since this is really an issue with not being familiar with coding rather than a problem with the code per se? In these sorts of cases it's not something your supervisor would really be helping you with learning to code, but one where you've identified an area you're weak in and need to skill-up. The role of the supervisor in your MSc is to provide direction and advice, rather than teach you per se. You should certainly ask for help from your peers and lab-mates, and also look at specialist code and statistics forums such as StackExchange, and definitely do that when the problems are coding problems later on, but at the stage where you're really not good at coding, you're better off taking a full course, since you're starting at the beginning.

Signed, someone who could not code to save their life when they started their MSc.
0
reply
Callicious
Badges: 22
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#11
Report 1 month ago
#11
(Original post by AliceSwann)
I'm doing an MSc physics and my project is on astrophysics. Because I'm new to this area, I had a hard time learning to use the different python environments etc. Sometimes I run into trouble with coding and I feel really stuck because I'm really not good with coding... But I dare not tell my supervisor about it because the project is on physics and coding really seems like the most basic part that I should sort out myself. However I really need some help with it and I don't know whom I can turn to? Any suggestions?
Also doing an MSc in Physics and also Astrophysics and also coding in Python

If it's a problem with your code in and of itself, it's a you problem- your supervisor isn't there to teach you how to code. My project is entirely statistical, and entirely code-based, in a region of coding that I'm entirely unfamiliar with. I didn't even know what a multivariate normal with full-covariance looked like until 2 weeks ago, never mind how to Monte-Carlo (or whatever the hell Monte-Carlo even was until then) the errors on points while assuming an underlying error distribution: my supervisor guided me into the knowledge, and I handled the coding on my own. Edit: I should also add that I know **** all about Statistics. Lord help me the one course I came closest to messing up in my years here is Fourier Analysis and Statistics, namely the Statistics. I'll solve you any number of Bessels but god help my soul if I know what the hell a Bayesian Posterior is (well, was- now I do.)

If your theory is lacking, he can point you in the right direction, and he can make sure your code (and you) stay on track. My man *redacted* keeps me on point for where I'm going with my work, but he doesn't teach me how to do it- he just says "Maybe this would be a good idea" or "Your idea is good, try it for next week" and I try it, and if it fails to give a result, he then looks through and tries to see where I went wrong. Granted, he codes in FORTRAN and C, and I code in Python and a teeny bit of Mathematica, so it's a bit of a contrasting world- but by god it works.
Last edited by Callicious; 1 month ago
0
reply
Composure
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#12
Report 1 month ago
#12
(Original post by AliceSwann)
Well I was running the same piece of code but it suddenly says couldn't find module... but it was running before and I couldn't figure out what's wrong
What's the module you're trying to import? And assuming it's not a module from the standard library, did you pip install it?
Last edited by Composure; 1 month ago
0
reply
AliceSwann
Badges: 12
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#13
Report Thread starter 1 month ago
#13
(Original post by Composure)
What's the module you're trying to import? And assuming it's not a module from the standard library, did you pip install it
It was pymultinest and yes, I did pip install it.
0
reply
AliceSwann
Badges: 12
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#14
Report Thread starter 1 month ago
#14
(Original post by Steam0204)
So I don't work with python myself, I use R, but from your post it seems the problem is that python is looking for a coding object (i.e. a module) which it could find before and now can't find. When a problem like that occurs in R it's usually because R/python has "forgotten" the line of code that created that coding object. This is generally either one of two reasons. Reason 1 - You originally created that module manually so when you run your code again it isn't recreated, hence python can't find it because it 'doesn't exist' for it, or reason 2 - You aren't re-running the section of code where that module is created when you re-run it. If it should be created as part of the code you should just try re-running the entirety of your code for this thing, in the correct order. If it's manual, you'll need to a) recreate it manually and b) it's good practice to code it in so it runs automatically. At least, I think that's likely to be the problem. Tbh it's hard to help with coding problems without being able to see the code in person, but I think I recognise this one!

To answer your original question, I'd say that, if this is the solution, then really you'd probably benefit from finding an intro to coding course, either at your uni or online (there are plenty of free courses online!) since this is really an issue with not being familiar with coding rather than a problem with the code per se? In these sorts of cases it's not something your supervisor would really be helping you with learning to code, but one where you've identified an area you're weak in and need to skill-up. The role of the supervisor in your MSc is to provide direction and advice, rather than teach you per se. You should certainly ask for help from your peers and lab-mates, and also look at specialist code and statistics forums such as StackExchange, and definitely do that when the problems are coding problems later on, but at the stage where you're really not good at coding, you're better off taking a full course, since you're starting at the beginning.

Signed, someone who could not code to save their life when they started their MSc.
Thank you! I'm still trying to figure it out, and I use StackOverflow when I run into problems. I'm not completely new to programming, I did a few Python courses in undergrad but that doesn't mean I'm good at it hahaha
1
reply
AliceSwann
Badges: 12
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#15
Report Thread starter 1 month ago
#15
(Original post by Callicious)
Also doing an MSc in Physics and also Astrophysics and also coding in Python

If it's a problem with your code in and of itself, it's a you problem- your supervisor isn't there to teach you how to code. My project is entirely statistical, and entirely code-based, in a region of coding that I'm entirely unfamiliar with. I didn't even know what a multivariate normal with full-covariance looked like until 2 weeks ago, never mind how to Monte-Carlo (or whatever the hell Monte-Carlo even was until then) the errors on points while assuming an underlying error distribution: my supervisor guided me into the knowledge, and I handled the coding on my own. Edit: I should also add that I know **** all about Statistics. Lord help me the one course I came closest to messing up in my years here is Fourier Analysis and Statistics, namely the Statistics. I'll solve you any number of Bessels but god help my soul if I know what the hell a Bayesian Posterior is (well, was- now I do.)

If your theory is lacking, he can point you in the right direction, and he can make sure your code (and you) stay on track. My man *redacted* keeps me on point for where I'm going with my work, but he doesn't teach me how to do it- he just says "Maybe this would be a good idea" or "Your idea is good, try it for next week" and I try it, and if it fails to give a result, he then looks through and tries to see where I went wrong. Granted, he codes in FORTRAN and C, and I code in Python and a teeny bit of Mathematica, so it's a bit of a contrasting world- but by god it works.
SAME! I also need to catch up on statistics... of course my supervisor is not in a place to teach me everything and I'll have to do that by myself, but it feels a bit impossible and I'm overwhelmed! Well let's hope I will find out what these mysterious things are!
0
reply
Composure
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#16
Report 1 month ago
#16
(Original post by AliceSwann)
It was pymultinest and yes, I did pip install it.
Maybe these questions can help narrow it down (assuming you're on Windows):

Are you spelling the module name correctly when you're importing it?
Do you have multiple Python versions installed?
Are you using a virtual environment?
What editor/IDE are you using?
Is the install location within the "Path" system variable?
Can you see the module when you enter pip list into Command Prompt?
Does entering python -c "import pymultinest" into Command Prompt give the same error as before?
0
reply
AliceSwann
Badges: 12
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#17
Report Thread starter 1 month ago
#17
(Original post by Composure)
Maybe these questions can help narrow it down (assuming you're on Windows):

Are you spelling the module name correctly when you're importing it?
Do you have multiple Python versions installed?
Are you using a virtual environment?
What editor/IDE are you using?
Is the install location within the "Path" system variable?
Can you see the module when you enter pip list into Command Prompt?
Does entering python -c "import pymultinest" into Command Prompt give the same error as before?
Yeah, I've only got one version of Python, and I'm using the isochrones environment which I installed. I'm using Jupyter Notebook, pymultinest is there when I enter pip list, but entering python -c 'import pymultinest' gives me SyntaxError: EOL while scanning string literal. Sorry, this is probably a really dumb problem!
0
reply
Composure
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#18
Report 1 month ago
#18
(Original post by AliceSwann)
entering python -c 'import pymultinest' gives me SyntaxError: EOL while scanning string literal.
This question was just to see if you actually had the module installed and could import it -- but the issue you're having is likely because you haven't installed the module to the environment you're using.

Although, you're getting this SyntaxError because with Command Prompt you will need double quotes around the Python code.
(Original post by AliceSwann)
I'm using the isochrones environment which I installed. I'm using Jupyter Notebook
This looks like a Conda environment (which I'm not too familiar with).

So within a terminal you need to activate the environment you created (assuming you actually created one) e.g. activate isochrones. Then from within the environment enter pip install pymultinest.

Alternatively, I believe you can enter !pip install pymultinest within a Jupyter Notebook cell.
Last edited by Composure; 1 month ago
1
reply
AliceSwann
Badges: 12
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#19
Report Thread starter 1 month ago
#19
(Original post by Composure)
This question was just to see if you actually had the module installed and could import it -- but the issue you're having is likely because you haven't installed the module to the environment you're using.

Although, you're getting this SyntaxError because with Command Prompt you will need double quotes around the Python code.

This looks like a Conda environment (which I'm not too familiar with).

So within a terminal you need to activate the environment you created (assuming you actually created one) e.g. activate isochrones. Then from within the environment enter pip install pymultinest.

Alternatively, I believe you can enter !pip install pymultinest within a Jupyter Notebook cell.
I did activate isochrones! But I'll check again just to be sure. But I was coding in the isochrones environment, so I think the problem wasn't there. And I didn't know about the install option within Jupyter Notebook. Thanks!
0
reply
Callicious
Badges: 22
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#20
Report 1 month ago
#20
(Original post by AliceSwann)
Yeah, I've only got one version of Python, and I'm using the isochrones environment which I installed. I'm using Jupyter Notebook, pymultinest is there when I enter pip list, but entering python -c 'import pymultinest' gives me SyntaxError: EOL while scanning string literal. Sorry, this is probably a really dumb problem!
FYI to use pymultinest you need multinest installed too. Idk about Conda, but I never pulled this off on Windows using PyCharm (though I didn't exactly put much effort into it and just switched to my Linux environment.) Without multinest installed and correctly built, it won't work. IIRC it's "designed" to be used on Linux/Unix-based environments, which makes it a bit of a faff to get working on Windows- my supervisor told me "don't bother" and I switched to a virtual machine to run my MN-based bayesian analysis. (I use Python 3.8 with my Pycharm)

I really really really recommend using PyCharm for coding Python- Jupyter isn't a very effective way to deal with larger projects (unless it's for a final "display style" code-up.
Last edited by Callicious; 1 month ago
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

How would you describe the quality of the digital skills you're taught at school?

Excellent (23)
9.24%
Okay (72)
28.92%
A bit lacking (93)
37.35%
Not good at all (61)
24.5%

Watched Threads

View All