@@ -333,4 +333,41 @@ public void testTaskResultNull() throws IOException, InterruptedException {
333333 assertNull (task .result ());
334334 }
335335 }
336+
337+ /** Tests that NumPy works on every platform, even Windows. */
338+ @ Test
339+ public void testInitNumpy () throws IOException , InterruptedException {
340+ Environment env = Appose .pixi ()
341+ .base ("target/envs/test-init-numpy" )
342+ .conda ("numpy=2.3.4" )
343+ .pypi ("appose==0.7.2" )
344+ .logDebug ()
345+ .build ();
346+ try (Service service = env .python ().init ("import numpy" )) {
347+ maybeDebug (service );
348+
349+ Task task = service .task (
350+ "narr = numpy.random.default_rng(seed=1337).random([3, 5])\n " +
351+ "[float(v) for v in narr.flatten()]"
352+ ).waitFor ();
353+ assertComplete (task );
354+
355+ Object result = task .outputs .get ("result" );
356+ assertInstanceOf (List .class , result );
357+ List <?> actual = (List <?>) result ;
358+ System .out .println (result .getClass ());
359+ System .out .println (result );
360+ double [] expected = {
361+ 0.8781019003 , 0.1855279616 , 0.9209004548 , 0.9465658637 , 0.8745080903 ,
362+ 0.1157427629 , 0.1937316623 , 0.3417371975 , 0.4957909002 , 0.8983712328 ,
363+ 0.0064586191 , 0.2274114670 , 0.7936549524 , 0.4142867178 , 0.0838144031
364+ };
365+ for (int i = 0 ; i < expected .length ; i ++) {
366+ Object element = actual .get (i );
367+ assertInstanceOf (Number .class , element );
368+ double value = ((Number ) element ).doubleValue ();
369+ assertEquals (expected [i ], value , 1e-10 );
370+ }
371+ }
372+ }
336373}
0 commit comments