就像标题所说的那样,我正在尝试为我已定义的类包含其他类我定义的对象的对象编写自定义解码器."外部"类是Edge,定义如下:
class Edge:
def __init__(self, actor, movie):
self.actor = actor
self.movie = movie
def __eq__(self, other):
if (self.movie == other.movie) & (self.actor == other.actor):
return True
else:
return False
def __str__(self):
print("Actor: ", self.actor, " Movie: ", self.movie)
def get_actor(self):
return self.actor
def get_movie(self):
return self.movie
Run Code Online (Sandbox Code Playgroud)
与"内部"类的actor和电影定义如下:
class Movie:
def __init__(self, title, gross, soup, year):
self.title = title
self.gross = gross
self.soup = soup
self.year = year
def __eq__(self, other):
if self.title == other.title:
return True
else:
return False
def …Run Code Online (Sandbox Code Playgroud) 我在这里要完成的是合并这两个教程(x)(x),以创建一个具有自定义图标的简单TabBar.我正在尝试使用react-native-vector-icons库中的图标,我已将其添加到我的节点模块中.但是,我遇到了一个障碍:
不变违规:元素类型无效:期望一个字符串(对于内置的>组件)或一个类/函数(对于复合组件)但得到:undefined.您可能忘记从其定义的文件中导出组件,或者您可能混淆了默认导入和命名导入.
检查ProfileTabs的render方法.
此错误位于:在RCTTabBar中(在TabBarIOS.ios.js:82)
在TabBarIOS中(在App.js:19)
在ProfileTabs中(在App.js:80)
在ProfileApp中(在registerRootComponent.js:35)
在RootErrorBoundary中(在registerRootComponent.js:34)
这是相关的代码:
import React, { Component } from 'react';
import { AppRegistry, Image, StyleSheet, TabBarIOS, Text, View } from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';
var Profile = require('./profile');
var Repositories = require('./repositories');
var Following = require('./following');
var Followers = require('./followers');
class ProfileTabs extends Component {
constructor(props) {
super(props);
this.state = {
selectedTab: 'profile'
};
}
render() {
return (
<TabBarIOS
selectedTab={this.state.selectedTab}>
<Icon.TabBarIOS
selected={this.state.selectedTab === 'profile'}
title="Profile"
iconName='ios-home-outline'
onPress={() => { …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作具有数百条边的 networkx 图:
def generate_network_graph(graph):
visual_graph = networkx.Graph()
for edge in graph.edges:
visual_graph.add_edge(edge.actor.name, edge.movie.title)
plt.figure(3, figsize=(30, 30))
networkx.spring_layout(visual_graph, k=0.9, iterations=20)
networkx.draw_spring(visual_graph)
plt.show()
Run Code Online (Sandbox Code Playgroud)
然而,无论我似乎将 k 增加多少,我的图表看起来都像一团糟:
我不知道还能做什么来防止节点重叠;我尝试了从 0.0 到 5.0 的 k 值范围。我考虑过减小节点的大小,但我不确定这是否只会使图表的可读性降低。不仅如此,重新生成这个图需要很长的时间,大约 15 分钟。我只是没有使用正确的图形库来完成这项工作吗?或者有什么我可以修改以使我的图表更清晰的东西。
python-3.x ×2
decoder ×1
javascript ×1
json ×1
networkx ×1
python ×1
react-native ×1
tabbar ×1