Title: Implement named arguments and With semantics in C# embedding side by dsuarezv · Pull Request #461 · pythonnet/pythonnet · GitHub
Open Graph Title: Implement named arguments and With semantics in C# embedding side by dsuarezv · Pull Request #461 · pythonnet/pythonnet
X Title: Implement named arguments and With semantics in C# embedding side by dsuarezv · Pull Request #461 · pythonnet/pythonnet
Description: Named Arguments I have implemented support for calling methods using named arguments on the C# side. Say we have this code in Python: yes = numpy.ones(9, dtype = numpy.int) logger = k.callbacks.CSVLogger('log.csv', separator = ',', append = False) Here is how this translated to C# with the old syntax (using keyword arguments in Py): dynamic yes = numpy.ones(9, Py.pw("dtype", numpy.@int)); dynamic logger = k.callbacks.CSVLogger("log.csv", Py.kw("separator", ",", "append", false)); With the new named argument support: dynamic yes = numpy.ones(9, dtype: numpy.@int); dynamic logger = k.callbacks.CSVLogger("log.csv", separator:",", append: false); I think the new syntax has better readability. With semantics Also implemented the semantics of the Python with statement in the embedded side. Take this pice of python code: with tf.device('/cpu:0') as dev: model = GetSequenceModel() model.fit(X, Y, epochs = 150, batch_size = 32) This was tricky to replicate before in embedded C#. Now it can be called like this: Py.With((PyObject)tf.device("/cpu:0"), dev => { dynamic model = GetSequenceModel(); model.fit(X, Y, epochs: 150, batch_size: 32); }); I implemented the semantics of calling enter and exit in context managers as described in the python docs. Tests Some new NUnit tests have been created and added to the embeddingTest project for both named arguments and the new With method. Hope you find it useful for the project.
Open Graph Description: Named Arguments I have implemented support for calling methods using named arguments on the C# side. Say we have this code in Python: yes = numpy.ones(9, dtype = numpy.int) logger = k.callbacks.CSV...
X Description: Named Arguments I have implemented support for calling methods using named arguments on the C# side. Say we have this code in Python: yes = numpy.ones(9, dtype = numpy.int) logger = k.callbacks.CSV...
Opengraph URL: https://github.com/pythonnet/pythonnet/pull/461
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:51e31dc2-d187-5a8a-98b8-57aaa4f50ea7 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | D454:377E29:AD9317:E38C0D:69716C79 |
| html-safe-nonce | f350b54a3003fd141e2163024ee745f4a4547c2d2d1d20950371d2687cfd8d75 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDU0OjM3N0UyOTpBRDkzMTc6RTM4QzBEOjY5NzE2Qzc5IiwidmlzaXRvcl9pZCI6IjQzODQ1MjMxMTY4NTE4NTAzNjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c4aee322cb6bd40974b2beb3a234c941d342b1671f6be7b0ae13d43486c2105e |
| hovercard-subject-tag | pull_request:119816840 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,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/pythonnet/pythonnet/pull/461/checks |
| twitter:image | https://avatars.githubusercontent.com/u/220631?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/220631?s=400&v=4 |
| og:image:alt | Named Arguments I have implemented support for calling methods using named arguments on the C# side. Say we have this code in Python: yes = numpy.ones(9, dtype = numpy.int) logger = k.callbacks.CSV... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 353479110ec1e87d687013548f216c852055ec907d09d2fb6a180cb5ed9d28e1 |
| turbo-cache-control | no-preview |
| go-import | github.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git |
| octolytics-dimension-user_id | 6050430 |
| octolytics-dimension-user_login | pythonnet |
| octolytics-dimension-repository_id | 14748123 |
| octolytics-dimension-repository_nwo | pythonnet/pythonnet |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14748123 |
| octolytics-dimension-repository_network_root_nwo | pythonnet/pythonnet |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a4c7e274c03a115b82dcef6c47ce3f7f903e88e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width