Title: Autocompletion on rcParams: long-overdue restructuring of rcParams · Issue #2249 · matplotlib/matplotlib · GitHub
Open Graph Title: Autocompletion on rcParams: long-overdue restructuring of rcParams · Issue #2249 · matplotlib/matplotlib
X Title: Autocompletion on rcParams: long-overdue restructuring of rcParams · Issue #2249 · matplotlib/matplotlib
Description: It would be great to have autocompletion on rcParams (or settings) in IPython, so you could do settings["fon
Open Graph Description: It would be great to have autocompletion on rcParams (or settings) in IPython, so you could do settings["fon
X Description: It would be great to have autocompletion on rcParams (or settings) in IPython, so you could do settings["fon<TAB>"] and get a list of all keys containing the string "fon"....
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/2249
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Autocompletion on rcParams: long-overdue restructuring of rcParams","articleBody":"It would be great to have autocompletion on `rcParams` (or `settings`) in IPython, so you could do\n\n```\nsettings[\"fon\u003cTAB\u003e\"]\n```\n\nand get a list of all keys containing the string \"fon\".\nThis would be another tool to get people modifying settings.\n\nCurrently there is no completion on dictionary keys in IPython -- I am hoping to implement this this week.\n\nHowever, a nicer solution, in my opinion, is attribute access, so you could do e.g.\n\n```\nsettings.xtick.color = 'b'\n```\n\nThis is easy to implement by hand. But it turns out that it is already implemented in IPython! Even if in a slightly obscure (but super-general so nothing done by hand) way:\n\n```\nfrom matplotlib import rcParams\nfrom IPython.config import Config\n\nsettings = Config(rcParams)\n```\n\nYou can now _automatically_ use the `settings.xtick.color` syntax _and_ completion!:\n\n```\nsettings.xtic\u003cTAB\u003e\n```\n\ngives a list of all the settings starting with `xtic`. (See below for more completion magic).\n\n_However_, there is a problem with the names of the `rcParams` keys using `.` as a separator, namely that doing\n\n```\nsettings.xtick.\u003cTAB\u003e\n```\n\nno longer completes anything. This is because it is treating `settings.xtick` as a subdictionary or subclass.\n\nThere are 2 possible solutions:\n1. Change the names of the `settings` keys, e.g. to xtick_minor_pad. Yuck.\n2. An excellent solution -- not just for this autocompletion problem -- is the following:\n\nReally turn the sequence of names including `.`s in the string in the attribute-access pattern into _real sub-dictionaries_ of `rcParams`.\n\nOf course, this makes the dictionary key syntax horrible, but there would be no longer be any need for it -- we would just switch over wholesale to the `.` attribute syntax.\n\nOf course, this breaks some backward compatibility, but it gives a much more logical structure to rcParams as a whole.\n[And, thinking about it, it should be possible to rewrite the dictionary access functions so that the old key accesses still work!]\n\nOf course, the magic going on in the IPython.config module is easily extractable straight in to rcParams, in case somebody is worried that this depends on IPython.\n\n------- [Comments on future IPython command completion possibilities below]\n\nIn fact, I have a mod for IPython's command completion which completes any word containing the letters that you type in a certain order. Here is the output for\n\n```\nsettings.fon\u003cTAB\u003e:\n```\n\n```\nsettings.figure.frameon settings.legend.fontsize\nsettings.figure.max_open_warning settings.legend.frameon\nsettings.font.cursive settings.mathtext.fontset\nsettings.font.family settings.pdf.compression\nsettings.font.fantasy settings.pdf.fonttype\nsettings.font.monospace settings.pdf.use14corefonts\nsettings.font.sans-serif settings.pgf.rcfonts\nsettings.font.serif settings.ps.fonttype\nsettings.font.size settings.savefig.extension\nsettings.font.stretch settings.savefig.frameon\nsettings.font.style settings.savefig.orientation\nsettings.font.variant settings.svg.fonttype\nsettings.font.weight \n```\n\nIt includes things that don't _start_ with `fon` but contain the sequence of characters `f`, `o`, `n` in that order.\n\nAn alternative is to just search for the word `fon`, without splitting up the characters.\nI hope to submit an IPython pull request soon. It will be possible to change between these different types of completion mechanism with a standard IPython configuration method.\n","author":{"url":"https://github.com/dpsanders","@type":"Person","name":"dpsanders"},"datePublished":"2013-07-24T13:08:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/2249/matplotlib/issues/2249"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:898aa1c5-002c-7514-aa9b-75ca746c345d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E4AA:23767B:12B8194:1B1ED4B:6A54D446 |
| html-safe-nonce | bcf1b9bc081c91fab21f139429867f53e76438629101c004bba2cd62b16ba36d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNEFBOjIzNzY3QjoxMkI4MTk0OjFCMUVENEI6NkE1NEQ0NDYiLCJ2aXNpdG9yX2lkIjoiNjE1NjUyNzE3NzUyMzU4MjAyMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cd4b792944025a4ac18ec14ff30fcdf863f8b782f569ebbd38ee72e440632d69 |
| hovercard-subject-tag | issue:17155294 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/2249/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f834216f6d84ce7008f8c9655fb4ccb83736a0741772fee5d5bd3043f6463d1f/matplotlib/matplotlib/issues/2249 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f834216f6d84ce7008f8c9655fb4ccb83736a0741772fee5d5bd3043f6463d1f/matplotlib/matplotlib/issues/2249 |
| og:image:alt | It would be great to have autocompletion on rcParams (or settings) in IPython, so you could do settings["fon |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dpsanders |
| hostname | github.com |
| expected-hostname | github.com |
| None | a556215b071af6609619e2bbe6f00bdfbf0812ad723b1ae6c301858a7a829f54 |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 840b5d20d5a883c23cf56f5240b2c343d6cc0867 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width