Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create "block off" or something to comment or remove a block of nml #156

Closed
jordansread opened this issue Mar 17, 2015 · 13 comments
Closed

Comments

@jordansread
Copy link
Member

function to easily turn off (for example) aed part of the sim

@lawinslow
Copy link
Member

@dzrobert upvotes this

@jordansread
Copy link
Member Author

@lawinslow got any suggestions for the syntax on this? I think I can implement it (and will self-assign), but should this be an arg in set_nml, or a different function?

@lawinslow
Copy link
Member

No clue, would we be able to turn it back on? If not, it seems you'd just need a rm_nml_block or something function. Otherwise, toggle or enable/disable would be nice functionality.

@jordansread
Copy link
Member Author

the complexity of this wildly varies depending on whether we want "switch off" vs "toggle on/off". If it is a toggle, it is kind of more in-line with the support of comments in #139

@lawinslow
Copy link
Member

Yeah, I know. @dzrobert, would just rm_nml_block be helpful? Or do you want to toggle it on and off?

@jordansread
Copy link
Member Author

@hdugan did you have a use-case for this, or does it not apply to your workflow?

@jordansread
Copy link
Member Author

@lawinslow I think I may add the rm_nml_block and then a quick add_nml_block that accepts a list of depth = 1. To get fancy, the return of rm_nml_block could be an invisible list of that block that was removed, so if you wanted to toggle:

aed_block <- rm_nml_block(glm_nml, 'wq_setup')
#...write glm etc
# run sim w/ aed off
add_nml_block(glm_nml, aed_block)
# run sim w/ aed off

ugg, nevermind, that won't work w/ pass by copy.

Would actually need to do a much uglier:

aed_block <- glm_nml['wq_setup']
glm_nml<- rm_nml_block(glm_nml, 'wq_setup')
#...write glm etc
# run sim w/ aed off
add_nml_block(glm_nml, aed_block)
# run sim w/ aed off

Other ideas to support a toggle without a major overhaul?

@lawinslow
Copy link
Member

Ok, how about this

#this gets a block
cached_block = glm_nml['&wq_setup'] 

#this sets a new block or overwrites one with that name
glm_nml['&wq_2_setup'] = cached_block

#this removes a block
glm_nml['&wq_setup'] = NULL

#this gets a value for a variable in a specific block (supporting AED files)
glm_nml['&wq_setup/variable']

#this sets that variable inside the block
glm_nml['&wq_setup/variable'] = newvalue

#this works just like get_nml_value
glm_nml['variable']

#This works jus tlike set_nml
glm_nml['variable'] = 'some new value'

Thoughts?

@jordansread
Copy link
Member Author

I like this a lot.

Personally, I do like going with
glm_nml['&wq_setup::variable'] = newvalue
to follow R's hierarchy for package::function, instead of treating it like xpath. I would like to converge on something though, because I am using something similar in geoknife to do quick feature grabs (webgeom('state::NH') for the state of New Hampshire; similar for ecoregions, etc.) I would like to have consistency w/ this too.

@jordansread
Copy link
Member Author

Curious though, @lawinslow - is this kind of thing possible with the [ generic?

glm_nml['variable','variable_2'] = c('some new value','other new value')

@lawinslow
Copy link
Member

It would be possible, but maybe not desirable given the conflation of dimensionality.

How about

glm_nml[c('variable','variable_2')] = c('some new value','other new value')

@jordansread
Copy link
Member Author

yes, that works for me

@jordansread
Copy link
Member Author

Closing for #255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants