{"payload":{"feedbackUrl":"https://github.com/orgs/community/discussions/53140","repo":{"id":752155048,"defaultBranch":"master","name":"scanpy","ownerLogin":"misrasaurabh1","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2024-02-03T07:23:11.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/1271289?v=4","public":true,"private":false,"isOrgOwned":false},"refInfo":{"name":"","listCacheKey":"v0:1711322027.0","currentOid":""},"activityList":{"items":[{"before":"a54d52c788a811bcae322119a0238b0b378ab90e","after":"457861dad93d52fda2624dd3da9e2a684697ec76","ref":"refs/heads/codeflash/optimize-_make_forest_dict-2024-03-24T23.13.47","pushedAt":"2024-03-29T22:55:58.000Z","pushType":"push","commitsCount":55,"pusher":{"login":"misrasaurabh1","name":"Saurabh Misra","path":"/misrasaurabh1","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/1271289?s=80&v=4"},"commit":{"message":"Merge branch 'main' into codeflash/optimize-_make_forest_dict-2024-03-24T23.13.47","shortMessageHtmlLink":"Merge branch 'main' into codeflash/optimize-_make_forest_dict-2024-03…"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"a54d52c788a811bcae322119a0238b0b378ab90e","ref":"refs/heads/codeflash/optimize-_make_forest_dict-2024-03-24T23.13.47","pushedAt":"2024-03-24T23:13:51.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _make_forest_dict() by 77%\nHere is your optimized Python program.\n\n\nI have used `numpy.array` and `numpy.concatenate` for your sizes and dat object which are much faster than `numpy.fromiter` and assignation respectively, especially when dealing with a large dataset. The sizes of your data_list are computed only once and used where needed. Which results in runtime improvements compared to previous code, where data sizes were computed multiple times in different parts of the code.","shortMessageHtmlLink":"⚡️ Speed up _make_forest_dict() by 77%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-_make_forest_dict-2024-03-24T23.13.47","pushedAt":"2024-03-24T23:13:47.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"e5892ec00ac32a030ef9275679fb7d5ee47988c0","ref":"refs/heads/codeflash/optimize-_backwards_compat_get_full_eval-2024-03-24T23.02.22","pushedAt":"2024-03-24T23:02:26.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _backwards_compat_get_full_eval() by 62%\nYour function is clean and optimal in terms of the operations it performs. However, you can optimize it a bit more by trying to remove the check for 'X_diffmap0' in every possible element in 'adata.obs'. If 'adata.obs' is large, this check becomes costly. A slight change would be to convert 'adata.obs' to a set and perform the check, as a lookup in a set is faster.","shortMessageHtmlLink":"⚡️ Speed up _backwards_compat_get_full_eval() by 62%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-_backwards_compat_get_full_eval-2024-03-24T23.02.22","pushedAt":"2024-03-24T23:02:22.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"749e2575d70d4ad1929fba7b7ddaaee3e3576e4b","ref":"refs/heads/codeflash/optimize-rank_genes_groups_df-2024-03-09T18.01.44","pushedAt":"2024-03-09T18:01:48.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up rank_genes_groups_df() by 5%\nYou have written a quite complex Python function. The overall structure of your function seems necessary for the data manipulations you are performing, so it is a bit difficult to make significant structural changes without potentially affecting functionality. However, we can make a small optimization by reusing the conditions from the \"if\" statements. Here is a slightly improved version of your function.\n\n\nThis version saves memory because, instead of creating multiple new DataFrame instances, it applies filter conditions together at once. Also, it reduces the computation time by checking conditions at a single line, which improves processing.\nPlease test this newer version to see if it offers the performance improvements you are looking for. Because the function is complex and involves intricate data manipulations, I recommend thoroughly testing the optimized function to ensure that it does not introduce any unintentional side effects.","shortMessageHtmlLink":"⚡️ Speed up rank_genes_groups_df() by 5%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-rank_genes_groups_df-2024-03-09T18.01.44","pushedAt":"2024-03-09T18:01:44.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"c507f60b175179b0eb6dc7779e9f3d4d85c2298a","ref":"refs/heads/codeflash/optimize-_fallback_to_uns-2024-03-09T17.01.38","pushedAt":"2024-03-09T17:01:42.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _fallback_to_uns() by 7%\nThe function you have provided is already quite optimized. In Python, there are a few ways you can potentially speed up a function but this one cannot be optimized any further because it's already quite minimal in its functionality.\n\nHowever, for readability, clarity, and Python's Zen of \"Explicit is better than implicit\", you might want to consider the following alternative. It is not faster but gives a more intuitive understanding of the function.\n\n\nIn this version, `dct.get(Key, Default)` checks if the key is in the dictionary, returns its value if it is, and returns the \"default\" value if it's not. It is also shorter and might be considered more Pythonic by some.\n\nBut please note, the performance optimization options for python are few and mostly depend on the work a function is doing. If the function is performing common tasks, like the one above, it is unlikely that manual optimization will have any effect. On the contrary, it might make the code less legible and harder to maintain.","shortMessageHtmlLink":"⚡️ Speed up _fallback_to_uns() by 7%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-_fallback_to_uns-2024-03-09T17.01.38","pushedAt":"2024-03-09T17:01:38.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"1f800bc6099eaa319ee4f29bf65e7cdc315fa959","ref":"refs/heads/codeflash/optimize-_elem_mul_in_mem-2024-03-09T16.10.22","pushedAt":"2024-03-09T16:10:26.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _elem_mul_in_mem() by 7%\nThe mentioned code is already well-optimized, especially given the constraints on not changing function names or signatures and keeping the same return value. The use of decorators for dynamic dispatch based on the type of provided arrays is an efficient approach in Python. For specific types, such as np.ndarray or sparse.spmatrix, the appropriate multiplication method is used.\n\nHowever, there is a tiny optimization that we can apply. We can avoid calling `isinstance()` twice by storing its result since it is a bit costly operation in Python.\n\nHere is the slightly optimized version of your code.\n\n\n\nPlease note that the improvement will be negligible and might not be noticeable in all cases due to the speed of `isinstance()` in modern Python interpreters and the nature of your function, which does not consist of a loop where `isinstance()` would have been called multiple times.","shortMessageHtmlLink":"⚡️ Speed up _elem_mul_in_mem() by 7%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-_elem_mul_in_mem-2024-03-09T16.10.22","pushedAt":"2024-03-09T16:10:22.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"19a7abb641f0ced2ec911e6302197cc4c2b6979a","ref":"refs/heads/codeflash/optimize-update_params-2024-03-09T15.58.23","pushedAt":"2024-03-09T15:58:27.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up update_params() by 8%\nYour function is already quite efficient but it can be optimized a bit by eliminating the need to convert `old_params.keys()` to list everytime a key is not found while `check` is True. Here's an optimized version of the function.\n\n\nMost changes here are rearrangements; the structure of the code is mostly unchanged. In the optimized version.\n\n1. We reverse the check for `new_params` so we can return `updated_params` as soon as possible if `new_params` is None.\n2. We check if `check` is True before iterating through `new_params`. This approach prevents unnecessary checking of the `check` condition.\n3. We generate `old_keys` once before the for loop, this way we don't need to generate it again and again if `key` not in `old_params` turns out to be True.\n4. Use f-string formatting to reduce string concatenations which are expensive operations.","shortMessageHtmlLink":"⚡️ Speed up update_params() by 8%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-update_params-2024-03-09T15.58.23","pushedAt":"2024-03-09T15:58:23.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"cad909fa15ea41300af0eb87d64b95e47593bc8f","ref":"refs/heads/codeflash/optimize-_one_of_ours-2024-03-09T14.53.54","pushedAt":"2024-03-09T14:53:59.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _one_of_ours() by 7%\nWhen optimizing a program for speed, you generally want to minimize expensive operations and remove any unnecessary ones. In this function, we can achieve this by using the walrus operator ':=' (assignment expression) introduced in Python 3.8 and rearranging the conditions for early returning when possible.\n\nAlso, accessing attributes of an object using dot notation is generally faster than using the getattr function. Here is a refactored function.\n\n\n\nThe advantage of using this technique is that the function will return as soon as it finds that one of the conditions is not met without needing to check all the conditions. Furthermore, it reduces the need to call functions (like getattr) multiple times, which helps in improving the function's speed.","shortMessageHtmlLink":"⚡️ Speed up _one_of_ours() by 7%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-_one_of_ours-2024-03-09T14.53.54","pushedAt":"2024-03-09T14:53:55.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"47bfc53aadf386932c9f550ce8d1d85e62c1c02a","ref":"refs/heads/codeflash/optimize-_is_constant_rows-2024-03-09T14.15.36","pushedAt":"2024-03-09T14:15:40.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _is_constant_rows() by 5%\nThis function determines if all rows in the provided array are constant. As the function `np.broadcast_to` is generally fast and likely not the main performance bottleneck, the way to optimize this function is by reducing the calls of `all` function which is running on all the elements. Here is a way to rewrite this.\n\n\n\nThis script maximizes the efficiency of the function by leveraging NumPy's broadcasting feature in the equality comparison, which inherently reduces the runtime of the operation and omits the call to `np.broadcast_to`. This approach will give the exactly same result but will run significantly faster particularly when handling larger arrays. The bottleneck in the initial function was the all() function running on all matched elements. Replacing the broadcast_to and the following equality check with an inline broadcasted equality check would result in a significant improvement.","shortMessageHtmlLink":"⚡️ Speed up _is_constant_rows() by 5%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-_is_constant_rows-2024-03-09T14.15.36","pushedAt":"2024-03-09T14:15:36.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"f0201eca5ea70864eba5b1044b6adb93f9128456","ref":"refs/heads/codeflash/optimize-_check_na_color-2024-03-09T12.44.42","pushedAt":"2024-03-09T12:44:46.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _check_na_color() by 6%\nThe Python code you provided had no actual runtime problem but few optimizations can be made to your _check_na_color function that may slightly speed up execution, by removing redundant if conditions.\n\nThe important thing that I changed was to perform an early return if na_color is not None. With this approach, we avoid unnecessary if checks when na_color is not None. Later, I used Python's shorthand for if-else, which might be a bit faster because it consists of only one line. However, note that the performance gain from this refactoring would normally be negligible.","shortMessageHtmlLink":"⚡️ Speed up _check_na_color() by 6%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-_check_na_color-2024-03-09T12.44.42","pushedAt":"2024-03-09T12:44:42.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"1c6f3c8a2914b706b7358a022a1499788749178e","ref":"refs/heads/codeflash/optimize-_check_crop_coord-2024-03-09T12.29.47","pushedAt":"2024-03-09T12:29:51.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _check_crop_coord() by 82%\nThe changes to the code will focus on memory optimization and avoidable operations for the Python interpreter. In Python, it's faster to scale variables individually than using a generator in a tuple constructor since it avoids creating an intermediate generator object.\n\nHere is your optimized code.\n\n\nAs you can see, the logic remains exactly the same, the function simply avoids creating the intermediate generator object when the tuple is being created. This should marginally increase the speed of your function.","shortMessageHtmlLink":"⚡️ Speed up _check_crop_coord() by 82%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-_check_crop_coord-2024-03-09T12.29.47","pushedAt":"2024-03-09T12:29:47.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"5bf559dc216e1fcbdc7f7aeeb1833b19ad347598","ref":"refs/heads/codeflash/optimize-_check_spot_size-2024-03-09T11.44.13","pushedAt":"2024-03-09T11:44:17.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _check_spot_size() by 10%\nThe existing code already looks optimized. It has conditional branching to check for specific conditions and return values appropriately. However, by reversing the condition checks, I can reduce the need for multiple comparisons in some cases which could lead to slightly faster execution times, particularly when `spot_size` is not `None`. Here's the refined code: \n\n\nThis rewrite will save multiple comparisons in the cases when `spot_size` is not `None`. However, it's worth noting that this rewrite will only make actually noticeable difference in very large datasets or applications where performance is a critical concern.","shortMessageHtmlLink":"⚡️ Speed up _check_spot_size() by 10%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-_check_spot_size-2024-03-09T11.44.13","pushedAt":"2024-03-09T11:44:13.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"c28916fb1d58c0b9c40fef30e60b8098a896cf9c","ref":"refs/heads/codeflash/optimize-_components_to_dimensions-2024-03-09T11.19.00","pushedAt":"2024-03-09T11:19:05.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _components_to_dimensions() by 11%\nHere's a variant of your program that avoids unnecessary computations.\n\n\nChanges I made to optimize your code are.\n\n1. I changed the way you were using ndims variable. Accessing a dictionary key directly is slightly faster than using the dict[key] way.\n\n2. Another optimization is changing the all(isinstance(el, Integral) for el in dimensions) check to just checking the first item. Because in Python, a list can't hold elements of different types without explicitly added, so if the first member of the list is an integer, all members are. However, be aware, this assumes none of the dimensions list will be empty. Otherwise, this would raise an IndexError. Make sure that the lists are always populated or add a safeguard against empty lists.\n\nThe optimizations here will give minor improvements. The main runtime of your function depends on your data size and data itself (like how big the dimensions list ends up being). \n\nSo, the significant speedup of this function isn't possible without more extensive refactoring which might cause a change in functionality, so it's left as is. For a really impressive speedup, you might want to think about moving components/dimensions handling to a different part of your program that calls this function, or redesigning the data structure you're using.","shortMessageHtmlLink":"⚡️ Speed up _components_to_dimensions() by 11%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-_components_to_dimensions-2024-03-09T11.19.00","pushedAt":"2024-03-09T11:19:00.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"760d6db7d25b7d21a5f6c1c4198171670159bd5e","ref":"refs/heads/codeflash/optimize-_get_color_stats_custom-2024-03-09T10.08.44","pushedAt":"2024-03-09T10:08:48.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _get_color_stats_custom() by 17%\nHere is a potentially optimized code for your function. Here we avoid using the map function which might be slower in Python and replaced it with direct calculations. Also, the calculations are only performed once and stored in variables. \n\nKeep in mind that it might not always be faster, as the speed depends on multiple factors such as the size of your data. \n\n\n\nIt's also worth mentioning that if the values in the `custom_colors` dictionary are large numpy arrays, this function may actually perform better in the original form. The choice between the map function and a loop depends on which the Python interpreter can handle more efficiently.\n\nIf your `custom_colors` dictionary has very large data arrays, you might find that you'll need to optimise memory usage as well. This could involve techniques such as processing the data in chunks if possible, or using a datatype that uses less memory for the color values.","shortMessageHtmlLink":"⚡️ Speed up _get_color_stats_custom() by 17%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-_get_color_stats_custom-2024-03-09T10.08.44","pushedAt":"2024-03-09T10:08:44.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"6ce0a69e99008d1d615145efb032a6277816b114","ref":"refs/heads/codeflash/optimize-_frac_to_hex-2024-03-09T10.01.28","pushedAt":"2024-03-09T10:01:32.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _frac_to_hex() by 12%\nThe provided code fragment utilizes a lot of NumPy's functionality, which, while very powerful, has more overhead than necessary for dealing with small arrays. Given that the RGB arrays produced by plt.cm.jet always have three elements, none of the slower NumPy array manipulations are necessary. Furthermore, the conversion between NumPy arrays is done twice, whereas it's only necessary to perform it once.\n\nHere is an optimized version.\n\n\n\nIn this version, `plt.cm.jet(frac)` still returns a NumPy array, but we only get the items from the resulting array once. This avoids the conversion from a NumPy array to a list (tuple) and then re-converting it. Also, it gets rid of the duplicated array creation line. So, it is faster and also uses less memory. The output will be the same as in the initial function.","shortMessageHtmlLink":"⚡️ Speed up _frac_to_hex() by 12%"}},{"before":null,"after":"330a099ffe76286f0f047387701af7e9fd58831a","ref":"refs/heads/codeflash/optimize-_frac_to_hex-2024-03-09T10.01.28","pushedAt":"2024-03-09T10:01:28.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"Fix pytest 8 compat (#2838)","shortMessageHtmlLink":"Fix pytest 8 compat (scverse#2838)"}},{"before":"330a099ffe76286f0f047387701af7e9fd58831a","after":"8ddec929427501f862903878e6ee2f44c7acf4cc","ref":"refs/heads/codeflash/optimize-_calc_frac-2024-03-09T08.08.22","pushedAt":"2024-03-09T08:08:26.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"codeflash-ai[bot]","name":null,"path":"/apps/codeflash-ai","primaryAvatarUrl":"https://avatars.githubusercontent.com/in/413177?s=80&v=4"},"commit":{"message":"⚡️ Speed up _calc_frac() by 8%\nYour function relies on two key operations: checking if your input matrix `X` is sparse, and performing element-wise operations across the matrix. Though Python is not generally known for its speed when it comes to these types of tasks, you can make use of packages like NumPy and SciPy, which are both designed for efficient scientific computation, especially for operations that involve large datasets.\n\nYour function seems to be already well-written and efficient, especially by making use of special functions for sparse matrices when appropriate. This is already a good practice.\n\nHere is a version of your function that might run a bit faster.\n\n\n\nThere are not many changes from the original function but this version performs the selection operation (`if issparse()`) in one line together with the calculation of a non-zero elements. \n\nThe `max(1, X.shape[0])` is used to prevent division by zero. \n\nThis optimization won't have a drastic impact on performance, your original function is already quite optimized.\nHowever, remember that the improvements may not be significant if your function is not a performance bottleneck. Make sure to profile your application to identify where the most time is being spent before deciding where to optimize.","shortMessageHtmlLink":"⚡️ Speed up _calc_frac() by 8%"}}],"hasNextPage":true,"hasPreviousPage":false,"activityType":"all","actor":null,"timePeriod":"all","sort":"DESC","perPage":30,"cursor":"djE6ks8AAAAEIwX-qgA","startCursor":null,"endCursor":null}},"title":"Activity · misrasaurabh1/scanpy"}