rust-pgn-reader-python-binding 2.4.0__tar.gz → 2.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/Cargo.lock +11 -11
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/Cargo.toml +1 -1
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/PKG-INFO +1 -1
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/src/lib.rs +20 -0
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/src/test.py +27 -0
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/.github/workflows/CI.yml +0 -0
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/.gitignore +0 -0
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/README.md +0 -0
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/benches/parquet_bench.rs +0 -0
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/pyproject.toml +0 -0
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/src/bench.py +0 -0
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/src/bench_parquet.py +0 -0
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/src/bench_parquet_parallel.py +0 -0
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/src/comment_parsing.rs +0 -0
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/src/example_rowgroup.py +0 -0
- {rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/src/example_str.py +0 -0
|
@@ -382,9 +382,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
|
|
382
382
|
|
|
383
383
|
[[package]]
|
|
384
384
|
name = "cc"
|
|
385
|
-
version = "1.2.
|
|
385
|
+
version = "1.2.7"
|
|
386
386
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
387
|
-
checksum = "
|
|
387
|
+
checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7"
|
|
388
388
|
dependencies = [
|
|
389
389
|
"jobserver",
|
|
390
390
|
"libc",
|
|
@@ -1171,9 +1171,9 @@ dependencies = [
|
|
|
1171
1171
|
|
|
1172
1172
|
[[package]]
|
|
1173
1173
|
name = "quote"
|
|
1174
|
-
version = "1.0.
|
|
1174
|
+
version = "1.0.38"
|
|
1175
1175
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1176
|
-
checksum = "
|
|
1176
|
+
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
|
1177
1177
|
dependencies = [
|
|
1178
1178
|
"proc-macro2",
|
|
1179
1179
|
]
|
|
@@ -1229,7 +1229,7 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
|
|
1229
1229
|
|
|
1230
1230
|
[[package]]
|
|
1231
1231
|
name = "rust_pgn_reader_python_binding"
|
|
1232
|
-
version = "2.
|
|
1232
|
+
version = "2.5.1"
|
|
1233
1233
|
dependencies = [
|
|
1234
1234
|
"arrow",
|
|
1235
1235
|
"criterion",
|
|
@@ -1280,18 +1280,18 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4"
|
|
|
1280
1280
|
|
|
1281
1281
|
[[package]]
|
|
1282
1282
|
name = "serde"
|
|
1283
|
-
version = "1.0.
|
|
1283
|
+
version = "1.0.217"
|
|
1284
1284
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1285
|
-
checksum = "
|
|
1285
|
+
checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
|
|
1286
1286
|
dependencies = [
|
|
1287
1287
|
"serde_derive",
|
|
1288
1288
|
]
|
|
1289
1289
|
|
|
1290
1290
|
[[package]]
|
|
1291
1291
|
name = "serde_derive"
|
|
1292
|
-
version = "1.0.
|
|
1292
|
+
version = "1.0.217"
|
|
1293
1293
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1294
|
-
checksum = "
|
|
1294
|
+
checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
|
|
1295
1295
|
dependencies = [
|
|
1296
1296
|
"proc-macro2",
|
|
1297
1297
|
"quote",
|
|
@@ -1342,9 +1342,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|
|
1342
1342
|
|
|
1343
1343
|
[[package]]
|
|
1344
1344
|
name = "syn"
|
|
1345
|
-
version = "2.0.
|
|
1345
|
+
version = "2.0.94"
|
|
1346
1346
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1347
|
-
checksum = "
|
|
1347
|
+
checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3"
|
|
1348
1348
|
dependencies = [
|
|
1349
1349
|
"proc-macro2",
|
|
1350
1350
|
"quote",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rust_pgn_reader_python_binding
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.1
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -55,6 +55,9 @@ pub struct MoveExtractor {
|
|
|
55
55
|
#[pyo3(get)]
|
|
56
56
|
headers: Vec<(String, String)>,
|
|
57
57
|
|
|
58
|
+
#[pyo3(get)]
|
|
59
|
+
castling_rights: Vec<(bool, bool, bool, bool)>,
|
|
60
|
+
|
|
58
61
|
#[pyo3(get)]
|
|
59
62
|
position_status: Option<PositionStatus>,
|
|
60
63
|
|
|
@@ -74,6 +77,7 @@ impl MoveExtractor {
|
|
|
74
77
|
clock_times: Vec::with_capacity(100),
|
|
75
78
|
outcome: None,
|
|
76
79
|
headers: Vec::with_capacity(10),
|
|
80
|
+
castling_rights: Vec::with_capacity(100),
|
|
77
81
|
position_status: None,
|
|
78
82
|
}
|
|
79
83
|
}
|
|
@@ -85,6 +89,18 @@ impl MoveExtractor {
|
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
|
|
92
|
+
fn push_castling_bitboards(&mut self) {
|
|
93
|
+
let castling_bitboard = self.pos.castles().castling_rights();
|
|
94
|
+
let castling_rights = (
|
|
95
|
+
castling_bitboard.contains(shakmaty::Square::A1),
|
|
96
|
+
castling_bitboard.contains(shakmaty::Square::H1),
|
|
97
|
+
castling_bitboard.contains(shakmaty::Square::A8),
|
|
98
|
+
castling_bitboard.contains(shakmaty::Square::H8),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
self.castling_rights.push(castling_rights);
|
|
102
|
+
}
|
|
103
|
+
|
|
88
104
|
fn update_position_status(&mut self) {
|
|
89
105
|
// TODO this checks legal_moves() a bunch of times
|
|
90
106
|
self.position_status = Some(PositionStatus {
|
|
@@ -120,6 +136,8 @@ impl Visitor for MoveExtractor {
|
|
|
120
136
|
self.comments.clear();
|
|
121
137
|
self.evals.clear();
|
|
122
138
|
self.clock_times.clear();
|
|
139
|
+
|
|
140
|
+
self.push_castling_bitboards();
|
|
123
141
|
}
|
|
124
142
|
|
|
125
143
|
fn san(&mut self, san_plus: SanPlus) {
|
|
@@ -129,6 +147,7 @@ impl Visitor for MoveExtractor {
|
|
|
129
147
|
self.pos.play_unchecked(&m);
|
|
130
148
|
let uci = UciMove::from_standard(&m);
|
|
131
149
|
self.moves.push(uci.to_string());
|
|
150
|
+
self.push_castling_bitboards();
|
|
132
151
|
}
|
|
133
152
|
Err(err) => {
|
|
134
153
|
eprintln!("error in game: {} {}", err, san_plus);
|
|
@@ -257,6 +276,7 @@ fn parse_games(pgns: Vec<String>, num_threads: Option<usize>) -> PyResult<Vec<Mo
|
|
|
257
276
|
.map_err(|err| pyo3::exceptions::PyValueError::new_err(err))
|
|
258
277
|
}
|
|
259
278
|
|
|
279
|
+
// Parser for chess PGN notation
|
|
260
280
|
#[pymodule]
|
|
261
281
|
fn rust_pgn_reader_python_binding(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
262
282
|
m.add_function(wrap_pyfunction!(parse_game, m)?)?;
|
|
@@ -448,6 +448,33 @@ class TestPgnExtraction(unittest.TestCase):
|
|
|
448
448
|
self.assertTrue(extractor[1].position_status.turn == 1)
|
|
449
449
|
self.assertTrue(extractor[1].position_status.insufficient_material == (0, 0))
|
|
450
450
|
|
|
451
|
+
def test_castling(self):
|
|
452
|
+
pgn_moves = """
|
|
453
|
+
1. e4 e5 2. Bc4 c6 3. Nf3 d6 4. Rg1 f6 5. Rh1 g6 6. Ke2 b6 7. Ke1 g5
|
|
454
|
+
"""
|
|
455
|
+
|
|
456
|
+
extractor = self.run_extractor(pgn_moves)
|
|
457
|
+
|
|
458
|
+
castling_reference = [
|
|
459
|
+
(True, True, True, True),
|
|
460
|
+
(True, True, True, True),
|
|
461
|
+
(True, True, True, True),
|
|
462
|
+
(True, True, True, True),
|
|
463
|
+
(True, True, True, True),
|
|
464
|
+
(True, True, True, True),
|
|
465
|
+
(True, True, True, True),
|
|
466
|
+
(True, False, True, True),
|
|
467
|
+
(True, False, True, True),
|
|
468
|
+
(True, False, True, True),
|
|
469
|
+
(True, False, True, True),
|
|
470
|
+
(False, False, True, True),
|
|
471
|
+
(False, False, True, True),
|
|
472
|
+
(False, False, True, True),
|
|
473
|
+
(False, False, True, True),
|
|
474
|
+
]
|
|
475
|
+
|
|
476
|
+
self.assertTrue(extractor.castling_rights == castling_reference)
|
|
477
|
+
|
|
451
478
|
|
|
452
479
|
if __name__ == "__main__":
|
|
453
480
|
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/pyproject.toml
RENAMED
|
File without changes
|
|
File without changes
|
{rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/src/bench_parquet.py
RENAMED
|
File without changes
|
|
File without changes
|
{rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/src/comment_parsing.rs
RENAMED
|
File without changes
|
|
File without changes
|
{rust_pgn_reader_python_binding-2.4.0 → rust_pgn_reader_python_binding-2.5.1}/src/example_str.py
RENAMED
|
File without changes
|