|
11 | 11 | import pytest |
12 | 12 | import numpy as np |
13 | 13 | import pandas as pd |
14 | | -from pytest_lazyfixture import lazy_fixture |
15 | 14 |
|
| 15 | +from conftest import lazy_fixture |
16 | 16 | from gnss_lib_py.navdata.navdata import NavData |
17 | 17 |
|
18 | 18 | def test_init_blank(): |
@@ -563,168 +563,145 @@ def test_rename_mapper_and_rows(df_simple): |
563 | 563 | assert data["floats"].dtype == np.float64 |
564 | 564 | assert data["strings"].dtype == object |
565 | 565 |
|
566 | | - |
567 | | - |
568 | | -@pytest.fixture(name="df_rows", |
569 | | - params=[ |
570 | | - lazy_fixture("df_simple") |
571 | | - ]) |
572 | | -def return_df_rows(request): |
573 | | - """Extract and return rows from the DataFrame for testing |
574 | | -
|
575 | | - Parameters |
576 | | - ---------- |
577 | | - pandas_df : pd.DataFrame |
578 | | - Dataframe for testing values |
579 | | -
|
580 | | - Returns |
581 | | - ------- |
582 | | - names : np.ndarray |
583 | | - String entries in 'names' column of the DataFrame |
584 | | - integers : np.ndarray |
585 | | - Numeric entries in 'integers' column of the DataFrame |
586 | | - floats : np.ndarray |
587 | | - Numeric entries in 'floats' column of the DataFrame |
588 | | - strings : np.ndarray |
589 | | - String entries in 'strings' column of the DataFrame |
590 | | - """ |
591 | | - pandas_df = request.param |
592 | | - names = np.asarray(pandas_df['names'].values, dtype=object) |
593 | | - integers = np.reshape(np.asarray(pandas_df['integers'].values, |
594 | | - dtype=np.float64), [1, -1]) |
595 | | - floats = np.reshape(np.asarray(pandas_df['floats'].values, |
596 | | - dtype=np.float64), [1, -1]) |
597 | | - strings = np.asarray(pandas_df['strings'].values, dtype=object) |
598 | | - return [names, integers, floats, strings] |
599 | | - |
600 | | - |
601 | 566 | @pytest.fixture(name="integers") |
602 | | -def fixture_integers(df_rows): |
| 567 | +def fixture_integers(df_simple): |
603 | 568 | """Return data corresponding to the integers label from the test data |
604 | 569 |
|
605 | 570 | Parameters |
606 | 571 | ---------- |
607 | | - df_rows : list |
608 | | - List of rows from the testing data |
| 572 | + df_simple : pd.DataFrame |
| 573 | + pd.DataFrame to initialize NavData with. |
609 | 574 |
|
610 | 575 | Returns |
611 | 576 | ------- |
612 | 577 | integers : np.ndarray |
613 | 578 | Array of numeric entries in 'integers' label of data |
614 | 579 | """ |
615 | | - _, integers, _, _ = df_rows |
| 580 | + integers = np.reshape(np.asarray(df_simple['integers'].values, |
| 581 | + dtype=np.float64), [1, -1]) |
| 582 | + |
616 | 583 | return integers |
617 | 584 |
|
618 | 585 | @pytest.fixture(name="floats") |
619 | | -def fixture_floats(df_rows): |
| 586 | +def fixture_floats(df_simple): |
620 | 587 | """Return data corresponding to the floats label from the test data |
621 | 588 |
|
622 | 589 | Parameters |
623 | 590 | ---------- |
624 | | - df_rows : list |
625 | | - List of rows from the testing data |
| 591 | + df_simple : pd.DataFrame |
| 592 | + pd.DataFrame to initialize NavData with. |
626 | 593 |
|
627 | 594 | Returns |
628 | 595 | ------- |
629 | 596 | floats : np.ndarray |
630 | 597 | Array of numeric entries in 'floats' label of data |
631 | 598 | """ |
632 | | - _, _, floats, _ = df_rows |
| 599 | + floats = np.reshape(np.asarray(df_simple['floats'].values, |
| 600 | + dtype=np.float64), [1, -1]) |
633 | 601 | return floats |
634 | 602 |
|
635 | 603 |
|
636 | 604 | @pytest.fixture(name="strings") |
637 | | -def fixture_strings(df_rows): |
| 605 | +def fixture_strings(df_simple): |
638 | 606 | """Return data corresponding to the strings label from the test data |
639 | 607 |
|
640 | 608 | Parameters |
641 | 609 | ---------- |
642 | | - df_rows : list |
643 | | - List of rows from the testing data |
| 610 | + df_simple : pd.DataFrame |
| 611 | + pd.DataFrame to initialize NavData with. |
644 | 612 |
|
645 | 613 | Returns |
646 | 614 | ------- |
647 | 615 | strings : np.ndarray |
648 | 616 | Array of string entries in 'strings' label of data |
649 | 617 | """ |
650 | | - _, _, _, strings = df_rows |
| 618 | + strings = np.asarray(df_simple['strings'].values, dtype=object) |
651 | 619 | return strings |
652 | 620 |
|
653 | 621 |
|
654 | 622 | @pytest.fixture(name="int_flt") |
655 | | -def fixture_int_flt(df_rows): |
| 623 | +def fixture_int_flt(df_simple): |
656 | 624 | """Return data corresponding to the integers and floats. |
657 | 625 |
|
658 | 626 | Labeled from the test data. |
659 | 627 |
|
660 | 628 | Parameters |
661 | 629 | ---------- |
662 | | - df_rows : list |
663 | | - List of rows from the testing data |
| 630 | + df_simple : pd.DataFrame |
| 631 | + pd.DataFrame to initialize NavData with. |
664 | 632 |
|
665 | 633 | Returns |
666 | 634 | ------- |
667 | 635 | int_flt : np.ndarray |
668 | 636 | 2D array of numeric entries in 'integers' and 'floats' labels of data |
669 | 637 | """ |
670 | | - _, integers, floats, _ = df_rows |
| 638 | + integers = np.reshape(np.asarray(df_simple['integers'].values, |
| 639 | + dtype=np.float64), [1, -1]) |
| 640 | + floats = np.reshape(np.asarray(df_simple['floats'].values, |
| 641 | + dtype=np.float64), [1, -1]) |
| 642 | + |
671 | 643 | int_flt = np.vstack((integers, floats)) |
672 | 644 | return int_flt |
673 | 645 |
|
674 | 646 |
|
675 | 647 | @pytest.fixture(name="nm_str") |
676 | | -def fixture_nm_str(df_rows): |
| 648 | +def fixture_nm_str(df_simple): |
677 | 649 | """Return data corresponding to the names and strings label from the test data |
678 | 650 |
|
679 | 651 | Parameters |
680 | 652 | ---------- |
681 | | - df_rows : list |
682 | | - List of rows from the testing data |
| 653 | + df_simple : pd.DataFrame |
| 654 | + pd.DataFrame to initialize NavData with. |
683 | 655 |
|
684 | 656 | Returns |
685 | 657 | ------- |
686 | 658 | nm_str : np.ndarray |
687 | 659 | 2D array of numeric entries in 'names' and 'strings' labels of data |
688 | 660 | """ |
689 | | - names, _, _, strings = df_rows |
| 661 | + names = np.asarray(df_simple['names'].values, dtype=object) |
| 662 | + strings = np.asarray(df_simple['strings'].values, dtype=object) |
690 | 663 | nm_str = np.vstack((names, strings)) |
691 | 664 | return nm_str |
692 | 665 |
|
693 | 666 |
|
694 | 667 | @pytest.fixture(name="str_nm") |
695 | | -def fixture_str_nm(df_rows): |
| 668 | +def fixture_str_nm(df_simple): |
696 | 669 | """Return data corresponding to the strings and names label from the test data |
697 | 670 |
|
698 | 671 | Parameters |
699 | 672 | ---------- |
700 | | - df_rows : list |
701 | | - List of rows from the testing data |
| 673 | + df_simple : pd.DataFrame |
| 674 | + pd.DataFrame to initialize NavData with. |
702 | 675 |
|
703 | 676 | Returns |
704 | 677 | ------- |
705 | 678 | str_nm : np.ndarray |
706 | 679 | 2D array of numeric entries in 'strings' and 'names' labels of data |
707 | 680 | """ |
708 | | - names, _, _, strings = df_rows |
| 681 | + names = np.asarray(df_simple['names'].values, dtype=object) |
| 682 | + strings = np.asarray(df_simple['strings'].values, dtype=object) |
709 | 683 | str_nm = np.vstack((strings, names)) |
710 | 684 | return str_nm |
711 | 685 |
|
712 | 686 |
|
713 | 687 | @pytest.fixture(name="flt_int_slc") |
714 | | -def fixture_flt_int_slc(df_rows): |
| 688 | +def fixture_flt_int_slc(df_simple): |
715 | 689 | """Return data corresponding to the names and strings label from the test data |
716 | 690 |
|
717 | 691 | Parameters |
718 | 692 | ---------- |
719 | | - df_rows : list |
720 | | - List of rows from the testing data |
| 693 | + df_simple : pd.DataFrame |
| 694 | + pd.DataFrame to initialize NavData with. |
721 | 695 |
|
722 | 696 | Returns |
723 | 697 | ------- |
724 | 698 | flt_int_slc : np.ndarray |
725 | 699 | 2D array of some numeric entries in 'integers' and 'floats' labels of data |
726 | 700 | """ |
727 | | - _, integers, floats, _ = df_rows |
| 701 | + integers = np.reshape(np.asarray(df_simple['integers'].values, |
| 702 | + dtype=np.float64), [1, -1]) |
| 703 | + floats = np.reshape(np.asarray(df_simple['floats'].values, |
| 704 | + dtype=np.float64), [1, -1]) |
728 | 705 | flt_int_slc = np.vstack((integers, floats))[:, 3:] |
729 | 706 | return flt_int_slc |
730 | 707 |
|
|
0 commit comments