malariagen / malariagen-data-python

Analyse MalariaGEN data from Python
https://malariagen.github.io/malariagen-data-python/latest/
MIT License
14 stars 24 forks source link

Slow import #656

Open alimanfoo opened 1 week ago

alimanfoo commented 1 week ago

Importing malariagen_data is a little slow at the moment, likely because anjl is imported internally which triggers jit compilation of anjl functions. Perhapse we could move to only importing anjl when needed within the neighbour-joining functions.

leehart commented 3 days ago

Noting that the only use of anjl appears to be malariagen_data/anoph/distance.py, which has:

import anjl.params  # type: ignore

as well as

    def _njt(
[...]
    ):
        # Only import anjl if needed, as it requires a couple of seconds to compile
        # functions.
        import anjl  # type: ignore
leehart commented 48 minutes ago

One complication is that anjl.params is being used for the params of plot_njt()

    def plot_njt(
        self,
[...]
        center_x: anjl.params.center_x = 0,
        center_y: anjl.params.center_y = 0,
        arc_start: anjl.params.arc_start = 0,
        arc_stop: anjl.params.arc_stop = 2 * math.pi,
[...]
        edge_legend: anjl.params.edge_legend = False,
        leaf_legend: anjl.params.leaf_legend = True,
[...]
    ) -> plotly_params.figure:
leehart commented 23 minutes ago

Another complication, encountered when trying to handle the use of anjl in function params, is the requirement for parameters to be documented. 🤔