зеркало из
				https://github.com/ssciwr/AMMICO.git
				synced 2025-10-30 13:36:04 +02:00 
			
		
		
		
	force_rounding_of_all_colors (#140)
* force_rounding_of_all_colors * update test * fixed bug in color analysis * changed color rounding to seperate loop
Этот коммит содержится в:
		
							родитель
							
								
									911a43bfad
								
							
						
					
					
						Коммит
						d98a5d3c0e
					
				| @ -91,7 +91,12 @@ class ColorDetector(AnalysisMethod): | ||||
|                 merge_color=self.merge_color, | ||||
|                 delta_e_method=self.delta_e_method, | ||||
|             ) | ||||
|             self.subdict[rgb_name] += round(color.proportion, 2) | ||||
|             self.subdict[rgb_name] += color.proportion | ||||
| 
 | ||||
|         # ensure color rounding | ||||
|         for key in self.set_keys().keys(): | ||||
|             if self.subdict[key]: | ||||
|                 self.subdict[key] = round(self.subdict[key], 2) | ||||
| 
 | ||||
|         return self.subdict | ||||
| 
 | ||||
|  | ||||
| @ -1,5 +1,6 @@ | ||||
| from ammico.colors import ColorDetector | ||||
| import pytest | ||||
| from numpy import isclose | ||||
| 
 | ||||
| 
 | ||||
| def test_init(): | ||||
| @ -57,11 +58,20 @@ def test_analyze_images(get_path): | ||||
|     mydict_1 = { | ||||
|         "filename": get_path + "IMG_2809.png", | ||||
|     } | ||||
|     mydict_2 = { | ||||
|         "filename": get_path + "IMG_2809.png", | ||||
|     } | ||||
| 
 | ||||
|     test1 = ColorDetector(mydict_1, delta_e_method="CIE 2000").analyse_image() | ||||
|     assert test1["red"] == 0.0 | ||||
|     assert round(test1["green"], 2) == 0.62 | ||||
|     assert isclose(test1["red"], 0.0, atol=0.01) | ||||
|     assert isclose(test1["green"], 0.63, atol=0.01) | ||||
| 
 | ||||
|     test2 = ColorDetector(mydict_1).analyse_image() | ||||
|     assert test2["red"] == 0.0 | ||||
|     assert test2["green"] == 0.05 | ||||
|     test2 = ColorDetector(mydict_2).analyse_image() | ||||
|     assert isclose(test2["red"], 0.0, atol=0.01) | ||||
|     assert isclose(test2["green"], 0.06, atol=0.01) | ||||
| 
 | ||||
|     mydict_1["test"] = "test" | ||||
|     test3 = ColorDetector(mydict_1).analyse_image() | ||||
|     assert isclose(test3["red"], 0.0, atol=0.01) | ||||
|     assert isclose(test3["green"], 0.06, atol=0.01) | ||||
|     assert test3["test"] == "test" | ||||
|  | ||||
		Загрузка…
	
	
			
			x
			
			
		
	
		Ссылка в новой задаче
	
	Block a user
	 GwydionJon
						GwydionJon