{"id":7560,"date":"2024-02-08T16:55:12","date_gmt":"2024-02-08T07:55:12","guid":{"rendered":"https:\/\/home.hirosaki-u.ac.jp\/relativity\/?p=7560"},"modified":"2024-02-12T15:28:06","modified_gmt":"2024-02-12T06:28:06","slug":"from-sympy-abc-import-%e3%81%99%e3%82%8b%e9%9a%9b%e3%81%ae%e9%a0%86%e7%95%aa","status":"publish","type":"post","link":"https:\/\/home.hirosaki-u.ac.jp\/relativity\/7560\/","title":{"rendered":"from sympy.abc import * \u3059\u308b\u969b\u306e\u9806\u756a\u3068\u8ffd\u8a18\u4e8b\u9805"},"content":{"rendered":"<p>sympy.abc \u306e\u30b3\u30fc\u30c9\u306b\u306f\uff0c<\/p>\n<pre>Caveats\r\n=======\r\n\r\n1. As of the time of writing this, the names ``O``, ``S``, ``I``, ``N``,\r\n``E``, and ``Q`` are colliding with names defined in SymPy. If you import them\r\nfrom both ``sympy.abc`` and ``sympy``, the second import will \"win\".\r\nThis is an issue only for * imports, which should only be used for short-lived\r\ncode such as interactive sessions and throwaway scripts that do not survive\r\nuntil the next SymPy upgrade, where ``sympy`` may contain a different set of\r\nnames.<\/pre>\n<p>\u3068\u3042\u308b\u3002\u307e\u305f\uff0csympy.abc \u306b\u306f\u30ae\u30ea\u30b7\u30e3\u6587\u5b57\u306e\u5927\u6587\u5b57\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u3002\u3057\u305f\u304c\u3063\u3066\uff0c\u4eca\u5f8c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u305f\u3089\u3069\u3046\u304b\uff0c\u3068\u3044\u3046\u30e1\u30e2\u3002<!--more--><\/p>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"prompt input_prompt\"><\/div>\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 id=\"\u5148\u306b-sympy.abc-\u3092-import\">\u5148\u306b sympy.abc \u3092 import<\/h3>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[1]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\" highlight hl-ipython3\">\n<pre><span class=\"c1\"># \u5148\u306b sympy.abc \u3092 import<\/span>\r\n<span class=\"kn\">from<\/span> <span class=\"nn\">sympy.abc<\/span> <span class=\"kn\">import<\/span> <span class=\"o\">*<\/span>\r\n<span class=\"kn\">from<\/span> <span class=\"nn\">sympy<\/span> <span class=\"kn\">import<\/span> <span class=\"o\">*<\/span>\r\n\r\n<span class=\"c1\"># \u5c0f\u6587\u5b57 \u03bb \u306f lamda (lambda \u3068\u306e\u91cd\u8907\u3092\u907f\u3051\u308b\u305f\u3081)<\/span>\r\n<span class=\"c1\"># \u30ae\u30ea\u30b7\u30e3\u6587\u5b57\u306e\u5927\u6587\u5b57\u306f\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\uff0c\u3044\u304f\u3064\u304b\u8ffd\u52a0<\/span>\r\n<span class=\"n\">Gamma<\/span><span class=\"p\">,<\/span> <span class=\"n\">Delta<\/span><span class=\"p\">,<\/span> <span class=\"n\">Theta<\/span><span class=\"p\">,<\/span> <span class=\"n\">Lambda<\/span><span class=\"p\">,<\/span> <span class=\"n\">Pi<\/span> <span class=\"o\">=<\/span> <span class=\"n\">symbols<\/span><span class=\"p\">(<\/span><span class=\"s1\">'Gamma, Delta, Theta, Lambda, Pi'<\/span><span class=\"p\">)<\/span>\r\n<span class=\"n\">Sigma<\/span><span class=\"p\">,<\/span> <span class=\"n\">Phi<\/span><span class=\"p\">,<\/span> <span class=\"n\">Psi<\/span><span class=\"p\">,<\/span> <span class=\"n\">Omega<\/span> <span class=\"o\">=<\/span> <span class=\"n\">symbols<\/span><span class=\"p\">(<\/span><span class=\"s1\">'Sigma, Phi, Psi, Omega'<\/span><span class=\"p\">)<\/span>\r\n\r\n<span class=\"n\">init_printing<\/span><span class=\"p\">()<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"prompt input_prompt\"><\/div>\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p><code>N()<\/code> \u3082\u4f7f\u3048\u308b\u3057\uff0c<code>pi<\/code>, <code>E<\/code> \u3082\u4f7f\u3048\u308b\u3002<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[2]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\" highlight hl-ipython3\">\n<pre><span class=\"n\">N<\/span><span class=\"p\">(<\/span><span class=\"n\">pi<\/span><span class=\"p\">)<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt output_prompt\">Out[2]:<\/div>\n<div class=\"output_latex output_subarea output_execute_result\">$\\displaystyle 3.14159265358979$<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[3]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\" highlight hl-ipython3\">\n<pre><span class=\"n\">N<\/span><span class=\"p\">(<\/span><span class=\"n\">E<\/span><span class=\"p\">)<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt output_prompt\">Out[3]:<\/div>\n<div class=\"output_latex output_subarea output_execute_result\">$\\displaystyle 2.71828182845905$<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"prompt input_prompt\"><\/div>\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 id=\"\u30ae\u30ea\u30b7\u30a2\u6587\u5b57\u306e\u5927\u6587\u5b57\u3082\u5b9a\u7fa9\u3055\u308c\u308b\">\u30ae\u30ea\u30b7\u30a2\u6587\u5b57\u306e\u5927\u6587\u5b57\u3082\u5b9a\u7fa9\u3055\u308c\u308b<\/h3>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[4]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\" highlight hl-ipython3\">\n<pre><span class=\"n\">lamda<\/span><span class=\"p\">,<\/span> <span class=\"n\">Lambda<\/span><span class=\"p\">,<\/span> <span class=\"n\">Sigma<\/span><span class=\"p\">,<\/span> <span class=\"n\">Omega<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt output_prompt\">Out[4]:<\/div>\n<div class=\"output_latex output_subarea output_execute_result\">$\\displaystyle \\left( \\lambda, \\ \\Lambda, \\ \\Sigma, \\ \\Omega\\right)$<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>sympy.abc \u306e\u30b3\u30fc\u30c9\u306b\u306f\uff0c<\/p>\n<p> Caveats ======= 1. As of the time of writing this, the names &#8220;O&#8220;, &#8220;S&#8220;, &#8220;I&#8220;, &#8220;N&#8220;, &#8220;E&#8220;, and &#8220;Q&#8220; are colliding with names defined in SymPy. If you import them from both &#8220;sympy.abc&#8220; and &#8220;sympy&#8220;, the second import will &#8220;win&#8221;. This is an issue only for * imports, which should only be used for short-lived code such as interactive sessions and throwaway scripts that do not survive until the next SymPy upgrade, where &#8220;sympy&#8220; may contain a different set of names. <\/p>\n<p>\u3068\u3042\u308b\u3002\u307e\u305f\uff0csympy.abc \u306b\u306f\u30ae\u30ea\u30b7\u30e3\u6587\u5b57\u306e\u5927\u6587\u5b57\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u3002\u3057\u305f\u304c\u3063\u3066\uff0c\u4eca\u5f8c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u305f\u3089\u3069\u3046\u304b\uff0c\u3068\u3044\u3046\u30e1\u30e2\u3002<\/p>\n","protected":false},"author":33,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[12],"tags":[],"class_list":["post-7560","post","type-post","status-publish","format-standard","hentry","category-sympy","nodate","item-wrap"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/home.hirosaki-u.ac.jp\/relativity\/wp-json\/wp\/v2\/posts\/7560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/home.hirosaki-u.ac.jp\/relativity\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/home.hirosaki-u.ac.jp\/relativity\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/home.hirosaki-u.ac.jp\/relativity\/wp-json\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/home.hirosaki-u.ac.jp\/relativity\/wp-json\/wp\/v2\/comments?post=7560"}],"version-history":[{"count":7,"href":"https:\/\/home.hirosaki-u.ac.jp\/relativity\/wp-json\/wp\/v2\/posts\/7560\/revisions"}],"predecessor-version":[{"id":7594,"href":"https:\/\/home.hirosaki-u.ac.jp\/relativity\/wp-json\/wp\/v2\/posts\/7560\/revisions\/7594"}],"wp:attachment":[{"href":"https:\/\/home.hirosaki-u.ac.jp\/relativity\/wp-json\/wp\/v2\/media?parent=7560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/home.hirosaki-u.ac.jp\/relativity\/wp-json\/wp\/v2\/categories?post=7560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/home.hirosaki-u.ac.jp\/relativity\/wp-json\/wp\/v2\/tags?post=7560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}