Not yet ready for use. APIs subject to change without notice

本文介绍如何在Tapestry4.1中创建自定义Dojo组件,并解决运行时出现的未准备好使用API警告。通过具体代码示例展示了组件的实现过程。
在tapestry4.1中创建自己的jodo组件,运行的时候,有这样的提示,Not yet ready for use. APIs subject to change without notice不知道是什么东东,有哪位可以指教一下,代码如下
Circles.script
xml 代码
 
  1. xml version="1.0"?>  
  2.   "-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"  
  3.   "http://tapestry.apache.org/dtd/Script_3_0.dtd">  
  4. <script>  
  5.   
  6.     <body>  
  7.         <unique>  
  8.             dojo.require("dojo.gfx.*");  
  9.         unique>  
  10.     body>  
  11.   
  12. script>  

Circles.jwc
xml 代码
 
  1. xml version="1.0" encoding="UTF-8"?>  
  2.    Copyright 2004, 2005, 2006 The Apache Software Foundation  
  3.   
  4.    Licensed under the Apache License, Version 2.0 (the "License");  
  5.    you may not use this file except in compliance with the License.  
  6.    You may obtain a copy of the License at  
  7.   
  8.        http://www.apache.org/licenses/LICENSE-2.0  
  9.   
  10.    Unless required by applicable law or agreed to in writing, software  
  11.    distributed under the License is distributed on an "AS IS" BASIS,  
  12.    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  13.    See the License for the specific language governing permissions and  
  14.    limitations under the License.  
  15. -->  
  16.   
  17.         "-//Apache Software Foundation//Tapestry Specification 4.0//EN"  
  18.         "http://tapestry.apache.org/dtd/Tapestry_4_0.dtd">  
  19.   
  20. <component-specification class="myComponent.Circles"  
  21.                          allow-body="yes" allow-informal-parameters="yes">  
  22.   
  23.     <description>  
  24.         Creates a modal Circles.  
  25.     description>  
  26.     <inject property="script" type="script" object="Circles.script"/>  
  27.   
  28. component-specification>  

Circles.java
java 代码
 
  1. package myComponent;  
  2.   
  3. import java.util.HashMap;  
  4. import java.util.Map;  
  5.   
  6. import org.apache.tapestry.IMarkupWriter;  
  7. import org.apache.tapestry.IRequestCycle;  
  8. import org.apache.tapestry.IScript;  
  9. import org.apache.tapestry.PageRenderSupport;  
  10. import org.apache.tapestry.TapestryUtils;  
  11. import org.apache.tapestry.dojo.form.IFormWidget;  
  12. import org.apache.tapestry.form.AbstractFormComponent;  
  13.   
  14. public  abstract class Circles extends AbstractFormComponent implements IFormWidget  
  15. {  
  16.   
  17. public abstract void setDestroy(boolean destroy);  
  18. public abstract IScript getScript();  
  19.   
  20. public abstract String getClientId();  
  21.   
  22. public abstract void setClientId(String id);  
  23. /** 
  24.  * Determined dynamically at runtime during rendering, informs widget implementations 
  25.  * if they should destroy their client side widget equivalents or leave them in tact. 
  26.  *  
  27.  * @return True if the widget should be destroyed on this render, false otherwise. 
  28.  */  
  29. public abstract boolean getDestroy();  
  30.   
  31. /** 
  32.  * {@inheritDoc} 
  33.  */  
  34. public void renderWidget(IMarkupWriter writer, IRequestCycle cycle)  
  35. {  
  36.     renderComponent(writer, cycle);  
  37. }  
  38.   
  39. /** 
  40.  * {@inheritDoc} 
  41.  */  
  42. protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)  
  43. {  
  44.     if(!cycle.isRewinding()) {  
  45.           
  46.         if (!cycle.getResponseBuilder().isDynamic()   
  47.                 || cycle.getResponseBuilder().explicitlyContains(this)) {  
  48.               
  49.             setDestroy(false);  
  50.         } else  
  51.             setDestroy(true);  
  52.     }  
  53.       
  54.     // don't render if not part of update response  
  55.       
  56.     if (cycle.getResponseBuilder().isDynamic()  
  57.             && (!cycle.getResponseBuilder().explicitlyContains(this)   
  58.                     && !cycle.getResponseBuilder().contains(this))) {  
  59.           
  60.         return;  
  61.     }  
  62.       
  63.     renderFormWidget(writer, cycle);  
  64. }  
  65.   
  66. /** 
  67.  * {@inheritDoc} 
  68.  */  
  69. protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)  
  70. {  
  71.     rewindFormWidget(writer, cycle);  
  72. }  
  73.   
  74. /** 
  75.  * Called when rendering a form widget.  
  76.  *  
  77.  * @param writer 
  78.  *          The markup writer to render with. 
  79.  * @param cycle 
  80.  *          The cycle associated with request. 
  81.  */  
  82. protected void renderFormWidget(IMarkupWriter writer, IRequestCycle cycle)  
  83. {  
  84.     Map parms = new HashMap();  
  85.     parms.put("id", getClientId());  
  86.     parms.put("widget"this);  
  87.     PageRenderSupport pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, this);  
  88.     getScript().execute(this , cycle, pageRenderSupport , parms);  
  89. }  
  90.   
  91. /** 
  92.  * Called during form submission to retrieve submitted input values.  
  93.  * Components should do any validation/retrieval of values in this method.  
  94.  *  
  95.  * @param writer 
  96.  *          The passed in {@link IMarkupWriter} will be a {@link NullMarkupWriter}, making  
  97.  *          any content written ignored.  
  98.  * @param cycle 
  99.  *           Typically used to retrieve submitted value via cycle.getParameter(getName()). 
  100.  */  
  101. protected void rewindFormWidget(IMarkupWriter writer, IRequestCycle cycle)  
  102. {  
  103. }  
  104.   
  105. }  


application文件
xml 代码
 
  1. xml version="1.0"?>  
  2.   
  3.   "-//Apache Software Foundation//Tapestry Specification 4.0//EN"   
  4.   "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">  
  5.       
  6. <application name="workbench">  
  7.   <meta key="org.apache.tapestry.visit-class" value="org.apache.tapestry.workbench.Visit"/>  
  8.   <meta key="org.apache.tapestry.template-encoding" value="ISO-8859-1"/>  
  9.   <meta key="org.apache.tapestry.page-class-packages" value="org.apache.tapestry.workbench"/>  
  10.   <meta key="org.apache.tapestry.component-class-packages" value="org.apache.tapestry.workbench.components"/>  
  11.           
  12.   <library id="contrib" specification-path="classpath:/org/apache/tapestry/contrib/Contrib.library"/>  
  13.     
  14.   
  15.   
  16.   
  17.    <page name="Home" specification-path="/WEB-INF/home/Home.page"/>  
  18.    <page name="Page1" specification-path="/WEB-INF/pages/Page1.page"/>  
  19.      
  20.    <component-type type="Circles" specification-path="/myComponent/Circles.jwc"/>  
  21. application>  

代码就是这些,如有哪位高手遇到过这个问题,希望可以帮忙一下.
PyTorch 中的命名张量(Named Tensors)是一项实验性功能,旨在为张量的维度提供语义化的命名,从而提高代码的可读性和可维护性。然而,由于该功能仍处于实验阶段,因此在使用时可能会遇到以下警告信息: ``` UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. ``` 该警告表明命名张量的功能尚未完全稳定,可能会在未来版本中发生变化,因此不建议在生产环境中使用。 ### 使用命名张量的基本方式 可以通过 `torch.tensor` 或 `torch.randn` 等函数创建命名张量,并通过 `names` 参数指定维度名称: ```python import torch # 创建一个带有命名维度的张量 x = torch.randn(3, 5, names=('batch', 'features')) print(x.names) # 输出: ('batch', 'features') ``` ### 禁用警告 如果希望在开发过程中暂时忽略该警告,可以使用 Python 的 `warnings` 模块来过滤掉特定的警告信息: ```python import warnings # 忽略命名张量的实验性功能警告 warnings.filterwarnings("ignore", category=UserWarning, module="torch") # 现在创建命名张量不会触发警告 x = torch.randn(3, 5, names=('batch', 'features')) ``` ### 替代方案 由于命名张量仍处于实验阶段,如果需要稳定的维度命名功能,可以考虑使用其他库(如 `xarray`)来处理带有语义维度的数据。`xarray` 提供了类似于 NumPy 的多维数组结构,并支持维度名称和坐标标签。 ```python import xarray as xr import numpy as np # 使用 xarray 创建带有命名维度的数据 data = xr.DataArray(np.random.randn(3, 5), dims=('batch', 'features')) print(data) ``` ### 注意事项 - 命名张量的功能可能会在未来的 PyTorch 版本中发生变化,因此在使用时应密切关注官方文档和更新日志[^1]。 - 如果项目需要长期维护或部署到生产环境,建议避免依赖实验性功能,以减少潜在的兼容性问题[^1]。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值