Code Monkey home page Code Monkey logo

Comments (5)

joshmoore avatar joshmoore commented on September 12, 2024

I'm not sure I agree, but I could be missing something. If we auto-fill the values with Nones, how would we know if the user chose to not fill something out? Seems whether the values are present or not present you can use params.get("key"): safely, but you'd in addition be able to check "key" in params for the case where the user didn't even set that value.

In what way would you want to loop over the keys so that they should all be present but None?

from openmicroscopy.

carandraug avatar carandraug commented on September 12, 2024

If a not filled option has a value of None, the program will know which options were not filled in. If they are simply removed from the returned params, then it must also know the names of the options that went in. Note that getInputKeys() will also not return their names.

None is exactly what one would expect for a non-specified option. It makes sense to get None when there is no value for an option. On the other hand, not having a key with that name means the option does not exist.

from openmicroscopy.

joshmoore avatar joshmoore commented on September 12, 2024

Sorry, but I'm still missing what you what do in a loop with these keys. Certainly, inputs.get("key") will give you the None you want without an extra check for key existence. Even better, you can pass a default which will be returned whether the user sets nothing or the value is None anyway:

>>> {}.get(2, 3)
3
>>> {1:None}.get(2, 3)
3

from openmicroscopy.

carandraug avatar carandraug commented on September 12, 2024

To use inputs.get("key") requires knowing what the key is. But the keys are defined once when constructing the UI and one should be able to not repeat their names through the rest of the code. In my specific case, the keys are commands for other programs and are all treated equally. I loop over all the keys and their values are the arguments. If the user sets no value for an option, the default is dependent on the image size, number of channels, and z-slices (so I can't make it non-optional).

I know how to work around this (I will have to so it works with 5.0.1). The simplest solution being to duplicate all the key names in a list and if they're missing after getInputs(), fill them with None. But the point is that one sets an option with a specific name, the user decides not to fill it (None), but when I get the list of options and values back, the option. An option without a value is different from a non-existing option. Or maybe I'm wrong. I've been reading a lot about the "pythonic" way and I'm still not sure what that would be in this case.

After creating the client, even forgetting about getting their values, I actually couldn't find a method that would give me the names all types that were used in its construction.

from openmicroscopy.

joshmoore avatar joshmoore commented on September 12, 2024

In my specific case, the keys are commands for other programs and are all treated equally.

That I can certainly understand. Thanks for the example. I'll see if I can add a workaround for what you want to #2460, or if there's not one, at least to record the requirement. Cheers, ~J.

from openmicroscopy.

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.