Giter VIP home page Giter VIP logo

Comments (12)

AstroRobin avatar AstroRobin commented on August 29, 2024

Okay yes, so the solution is to use the os basename function to get the stem of the file path:

import os

cmaps = [os.path.basename(c).split('.')[0] for c in sorted(glob(f'{data_path}/*.txt'))]

or perhaps even neater is using pathlibs

from pathlib import Path

cmaps = [Path(c).stem for c in sorted(glob(f'{data_path}/*.txt'))]

which also removes file extensions at the same time.

Sidenote, when I test using both of these packages on my machine for a file path that contains '\' separators, I doesn't appear to work, but it does work on a windows machine so the function itself is OS dependent.

from scicm.

MBravoS avatar MBravoS commented on August 29, 2024

That's interesting, as from what I'm reading it seems that in theory Windows should handle both type of separators. I went a different route with the fix though, as os does know what type to use and it's exposed through os.sep. So in the windows_path_fix branch I made the following change:

from os import path, sep

cmaps=[c.split(sep)[-1].split('.')[0] for c in sorted(glob(f'{data_path}{sep}*.txt'))]

That works fine on my Linux machine, so it should also work with MacOS. Is the student still around to test this fix in Windows? If so, let me know if it works so we can move this to the master branch.

from scicm.

AstroRobin avatar AstroRobin commented on August 29, 2024

They will have to install from the devel branch on github yes?

from scicm.

MBravoS avatar MBravoS commented on August 29, 2024

From the windows_path_fix branch I mentioned and linked before. I'm halfway through my work on the CI on the devel branch and didn't want to delay this fix until that's finished.

from scicm.

AstroRobin avatar AstroRobin commented on August 29, 2024

Realised afterwards there was a separate branch. It's strange though because I can't use the @windows_path_fix extension when using pip to install from github? @devel works, but the 2D_cmaps also doesn't work...

Can you try to install these branches to test this?

from scicm.

MBravoS avatar MBravoS commented on August 29, 2024

That's weird, I haven't tried installing 2D_cmaps from GitHub, but earlier today I tested installing windows_path_fix from GitHub and it worked (though it wasn't fast). What's the error that it's giving you?

from scicm.

AstroRobin avatar AstroRobin commented on August 29, 2024

Error message:

>>> pip install git+https://github.com/MBravoS/splotch.git@windows_path_fix
Collecting git+https://github.com/MBravoS/splotch.git@windows_path_fix
  Cloning https://github.com/MBravoS/splotch.git (to revision windows_path_fix) to /private/var/folders/5k/ps7pc2p16fsgzqhfryy_xkc0p_v4ys/T/pip-req-build-l9vmat0z
  Running command git clone -q https://github.com/MBravoS/splotch.git /private/var/folders/5k/ps7pc2p16fsgzqhfryy_xkc0p_v4ys/T/pip-req-build-l9vmat0z
  WARNING: Did not find branch or tag 'windows_path_fix', assuming revision or ref.
  Running command git checkout -q windows_path_fix
  error: pathspec 'windows_path_fix' did not match any file(s) known to git
WARNING: Discarding git+https://github.com/MBravoS/splotch.git@windows_path_fix. Command errored out with exit status 1: git checkout -q windows_path_fix Check the logs for full command output.
ERROR: Command errored out with exit status 1: git checkout -q windows_path_fix Check the logs for full command output.```

from scicm.

MBravoS avatar MBravoS commented on August 29, 2024

That's because you are trying to install splotch and not scicm. 😉

from scicm.

AstroRobin avatar AstroRobin commented on August 29, 2024

Okay, if muck up monday still existed, this would classify as one of the classics....

That said, I just realised I must have copied this from the scicm GitHub Readme, which still says splotch :O

from scicm.

MBravoS avatar MBravoS commented on August 29, 2024

Sad to hear that muck up Monday is no longer a thing. That said, you are right that we have the wrong repo url in the README, I fixed that in the windows_path_fix branch. If the fix works in Windows I'll merge into master.

from scicm.

AstroRobin avatar AstroRobin commented on August 29, 2024

Confirmed that it is now working.

from scicm.

MBravoS avatar MBravoS commented on August 29, 2024

Excellent! I pushed v1.0.4 to master and to PyPI.

from scicm.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.