From 257787663e2845d3251159a7dc923812076fee5d Mon Sep 17 00:00:00 2001 From: FusRoman <46221629+FusRoman@users.noreply.github.com> Date: Tue, 10 Jan 2023 10:30:53 +0100 Subject: [PATCH] Issue/110/fix assign tags test (#111) * fix test assign * add file test * fix ci test for the same bug --- bin/utils_cli.py | 49 +++++----------------- fink_fat/test/cli_test/test_cli.py | 4 ++ fink_fat/test/utils_cli_test_orb.parquet | Bin 0 -> 3659 bytes fink_fat/test/utils_cli_test_traj.parquet | Bin 0 -> 3122 bytes 4 files changed, 14 insertions(+), 39 deletions(-) create mode 100644 fink_fat/test/utils_cli_test_orb.parquet create mode 100644 fink_fat/test/utils_cli_test_traj.parquet diff --git a/bin/utils_cli.py b/bin/utils_cli.py index 08612b04..7d89ecfe 100644 --- a/bin/utils_cli.py +++ b/bin/utils_cli.py @@ -441,45 +441,15 @@ def assig_tags(orb_df, traj_orb_df, start_tags): ... "ra": [0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 3, 3, 4, 5, 3, 5, 4, 5, 4, 3, 1, 2, 3, 4, 5, 5, 2] ... }) >>> new_orb, new_traj = assig_tags(orb, traj, 0) - >>> new_orb[["ssoCandId", "ref_epoch", "a"]] - ssoCandId ref_epoch a - 0 FF2022aaaaaaa 0 1.00 - 5 FF2022aaaaaab 1 265.32 - 1 FF2022aaaaaac 2 1.50 - 2 FF2022aaaaaad 3 1.60 - 4 FF2022aaaaaae 4 35.41 - 3 FF2022aaaaaaf 5 2.80 - - >>> new_traj[["ssoCandId", "candid", "ra"]] - ssoCandId candid ra - 0 FF2022aaaaaaa 0 0 - 1 FF2022aaaaaaa 1 0 - 2 FF2022aaaaaaa 2 0 - 3 FF2022aaaaaaa 3 0 - 4 FF2022aaaaaaa 4 0 - 5 FF2022aaaaaaa 5 0 - 6 FF2022aaaaaac 6 1 - 7 FF2022aaaaaad 7 2 - 8 FF2022aaaaaac 8 1 - 9 FF2022aaaaaad 9 2 - 10 FF2022aaaaaac 10 1 - 11 FF2022aaaaaaf 11 3 - 12 FF2022aaaaaaf 12 3 - 13 FF2022aaaaaae 13 4 - 14 FF2022aaaaaab 14 5 - 15 FF2022aaaaaaf 15 3 - 16 FF2022aaaaaab 16 5 - 17 FF2022aaaaaae 17 4 - 18 FF2022aaaaaab 18 5 - 19 FF2022aaaaaae 19 4 - 20 FF2022aaaaaaf 20 3 - 21 FF2022aaaaaac 21 1 - 22 FF2022aaaaaad 22 2 - 23 FF2022aaaaaaf 23 3 - 24 FF2022aaaaaae 24 4 - 25 FF2022aaaaaab 25 5 - 26 FF2022aaaaaab 26 5 - 27 FF2022aaaaaad 27 2 + + >>> orb_test = pd.read_parquet("fink_fat/test/utils_cli_test_orb.parquet") + >>> traj_test = pd.read_parquet("fink_fat/test/utils_cli_test_traj.parquet") + + >>> orb_test["ssoCandId"] = orb_test["ssoCandId"].str.replace("2022", str(datetime.date.today().year), regex=False) + >>> traj_test["ssoCandId"] = traj_test["ssoCandId"].str.replace("2022", str(datetime.date.today().year), regex=False) + + >>> assert_frame_equal(orb_test, new_orb) + >>> assert_frame_equal(traj_test, new_traj) """ orb_df = orb_df.sort_values("ref_epoch") @@ -506,6 +476,7 @@ def assig_tags(orb_df, traj_orb_df, start_tags): import fink_fat.test.test_sample as ts # noqa: F401 from unittest import TestCase # noqa: F401 import shutil # noqa: F401 + import datetime # noqa: F401 if "unittest.util" in __import__("sys").modules: # Show full diff in self.assertEqual. diff --git a/fink_fat/test/cli_test/test_cli.py b/fink_fat/test/cli_test/test_cli.py index 7e5189c8..630470ae 100644 --- a/fink_fat/test/cli_test/test_cli.py +++ b/fink_fat/test/cli_test/test_cli.py @@ -2,6 +2,7 @@ from pandas.testing import assert_frame_equal import shutil import sys +import datetime import traceback import logging @@ -117,6 +118,9 @@ "{}mpc/trajectory_orb.parquet".format(data_test_path) ) + orb_test["ssoCandId"] = orb_test["ssoCandId"].str.replace("2022", str(datetime.date.today().year), regex=False) + obs_orb_test["ssoCandId"] = obs_orb_test["ssoCandId"].str.replace("2022", str(datetime.date.today().year), regex=False) + try: assert_frame_equal( old_obs.sort_values("candid").round(decimals=5), diff --git a/fink_fat/test/utils_cli_test_orb.parquet b/fink_fat/test/utils_cli_test_orb.parquet new file mode 100644 index 0000000000000000000000000000000000000000..f061d13f6351fab8466b898a9f0f82cf7be1fa06 GIT binary patch literal 3659 zcmcgv&2Jk;6dyZI>ZXpMsB78Cf@npp9MWKK;!;;YI(FiXjpH;<>$Mk#d(qk)DQsR?bHeO#EG&HdqcixaGr%nS zBQCV$_cGgO&ae5y(gC7LlPvY0V4p>}_69G1|AhO(Hc24nIaUjQv8#&=wSaHAU zqCkQ6aGfPJ+8L2Th>)60SdQGW}$USldzj6hCUI2QtzRrj+ zm)wzdK=5(zHEZA#}IZ(l@6CX+&@5}8yoY11sPqP3Nwl|+W-oA{JwxIJzVw_V>|(K~ zTP3wuG}Ml26hp=0sl+|F5d3=ieJ^p|{{S5C@@Oe~q@Y$7D@OdWL`{2CS1Ih6IcJ2~F{&n9{9qx(L z^!>VcpS8c?-(_b?j(vZ9m9;hOYE-G>eb$mp6-=zQVSt9Ft466fDYF9= zTm3pwWZRam)JiG~+E&}F_s1JGxvDBHA~)5RRFYZ}sNZK*3)FS1Ol)u8N?f_d9v`28 znMA=##C!sTEtnSXwpESm=S&l*X+TLyn&IUkGUH?t9iCw{RmbE$ixkO|rQVWY$+fK#@Ttk%kE zKV`^frX%vei(rbUa=G0?>mZ(rYPkvQ1EMc%HuW*Cc&cLi6zjnEZk`))!Fu5+c@|z% z=A)I;PGN{=7O!abI)(fpmx)s!EfKJad?ExshiB1?rsE_RC-D?BXXd$FSLQOcvoOu* zSh0$1W-CfK8dCEygYYByeH=E(aVS$g)JdLXAr~qL*-DAu9p_Iw>XI{U7lg3w&&mws zP=>@wi8dco5^_y35q+G_Q_r((<(l#y~7xJkH&5ad{z_^^e*flZ4J`Z+q!0V64Fy}pGSJy^aG3&RcJcb;AJ;Xg>h;?U&*$u8q@OJ zs2}tUz|+hRKt@_iYB03NF>0B*HS(9R{ZTI`{_tJmbf9q29ny1-gi*Xh(w{KiAKTBz zW83#dLDa;2tW)4d{j7_jaqSKJ8}Vf00jJPBq2Cpt%VB76wC~xc0y?-yB(w?I@#&}i zS~$c!@dy1ERyrUA9d9Aut97YyudTMODE0ak`a58C*yLAf_xF=OKgU1lr)7k0!oQLK E0(5$tod5s; literal 0 HcmV?d00001 diff --git a/fink_fat/test/utils_cli_test_traj.parquet b/fink_fat/test/utils_cli_test_traj.parquet new file mode 100644 index 0000000000000000000000000000000000000000..345d01c8604f587b9f62679bd999be7f6823d41f GIT binary patch literal 3122 zcmcIn&2Jh<6dy2PNbR;svlLpST2w(kIPUW0LS$81uz{tR*f?f^s&eLoo?IaNL6n0xP0k9{+{U@)Xrqk%0qcV0q@un@Y+j|AFVIY zf;FT%p-nm5zO^rzuhQ#3KKbsP{+<2lm(*XY2u1!}3Q?|L(uF+1fJfwYNs%b0Kjr_% z?SHxydF+gMUnN{{10cF6Cj!X0L%92l+9^>hghcu(hubbY0k_@5#&v3AI@hsfHrIJA zIJjN1a$WKvv~#dEkbiEeZWQ@``7%dmmnZo>cKW|?Mqaoh-?|~ed2g7{c`aI);8O>+ zKhE%E9au%VT#Syzd7tB>n+S=xk#KW@8yPpk)jYS*`l`K)$KOd{X3D=jyJt5-)QVj} zpJ{foP(;=$;@?jH=g!D)zQ{9g=syE2NX;26B~id*iY-~=DGwC$j&poUtO?MGs1?v& zM!theAwcU-1w+B@Yd>GtTinR?k?a5AhCc=L`2SeGjo@4bJO&hwHv?b0&%=r?$&Zf3 zj@s9BGkkCDlk@N?=wKA?@_JJaZ>)uNUXwwg_f-{UW{>aoU`ms5$ADohMaD87M=w5w ziRJK^c$aOzvu;ilS(T1wbr!DU-pIi5!hKy4JCX&VuNk9>p(C_qv4^2)a*vnz9uLdU z!?F&`6}^e~9zDq2O@%L}z|5iuTQ3myF@t1Ee+7-A_qGy*ju|Wy^%NA$)WrrMveN@9 z=L1=~|1rqqM$X5YF(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