55import os
66from tempfile import TemporaryDirectory
77
8+ import numpy as np
89import pandas as pd
910import pytest
1011
@@ -25,14 +26,15 @@ def fixture_mock_x2sys_home(monkeypatch):
2526
2627def test_x2sys_cross_input_file_output_file (mock_x2sys_home ):
2728 """
28- Run x2sys_cross by passing in a filename and output to an ASCII txt file
29+ Run x2sys_cross by passing in a filename, and output internal crossovers to
30+ an ASCII txt file
2931 """
3032 with TemporaryDirectory (prefix = "X2SYS" , dir = os .getcwd ()) as tmpdir :
3133 tag = os .path .basename (tmpdir )
3234 x2sys_init (tag = tag , fmtfile = "xyz" , force = True )
3335 outfile = os .path .join (tmpdir , "tmp_coe.txt" )
3436 output = x2sys_cross (
35- tracks = ["@tut_ship.xyz" ], tag = tag , coe = "i" , outfile = outfile , verbose = "d "
37+ tracks = ["@tut_ship.xyz" ], tag = tag , coe = "i" , outfile = outfile , verbose = "i "
3638 )
3739
3840 assert output is None # check that output is None since outfile is set
@@ -44,12 +46,13 @@ def test_x2sys_cross_input_file_output_file(mock_x2sys_home):
4446
4547def test_x2sys_cross_input_file_output_dataframe (mock_x2sys_home ):
4648 """
47- Run x2sys_cross by passing in a filename and output to a pandas.DataFrame
49+ Run x2sys_cross by passing in a filename, and output internal crossovers to
50+ a pandas.DataFrame
4851 """
4952 with TemporaryDirectory (prefix = "X2SYS" , dir = os .getcwd ()) as tmpdir :
5053 tag = os .path .basename (tmpdir )
5154 x2sys_init (tag = tag , fmtfile = "xyz" , force = True )
52- output = x2sys_cross (tracks = ["@tut_ship.xyz" ], tag = tag , coe = "i" , verbose = "d " )
55+ output = x2sys_cross (tracks = ["@tut_ship.xyz" ], tag = tag , coe = "i" , verbose = "i " )
5356
5457 assert isinstance (output , pd .DataFrame )
5558 assert output .shape == (14294 , 12 )
@@ -58,3 +61,31 @@ def test_x2sys_cross_input_file_output_dataframe(mock_x2sys_home):
5861 assert columns [6 :] == ["head_1" , "head_2" , "vel_1" , "vel_2" , "z_X" , "z_M" ]
5962
6063 return output
64+
65+
66+ def test_x2sys_cross_input_two_filenames (mock_x2sys_home ):
67+ """
68+ Run x2sys_cross by passing in two filenames, and output external crossovers
69+ to a pandas.DataFrame
70+ """
71+ with TemporaryDirectory (prefix = "X2SYS" , dir = os .getcwd ()) as tmpdir :
72+ tag = os .path .basename (tmpdir )
73+ x2sys_init (tag = tag , fmtfile = "xyz" , force = True )
74+
75+ # Create temporary xyz files
76+ for i in range (2 ):
77+ np .random .seed (seed = i )
78+ with open (os .path .join (os .getcwd (), f"track_{ i } .xyz" ), mode = "w" ) as fname :
79+ np .savetxt (fname = fname , X = np .random .rand (10 , 3 ))
80+
81+ output = x2sys_cross (
82+ tracks = ["track_0.xyz" , "track_1.xyz" ], tag = tag , coe = "e" , verbose = "i"
83+ )
84+
85+ assert isinstance (output , pd .DataFrame )
86+ assert output .shape == (24 , 12 )
87+ columns = list (output .columns )
88+ assert columns [:6 ] == ["x" , "y" , "i_1" , "i_2" , "dist_1" , "dist_2" ]
89+ assert columns [6 :] == ["head_1" , "head_2" , "vel_1" , "vel_2" , "z_X" , "z_M" ]
90+
91+ return output
0 commit comments