Code Monkey home page Code Monkey logo

Comments (2)

jjobel avatar jjobel commented on September 15, 2024

This is a follow up.

It seems that I can define def get_data(self, config, catalog): as the following,

def get_data(self, config, catalog):
        args = parser.parse_args()
        x_label = args.x
        y_label = args.y
        xlabel = fits_label(config.__getitem__(x_label))
        ylabel = fits_label(config.__getitem__(y_label))
        x = catalog[xlabel]
        y = catalog[ylabel]

This way I'm able to retrieve x_label = r2500_band_lumin value. Unfortunately, I still get a KeyError message but I'm working that out.
I used the user input arguments for the x and y values and define them as x_label and y_label. This is an alternative to def get_data(options): from the master branch.

from clustr.

sweverett avatar sweverett commented on September 15, 2024

I wrote the __getitem__() function of the Config class so that you can access it like a normal dictionary, so you don't need to do config.__getitem__(x_label).

The key error just means that there is no entry for x_label in the config. In the master branch that is because it is passed as a command line argument rather than through the config. Personally I think that is probably the better way, so you can quickly explore different x,y fits on a catalog with the same config settings. But we could move it to the config if you'd like.

Here's the short version of what I'd suggest:

# in main():
args = parser.parse_args()
config = Config(args)

...

# in Config():

def __init__(args):
        self.config_filename = args.config_file
        self.x = args.x
        self.y = args.y

        with open(self.config_filename, 'r') as stream:
            self._config = yaml.safe_load(stream)

        return

This way now constructs a Config purely from the command line arguments. It still grabs the config_file from args, but also grabs other useful things like the x and y names that are passed to fits_label() in the master branch.

from clustr.

Related Issues (20)

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.