@@ -763,3 +763,124 @@ def test_tri_map_map_float_d(self) -> None:
763763 post_dst = tm .map_dst_fill (dst , 17 , np .dtype (np .float64 ))
764764 self .assertEqual (post_dst .dtype , np .dtype (np .float64 ))
765765 self .assertEqual (post_dst .tolist (), [17 , 20 , 20 , 8 , 8 , 7 ])
766+
767+ def test_tri_map_map_float_e (self ) -> None :
768+ src = np .array ([0 , 20 , 8 , 8 ], dtype = np .float32 )
769+ dst = np .array ([7 , 20 , 20 , 8 ], dtype = np .float32 )
770+
771+ # full outer
772+ tm = TriMap (len (src ), len (dst ))
773+ tm .register_one (0 , - 1 )
774+ tm .register_many (1 , np .array ([1 , 2 ], dtype = np .dtype (np .int64 )))
775+ tm .register_one (2 , 3 )
776+ tm .register_one (3 , 3 )
777+ tm .register_unmatched_dst ()
778+
779+ post_src = tm .map_src_fill (src , 17 , np .dtype (np .int8 ))
780+ self .assertEqual (post_src .tolist (), [0 , 20 , 20 , 8 , 8 , 17 ])
781+ self .assertEqual (post_src .dtype , np .dtype (np .float32 ))
782+
783+ post_dst = tm .map_dst_fill (dst , 17 , np .dtype (np .int8 ))
784+ self .assertEqual (post_dst .dtype , np .dtype (np .float32 ))
785+ self .assertEqual (post_dst .tolist (), [17 , 20 , 20 , 8 , 8 , 7 ])
786+
787+ def test_tri_map_map_float_f (self ) -> None :
788+ src = np .array ([0 , 20 , 8 , 8 ], dtype = np .float32 )
789+ dst = np .array ([7 , 20 , 20 , 8 ], dtype = np .float32 )
790+
791+ # full outer
792+ tm = TriMap (len (src ), len (dst ))
793+ tm .register_one (0 , - 1 )
794+ tm .register_many (1 , np .array ([1 , 2 ], dtype = np .dtype (np .int64 )))
795+ tm .register_one (2 , 3 )
796+ tm .register_one (3 , 3 )
797+ tm .register_unmatched_dst ()
798+
799+ post_src = tm .map_src_fill (src , 17 , np .dtype (np .uint16 ))
800+ self .assertEqual (post_src .tolist (), [0 , 20 , 20 , 8 , 8 , 17 ])
801+ self .assertEqual (post_src .dtype , np .dtype (np .float32 ))
802+
803+ post_dst = tm .map_dst_fill (dst , 17 , np .dtype (np .uint16 ))
804+ self .assertEqual (post_dst .dtype , np .dtype (np .float32 ))
805+ self .assertEqual (post_dst .tolist (), [17 , 20 , 20 , 8 , 8 , 7 ])
806+
807+ def test_tri_map_map_float_g (self ) -> None :
808+ src = np .array ([0 , 20 , 8 , 8 ], dtype = np .float32 )
809+ dst = np .array ([7 , 20 , 20 , 8 ], dtype = np .float32 )
810+
811+ # full outer
812+ tm = TriMap (len (src ), len (dst ))
813+ tm .register_one (0 , - 1 )
814+ tm .register_many (1 , np .array ([1 , 2 ], dtype = np .dtype (np .int64 )))
815+ tm .register_one (2 , 3 )
816+ tm .register_one (3 , 3 )
817+ tm .register_unmatched_dst ()
818+
819+ post_src = tm .map_src_fill (src , 17 , np .dtype (np .float32 ))
820+ self .assertEqual (post_src .tolist (), [0 , 20 , 20 , 8 , 8 , 17 ])
821+ self .assertEqual (post_src .dtype , np .dtype (np .float32 ))
822+
823+ post_dst = tm .map_dst_fill (dst , 17 , np .dtype (np .float32 ))
824+ self .assertEqual (post_dst .dtype , np .dtype (np .float32 ))
825+ self .assertEqual (post_dst .tolist (), [17 , 20 , 20 , 8 , 8 , 7 ])
826+
827+ def test_tri_map_map_float_h (self ) -> None :
828+ src = np .array ([0 , 20 , 8 , 8 ], dtype = np .float16 )
829+ dst = np .array ([7 , 20 , 20 , 8 ], dtype = np .float16 )
830+
831+ # full outer
832+ tm = TriMap (len (src ), len (dst ))
833+ tm .register_one (0 , - 1 )
834+ tm .register_many (1 , np .array ([1 , 2 ], dtype = np .dtype (np .int64 )))
835+ tm .register_one (2 , 3 )
836+ tm .register_one (3 , 3 )
837+ tm .register_unmatched_dst ()
838+
839+ post_src = tm .map_src_fill (src , 17 , np .dtype (np .float16 ))
840+ self .assertEqual (post_src .tolist (), [0 , 20 , 20 , 8 , 8 , 17 ])
841+ self .assertEqual (post_src .dtype , np .dtype (np .float16 ))
842+
843+ post_dst = tm .map_dst_fill (dst , 17 , np .dtype (np .float16 ))
844+ self .assertEqual (post_dst .dtype , np .dtype (np .float16 ))
845+ self .assertEqual (post_dst .tolist (), [17 , 20 , 20 , 8 , 8 , 7 ])
846+
847+
848+ def test_tri_map_map_float_i (self ) -> None :
849+ src = np .array ([0 , 20 , 8 , 8 ], dtype = np .float16 )
850+ dst = np .array ([7 , 20 , 20 , 8 ], dtype = np .float16 )
851+
852+ # full outer
853+ tm = TriMap (len (src ), len (dst ))
854+ tm .register_one (0 , - 1 )
855+ tm .register_many (1 , np .array ([1 , 2 ], dtype = np .dtype (np .int64 )))
856+ tm .register_one (2 , 3 )
857+ tm .register_one (3 , 3 )
858+ tm .register_unmatched_dst ()
859+
860+ post_src = tm .map_src_fill (src , 17 , np .dtype (np .int8 ))
861+ self .assertEqual (post_src .tolist (), [0 , 20 , 20 , 8 , 8 , 17 ])
862+ self .assertEqual (post_src .dtype , np .dtype (np .float16 ))
863+
864+ post_dst = tm .map_dst_fill (dst , 17 , np .dtype (np .int8 ))
865+ self .assertEqual (post_dst .dtype , np .dtype (np .float16 ))
866+ self .assertEqual (post_dst .tolist (), [17 , 20 , 20 , 8 , 8 , 7 ])
867+
868+ def test_tri_map_map_float_i (self ) -> None :
869+ src = np .array ([0 , 20 , 8 , 8 ], dtype = np .float16 )
870+ dst = np .array ([7 , 20 , 20 , 8 ], dtype = np .float16 )
871+
872+ # full outer
873+ tm = TriMap (len (src ), len (dst ))
874+ tm .register_one (0 , - 1 )
875+ tm .register_many (1 , np .array ([1 , 2 ], dtype = np .dtype (np .int64 )))
876+ tm .register_one (2 , 3 )
877+ tm .register_one (3 , 3 )
878+ tm .register_unmatched_dst ()
879+
880+ post_src = tm .map_src_fill (src , 17 , np .dtype (np .uint8 ))
881+ self .assertEqual (post_src .tolist (), [0 , 20 , 20 , 8 , 8 , 17 ])
882+ self .assertEqual (post_src .dtype , np .dtype (np .float16 ))
883+
884+ post_dst = tm .map_dst_fill (dst , 17 , np .dtype (np .uint8 ))
885+ self .assertEqual (post_dst .dtype , np .dtype (np .float16 ))
886+ self .assertEqual (post_dst .tolist (), [17 , 20 , 20 , 8 , 8 , 7 ])
0 commit comments