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

OpenAlea Namespace Package #90

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ source:
build:
noarch: python
preserve_egg_dir: True
number: 3
number: 0
script: {{PYTHON}} setup.py install

requirements:
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import sys
import os

from setuptools import setup, find_packages
from setuptools import setup, find_namespace_packages

name = 'OpenAlea.Strawberry'
version = '1.1.0'
version = '1.1.1'

description = "Strawberry is a package for architecture analysis and 2D/3D reconstruction."
long_description = open('README.md').read()
Expand All @@ -22,7 +22,7 @@
setup_requires = ['openalea.deploy']

# find packages
packages = find_packages('src')
packages=find_namespace_packages(where='src', include=['openalea.*'])
package_dir={'': 'src'}

setup(
Expand Down
1 change: 0 additions & 1 deletion src/openalea/__init__.py

This file was deleted.

8 changes: 4 additions & 4 deletions src/openalea/strawberry/application/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
from io import StringIO
import pandas as pd
import base64

from ipywidgets import HTML
import ipywidgets as widgets

from oawidgets.plantgl import PlantGL

import openalea.strawberry
from openalea.mtg.io import write_mtg
from openalea.mtg import MTG
from openalea.strawberry.application.layout import layout_dataframe, layout_output_wgt, layout_visu3d
from openalea.deploy.shared_data import shared_data


data_directory = shared_data(openalea.strawberry.__path__)
from openalea.strawberry.data import data_directory
from openalea.strawberry.application.layout import layout_dataframe, layout_output_wgt, layout_visu3d


if layout_dataframe == "qgrid":
Expand Down
16 changes: 16 additions & 0 deletions src/openalea/strawberry/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
""" Module providing shared data access
"""
from pathlib import Path

from openalea.deploy.shared_data import shared_data
import openalea.strawberry


data_directory = shared_data(openalea.strawberry.__path__)
count = 0
d = Path(openalea.strawberry.__path__[0])
while data_directory is None and count <=3:
d = d/'..'
data_directory = shared_data(d)
count+=1

5 changes: 3 additions & 2 deletions src/openalea/strawberry/import_mtgfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import pandas as pd
import numpy as np
from openpyxl import load_workbook

from openalea.plantgl.all import*
from openalea.mtg import io
from openalea.mtg import algo
from openalea.lpy import *

import openalea.strawberry
from openalea.mtg import MTG, algo
from openalea.deploy.shared_data import shared_data
from openalea.strawberry.data import data_directory


def name(f):
Expand All @@ -34,7 +35,7 @@ def import_mtgfile(filename):
:rtype: MTG
"""
filenames = filename
files = shared_data(openalea.strawberry).glob('*.mtg')
files = data_directory.glob('*.mtg')
mtg_path = dict((name(f), f) for f in files)
mtgfile = dict((k,f) for k,f in mtg_path.items() if k in filenames)
if len(filenames) == 1:
Expand Down
21 changes: 15 additions & 6 deletions test/test_analysis.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import pandas as pd
from openalea.mtg.io import read_mtg_file

from openalea.strawberry.analysis import extract_at_module_scale, extract_at_node_scale
from openalea.strawberry.analysis import occurence_module_order_along_time, prob_axillary_production
from openalea.deploy.shared_data import shared_data
import openalea.strawberry
from openalea.mtg.io import read_mtg_file
from openalea.strawberry.data import data_directory


def name(f):
return f.basename().splitext()[0]


def test_extract_at_module_scale():
files = shared_data(openalea.strawberry).glob('*.mtg')
files = data_directory.glob('*.mtg')
mtg_path = dict((name(f), f) for f in files)
gariguette = read_mtg_file(mtg_path['Gariguette'])
gariguette_extraction_at_module_scale = extract_at_module_scale(gariguette)
Expand All @@ -18,13 +21,19 @@ def test_extract_at_module_scale():
gariguette_frequency = occurence_module_order_along_time(data= gariguette_extraction_at_module_scale,frequency_type= "cdf")
assert len(gariguette_frequency) == 6

mean= gariguette_extraction_at_module_scale.groupby(["Genotype", "order"]).mean()
sd= gariguette_extraction_at_module_scale.groupby(["Genotype", "order"]).std()

# remove object value from mean & std
fd = gariguette_extraction_at_module_scale
fd.date = pd.to_datetime(fd.date)
props = [x for x in fd if x in ["Genotype", "order"] or fd[x].dtype!=object]

mean= fd.filter(props).groupby(["Genotype", "order"]).mean()
sd= fd.filter(props).groupby(["Genotype", "order"]).std()
assert len(mean) == 6
assert len(sd) == 6

def test_extraction_at_node_scale():
files = shared_data(openalea.strawberry).glob('*.mtg')
files = data_directory.glob('*.mtg')
mtg_path = dict((name(f), f) for f in files)
gariguette = read_mtg_file(mtg_path['Gariguette'])
gariguette_extraction_at_node_scale = extract_at_node_scale(gariguette)
Expand Down
8 changes: 4 additions & 4 deletions test/test_extraction.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from openalea.deploy.shared_data import shared_data
import openalea.strawberry
from openalea.mtg.io import read_mtg_file
from openalea.mtg.algo import union
from openalea.mtg import MTG


from openalea.strawberry.analysis import extract_at_module_scale, extract_at_node_scale, extract_at_plant_scale
from openalea.strawberry.data import data_directory

def name(f):
return f.basename().splitext()[0]

def test_extract_at_module_scale():
files = shared_data(openalea.strawberry).glob('*.mtg')
files = data_directory.glob('*.mtg')

mtg_path = dict((name(f), f) for f in files)
mtg = MTG()
Expand All @@ -32,7 +32,7 @@ def test_extract_at_module_scale():


def test_extract_at_node_scale():
files = shared_data(openalea.strawberry).glob('*.mtg')
files = data_directory.glob('*.mtg')

mtg_path = dict((name(f), f) for f in files)
mtg = MTG()
Expand All @@ -53,7 +53,7 @@ def test_extract_at_node_scale():


def test_extract_at_plant_scale():
files = shared_data(openalea.strawberry).glob('*.mtg')
files = data_directory.glob('*.mtg')

mtg_path = dict((name(f), f) for f in files)
mtg = MTG()
Expand Down
16 changes: 8 additions & 8 deletions test/test_import_data.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
from openalea.deploy.shared_data import shared_data
import os

import openalea.strawberry
from openalea.strawberry.import_mtgfile import import_mtgfile, import_mtg_from_csv, strawberry_reader_csv
from openalea.strawberry.data import data_directory



data_dir = data_directory

def name(f):
return f.basename().splitext()[0]

mtg_files = shared_data(openalea.strawberry).glob('*.mtg')
mtg_files = data_dir.glob('*.mtg')

excel_files = shared_data(openalea.strawberry).glob('*.xlsx')
import os
excel_files = data_dir.glob('*.xlsx')

def test_import_mtgfile():
"""test import_mtgfile function by filename or list of filename
"""
mtg_files = shared_data(openalea.strawberry).glob('*.mtg')
mtg_files = data_dir.glob('*.mtg')
mtg_path= dict((name(f), f) for f in mtg_files)
genotypes= list(mtg_path.keys())

Expand All @@ -31,14 +31,14 @@ def test_import_mtgfile():
def test_import_mtg_from_csv():
"""test import of mtg from excel files
"""
excel_files = shared_data(openalea.strawberry).glob('*/*.xlsx')
excel_files = data_dir.glob('*/*.xlsx')
g= import_mtg_from_csv(files=excel_files,first_property="experimental_names",symbol_at_scale=dict(P=1,T=2, F=3, f=3, b=3, HT=3, bt=3, ht=3,s=3))
assert (isinstance(g, openalea.mtg.mtg.MTG),"data not exist or data not respect the formalism")

def test_strawberry_reader_csv():
""" test one excel files
"""
excel_files = shared_data(openalea.strawberry).glob('*/*.xlsx')
excel_files = data_dir.glob('*/*.xlsx')
for file in excel_files:
g=strawberry_reader_csv(file=file)
assert (isinstance(g, openalea.mtg.mtg.MTG), "data not exist or data in"+ file + "not respect the formalism")
13 changes: 7 additions & 6 deletions test/test_visualization.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
from openalea.deploy.shared_data import shared_data
import openalea.strawberry
import openalea
from openalea.mtg.io import read_mtg_file
from openalea.mtg.algo import orders, split
import openalea

from oawidgets.plantgl import PlantGL
import openalea.strawberry
from openalea.strawberry import visu2d, visu3d
from openalea.strawberry.data import data_directory


def name(f):
return f.basename().splitext()[0]

def test_import_mtg():
files = shared_data(openalea.strawberry).glob('*.mtg')
files = data_directory.glob('*.mtg')
mtg_path = dict((name(f), f) for f in files)
gariguette = read_mtg_file(mtg_path['Gariguette'])
straws = split(gariguette)
assert isinstance(straws[0], openalea.mtg.mtg.MTG)


def test_3D():
files = shared_data(openalea.strawberry).glob('*.mtg')
files = data_directory.glob('*.mtg')
mtg_path = dict((name(f), f) for f in files)
gariguette = read_mtg_file(mtg_path['Gariguette'])
gariguette.properties()['order'] = orders(gariguette)
Expand All @@ -34,7 +35,7 @@ def test_3D():


def __test_2D():
files = shared_data(openalea.strawberry).glob('*.mtg')
files = data_directory.glob('*.mtg')
mtg_path = dict((name(f), f) for f in files)
gariguette = read_mtg_file(mtg_path['Gariguette'])
gariguette.properties()['order'] = orders(gariguette)
Expand Down
11 changes: 6 additions & 5 deletions test/test_waffle.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from pathlib import Path
import os
from pathlib import Path
from openalea.mtg.io import read_mtg_file, write_mtg
from openalea.strawberry.analysis import extract_at_node_scale, extract_at_module_scale
from openalea.deploy.shared_data import shared_data
import openalea.strawberry

import openalea.strawberry
from openalea.strawberry.analysis import extract_at_node_scale, extract_at_module_scale
from openalea.strawberry.analysis import df2waffle
from openalea.strawberry.data import data_directory


def name(f):
return f.basename().splitext()[0]

def test_df2waffle():
files = shared_data(openalea.strawberry).glob('*.mtg')
files = data_directory.glob('*.mtg')
mtg_path = dict((name(f), f) for f in files)
mtg = read_mtg_file(mtg_path['Capriss'])

Expand Down
Loading