Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3Packages.phonopy: fix build and tests #96501

Merged
merged 1 commit into from Sep 3, 2020

Conversation

jonringer
Copy link
Contributor

Motivation for this change

noticed it was broken reviewing other packages

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@risicle
Copy link
Contributor

risicle commented Sep 2, 2020

Hmmmm. On x86_64 linux for me phonopy's tests fail for all python versions due to accuracy tolerances:

______________________ TestRandomDisplacements.test_NaCl _______________________

self = <test.phonon.test_random_displacements.TestRandomDisplacements testMethod=test_NaCl>

    def test_NaCl(self):
        """Test by fixed random numbers of np.random.normal
    
        randn_ii and randn_ij were created by
    
            np.random.seed(seed=100)
            randn_ii = np.random.normal(size=(N_ii, 1, num_band))
            randn_ij = np.random.normal(size=(N_ij, 2, 1, num_band)).
    
        numpy v1.16.4 (py37h6b0580a_0) on macOS installed from conda-forge
        was used.
    
        """
    
        phonon = self._get_phonon_NaCl()
        rd = RandomDisplacements(phonon.supercell,
                                 phonon.primitive,
                                 phonon.force_constants,
                                 cutoff_frequency=0.01)
        num_band = len(phonon.primitive) * 3
        N = int(np.rint(phonon.supercell.volume / phonon.primitive.volume))
        N_ij = N - len(rd.qpoints)
        N_ii = N - N_ij * 2
        shape_ii = (N_ii, 1, num_band)
        randn_ii = np.fromstring(randn_ii_str.replace('\n', ' '),
                                 dtype=float, sep=' ').reshape(shape_ii)
        shape_ij = (N_ij, 2, 1, num_band)
        randn_ij = np.zeros(shape_ij, dtype=float)
        randn_ij[:, 0, 0, :] = np.fromstring(
            randn_ij_str_1.replace('\n', ' '),
            dtype=float, sep=' ').reshape(N_ij, num_band)
        randn_ij[:, 1, 0, :] = np.fromstring(
            randn_ij_str_2.replace('\n', ' '),
            dtype=float, sep=' ').reshape(N_ij, num_band)
    
        rd.run(500, randn=(randn_ii, randn_ij))
    
        data = np.fromstring(disp_str.replace('\n', ' '), dtype=float, sep=' ')
>       np.testing.assert_allclose(data, rd.u.ravel(), atol=1e-5)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=1e-05
E       
E       Mismatched elements: 192 / 192 (100%)
E       Max absolute difference: 0.13824334
E       Max relative difference: 4.27892589
E        x: array([ 0.086047, -0.121369,  0.225956, -0.130415,  0.150978,  0.026314,
E              -0.07863 , -0.024818,  0.25071 ,  0.184087,  0.076944, -0.165589,
E               0.33707 ,  0.006281,  0.209698,  0.214342,  0.029129, -0.040215,...
E        y: array([ 0.093087, -0.18405 ,  0.231426, -0.129183,  0.109239,  0.031719,
E              -0.079812, -0.064275,  0.254599,  0.177097,  0.05843 , -0.161765,
E               0.345782, -0.054782,  0.212119,  0.217246, -0.010992, -0.03786 ,...

test/phonon/test_random_displacements.py:174: AssertionError
=========================== short test summary info ============================
FAILED test/phonon/test_random_displacements.py::TestRandomDisplacements::test_NaCl
============= 1 failed, 67 passed, 1 skipped in 113.71s (0:01:53) ==============

@risicle
Copy link
Contributor

risicle commented Sep 3, 2020

Better now.

Builds on macos 10.14 too - reverse dependency sumo still doesn't, but a step in the right direction.

@risicle risicle merged commit 55e8cbd into NixOS:master Sep 3, 2020
@jonringer jonringer deleted the fix-phonopy branch September 3, 2020 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants