我是 Python 静态类型模块的新手mypy。我试图将整数和浮点数附加到一个数组中,我静态地将其输入为 Real。但mypy说它们是与 Real 不兼容的类型。我认为整数和浮点数是实数的子类型?
from typing import List
from numbers import Real
data : List[Real] = []
with open(path, 'r') as file:
for line in file:
line = line.strip()
if subject == 'time':
data.append(float(line))
else:
data.append(int(line))
Run Code Online (Sandbox Code Playgroud)
错误信息:
from typing import List
from numbers import Real
data : List[Real] = []
with open(path, 'r') as file:
for line in file:
line = line.strip()
if subject == 'time':
data.append(float(line))
else:
data.append(int(line))
Run Code Online (Sandbox Code Playgroud) 我已经安装了 vcpkg,一个 C++ 包管理器。现在过了一段时间,我想更新一下。我怎样才能做到这一点?我需要卸载并重新安装吗?
以下片段来自教程https://cnvrg.io/graph-neural-networks/。如何可视化 中的图表dataset?如果可能的话,使用类似的东西matplotlib。
import dgl
import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl.data
dataset = dgl.data.CoraGraphDataset()
g = dataset[0]
Run Code Online (Sandbox Code Playgroud)