Skip to content

Commit eca2168

Browse files
terapyonterapyon
authored andcommitted
comment and sample from Japanese to English and remove some coment in
code
1 parent 7966c9e commit eca2168

File tree

10 files changed

+23
-52
lines changed

10 files changed

+23
-52
lines changed

CHANGES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Changelog
22

3-
## 0.4.0 (2025-XX-XX)
3+
## 0.4.0 (2025-11-21)
44

5-
**Major Release: Migration to MIME Renderer Architecture**
5+
**Major Release: Migration to MIME Renderer Architecture** (terapyon)
66

77
### Breaking Changes
88

net_vis/tests/test_netvis.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def test_netvis_creation_with_str():
2828
assert w.value == data
2929

3030

31-
# T010: MIME bundle tests
3231
def test_netvis_mimebundle():
3332
"""Test that NetVis returns correct MIME bundle for JupyterLab."""
3433
data = '{"nodes": [{"id": "A"}], "links": []}'
@@ -56,7 +55,6 @@ def test_netvis_mimebundle():
5655
assert isinstance(bundle["text/plain"], str)
5756

5857

59-
# T011: Error handling tests
6058
def test_netvis_invalid_json():
6159
"""Test that invalid JSON raises ValueError."""
6260
with pytest.raises(ValueError, match="Invalid JSON format"):
@@ -91,7 +89,6 @@ def test_netvis_missing_links():
9189
NetVis(value=data)
9290

9391

94-
# T020: Empty data handling test
9592
def test_empty_data_handling():
9693
"""Test that NetVis can be created with empty string and returns correct MIME bundle."""
9794
# Create NetVis with empty string
@@ -108,7 +105,6 @@ def test_empty_data_handling():
108105
assert "version" in mime_data
109106

110107

111-
# T032: MIME bundle structure validation (enhanced from existing test_netvis_mimebundle)
112108
def test_repr_mimebundle_structure():
113109
"""Test that _repr_mimebundle_() returns correct structure with all required fields."""
114110
data = '{"nodes": [{"id": "A"}, {"id": "B"}], "links": [{"source": "A", "target": "B"}]}'
@@ -133,7 +129,6 @@ def test_repr_mimebundle_structure():
133129
assert mime_data["version"] == __version__
134130

135131

136-
# T033: Plain text fallback test
137132
def test_plain_text_fallback():
138133
"""Test that MIME bundle includes text/plain fallback for environments without custom renderer."""
139134
data = '{"nodes": [{"id": "A"}], "links": []}'
@@ -150,7 +145,6 @@ def test_plain_text_fallback():
150145
assert "NetVis" in bundle["text/plain"]
151146

152147

153-
# T034: Multiple instances independence test
154148
def test_multiple_instances():
155149
"""Test that multiple NetVis instances maintain independent state."""
156150
data1 = '{"nodes": [{"id": "A"}], "links": []}'
@@ -178,7 +172,6 @@ def test_multiple_instances():
178172
assert w2.value == data2 # w2 unchanged
179173

180174

181-
# T069: Large graph test (SC-008: 1000 nodes/2000 links)
182175
def test_large_graph():
183176
"""Test that NetVis can handle large graphs without crashing (1000 nodes, 2000 links)."""
184177
# Generate large graph data
@@ -213,15 +206,14 @@ def test_large_graph():
213206
assert len(parsed_data["links"]) == 2000
214207

215208

216-
# T070: Special characters and Unicode in node IDs
217209
def test_special_characters_in_node_id():
218210
"""Test that NetVis handles special characters and Unicode in node IDs."""
219211
# Test various special characters and Unicode
220212
test_cases = [
221213
# Special characters
222214
'{"nodes": [{"id": "node-with-dash"}, {"id": "node_with_underscore"}], "links": [{"source": "node-with-dash", "target": "node_with_underscore"}]}',
223-
# Unicode characters (Japanese)
224-
'{"nodes": [{"id": "ノードA"}, {"id": "ノードB"}], "links": [{"source": "ノードA", "target": "ノードB"}]}',
215+
# Unicode characters (non-ASCII)
216+
'{"nodes": [{"id": "Nöde_Ä"}, {"id": "Nöde_Ö"}], "links": [{"source": "Nöde_Ä", "target": "Nöde_Ö"}]}',
225217
# Unicode characters (Emoji)
226218
'{"nodes": [{"id": "🔴"}, {"id": "🔵"}], "links": [{"source": "🔴", "target": "🔵"}]}',
227219
# Mixed alphanumeric and symbols

src/__tests__/graph.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// T050-T051: D3.js interaction tests for graph.ts
21
// Note: Full D3.js DOM manipulation testing requires integration tests in JupyterLab.
32
// These tests verify the API and error handling.
43

@@ -18,7 +17,6 @@ describe('D3.js Graph Interactions', () => {
1817
document.body.removeChild(container);
1918
});
2019

21-
// T050: D3.js simulation initialization test
2220
describe('force simulation initialization', () => {
2321
it('should initialize D3 force simulation without errors', () => {
2422
const graphData: GraphData = {
@@ -55,7 +53,6 @@ describe('D3.js Graph Interactions', () => {
5553
});
5654
});
5755

58-
// T051: Drag event handler tests
5956
describe('drag and interaction handlers', () => {
6057
it('should successfully render graph with nodes for drag interaction', () => {
6158
const graphData: GraphData = {

src/__tests__/mimePlugin.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Phase 2 TypeScript tests for MIME renderer helper functions (T021-T023)
2-
31
import { parseGraphData, validateVersion, MIME_TYPE } from '../mimePlugin';
42

53
describe('parseGraphData', () => {
@@ -172,8 +170,8 @@ describe('mimeExtension plugin', () => {
172170
it('should have correct extension properties', async () => {
173171
const mimeExtension = (await import('../mimePlugin')).default;
174172

175-
// JupyterLab 4のIExtensionにはautoStartプロパティなし
176-
// 正しいインターフェースプロパティのみテスト
173+
// JupyterLab 4 IExtension does not have autoStart property
174+
// Test only the correct interface properties
177175
expect(mimeExtension.id).toBe('net_vis:mime');
178176
expect(mimeExtension.rendererFactory).toBeDefined();
179177
expect(mimeExtension.dataType).toBe('json');

src/__tests__/renderer.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// T012: TypeScript renderer tests
2-
31
import { NetVisRenderer } from '../renderer';
42
import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
53

@@ -230,7 +228,6 @@ describe('NetVisRenderer', () => {
230228
});
231229
});
232230

233-
// T037: Node and link rendering tests
234231
// Note: These tests verify that the renderer can process node and link data without errors.
235232
// Full SVG element verification requires integration tests in JupyterLab environment.
236233
describe('node and link rendering', () => {
@@ -320,7 +317,6 @@ describe('NetVisRenderer', () => {
320317
});
321318
});
322319

323-
// T071: Large graph rendering test
324320
describe('large graph performance', () => {
325321
it('should handle large graph (100 nodes, 200 links) without crashing', async () => {
326322
const renderer = new NetVisRenderer({

src/__tests__/utils.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Copyright (c) Jupyter Development Team.
2-
// Distributed under the terms of the Modified BSD License.
3-
41
import * as widgets from '@jupyter-widgets/base';
52
import * as baseManager from '@jupyter-widgets/base-manager';
63
import * as services from '@jupyterlab/services';

src/graph.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function adjustLinkPath(d: any) {
3535
const dy = d.target.y - d.source.y;
3636
const distance = Math.sqrt(dx * dx + dy * dy);
3737

38-
// 各ノードが持つ半径を取得(存在しない場合はデフォルト値を設定)
38+
// Get node radius (default to 5 if not specified)
3939
const sourceRadius = d.source.radius || 5;
4040
const targetRadius = d.target.radius || 5;
4141

@@ -82,15 +82,15 @@ function Graph(svg: any, { nodes, links }: { nodes: Node[]; links: Link[] }) {
8282
.append('marker')
8383
.attr('id', markerId)
8484
.attr('viewBox', '0 0 10 10')
85-
.attr('refX', 10) // 矢印の位置調整(重要)
85+
.attr('refX', 10) // Arrow position adjustment (important)
8686
.attr('refY', 5)
8787
.attr('markerWidth', 10)
8888
.attr('markerHeight', 10)
89-
.attr('orient', 'auto'); // 通常の 'auto' でもOK
89+
.attr('orient', 'auto'); // Standard 'auto' works fine
9090
marker
9191
.append('path')
92-
.attr('d', 'M 0 0 L 10 5 L 0 10 z') // 矢印の形
93-
.attr('fill', 'black'); // 見やすく
92+
.attr('d', 'M 0 0 L 10 5 L 0 10 z') // Arrow shape
93+
.attr('fill', 'black'); // For visibility
9494

9595
const link = g
9696
.selectAll('path')
@@ -100,14 +100,14 @@ function Graph(svg: any, { nodes, links }: { nodes: Node[]; links: Link[] }) {
100100
.attr('stroke', 'black')
101101
.attr('stroke-width', 1)
102102
.attr('fill', 'none')
103-
.attr('marker-end', `url(#${markerId})`) // 矢印のIDを指定
103+
.attr('marker-end', `url(#${markerId})`) // Reference arrow marker
104104
.attr('d', adjustLinkPath);
105105

106106
const node = g
107107
.selectAll('g')
108108
.data(nodes)
109109
.enter()
110-
.append('g') // グループ要素を追加
110+
.append('g') // Add group element
111111
.classed('node-group', true);
112112

113113
node
@@ -131,16 +131,16 @@ function Graph(svg: any, { nodes, links }: { nodes: Node[]; links: Link[] }) {
131131
)
132132
.classed('circle', true);
133133

134-
// テキスト(最初は非表示)を追加
134+
// Add text labels (initially hidden)
135135
node
136136
.append('text')
137137
.text((d: any) => (d.name ? d.name : d.id))
138-
.attr('y', -20) // ノードの上に表示
138+
.attr('y', -20) // Display above the node
139139
.attr('text-anchor', 'middle')
140140
.style('font-size', '12px')
141141
.style('display', 'none');
142142

143-
// ノードのクリックイベントを統合
143+
// Node click event handling
144144
node
145145
.on('mouseover', function (this: SVGGElement, event: any, d: any) {
146146
console.log('mouseover', d);
@@ -153,15 +153,15 @@ function Graph(svg: any, { nodes, links }: { nodes: Node[]; links: Link[] }) {
153153
}
154154
})
155155
.on('click', function (this: SVGGElement, event: any, d: any) {
156-
console.log('click', this, d); // thisが正しい要素を指しているか確認
156+
console.log('click', this, d); // Verify this points to the correct element
157157
const isClicked = d3.select(this).classed('clicked');
158-
console.log('isClicked:', isClicked); // 現在の状態を確認
159-
d3.select(this).classed('clicked', !isClicked); // クラスのトグル
158+
console.log('isClicked:', isClicked); // Check current state
159+
d3.select(this).classed('clicked', !isClicked); // Toggle class
160160
d3.select(this)
161161
.select('text')
162-
.style('display', isClicked ? 'none' : 'block'); // 表示状態をトグル
162+
.style('display', isClicked ? 'none' : 'block'); // Toggle visibility
163163

164-
// ドラッグ解除の処理
164+
// Release drag fixing
165165
if (isClicked) {
166166
delete d.fx;
167167
delete d.fy;
@@ -172,7 +172,7 @@ function Graph(svg: any, { nodes, links }: { nodes: Node[]; links: Link[] }) {
172172
simulation.on('tick', () => {
173173
link.attr('d', adjustLinkPath);
174174
// node.attr('cx', (d: any) => d.x).attr('cy', (d: any) => d.y);
175-
node.attr('transform', (d: any) => `translate(${d.x},${d.y})`); // グループ全体を移動
175+
node.attr('transform', (d: any) => `translate(${d.x},${d.y})`); // Move entire group
176176
});
177177

178178
const width = 800;
@@ -199,7 +199,7 @@ function Graph(svg: any, { nodes, links }: { nodes: Node[]; links: Link[] }) {
199199
node.call(drag);
200200

201201
function dragstart() {
202-
// ドラッグ開始時の処理(必要に応じて追加)
202+
// Drag start handler (add logic as needed)
203203
}
204204

205205
function dragged(event: any, d: any) {

src/mimePlugin.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Copyright (c) Manabu TERADA
2-
// Distributed under the terms of the Modified BSD License.
3-
41
import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
52
import { Widget } from '@lumino/widgets';
63

src/renderer.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Copyright (c) Manabu TERADA
2-
// Distributed under the terms of the Modified BSD License.
3-
41
import { Widget } from '@lumino/widgets';
52
import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
63
import { renderGraph } from './graph';

src/version.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Copyright (c) Manabu TERADA
2-
// Distributed under the terms of the Modified BSD License.
3-
41
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
52
// @ts-ignore
63
// eslint-disable-next-line @typescript-eslint/no-var-requires

0 commit comments

Comments
 (0)