我正在尝试将我的角度2项目从2.0.0升级到2.4.1.据我所知,自2.0.0版本开始采用语义版本控制,2.xx版本应该是替代版本.我的经验似乎表明不是这样.也许我只是不知道我在做什么,但我没有发现这是直截了当的......
我天真的第一种方法是手动更新我的@angular依赖项.您可以在下面引用我的package.json(更新1).我做了这些更改,然后做了一个2.0.0
,我收到了几个警告,然后当我尝试做一个时出现以下错误2.4.1
.
无法读取未定义的属性'AssetUrl'
我的警告......
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.15: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN @angular/core@2.4.1 requires a peer of rxjs@^5.0.1 but none was installed.
npm WARN @angular/core@2.4.1 requires a peer of zone.js@^0.7.2 but none was installed.
npm WARN @angular/http@2.4.1 requires a peer of rxjs@^5.0.1 but none was installed.
npm WARN @angular/compiler-cli@0.6.4 requires a peer of @angular/compiler@2.0.2 but none was …
Run Code Online (Sandbox Code Playgroud) 有没有办法用Python在MATLAB中创建一系列数字,使用简单的语法,即不使用循环.例如:
MATLAB:
a = 1:0.5:10
给
a = [1 1.5 2 2.5 3 3.5 .... 9.5 10]
这个问题类似于将列表切割成子列表列表,但在我的情况下,我希望包含每个前一个子列表的最后一个元素,作为下一个子列表中的第一个元素.并且必须考虑到最后一个元素总是至少有两个元素.
例如:
list_ = ['a','b','c','d','e','f','g','h']
Run Code Online (Sandbox Code Playgroud)
3号子列表的结果:
resultant_list = [['a','b','c'],['c','d','e'],['e','f','g'],['g','h']]
Run Code Online (Sandbox Code Playgroud) 您好我遇到了问题.当我尝试导航到不被允许的页面时,我的CanActivate警卫会被调用两次,因为我没有登录.
我有1个根模块,并提供了我的CanActivate后卫和其他服务.
先感谢您!
这是我的路由器:
const appRoutes: Routes = [
{
path: "",
pathMatch: "full",
redirectTo: "/meal-list",
},
{
path: "login",
component: LoginComponent,
},
{
path: "meal-list",
component: MealListComponent,
canActivate: [AuthActivateGuard],
}
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes, {useHash: true});
Run Code Online (Sandbox Code Playgroud)
守卫:
@Injectable()
export class AuthActivateGuard implements CanActivate {
constructor(private authService: AuthService,
private router: Router) {
console.log("guard created");
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean>|boolean {
if (!this.authService.authenticated) {
return this.authService.checkLogged().map(res => {
this.authService.authenticated = true;
return true;
}).catch(()=> {
this.authService.authenticated = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将我清理过的(并使用 kfold 拆分数据)上传到 s3,以便我可以使用 sagemaker 创建一个使用它的模型(因为 sagemaker 想要一个包含训练和测试数据的 s3 文件)。但是,每当我尝试将 csv 上传到 s3 时,它都会运行,但我在 s3 中看不到该文件。
我曾尝试更改我在 sagemaker 中访问的文件夹,或者尝试上传不同类型的文件,但这些文件都不起作用。此外,我在类似的 Stack Overflow 帖子中尝试了这些方法,但没有成功。
另请注意,我可以手动将我的 csv 上传到 s3,而不是通过 sagemaker 自动上传。
下面的代码是我目前必须上传到 s3 的,我是直接从 AWS 文档中复制的,用于使用 sagemaker 上传文件。
import io
import csv
import boto3
#key = "{}/{}/examples".format(prefix,data_partition_name)
#url = 's3n://{}/{}'.format(bucket, key)
name = boto3.Session().resource('s3').Bucket('nc-demo-sagemaker').name
print(name)
boto3.Session().resource('s3').Bucket('nc-demo-sagemaker').upload_file('train', '/')
print('Done writing to {}'.format('sagemaker bucket'))
Run Code Online (Sandbox Code Playgroud)
我希望当我运行该代码片段时,我能够将训练和测试数据上传到我想要用于创建 sagemaker 模型的文件夹中。
我试图让模态每周只弹出一次。
我正在使用 Wordpress 和 Roots 主题,并且正确地将脚本排队和注册。
我的模态代码是
<div class="modal hide fade modalborder" id="myModal">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<div class="modal-body">
<h2 class="modalheader">Header Here</h2>
<p class="modalcoffee">Text here</p>
<p class="modalcomesin">Text here</p>
</div>
<p class="modallearn">Text Here</p>
<p class="modalready">Are you ready to <span class="modalstart">start</span>?</p>
<a href="#" class="btn btn-info">Click Here</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
使这个节目完美运行的当前javascript:
<script type="text/javascript">
$(window).load(function(){
$('#myModal').modal('show');
});
</script>
Run Code Online (Sandbox Code Playgroud)
我对 jQuery 和 javascript 知之甚少。我需要做什么才能使用 cookie 进行这项工作?
嗨,我必须扩大向量内部的点数才能将向量放大到固定大小。例如:
对于这个简单的向量
>>> a = np.array([0, 1, 2, 3, 4, 5])
>>> len(a)
# 6
Run Code Online (Sandbox Code Playgroud)
现在,我想得到一个大小为 11 的a
向量,以向量为基础,结果将是
# array([ 0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5, 5. ])
Run Code Online (Sandbox Code Playgroud)
编辑 1
我需要的是一个函数,它将输入基本向量和必须是结果向量的值的数量,然后我返回一个大小等于参数的新向量。就像是
def enlargeVector(vector, size):
.....
return newVector
Run Code Online (Sandbox Code Playgroud)
使用像:
>>> a = np.array([0, 1, 2, 3, 4, 5])
>>> b = enlargeVector(a, 200):
>>> len(b)
# 200
Run Code Online (Sandbox Code Playgroud)
b 包含线性、三次或任何插值方法的数据结果
我想创建一个大小的方阵,n x n
其中对角元素和左对角线都等于1.其余元素等于0.
例如,如果矩阵为5 x 5,这将是预期的结果:
1 0 0 0 0
1 1 0 0 0
0 1 1 0 0
0 0 1 1 0
0 0 0 1 1
Run Code Online (Sandbox Code Playgroud)
我怎么能在MATLAB中做到这一点?
我正在尝试创建一个简单的可插入 FastAPI 应用程序,其中插件可以添加或不添加 API 端点
这是我的文件夹结构:
服务器.py
import importlib
import pkgutil
from pathlib import Path
import uvicorn
from fastapi import FastAPI
PLUGINS_PATH = Path(__file__).parent.joinpath("plugins")
app = FastAPI()
def import_module(module_name):
"""Imports a module by it's name from plugins folder."""
module = f"plugins.{module_name}"
return importlib.import_module(module, ".")
def load_plugins() -> list:
"""Import plugins from plugins folder."""
loaded_apps = []
for _, application, _ in pkgutil.iter_modules([str(PLUGINS_PATH)]):
module = import_module(application)
print(
f"Loaded app: {module.__meta__['plugin_name']} -- version: {module.__meta__['version']}"
)
loaded_apps.append(module)
return loaded_apps
@app.get("/")
def main():
return …
Run Code Online (Sandbox Code Playgroud)