From 98dbe7f4f1818e07a6ba0c741d958d57c4921ac3 Mon Sep 17 00:00:00 2001 From: Andy Stark Date: Mon, 1 Dec 2025 15:51:01 +0000 Subject: [PATCH] DOC-6021 removed redundant local example files --- .../client-specific/redis-py/home_json.py | 189 ------------- local_examples/tmp/VectorSetExample.java | 258 ------------------ local_examples/tmp/dt-bitmap.js | 159 ----------- local_examples/tmp/dt_bitmap.py | 155 ----------- 4 files changed, 761 deletions(-) delete mode 100644 local_examples/client-specific/redis-py/home_json.py delete mode 100644 local_examples/tmp/VectorSetExample.java delete mode 100644 local_examples/tmp/dt-bitmap.js delete mode 100644 local_examples/tmp/dt_bitmap.py diff --git a/local_examples/client-specific/redis-py/home_json.py b/local_examples/client-specific/redis-py/home_json.py deleted file mode 100644 index 2bd6d4ea70..0000000000 --- a/local_examples/client-specific/redis-py/home_json.py +++ /dev/null @@ -1,189 +0,0 @@ -# EXAMPLE: py_home_json -# BINDER_ID python-py_home_json -""" -JSON examples from redis-py "home" page" - https://redis.io/docs/latest/develop/connect/clients/python/redis-py/#example-indexing-and-querying-json-documents -""" - -# STEP_START import -import redis -from redis.commands.json.path import Path -import redis.commands.search.aggregation as aggregations -import redis.commands.search.reducers as reducers -from redis.commands.search.field import TextField, NumericField, TagField -from redis.commands.search.index_definition import IndexDefinition, IndexType -from redis.commands.search.query import Query -import redis.exceptions -# STEP_END - -# STEP_START create_data -user1 = { - "name": "Paul John", - "email": "paul.john@example.com", - "age": 42, - "city": "London" -} - -user2 = { - "name": "Eden Zamir", - "email": "eden.zamir@example.com", - "age": 29, - "city": "Tel Aviv" -} - -user3 = { - "name": "Paul Zamir", - "email": "paul.zamir@example.com", - "age": 35, - "city": "Tel Aviv" -} -# STEP_END - -# STEP_START connect -r = redis.Redis(decode_responses=True) -# STEP_END - -# STEP_START cleanup_json -try: - r.ft("idx:users").dropindex(True) -except redis.exceptions.ResponseError: - pass - -r.delete("user:1", "user:2", "user:3") -# STEP_END - -# STEP_START make_index -schema = ( - TextField("$.name", as_name="name"), - TagField("$.city", as_name="city"), - NumericField("$.age", as_name="age") -) - -indexCreated = r.ft("idx:users").create_index( - schema, - definition=IndexDefinition( - prefix=["user:"], index_type=IndexType.JSON - ) -) -# STEP_END -# REMOVE_START -assert indexCreated -# REMOVE_END - -# STEP_START add_data -user1Set = r.json().set("user:1", Path.root_path(), user1) -user2Set = r.json().set("user:2", Path.root_path(), user2) -user3Set = r.json().set("user:3", Path.root_path(), user3) -# STEP_END -# REMOVE_START -assert user1Set -assert user2Set -assert user3Set -# REMOVE_END - -# STEP_START query1 -findPaulResult = r.ft("idx:users").search( - Query("Paul @age:[30 40]") -) - -print(findPaulResult) -# >>> Result{1 total, docs: [Document {'id': 'user:3', ... -# STEP_END -# REMOVE_START -assert str(findPaulResult) == ( - "Result{1 total, docs: [Document {'id': 'user:3', 'payload': None, " - + "'json': '{\"name\":\"Paul Zamir\",\"email\":" - + "\"paul.zamir@example.com\",\"age\":35,\"city\":\"Tel Aviv\"}'}]}" -) -# REMOVE_END - -# STEP_START query2 -citiesResult = r.ft("idx:users").search( - Query("Paul").return_field("$.city", as_field="city") -).docs - -print(citiesResult) -# >>> [Document {'id': 'user:1', 'payload': None, ... -# STEP_END -# REMOVE_START -citiesResult.sort(key=lambda doc: doc['id']) - -assert str(citiesResult) == ( - "[Document {'id': 'user:1', 'payload': None, 'city': 'London'}, " - + "Document {'id': 'user:3', 'payload': None, 'city': 'Tel Aviv'}]" -) -# REMOVE_END - -# STEP_START query3 -req = aggregations.AggregateRequest("*").group_by( - '@city', reducers.count().alias('count') -) - -aggResult = r.ft("idx:users").aggregate(req).rows -print(aggResult) -# >>> [['city', 'London', 'count', '1'], ['city', 'Tel Aviv', 'count', '2']] -# STEP_END -# REMOVE_START -aggResult.sort(key=lambda row: row[1]) - -assert str(aggResult) == ( - "[['city', 'London', 'count', '1'], ['city', 'Tel Aviv', 'count', '2']]" -) -# REMOVE_END - -# STEP_START cleanup_hash -try: - r.ft("hash-idx:users").dropindex(True) -except redis.exceptions.ResponseError: - pass - -r.delete("huser:1", "huser:2", "huser:3") -# STEP_END - -# STEP_START make_hash_index -hashSchema = ( - TextField("name"), - TagField("city"), - NumericField("age") -) - -hashIndexCreated = r.ft("hash-idx:users").create_index( - hashSchema, - definition=IndexDefinition( - prefix=["huser:"], index_type=IndexType.HASH - ) -) -# STEP_END -# REMOVE_START -assert hashIndexCreated -# REMOVE_END - -# STEP_START add_hash_data -huser1Set = r.hset("huser:1", mapping=user1) -huser2Set = r.hset("huser:2", mapping=user2) -huser3Set = r.hset("huser:3", mapping=user3) -# STEP_END -# REMOVE_START -assert huser1Set -assert huser2Set -assert huser3Set -# REMOVE_END - -# STEP_START query1_hash -findPaulHashResult = r.ft("hash-idx:users").search( - Query("Paul @age:[30 40]") -) - -print(findPaulHashResult) -# >>> Result{1 total, docs: [Document {'id': 'huser:3', -# >>> 'payload': None, 'name': 'Paul Zamir', ... -# STEP_END -# REMOVE_START -assert str(findPaulHashResult) == ( - "Result{1 total, docs: [Document " + - "{'id': 'huser:3', 'payload': None, 'name': 'Paul Zamir', " + - "'email': 'paul.zamir@example.com', 'age': '35', 'city': 'Tel Aviv'}]}" -) -# REMOVE_END - -r.close() diff --git a/local_examples/tmp/VectorSetExample.java b/local_examples/tmp/VectorSetExample.java deleted file mode 100644 index af21c465e2..0000000000 --- a/local_examples/tmp/VectorSetExample.java +++ /dev/null @@ -1,258 +0,0 @@ -// EXAMPLE: vecset_tutorial -// REMOVE_START -package io.redis.examples; - -import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; -// REMOVE_END -import redis.clients.jedis.UnifiedJedis; -import redis.clients.jedis.params.VAddParams; -import redis.clients.jedis.params.VSimParams; - -import java.util.*; - -public class VectorSetExample { - - @Test - public void run() { - try (UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379")) { - // REMOVE_START - jedis.del("points", "quantSetQ8", "quantSetNoQ", "quantSetBin", "setNotReduced", - "setReduced"); - // REMOVE_END - - // STEP_START vadd - boolean res1 = jedis.vadd("points", new float[] { 1.0f, 1.0f }, "pt:A"); - System.out.println(res1); // >>> true - - boolean res2 = jedis.vadd("points", new float[] { -1.0f, -1.0f }, "pt:B"); - System.out.println(res2); // >>> true - - boolean res3 = jedis.vadd("points", new float[] { -1.0f, 1.0f }, "pt:C"); - System.out.println(res3); // >>> true - - boolean res4 = jedis.vadd("points", new float[] { 1.0f, -1.0f }, "pt:D"); - System.out.println(res4); // >>> true - - boolean res5 = jedis.vadd("points", new float[] { 1.0f, 0.0f }, "pt:E"); - System.out.println(res5); // >>> true - - String res6 = jedis.type("points"); - System.out.println(res6); // >>> vectorset - // STEP_END - // REMOVE_START - assertTrue(res1); - assertTrue(res2); - assertTrue(res3); - assertTrue(res4); - assertTrue(res5); - assertEquals("vectorset", res6); - // REMOVE_END - - // STEP_START vcardvdim - long res7 = jedis.vcard("points"); - System.out.println(res7); // >>> 5 - - long res8 = jedis.vdim("points"); - System.out.println(res8); // >>> 2 - // STEP_END - // REMOVE_START - assertEquals(5L, res7); - assertEquals(2L, res8); - // REMOVE_END - - // STEP_START vemb - List res9 = jedis.vemb("points", "pt:A"); - System.out.println(res9); // >>> [0.9999999..., 0.9999999...] - - List res10 = jedis.vemb("points", "pt:B"); - System.out.println(res10); // >>> [-0.9999999..., -0.9999999...] - - List res11 = jedis.vemb("points", "pt:C"); - System.out.println(res11); // >>> [-0.9999999..., 0.9999999...] - - List res12 = jedis.vemb("points", "pt:D"); - System.out.println(res12); // >>> [0.9999999..., -0.9999999...] - - List res13 = jedis.vemb("points", "pt:E"); - System.out.println(res13); // >>> [1, 0] - // STEP_END - // REMOVE_START - assertTrue(Math.abs(1 - res9.get(0)) < 0.01); - assertTrue(Math.abs(1 - res9.get(1)) < 0.01); - assertTrue(Math.abs(-1 - res10.get(0)) < 0.01); - assertTrue(Math.abs(-1 - res10.get(1)) < 0.01); - assertTrue(Math.abs(-1 - res11.get(0)) < 0.01); - assertTrue(Math.abs(1 - res11.get(1)) < 0.01); - assertTrue(Math.abs(1 - res12.get(0)) < 0.01); - assertTrue(Math.abs(-1 - res12.get(1)) < 0.01); - assertEquals(Arrays.asList(1.0, 0.0), res13); - // REMOVE_END - - // STEP_START attr - boolean res14 = jedis.vsetattr("points", "pt:A", - "{\"name\":\"Point A\",\"description\":\"First point added\"}"); - System.out.println(res14); // >>> true - - String res15 = jedis.vgetattr("points", "pt:A"); - System.out.println(res15); - // >>> {"name":"Point A","description":"First point added"} - - boolean res16 = jedis.vsetattr("points", "pt:A", ""); - System.out.println(res16); // >>> true - - String res17 = jedis.vgetattr("points", "pt:A"); - System.out.println(res17); // >>> null - // STEP_END - // REMOVE_START - assertTrue(res14); - assertTrue(res15.contains("\"name\":\"Point A\"")); - assertTrue(res15.contains("\"description\":\"First point added\"")); - assertTrue(res16); - assertNull(res17); - // REMOVE_END - - // STEP_START vrem - boolean res18 = jedis.vadd("points", new float[] { 0.0f, 0.0f }, "pt:F"); - System.out.println(res18); // >>> true - - long res19 = jedis.vcard("points"); - System.out.println(res19); // >>> 6 - - boolean res20 = jedis.vrem("points", "pt:F"); - System.out.println(res20); // >>> true - - long res21 = jedis.vcard("points"); - System.out.println(res21); // >>> 5 - // STEP_END - // REMOVE_START - assertTrue(res18); - assertEquals(6L, res19); - assertTrue(res20); - assertEquals(5L, res21); - // REMOVE_END - - // STEP_START vsim_basic - List res22 = jedis.vsim("points", new float[] { 0.9f, 0.1f }); - System.out.println(res22); - // >>> ["pt:E", "pt:A", "pt:D", "pt:C", "pt:B"] - // STEP_END - // REMOVE_START - assertEquals(Arrays.asList("pt:E", "pt:A", "pt:D", "pt:C", "pt:B"), res22); - // REMOVE_END - - // STEP_START vsim_options - Map res23 = jedis.vsimByElementWithScores("points", "pt:A", - new VSimParams().count(4)); - System.out.println(res23); - // >>> {pt:A=1.0, pt:E≈0.85355, pt:D=0.5, pt:C=0.5} - // STEP_END - // REMOVE_START - assertEquals(1.0, res23.get("pt:A"), 0.0001); - assertEquals(0.5, res23.get("pt:C"), 0.0001); - assertEquals(0.5, res23.get("pt:D"), 0.0001); - assertTrue(Math.abs(res23.get("pt:E") - 0.8535) < 0.01); - // REMOVE_END - - // STEP_START vsim_filter - boolean res24 = jedis.vsetattr("points", "pt:A", "{\"size\":\"large\",\"price\":18.99}"); - System.out.println(res24); // >>> true - - boolean res25 = jedis.vsetattr("points", "pt:B", "{\"size\":\"large\",\"price\":35.99}"); - System.out.println(res25); // >>> true - - boolean res26 = jedis.vsetattr("points", "pt:C", "{\"size\":\"large\",\"price\":25.99}"); - System.out.println(res26); // >>> true - - boolean res27 = jedis.vsetattr("points", "pt:D", "{\"size\":\"small\",\"price\":21.00}"); - System.out.println(res27); // >>> true - - boolean res28 = jedis.vsetattr("points", "pt:E", "{\"size\":\"small\",\"price\":17.75}"); - System.out.println(res28); // >>> true - - List res29 = jedis.vsimByElement("points", "pt:A", - new VSimParams().filter(".size == \"large\"")); - System.out.println(res29); // >>> ["pt:A", "pt:C", "pt:B"] - - List res30 = jedis.vsimByElement("points", "pt:A", - new VSimParams().filter(".size == \"large\" && .price > 20.00")); - System.out.println(res30); // >>> ["pt:C", "pt:B"] - // STEP_END - // REMOVE_START - assertTrue(res24); - assertTrue(res25); - assertTrue(res26); - assertTrue(res27); - assertTrue(res28); - assertEquals(Arrays.asList("pt:C", "pt:B"), res30); - // REMOVE_END - - // STEP_START add_quant - boolean res31 = jedis.vadd("quantSetQ8", new float[] { 1.262185f, 1.958231f }, "quantElement", - new VAddParams().q8()); - System.out.println(res31); // >>> true - - List res32 = jedis.vemb("quantSetQ8", "quantElement"); - System.out.println("Q8: " + res32); - // >>> Q8: [~1.264, ~1.958] - - boolean res33 = jedis.vadd("quantSetNoQ", new float[] { 1.262185f, 1.958231f }, - "quantElement", new VAddParams().noQuant()); - System.out.println(res33); // >>> true - - List res34 = jedis.vemb("quantSetNoQ", "quantElement"); - System.out.println("NOQUANT: " + res34); - // >>> NOQUANT: [~1.262185, ~1.958231] - - boolean res35 = jedis.vadd("quantSetBin", new float[] { 1.262185f, 1.958231f }, - "quantElement", new VAddParams().bin()); - System.out.println(res35); // >>> true - - List res36 = jedis.vemb("quantSetBin", "quantElement"); - System.out.println("BIN: " + res36); - // >>> BIN: [1, 1] - // STEP_END - // REMOVE_START - assertTrue(res31); - assertTrue(res33); - assertTrue(res35); - assertEquals(2, res32.size()); - assertEquals(2, res34.size()); - assertEquals(2, res36.size()); - assertTrue(Math.abs(res32.get(0) - 1.26) < 0.05); - assertTrue(Math.abs(res32.get(1) - 1.958) < 0.01); - assertTrue(Math.abs(res34.get(0) - 1.2622) < 0.01); - assertTrue(Math.abs(res34.get(1) - 1.9582) < 0.01); - assertEquals(Arrays.asList(1.0, 1.0), res36); - // REMOVE_END - - // STEP_START add_reduce - float[] values = new float[300]; - for (int i = 0; i < 300; i++) - values[i] = i / 299.0f; - - boolean res37 = jedis.vadd("setNotReduced", values, "element"); - System.out.println(res37); // >>> true - - long res38 = jedis.vdim("setNotReduced"); - System.out.println(res38); // >>> 300 - - boolean res39 = jedis.vadd("setReduced", values, "element", 100, new VAddParams()); - System.out.println(res39); // >>> true - - long res40 = jedis.vdim("setReduced"); - System.out.println(res40); // >>> 100 - // STEP_END - // REMOVE_START - assertTrue(res37); - assertEquals(300L, res38); - assertTrue(res39); - assertEquals(100L, res40); - // REMOVE_END - - // HIDE_START - jedis.close(); - } - } -} -// HIDE_END diff --git a/local_examples/tmp/dt-bitmap.js b/local_examples/tmp/dt-bitmap.js deleted file mode 100644 index 0d6a292d0f..0000000000 --- a/local_examples/tmp/dt-bitmap.js +++ /dev/null @@ -1,159 +0,0 @@ -// EXAMPLE: bitmap_tutorial -// REMOVE_START -import assert from 'assert'; -// REMOVE_END -import { createClient, RESP_TYPES } from 'redis'; - -const client = createClient({ - commandOptions: { - typeMapping: { - [RESP_TYPES.BLOB_STRING]: Buffer - } - } -}); -await client.connect(); - -// REMOVE_START -await client.flushDb(); -// REMOVE_END - -// STEP_START ping -const res1 = await client.setBit("pings:2024-01-01-00:00", 123, 1) -console.log(res1) // >>> 0 - -const res2 = await client.getBit("pings:2024-01-01-00:00", 123) -console.log(res2) // >>> 1 - -const res3 = await client.getBit("pings:2024-01-01-00:00", 456) -console.log(res3) // >>> 0 -// STEP_END - -// REMOVE_START -assert.equal(res1, 0) -// REMOVE_END - -// STEP_START bitcount -// HIDE_START -await client.setBit("pings:2024-01-01-00:00", 123, 1) -// HIDE_END -const res4 = await client.bitCount("pings:2024-01-01-00:00") -console.log(res4) // >>> 1 -// STEP_END -// REMOVE_START -assert.equal(res4, 1) -// REMOVE_END - -// STEP_START bitop_setup -await client.setBit("A", 0, 1) -await client.setBit("A", 1, 1) -await client.setBit("A", 3, 1) -await client.setBit("A", 4, 1) - -const res5 = await client.get("A") -console.log(res5.readUInt8(0).toString(2).padStart(8, '0')) -// >>> 11011000 - -await client.setBit("B", 3, 1) -await client.setBit("B", 4, 1) -await client.setBit("B", 7, 1) - -const res6 = await client.get("B") -console.log(res6.readUInt8(0).toString(2).padStart(8, '0')) -// >>> 00011001 - -await client.setBit("C", 1, 1) -await client.setBit("C", 2, 1) -await client.setBit("C", 4, 1) -await client.setBit("C", 5, 1) - -const res7 = await client.get("C") -console.log(res7.readUInt8(0).toString(2).padStart(8, '0')) -// >>> 01101100 -// STEP_END -// REMOVE_START -assert.equal(res5.readUInt8(0), 0b11011000) -assert.equal(res6.readUInt8(0), 0b00011001) -assert.equal(res7.readUInt8(0), 0b01101100) -// REMOVE_END - -// STEP_START bitop_and -await client.bitOp("AND", "R", ["A", "B", "C"]) -const res8 = await client.get("R") -console.log(res8.readUInt8(0).toString(2).padStart(8, '0')) -// >>> 00001000 -// STEP_END -// REMOVE_START -assert.equal(res8.readUInt8(0), 0b00001000) -// REMOVE_END - -// STEP_START bitop_or -await client.bitOp("OR", "R", ["A", "B", "C"]) -const res9 = await client.get("R") -console.log(res9.readUInt8(0).toString(2).padStart(8, '0')) -// >>> 11111101 -// STEP_END -// REMOVE_START -assert.equal(res9.readUInt8(0), 0b11111101) -// REMOVE_END - -// STEP_START bitop_xor -await client.bitOp("XOR", "R", ["A", "B"]) // XOR uses two keys here -const res10 = await client.get("R") -console.log(res10.readUInt8(0).toString(2).padStart(8, '0')) -// >>> 11000001 -// STEP_END -// REMOVE_START -assert.equal(res10.readUInt8(0), 0b11000001) -// REMOVE_END - -// STEP_START bitop_not -await client.bitOp("NOT", "R", "A") -const res11 = await client.get("R") -console.log(res11.readUInt8(0).toString(2).padStart(8, '0')) -// >>> 00100111 -// STEP_END -// REMOVE_START -assert.equal(res11.readUInt8(0), 0b00100111) -// REMOVE_END - -// STEP_START bitop_diff -await client.bitOp("DIFF", "R", ["A", "B", "C"]) -const res12 = await client.get("R") -console.log(res12.readUInt8(0).toString(2).padStart(8, '0')) -// >>> 10000000 -// STEP_END -// REMOVE_START -assert.equal(res12.readUInt8(0), 0b10000000) -// REMOVE_END - -// STEP_START bitop_diff1 -await client.bitOp("DIFF1", "R", ["A", "B", "C"]) -const res13 = await client.get("R") -console.log(res13.readUInt8(0).toString(2).padStart(8, '0')) -// >>> 00100101 -// STEP_END -// REMOVE_START -assert.equal(res13.readUInt8(0), 0b00100101) -// REMOVE_END - -// STEP_START bitop_andor -await client.bitOp("ANDOR", "R", ["A", "B", "C"]) -const res14 = await client.get("R") -console.log(res14.readUInt8(0).toString(2).padStart(8, '0')) -// >>> 01011000 -// STEP_END -// REMOVE_START -assert.equal(res14.readUInt8(0), 0b01011000) -// REMOVE_END - -// STEP_START bitop_one -await client.bitOp("ONE", "R", ["A", "B", "C"]) -const res15 = await client.get("R") -console.log(res15.readUInt8(0).toString(2).padStart(8, '0')) -// >>> 10100101 -// STEP_END -// REMOVE_START -assert.equal(res15.readUInt8(0), 0b10100101) - -await client.close(); -// REMOVE_END \ No newline at end of file diff --git a/local_examples/tmp/dt_bitmap.py b/local_examples/tmp/dt_bitmap.py deleted file mode 100644 index 056bf55515..0000000000 --- a/local_examples/tmp/dt_bitmap.py +++ /dev/null @@ -1,155 +0,0 @@ -# EXAMPLE: bitmap_tutorial -# HIDE_START -""" -Code samples for Bitmap doc pages: - https://redis.io/docs/latest/develop/data-types/bitmaps/ -""" -import redis - -# Connect without the usual `decode_responses=True` to -# see the binary values in the responses more easily. -r = redis.Redis() -# HIDE_END - -# REMOVE_START -r.delete("pings:2024-01-01-00:00", "A", "B", "C", "R") -# REMOVE_END - -# STEP_START ping -res1 = r.setbit("pings:2024-01-01-00:00", 123, 1) -print(res1) # >>> 0 - -res2 = r.getbit("pings:2024-01-01-00:00", 123) -print(res2) # >>> 1 - -res3 = r.getbit("pings:2024-01-01-00:00", 456) -print(res3) # >>> 0 -# STEP_END - -# REMOVE_START -assert res1 == 0 -# REMOVE_END - -# STEP_START bitcount -# HIDE_START -r.setbit("pings:2024-01-01-00:00", 123, 1) -# HIDE_END -res4 = r.bitcount("pings:2024-01-01-00:00") -print(res4) # >>> 1 -# STEP_END -# REMOVE_START -assert res4 == 1 -# REMOVE_END - -# STEP_START bitop_setup -r.setbit("A", 0, 1) -r.setbit("A", 1, 1) -r.setbit("A", 3, 1) -r.setbit("A", 4, 1) - -res5 = r.get("A") -print("{:08b}".format(int.from_bytes(res5, "big"))) -# >>> 11011000 - -r.setbit("B", 3, 1) -r.setbit("B", 4, 1) -r.setbit("B", 7, 1) - -res6 = r.get("B") -print("{:08b}".format(int.from_bytes(res6, "big"))) -# >>> 00011001 - -r.setbit("C", 1, 1) -r.setbit("C", 2, 1) -r.setbit("C", 4, 1) -r.setbit("C", 5, 1) - -res7 = r.get("C") -print("{:08b}".format(int.from_bytes(res7, "big"))) -# >>> 01101100 -# STEP_END -# REMOVE_START -assert int.from_bytes(res5, "big") == 0b11011000 -assert int.from_bytes(res6, "big") == 0b00011001 -assert int.from_bytes(res7, "big") == 0b01101100 -# REMOVE_END - -# STEP_START bitop_and -r.bitop("AND", "R", "A", "B", "C") -res8 = r.get("R") -print("{:08b}".format(int.from_bytes(res8, "big"))) -# >>> 00001000 -# STEP_END -# REMOVE_START -assert int.from_bytes(res8, "big") == 0b00001000 -# REMOVE_END - -# STEP_START bitop_or -r.bitop("OR", "R", "A", "B", "C") -res9 = r.get("R") -print("{:08b}".format(int.from_bytes(res9, "big"))) -# >>> 11111101 -# STEP_END -# REMOVE_START -assert int.from_bytes(res9, "big") == 0b11111101 -# REMOVE_END - -# STEP_START bitop_xor -r.bitop("XOR", "R", "A", "B") -res10 = r.get("R") -print("{:08b}".format(int.from_bytes(res10, "big"))) -# >>> 11000001 -# STEP_END -# REMOVE_START -assert int.from_bytes(res10, "big") == 0b11000001 -# REMOVE_END - -# STEP_START bitop_not -r.bitop("NOT", "R", "A") -res11 = r.get("R") -print("{:08b}".format(int.from_bytes(res11, "big"))) -# >>> 00100111 -# STEP_END -# REMOVE_START -assert int.from_bytes(res11, "big") == 0b00100111 -# REMOVE_END - -# STEP_START bitop_diff -r.bitop("DIFF", "R", "A", "B", "C") -res12 = r.get("R") -print("{:08b}".format(int.from_bytes(res12, "big"))) -# >>> 10000000 -# STEP_END -# REMOVE_START -assert int.from_bytes(res12, "big") == 0b10000000 -# REMOVE_END - -# STEP_START bitop_diff1 -r.bitop("DIFF1", "R", "A", "B", "C") -res13 = r.get("R") -print("{:08b}".format(int.from_bytes(res13, "big"))) -# >>> 00100101 -# STEP_END -# REMOVE_START -assert int.from_bytes(res13, "big") == 0b00100101 -# REMOVE_END - -# STEP_START bitop_andor -r.bitop("ANDOR", "R", "A", "B", "C") -res14 = r.get("R") -print("{:08b}".format(int.from_bytes(res14, "big"))) -# >>> 01011000 -# STEP_END -# REMOVE_START -assert int.from_bytes(res14, "big") == 0b01011000 -# REMOVE_END - -# STEP_START bitop_one -r.bitop("ONE", "R", "A", "B", "C") -res15 = r.get("R") -print("{:08b}".format(int.from_bytes(res15, "big"))) -# >>> 10100101 -# STEP_END -# REMOVE_START -assert int.from_bytes(res15, "big") == 0b10100101 -# REMOVE_END