Created
April 14, 2023 07:00
-
-
Save andycasey/ff9ebf251bb80ee9ebfe23161ee48a0b to your computer and use it in GitHub Desktop.
Revisions
-
andycasey revised this gist
Apr 14, 2023 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ cartons = [ SimplifiedCarton.create(id=5, carton="star"), SimplifiedCarton.create(id=8, carton="galaxy") @@ -32,4 +31,3 @@ print(int.from_bytes(source.carton_flags._buffer, byteorder='little')) # > 6546781215792283740026379393655198304433284092086129578966582736192267592809349109766540184651808314301773368255120142018434513091770786106657055179040 -
andycasey revised this gist
Apr 14, 2023 . 1 changed file with 23 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,35 +1,35 @@ cartons = [ SimplifiedCarton.create(id=5, carton="star"), SimplifiedCarton.create(id=8, carton="galaxy") ] source = Source.create(ra=0, dec=0) source.carton_flags.set_bit(5) # add to star source.carton_flags.set_bit(8) # add to galaxy print(source.carton_flags) # > bytearray(b' \x01') print(int.from_bytes(source.carton_flags._buffer, byteorder='little')) # > 288 assert (2**5 + 2**8) == 288 # Each byte can store up to 8 bits, so this one should be length 2 because the galaxy just pushes us over assert len(source.carton_flags._buffer) == 2 # Let's add a big carton ufo = SimplifiedCarton.create(id=501, carton="UFO") source.carton_flags.set_bit(ufo.id) print(source.carton_flags._buffer) # > 63 print(source.carton_flags._buffer) # > bytearray(b' \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 ') print(int.from_bytes(source.carton_flags._buffer, byteorder='little')) # > 6546781215792283740026379393655198304433284092086129578966582736192267592809349109766540184651808314301773368255120142018434513091770786106657055179040 -
andycasey created this gist
Apr 14, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ cartons = [ SimplifiedCarton.create(id=5, carton="star"), SimplifiedCarton.create(id=8, carton="galaxy") ] source = Source.create(ra=0, dec=0) source.carton_flags.set_bit(5) # add to star source.carton_flags.set_bit(8) # add to galaxy print(source.carton_flags) # > bytearray(b' \x01') print(int.from_bytes(source.carton_flags._buffer, byteorder='little')) # > 288 assert (2**5 + 2**8) == 288 # Each byte can store up to 8 bits, so this one should be length 2 because the galaxy just pushes us over assert len(source.carton_flags._buffer) == 2 # Let's add a big carton ufo = SimplifiedCarton.create(id=501, carton="UFO") source.carton_flags.set_bit(ufo.id) print(source.carton_flags._buffer) # > 63 print(source.carton_flags._buffer) # > bytearray(b' \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 ') print(int.from_bytes(source.carton_flags._buffer, byteorder='little')) # > 6546781215792283740026379393655198304433284092086129578966582736192267592809349109766540184651808314301773368255120142018434513091770786106657055179040