grd349 / PBjam

A repo for our peak baggin code and tips on jam
MIT License
17 stars 6 forks source link

TypeError in Version2.0.1 #278

Open diyiliaoya opened 1 month ago

diyiliaoya commented 1 month ago

When I run the star class like this: st = pb.star(ID, pg, numax, dnu, teff, bp_rp) TypeError will show:

TypeError                                 Traceback (most recent call last)
Cell In[10], [line 1](vscode-notebook-cell:?execution_count=10&line=1)
----> [1](vscode-notebook-cell:?execution_count=10&line=1) st = pb.star(ID, pg, numax, dnu, teff, bp_rp)

File ~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:916, in star.__init__(self, ID, f, s, addObs, outpath, priorpath)
    [912](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:912) def __init__(self, ID, f, s, addObs, outpath=None, priorpath=None):
    [914](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:914)     self.__dict__.update((k, v) for k, v in locals().items() if k not in ['self'])
--> [916](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:916)     self.outpath = IO._set_outpath(ID, self.outpath)
    [918](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:918)     if priorpath is None:
    [919](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:919)         self.priorpath = IO.get_priorpath()

File ~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/IO.py:895, in _set_outpath(ID, rootPath)
    [892](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/IO.py:892)     rootPath = os.getcwd()
    [894](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/IO.py:894) if not os.path.basename == ID:
--> [895](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/IO.py:895)     path = os.path.join(*[rootPath, f'{ID}'])
    [896](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/IO.py:896) else:
    [897](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/IO.py:897)     path = rootPath

File <frozen posixpath>:76, in join(a, *p)

TypeError: expected str, bytes or os.PathLike object, not tuple
grd349 commented 1 month ago

@nielsenmb - is this anticipated in 2.0.1?

nielsenmb commented 1 month ago

Hi Shijie,

The star class isn't currently functioning with the updates in v2.0.1.

I think your best bet is to look at one of the example notebooks that should be in the main directory of the repo.

Hope that helps!

On Mon, 23 Sept 2024, 09:31 Guy Davies, @.***> wrote:

@nielsenmb https://github.com/nielsenmb - is this anticipated in 2.0.1?

— Reply to this email directly, view it on GitHub https://github.com/grd349/PBjam/issues/278#issuecomment-2367547384, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJWO336XDG636TY6NJWQALZX7GXDAVCNFSM6AAAAABOVDQNKWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRXGU2DOMZYGQ . You are receiving this because you were mentioned.Message ID: @.***>

diyiliaoya commented 1 month ago

Hi Shijie, The star class isn't currently functioning with the updates in v2.0.1. I think your best bet is to look at one of the example notebooks that should be in the main directory of the repo. Hope that helps! On Mon, 23 Sept 2024, 09:31 Guy Davies, @.> wrote: @nielsenmb https://github.com/nielsenmb - is this anticipated in 2.0.1? — Reply to this email directly, view it on GitHub <#278 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJWO336XDG636TY6NJWQALZX7GXDAVCNFSM6AAAAABOVDQNKWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRXGU2DOMZYGQ . You are receiving this because you were mentioned.Message ID: @.>

Hi @nielsenmb ,

The error listed above is the one I encountered when running docs/example-star.ipynb

grd349 commented 1 month ago

Hi @diyiliaoya,

Could you post the error message from example-star here together with your os details and I will look in to it.

Thanks - Guy

diyiliaoya commented 1 month ago

example-star

Hi @grd349 ,

example-star was running fine until it hit the line st = pb.star(ID, pg, numax, dnu, teff, bp_rp), and then I got the following error:

TypeError                                 Traceback (most recent call last)
Cell In[9], [line 1](vscode-notebook-cell:?execution_count=9&line=1)
----> [1](vscode-notebook-cell:?execution_count=9&line=1) st = pb.star(ID, pg, numax, dnu, teff, bp_rp)

File ~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:916, in star.__init__(self, ID, f, s, addObs, outpath, priorpath)
    [912](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:912) def __init__(self, ID, f, s, addObs, outpath=None, priorpath=None):
    [914](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:914)     self.__dict__.update((k, v) for k, v in locals().items() if k not in ['self'])
--> [916](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:916)     self.outpath = IO._set_outpath(ID, self.outpath)
    [918](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:918)     if priorpath is None:
    [919](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:919)         self.priorpath = IO.get_priorpath()

File ~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/IO.py:895, in _set_outpath(ID, rootPath)
    [892](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/IO.py:892)     rootPath = os.getcwd()
    [894](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/IO.py:894) if not os.path.basename == ID:
--> [895](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/IO.py:895)     path = os.path.join(*[rootPath, f'{ID}'])
    [896](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/IO.py:896) else:
    [897](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/IO.py:897)     path = rootPath

File <frozen posixpath>:76, in join(a, *p)

TypeError: expected str, bytes or os.PathLike object, not tuple

Environment: Rocky linux9,python 3.12.5

grd349 commented 1 month ago

Thanks - The new syntax for running can be found in ...

https://github.com/grd349/PBjam/blob/master/example-Star.ipynb

The docs/example-Star.ipynb is out of date and should be removed/updated.

@diyiliaoya Could you see if the new syntax fixes your error?

Thanks,

Guy

diyiliaoya commented 1 month ago

Thanks - The new syntax for running can be found in ...

https://github.com/grd349/PBjam/blob/master/example-Star.ipynb

The docs/example-Star.ipynb is out of date and should be removed/updated.

@diyiliaoya Could you see if the new syntax fixes your error?

Thanks,

Guy

Hi @grd349 ,

It still can't work.

First, you need to change from pbjam.star import star to from pbjam import star, or you'll get an error like this:

ModuleNotFoundError                       Traceback (most recent call last)
Cell In[21], line 4
      2 get_ipython().run_line_magic('autoreload', '2')
      3 from pbjam import IO
----> 4 from pbjam.star import star

Next, S = star('KIC10963065', f, s, addObs) gives an error like this:

AttributeError                            Traceback (most recent call last)
Cell In[20], [line 1](vscode-notebook-cell:?execution_count=20&line=1)
----> [1](vscode-notebook-cell:?execution_count=20&line=1) S = star('KIC10963065', f, s, addObs)

File ~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:919, in star.__init__(self, ID, f, s, addObs, outpath, priorpath)
    [916](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:916) self.outpath = IO._set_outpath(ID, self.outpath)
    [918](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:918) if priorpath is None:
--> [919](https://file+.vscode-resource.vscode-cdn.net/home/lishijie/Tools/PBjam/~/anaconda3/envs/pbjam2/lib/python3.12/site-packages/pbjam/core.py:919)     self.priorpath = IO.get_priorpath()

AttributeError: module 'pbjam.IO' has no attribute 'get_priorpath'
grd349 commented 1 month ago

@diyiliaoya Thanks.

I can't recreate your bug right now, but I have another bug to solve first. I'll continue to look at this.

diyiliaoya commented 1 month ago

@diyiliaoya Thanks.

I can't recreate your bug right now, but I have another bug to solve first. I'll continue to look at this.

OK,Thanks!